Peano
Loading...
Searching...
No Matches
ProjectOntoFaces.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 There's documentation missing
13
14 """
15
16 templateTouchCellFirstTime="""
17 /*
18 all we need to do here is project updated solution u^c onto the faces
19 */
20
21 if (
22 fineGridCell{{SOLVER_NAME}}.getType() != celldata::{{SOLVER_NAME}}::Type::Coarse
23 and
24 repositories::{{SOLVER_INSTANCE}}.projectOntoFaces()
25 ) {
26 // apply cell to face projection, store it in faceProjections
27 // no tricky indexing needed here, since the whole of the cell
28 // solution vector is in scope here.
29 tarch::la::Vector< repositories::{{SOLVER_INSTANCE}}.FaceUnknownsProjection * TwoTimesD, double > faceProjections =
30 repositories::{{SOLVER_INSTANCE}}. applyFaceFromCellMatrix(
31 marker.x(),
32 marker.h(),
33 fineGridCell{{SOLVER_NAME}}.getSolution()
34 );
35
36 logTraceInWith3Arguments("ProjectOntoFace", marker.toString(), faceProjections, fineGridCell{{SOLVER_NAME}}.getSolution());
37
38 // first D faces - only care about right-side projection
39 for (int f=0; f<Dimensions; f++) {
40 // the projection vector should be twice as long as the number of solutions, so jump
41 // ahead by this number. NOTE THAT THIS CODE CAN BE REFACTORED TO REMOVE THE REDUNDANCY NOW
42 const int offset = repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution;
43
44 for (int p=0; p<repositories::{{SOLVER_INSTANCE}}.NodesPerFace * repositories::{{SOLVER_INSTANCE}}.ProjectionsPerFaceNode; p++)
45 {
46 fineGridFaces{{SOLVER_NAME}}(f).setRProjection(
47 p,
48 faceProjections( f*repositories::{{SOLVER_INSTANCE}}.FaceUnknownsProjection + p + offset )
49 );
50 }
51
52 }
53
54 // second D faces - left side this time
55 for (int f=Dimensions; f<TwoTimesD; f++) {
56 for (int p=0; p<repositories::{{SOLVER_INSTANCE}}.NodesPerFace * repositories::{{SOLVER_INSTANCE}}.ProjectionsPerFaceNode; p++)
57 {
58 fineGridFaces{{SOLVER_NAME}}(f).setLProjection(
59 p,
60 faceProjections( f*repositories::{{SOLVER_INSTANCE}}.FaceUnknownsProjection + p )
61 );
62 }
63
64 }
65
66 logTraceOut("ProjectOntoFace");
67 }
68"""
69
70
71 def __init__(self,
72 solver,
73 descend_invocation_order=0,
74 parallel=True):
75 super( ProjectOntoFaces, self ).__init__(
76 descend_invocation_order,
77 parallel
78 )
79 self.d = {}
80 self.d["SOLVER_INSTANCE"] = solver.instance_name()
81 self.d["SOLVER_NAME"] = solver.typename()
82
83 def get_body_of_operation(self,operation_name):
84 result = ""
85 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
86 result = jinja2.Template(self.templateTouchCellFirstTime).render(**self.d)
87 pass
88 return result
89
91 """!
92
93 Configure name of generated C++ action set
94
95 This action set will end up in the directory observers with a name that
96 reflects how the observer (initialisation) is mapped onto this action
97 set. The name pattern is ObserverName2ActionSetIdentifier where this
98 routine co-determines the ActionSetIdentifier. We make is reflect the
99 Python class name.
100
101 """
102 return __name__.replace(".py", "").replace(".", "_") + "_ProjectOntoFaces"
103
105 """!
106
107 The action set that Peano will generate that corresponds to this class
108 should not be modified by users and can safely be overwritten every time
109 we run the Python toolkit.
110
111 """
112 return False
113
114 def get_includes(self):
115 """!
116
117 We need the solver repository in this action set, as we directly access
118 the solver object. We also need access to Peano's d-dimensional loops.
119
120 """
121 return """
122#include "../repositories/SolverRepository.h"
123#include "peano4/utils/Loop.h"
124"""
Action set (reactions to events)
Definition ActionSet.py:6
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_action_set_name(self)
Configure name of generated C++ action set.
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
__init__(self, solver, descend_invocation_order=0, parallel=True)