13 @todo Add comments which document from Slack
16 TemplateTouchFaceFirstTime =
"""
17 if (fineGridFace{{SOLVER_NAME}}PETScData.getType() == facedata::{{SOLVER_NAME}}PETScData::Type::Boundary) {
18 std::pair<int,int> localFaceIndex = std::make_pair(_spacetreeId, fineGridFace{{SOLVER_NAME}}PETScData.getUnknownBaseNumber());
19 int globalFaceIndex = repositories::{{SOLVER_INSTANCE}}.getLocalToGlobalMap().getGlobalIndex(localFaceIndex, ::petsc::LocalToGlobalMap::Type::Face);
21 assertion( globalFaceIndex>=0 );
23 logTraceInWith2Arguments("touchFaceFirstTime::Boundary", globalFaceIndex, marker.toString());
26 we want to place -1 on the diagonal for each "interior-side" projection.
27 That is, for face 0 and 2, we write to the "+" projection
28 for face 1 and 3, we write to the "-" projection
30 We also write -1 to all of the "exterior-side" projections. The actual
31 value we use here is immaterial, so long as it is not zero.
32 This makes the matrix full-rank. We use -1 to make this loop easier
35 we go up to 2*repositories::{{SOLVER_INSTANCE}}.NodesPerFace*repositories::{{SOLVER_INSTANCE}}.FaceUnknowns
36 since this is total number of q^-, q^+, u^-, u^+.
38 for (int i=0; i<2*repositories::{{SOLVER_INSTANCE}}.NodesPerFace*repositories::{{SOLVER_INSTANCE}}.FaceUnknowns; i++)
40 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
47 int faceNormalAxis = marker.getSelectedFaceNumber()%Dimensions;
49 dfore(faceNode, repositories::{{SOLVER_INSTANCE}}.Order+1, faceNormalAxis, 0) {
51 tarch::la::Vector<Dimensions,double> x = marker.x(); // centre of face
52 for (int dd=0; dd<Dimensions; dd++) {
53 if (dd!=faceNormalAxis) {
54 x(dd) -= 0.5 * marker.h()(dd);
55 x(dd) += repositories::{{SOLVER_INSTANCE}}.QuadraturePointsInUnitInterval[ faceNode(dd) ] * marker.h()(dd);
59 logTraceInWith5Arguments("touchFaceFirstTime::dfore", faceNode, faceNormalAxis, marker.x(), x,repositories::{{SOLVER_INSTANCE}}.FaceUnknowns);
61 // Look up the value: rhs is not relevant here, but I want to reuse the existing signatures
62 double value, rhs, exact;
63 repositories::{{SOLVER_INSTANCE}}.initNode(
71 for (int unknown = 0; unknown<repositories::{{SOLVER_INSTANCE}}.FaceUnknowns; unknown++) {
72 // row corresponding to solution
73 int globalMatrixRow = globalFaceIndex + row + 2*repositories::{{SOLVER_INSTANCE}}.NodesPerFace*repositories::{{SOLVER_INSTANCE}}.FaceUnknowns;
75 logTraceInWith4Arguments("touchFaceFirstTime:unknownLoop", unknown, globalMatrixRow, row, marker.toString());
77 // insert identity into row corresponding to solution at this node / for this unknown
78 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
84 static_assert(Dimensions==2, "the bodge on the line below is untested for Dimensions != 2. see comment in code");
87 The faces are enumerated as follows:
94 if we are on negative side of coordinate axis, then we wanna write to the positive projection,
95 since this is the one that is on interior side of cell.
97 So, if the face number is >= than Dimensions, we wanna write to negative side projection.
99 bool writeToNegativeProjection = (marker.getSelectedFaceNumber() >= Dimensions);
102 This part is to round off the equation. If q^- projection is on the inside of the cell,
103 then we want the equation to read q^f - q^- = 0. Hence we write 1 onto the row, col
104 corresponding to q^f and then -1 in col for q^-. rhs will be zero to round this off.
107 // makes sure we only do this for q unknown
108 if ( row < repositories::{{SOLVER_INSTANCE}}.FaceUnknowns )
110 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
112 globalFaceIndex + row, // q^-
113 writeToNegativeProjection ? -1 : 0
116 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
118 globalFaceIndex + row + repositories::{{SOLVER_INSTANCE}}.NodesPerFace*repositories::{{SOLVER_INSTANCE}}.FaceUnknowns, // q^+
119 writeToNegativeProjection ? 0 : -1
124 Alternative behaviour for u unknown. Same as for q: If u^- projection is on the inside of the cell,
125 then we want the equation to read u^f - u^- = 0
127 if ( row >= repositories::{{SOLVER_INSTANCE}}.FaceUnknowns )
129 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
131 globalFaceIndex + row, // u^-
132 writeToNegativeProjection ? -1 : 0
135 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
137 globalFaceIndex + row + repositories::{{SOLVER_INSTANCE}}.NodesPerFace*repositories::{{SOLVER_INSTANCE}}.FaceUnknowns, // u^+
138 writeToNegativeProjection ? 0 : -1
144 logTraceOut("touchFaceFirstTime:unknownLoop");
146 logTraceOut("touchFaceFirstTime::dfore");
149 logTraceOut("touchFaceFirstTime::Boundary");
162 super( ImposeDirichletBoundaryConditionsWithInteriorPenaltyMethod, self ).
__init__()
164 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
165 self.
d[
"SOLVER_NAME"] = solver.typename()
171Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
172Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
174Only touchVertexFirstTime is an event where this action set actually
175does something: It inserts the template TemplateTouchVertexFirstTime and
176replaces it with entries from the dictionary. The latter is befilled
179We actually do something during touchVertexFirstTime and touchCellFirstTime. We insert the
180appropriate template into each.
184 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
193 Configure name of generated C++ action set
195 This action set will end up in the directory observers with a name that
196 reflects how the observer (initialisation) is mapped onto this action
197 set. The name pattern is ObserverName2ActionSetIdentifier where this
198 routine co-determines the ActionSetIdentifier. We make is reflect the
202 return __name__.replace(
".py",
"").replace(
".",
"_")
208 The action set that Peano will generate that corresponds to this class
209 should not be modified by users and can safely be overwritten every time
210 we run the Python toolkit.
219Consult petsc.Project for details
223#include "../repositories/SolverRepository.h"
224#include "tarch/la/Matrix.h"
225#include "peano4/utils/Loop.h"
240Define body of constructor
246 _spacetreeId = treeNumber;
get_body_of_operation(self, operation_name)
Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME Provide...
str TemplateTouchFaceFirstTime
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__init__(self, solver)
Yet to be written.
get_includes(self)
Consult petsc.Project for details.
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_constructor_body(self)
Define body of constructor.
Action set (reactions to events)