9 This should be identical to the original, with the only difference that we
10 do stuff when we touch the vertex for the last time
13 templateTouchVertexLastTime =
"""
15 fineGridVertex{{SOLVER_NAME}}.getType() == vertexdata::{{SOLVER_NAME}}::Type::Interior
17 repositories::{{SOLVER_INSTANCE}}.updateSolution( fineGridVertex{{SOLVER_NAME}}.getLevel() )
19 logTraceInWith3Arguments("TouchVertexLastTime", fineGridVertex{{SOLVER_NAME}}.toString(), marker.x(), marker.h());
21 for (int unknown=0; unknown<{{VERTEX_CARDINALITY}}; unknown++)
23 logTraceInWith3Arguments("updateValue", fineGridVertex{{SOLVER_NAME}}.getU(unknown), fineGridVertex{{SOLVER_NAME}}.getDiag(unknown), fineGridVertex{{SOLVER_NAME}}.getResidual(unknown));
24 assertion( fineGridVertex{{SOLVER_NAME}}.getDiag(unknown) > 0 );
26 double r = fineGridVertex{{SOLVER_NAME}}.getResidual(unknown);
27 double du = repositories::{{SOLVER_INSTANCE}}.Omega
28 * 1.0 / fineGridVertex{{SOLVER_NAME}}.getDiag(unknown) * r;
31 fineGridVertex{{SOLVER_NAME}}.setU(unknown, fineGridVertex{{SOLVER_NAME}}.getU(unknown) + du);
32 logTraceOutWith1Argument("updateValue", fineGridVertex{{SOLVER_NAME}}.getU(unknown));
34 logTraceOutWith1Argument("TouchVertexLastTime", fineGridVertex{{SOLVER_NAME}}.toString());
36 // only care about solution on finest level...
38 fineGridVertex{{SOLVER_NAME}}.getType() == vertexdata::{{SOLVER_NAME}}::Type::Interior
40 repositories::{{SOLVER_INSTANCE}}.reportSolutionUpdates( fineGridVertex{{SOLVER_NAME}}.getLevel() )
42 for (int unknown=0; unknown<{{VERTEX_CARDINALITY}}; unknown++) {
43 double r = fineGridVertex{{SOLVER_NAME}}.getResidual(unknown);
44 double du = repositories::{{SOLVER_INSTANCE}}.Omega
45 * 1.0 / fineGridVertex{{SOLVER_NAME}}.getDiag(unknown) * r;
47 repositories::{{SOLVER_INSTANCE}}.updateGlobalResidual(r, marker.h());
48 repositories::{{SOLVER_INSTANCE}}.updateGlobalSolutionUpdates(du, marker.h()(0));
55 descend_invocation_order=0,
57 super( UpdateSolution, self ).
__init__(
58 descend_invocation_order,
62 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
63 self.
d[
"SOLVER_NAME"] = solver.typename()
64 self.
d[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
68 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_LAST_TIME:
76 The action set that Peano will generate that corresponds to this class
77 should not be modified by users and can safely be overwritten every time
78 we run the Python toolkit.
86 We need the solver repository in this action set, as we directly access
87 the solver object. We also need access to Peano's d-dimensional loops.
91#include "repositories/SolverRepository.h"
92#include "peano4/utils/Loop.h"
93#include "mghype/matrixfree/solvers/CGMultigrid.h"
99 Configure name of generated C++ action set
101 This action set will end up in the directory observers with a name that
102 reflects how the observer (initialisation) is mapped onto this action
103 set. The name pattern is ObserverName2ActionSetIdentifier where this
104 routine co-determines the ActionSetIdentifier. We make is reflect the
108 return __name__.replace(
".py",
"").replace(
".",
"_")
Action set (reactions to events)
This should be identical to the original, with the only difference that we do stuff when we touch the...
__init__(self, solver, descend_invocation_order=0, parallel=False)
str templateTouchVertexLastTime
get_action_set_name(self)
Configure name of generated C++ action set.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.