Peano
Loading...
Searching...
No Matches
UpdateResidual.py
Go to the documentation of this file.
1from peano4.solversteps.ActionSet import ActionSet
2
3import peano4
4import jinja2
5
6
8 """!
9
10 This is for DG solver
11
12 @todo Documntation missing
13
14 """
15 templateTouchCellFirstTime="""
16 if (
17 fineGridCell{{SOLVER_NAME}}.getType() != celldata::{{SOLVER_NAME}}::Type::Coarse
18 and
19 // only one condition here - ensures that we don't do this when restricting the residual
20 repositories::{{SOLVER_INSTANCE}}.updateResidual()
21 ) {
22 logTraceInWith4Arguments("updateResidual",
23 fineGridCell{{SOLVER_NAME}}.getSolution(),
24 fineGridCell{{SOLVER_NAME}}.getRhs(),
25 marker.toString(),
26 repositories::{{SOLVER_INSTANCE}}.getMassMatrix( marker.x(), marker.h() )
27 );
28
29 // write Mb into it, i.e. mass matrix * rhs
30 tarch::la::Vector< repositories::{{SOLVER_INSTANCE}}.CellUnknowns, double > r =
31 repositories::{{SOLVER_INSTANCE}}.getMassMatrix( marker.x(), marker.h() ) * fineGridCell{{SOLVER_NAME}}.getRhs();
32
33 // also subtract A^cc u^c
34 r = r - repositories::{{SOLVER_INSTANCE}}.getLocalAssemblyMatrix(marker.x(), marker.h()) * fineGridCell{{SOLVER_NAME}}.getSolution();
35
36 fineGridCell{{SOLVER_NAME}}.setResidual( r );
37
38 logTraceOut("updateResidual");
39 }
40 """
41
42
43 def __init__(self,
44 solver,
45 descend_invocation_order=0,
46 parallel=True):
47 super( UpdateResidual, self ).__init__(
48 descend_invocation_order,
49 parallel
50 )
51 self.d = {}
52 self.d["SOLVER_INSTANCE"] = solver.instance_name()
53 self.d["SOLVER_NAME"] = solver.typename()
54
55 def get_body_of_operation(self,operation_name):
56 result = ""
57 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
58 result = jinja2.Template(self.templateTouchCellFirstTime).render(**self.d)
59 pass
60 return result
61
63 """!
64
65 Configure name of generated C++ action set
66
67 This action set will end up in the directory observers with a name that
68 reflects how the observer (initialisation) is mapped onto this action
69 set. The name pattern is ObserverName2ActionSetIdentifier where this
70 routine co-determines the ActionSetIdentifier. We make is reflect the
71 Python class name.
72
73 """
74 return __name__.replace(".py", "").replace(".", "_") + "_UpdateResidual"
75
77 """!
78
79 The action set that Peano will generate that corresponds to this class
80 should not be modified by users and can safely be overwritten every time
81 we run the Python toolkit.
82
83 """
84 return False
85
86 def get_includes(self):
87 """!
88
89 We need the solver repository in this action set, as we directly access
90 the solver object. We also need access to Peano's d-dimensional loops.
91
92 """
93 return """
94#include "../repositories/SolverRepository.h"
95#include "peano4/utils/Loop.h"
96"""
This is for DG solver.
__init__(self, solver, descend_invocation_order=0, parallel=True)
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
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_action_set_name(self)
Configure name of generated C++ action set.
Action set (reactions to events)
Definition ActionSet.py:6