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