8 templateTouchCellFirstTime=
"""
10 fineGridCell{{SOLVER_NAME}}.getType() != celldata::{{SOLVER_NAME}}::Type::Coarse
12 repositories::{{SOLVER_INSTANCE}}.projectOntoCells()
14 logTraceInWith2Arguments( "ProjectOntoCells", fineGridCell{{SOLVER_NAME}}.getResidual(), fineGridCell{{SOLVER_NAME}}.getSolution() );
16 // we intend that the internal residual vector should be reset and updated in the
17 // cell update procedure
19 // This vector faceSol will contain: soln on face 0 | soln on face 1 | soln on face 2 | .....
20 tarch::la::Vector< repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution*TwoTimesD, double > faceSol;
21 for (int f=0; f<TwoTimesD; f++)
22 for (int s=0; s<repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution; s++)
23 faceSol( f*repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution + s ) = fineGridFaces{{SOLVER_NAME}}(f).getSolution(s);
25 // next, we need to project solution on face onto the cell...
26 auto projection = repositories::{{SOLVER_INSTANCE}}.getCellFromFaceMatrix(marker.x(), marker.h()) * faceSol;
27 // loop over each face, finish updating residual as we go
28 for (int f=0; f<repositories::{{SOLVER_INSTANCE}}.CellUnknowns; f++)
30 // project the face solution onto the cell; add to r
31 fineGridCell{{SOLVER_NAME}}.setResidual(f,
32 fineGridCell{{SOLVER_NAME}}.getResidual(f)- projection(f));
35 // multiply by "smoother" / preconditioner
36 fineGridCell{{SOLVER_NAME}}.setResidual(
37 repositories::{{SOLVER_INSTANCE}}.getInvertedApproxSystemMatrix(marker.x(),marker.h())
38 * fineGridCell{{SOLVER_NAME}}.getResidual()
41 for (int i=0; i<fineGridCell{{SOLVER_NAME}}.getSolution().size(); i++) {
42 double res = fineGridCell{{SOLVER_NAME}}.getResidual( i );
43 double du = repositories::{{SOLVER_INSTANCE}}.OmegaCell * res;
44 fineGridCell{{SOLVER_NAME}}.setSolution( i,
45 fineGridCell{{SOLVER_NAME}}.getSolution( i ) + du
47 repositories::{{SOLVER_INSTANCE}}.updateGlobalResidual(res, marker.h());
48 repositories::{{SOLVER_INSTANCE}}.updateGlobalSolutionUpdates(du, marker.h()(0));
49 repositories::{{SOLVER_INSTANCE}}.updateMinMaxMeshSize( marker.h() );
52 logTraceOutWith2Arguments( "ProjectOntoCells", fineGridCell{{SOLVER_NAME}}.getResidual(), fineGridCell{{SOLVER_NAME}}.getSolution() );
58 descend_invocation_order=0,
60 super( ProjectIntoCellAndUpdateCellSolution, self ).
__init__(
61 descend_invocation_order,
65 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
66 self.
d[
"SOLVER_NAME"] = solver.typename()
70 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
78 Configure name of generated C++ action set
80 This action set will end up in the directory observers with a name that
81 reflects how the observer (initialisation) is mapped onto this action
82 set. The name pattern is ObserverName2ActionSetIdentifier where this
83 routine co-determines the ActionSetIdentifier. We make is reflect the
87 return __name__.replace(
".py",
"").replace(
".",
"_") +
"_ProjectIntoCellAndUpdateCellSolution"
92 The action set that Peano will generate that corresponds to this class
93 should not be modified by users and can safely be overwritten every time
94 we run the Python toolkit.
102 We need the solver repository in this action set, as we directly access
103 the solver object. We also need access to Peano's d-dimensional loops.
107#include "../repositories/SolverRepository.h"
108#include "peano4/utils/Loop.h"
__init__(self, solver, descend_invocation_order=0, parallel=True)
get_action_set_name(self)
Configure name of generated C++ action set.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
str templateTouchCellFirstTime
Action set (reactions to events)