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< repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution, double > projection =
25 repositories::{{SOLVER_INSTANCE}}.getRiemannMatrix() * fineGridFace{{SOLVER_NAME}}.getProjection();
26
27 for (int i=0; i<repositories::{{SOLVER_INSTANCE}}.FaceUnknownsSolution; i++)
28 fineGridFace{{SOLVER_NAME}}.setSolution(
29 i,
30 (1-repositories::{{SOLVER_INSTANCE}}.OmegaFace)*fineGridFace{{SOLVER_NAME}}.getSolution(i)
31 + repositories::{{SOLVER_INSTANCE}}.OmegaFace * projection(i)
32 );
33 logTraceOutWith1Argument( "updateFaceSolution::Interior", fineGridFace{{SOLVER_NAME}}.getSolution() );
34 }
35
36 else if (
37 fineGridFace{{SOLVER_NAME}}.getType() == facedata::{{SOLVER_NAME}}::Type::Boundary
38 and
39 repositories::{{SOLVER_INSTANCE}}.updateFace()
40 ) {
41 logTraceInWith1Argument( "updateFaceSolution::InteriorPenalty", fineGridFace{{SOLVER_NAME}}.getProjection() );
42 // Essentially what we do here is fix the solution on the boundary to be
43 // the inner-side projection.
44
45 // skip halfway along the projection vector if we are on face 0 or 1
46 int startIndexProjection =
47 marker.getSelectedFaceNumber() < Dimensions ?
48 repositories::{{SOLVER_INSTANCE}}.NodesPerFace * repositories::{{SOLVER_INSTANCE}}.ProjectionsPerFaceNode :
49 0;
50
51 auto boundaryMatrix = repositories::{{SOLVER_INSTANCE}}.getBoundaryConditionMatrix();
52
53 /*
54 Here we do slightly messy matrix multiplication. We would just multiply the boundary matrix
55 by the projection vector, and place that into the solution, but here we only want to capture
56 half of the projection vector; the other half lies outside the computational domain and
57 should be fixed to 0.
58 */
59 for (int row=0; row<boundaryMatrix.rows(); row++)
60 {
61 double rowSolution = 0;
62 for (int col=0; col<boundaryMatrix.cols(); col++)
63 {
64 rowSolution += boundaryMatrix( row, col ) * fineGridFace{{SOLVER_NAME}}.getProjection( col + startIndexProjection );
65 }
66 // place this solution into the face
67 fineGridFace{{SOLVER_NAME}}.setSolution( row, rowSolution );
68 }
69
70 logTraceOut( "updateFaceSolution::InteriorPenalty");
71 }
72
73
74"""
75
76
77 def __init__(self,
78 solver,
79 descend_invocation_order=0,
80 parallel=True):
81 super( UpdateFaceSolution, self ).__init__(
82 descend_invocation_order,
83 parallel
84 )
85 self.d = {}
86 self.d["SOLVER_INSTANCE"] = solver.instance_name()
87 self.d["SOLVER_NAME"] = solver.typename()
88
89 def get_body_of_operation(self,operation_name):
90 result = ""
91 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
92 result = jinja2.Template(self.templatetouchFaceFirstTime).render(**self.d)
93 pass
94 return result
95
97 """!
98
99 Configure name of generated C++ action set
100
101 This action set will end up in the directory observers with a name that
102 reflects how the observer (initialisation) is mapped onto this action
103 set. The name pattern is ObserverName2ActionSetIdentifier where this
104 routine co-determines the ActionSetIdentifier. We make is reflect the
105 Python class name.
106
107 """
108 return __name__.replace(".py", "").replace(".", "_") + "_UpdateFaceSolution"
109
111 """!
112
113 The action set that Peano will generate that corresponds to this class
114 should not be modified by users and can safely be overwritten every time
115 we run the Python toolkit.
116
117 """
118 return False
119
120 def get_includes(self):
121 """!
122
123 We need the solver repository in this action set, as we directly access
124 the solver object. We also need access to Peano's d-dimensional loops.
125
126 """
127 return """
128#include "../repositories/SolverRepository.h"
129#include "peano4/utils/Loop.h"
130"""
131
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.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
__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.
Action set (reactions to events)
Definition ActionSet.py:6