Peano
Loading...
Searching...
No Matches
UpdateFaceSolution.py
Go to the documentation of this file.
1from peano4.solversteps.ActionSet import ActionSet
2
3import peano4
4import jinja2
5
7 """!
8 This is for DG solver.
9
10 @todo Docu missing
11
12 """
13
14
15 templateTouchFaceFirstTime="""
16 if (
17 fineGridFace{{SOLVER_NAME}}.getType() == facedata::{{SOLVER_NAME}}::Type::Interior
18 and
19 repositories::{{SOLVER_INSTANCE}}.updateFace()
20 ) {
21 logTraceInWith2Arguments( "updateFaceSolution::Interior", fineGridFace{{SOLVER_NAME}}.getSolution(), marker.toString() );
22
23 // project the u^\pm into a temporary vector
24 tarch::la::Vector< 2*repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution, double > projections;
25 // alias for number of solutions
26 const int nSols = repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution;
27 for (int i=0; i<repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution; i++) {
28 projections[i] = fineGridFace{{SOLVER_NAME}}.getLProjection(i);
29 projections[i+nSols] = fineGridFace{{SOLVER_NAME}}.getRProjection(i);
30 }
31
32 // multiply by riemann matrix
33 auto faceSolutionUpdate = repositories::{{SOLVER_INSTANCE}}.applyRiemannMatrix( projections );
34
35 for (int i=0; i<repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution; i++)
36 fineGridFace{{SOLVER_NAME}}.setSolution(
37 i,
38 (1-repositories::{{SOLVER_INSTANCE}}.OmegaFace)*fineGridFace{{SOLVER_NAME}}.getSolution(i)
39 + repositories::{{SOLVER_INSTANCE}}.OmegaFace * faceSolutionUpdate(i)
40 );
41
42 fineGridFace{{SOLVER_NAME}}.setLProjection( 0.0 );
43 fineGridFace{{SOLVER_NAME}}.setRProjection( 0.0 );
44 logTraceOutWith1Argument( "updateFaceSolution::Interior", fineGridFace{{SOLVER_NAME}}.getSolution() );
45 }
46
47 else if (
48 fineGridFace{{SOLVER_NAME}}.getType() == facedata::{{SOLVER_NAME}}::Type::Boundary
49 and
50 repositories::{{SOLVER_INSTANCE}}.updateFace()
51 ) {
52 logTraceInWith2Arguments( "updateFaceSolution::InteriorPenalty", fineGridFace{{SOLVER_NAME}}.getLProjection(), fineGridFace{{SOLVER_NAME}}.getRProjection() );
53 // Essentially what we do here is fix the solution on the boundary to be
54 // the inner-side projection.
55
56 // skip halfway along the projection vector if we are on face 0 or 1
57 int startIndexProjection =
58 marker.getSelectedFaceNumber() < Dimensions ?
59 repositories::{{SOLVER_INSTANCE}}.NodesPerFace * repositories::{{SOLVER_INSTANCE}}.ProjectionsPerFaceNode :
60 0;
61
62 if ( marker.getSelectedFaceNumber() < Dimensions )
63 fineGridFace{{SOLVER_NAME}}.setSolution(
64 repositories::{{SOLVER_INSTANCE}}.applyBoundaryConditionMatrix(
65 fineGridFace{{SOLVER_NAME}}.getRProjection()
66 )
67 );
68
69 else
70 fineGridFace{{SOLVER_NAME}}.setSolution(
71 repositories::{{SOLVER_INSTANCE}}.applyBoundaryConditionMatrix(
72 fineGridFace{{SOLVER_NAME}}.getLProjection()
73
74 ));
75
76 logTraceOut( "updateFaceSolution::InteriorPenalty");
77 }
78
79
80"""
81
82
83 def __init__(self,
84 solver,
85 descend_invocation_order=0,
86 parallel=True):
87 super( UpdateFaceSolution, self ).__init__(
88 descend_invocation_order,
89 parallel
90 )
91 self.d = {}
92 self.d["SOLVER_INSTANCE"] = solver.instance_name()
93 self.d["SOLVER_NAME"] = solver.typename()
94
95 def get_body_of_operation(self,operation_name):
96 result = ""
97 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
98 result = jinja2.Template(self.templateTouchFaceFirstTime).render(**self.d)
99 pass
100 return result
101
103 """!
104
105 Configure name of generated C++ action set
106
107 This action set will end up in the directory observers with a name that
108 reflects how the observer (initialisation) is mapped onto this action
109 set. The name pattern is ObserverName2ActionSetIdentifier where this
110 routine co-determines the ActionSetIdentifier. We make is reflect the
111 Python class name.
112
113 """
114 return __name__.replace(".py", "").replace(".", "_") + "_UpdateFaceSolution"
115
117 """!
118
119 The action set that Peano will generate that corresponds to this class
120 should not be modified by users and can safely be overwritten every time
121 we run the Python toolkit.
122
123 """
124 return False
125
126 def get_includes(self):
127 """!
128
129 We need the solver repository in this action set, as we directly access
130 the solver object. We also need access to Peano's d-dimensional loops.
131
132 """
133 return """
134#include "../repositories/SolverRepository.h"
135#include "peano4/utils/Loop.h"
136"""
137
Action set (reactions to events)
Definition ActionSet.py:6
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.
__init__(self, solver, descend_invocation_order=0, parallel=True)
get_action_set_name(self)
Configure name of generated C++ action set.