8 This action set goes first, so that if we've done at least one sweep, we can update the
9 solution based on the residual and diag.
11 We wait until the next sweep so that vertices that are shared across multiple spacetrees
12 have a chance to agree on a value for residual and diag, since not all contributions
16 templateTouchVertexFirstTime=
"""
18 fineGridVertex{{SOLVER_NAME}}.getType() == vertexdata::{{SOLVER_NAME}}::Type::Interior
20 repositories::{{SOLVER_INSTANCE}}.updateSolution()
22 for (int unknown=0; unknown<{{VERTEX_CARDINALITY}}; 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;
30 repositories::{{SOLVER_INSTANCE}}.updateGlobalResidual(
33 repositories::{{SOLVER_INSTANCE}}.updateGlobalSolutionUpdates(
37 fineGridVertex{{SOLVER_NAME}}.setU(unknown, fineGridVertex{{SOLVER_NAME}}.getU(unknown) + du );
41 if ( fineGridVertex{{SOLVER_NAME}}.getType() == vertexdata::{{SOLVER_NAME}}::Type::Boundary ) {
43 for (int unknown=0; unknown<{{VERTEX_CARDINALITY}}; unknown++) {
44 fineGridVertex{{SOLVER_NAME}}.setU(unknown, value);
51 descend_invocation_order=0,
54 super( UpdateSolution, self ).
__init__(
55 descend_invocation_order,
59 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
60 self.
d[
"SOLVER_NAME"] = solver.typename()
61 self.
d[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
65 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
73 Configure name of generated C++ action set
75 This action set will end up in the directory observers with a name that
76 reflects how the observer (initialisation) is mapped onto this action
77 set. The name pattern is ObserverName2ActionSetIdentifier where this
78 routine co-determines the ActionSetIdentifier. We make is reflect the
82 return __name__.replace(
".py",
"").replace(
".",
"_")
87 The action set that Peano will generate that corresponds to this class
88 should not be modified by users and can safely be overwritten every time
89 we run the Python toolkit.
97 We need the solver repository in this action set, as we directly access
98 the solver object. We also need access to Peano's d-dimensional loops.
102#include "../repositories/SolverRepository.h"
103#include "peano4/utils/Loop.h"
Action set (reactions to events)
This action set goes first, so that if we've done at least one sweep, we can update the solution base...
__init__(self, solver, descend_invocation_order=0, parallel=False)
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
str templateTouchVertexFirstTime
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.
get_action_set_name(self)
Configure name of generated C++ action set.