13 @todo This version is not yet implemented, and maybe we don't need it ever!
16 Add those contributions to matrix which impose the boundary conditions
18 Dirichlet (and really all boundary) faces do not hold any artificial or real
19 degrees of freedom in our code. So the core assembly ignores these faces and
20 we end up with a linear equation system which is not coupled to the PDE's
21 boundary conditions. This additional action sets runs over the mesh and adds
24 For every cell that we visit (and that is not outside the computational
25 domain), we check its 2d faces, i.e. the left and right face along each
26 axis. If this face is an interior, nothing is to be done. We only have to do
27 something for boundary faces. In this action set, we assume that each face
30 If a face is a Dirichlet face, we loop over the nodes on the face. For
31 this, we emply Peano's exclusive d-dimensional for (dfore), which is a
32 d-dimensional for loop skipping one dimension. Per dof, we compute the
33 dof's coordinate x and ask the user's solver what the value there should be.
34 This gives us the right-hand side for the equation system row that
35 imposes the condition.
37 Next, we use compute the projection of the solution to the boundary. This
38 might be a different projection than used for the faces, even though the
39 code is basically the same. For some solvers, we project solely the
40 derivatives along the normal onto the face, for others, we
43 @todo We need the projection matrix for the solution!
44 @todo We have to add the corresponding matrix entries below, as well as
48 TemplateTouchCellFirstTime =
"""
49 if (fineGridCell{{SOLVER_NAME}}PETScData.getType() == celldata::{{SOLVER_NAME}}PETScData::Type::Interior) {
50 std::pair<int,int> localCellIndex = std::make_pair(_spacetreeId, fineGridCell{{SOLVER_NAME}}PETScData.getUnknownBaseNumber());
51 int globalCellIndex = repositories::{{SOLVER_INSTANCE}}.getLocalToGlobalMap().getGlobalIndex(localCellIndex, ::petsc::LocalToGlobalMap::Type::Cell);
53 assertion( globalCellIndex>=0 );
55 for (int d=0; d<Dimensions; d++) {
56 // =================================
57 // Look at left face along axis d
58 // =================================
59 if ( fineGridFaces{{SOLVER_NAME}}PETScData(d).getType()==facedata::{{SOLVER_NAME}}PETScData::Type::Boundary ) {
60 assertion( repositories::{{SOLVER_INSTANCE}}.CellUnknowns==1 );
64 // Loop over all projections of the solution onto the face. See docu on
65 // dfore in Peano's utilities
66 dfore(faceNode, repositories::{{SOLVER_INSTANCE}}.Order+1, d, 0) {
67 tarch::la::Vector<Dimensions,double> x = marker.getOffset(); // left bottom vertex of cell
68 for (int dd=0; dd<Dimensions; dd++) {
70 x(dd) += repositories::{{SOLVER_INSTANCE}}.QuadraturePointsInUnitInterval[ faceNode(dd) ] * marker.h()(dd);
74 // Look up the value: rhs is not relevant here, but I want to reuse the existing signatures
75 double value, rhs, exact;
76 repositories::{{SOLVER_INSTANCE}}.initNode(
84 // @todo We have to discuss this
86 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert( rhsRow, value );
87 for (int col=0; col<repositories::{{SOLVER_INSTANCE}}.DoFsPerCell; col++) {
88 //repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().insert(
90 // globalCellIndex+col,
91 // projectionCellToFaceMatrix(d * dofsPerFace + row,col)
99 // =================================
100 // Look at right face along axis d
101 // =================================
102 if ( fineGridFaces{{SOLVER_NAME}}PETScData(d+Dimensions).getType()==facedata::{{SOLVER_NAME}}PETScData::Type::Boundary ) {
118 super( ImposeDirichletBoundaryConditions, self ).
__init__()
120 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
121 self.
d[
"SOLVER_NAME"] = solver.typename()
127Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
128Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
130Only touchVertexFirstTime is an event where this action set actually
131does something: It inserts the template TemplateTouchVertexFirstTime and
132replaces it with entries from the dictionary. The latter is befilled
135We actually do something during touchVertexFirstTime and touchCellFirstTime. We insert the
136appropriate template into each.
140 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
149 Configure name of generated C++ action set
151 This action set will end up in the directory observers with a name that
152 reflects how the observer (initialisation) is mapped onto this action
153 set. The name pattern is ObserverName2ActionSetIdentifier where this
154 routine co-determines the ActionSetIdentifier. We make is reflect the
158 return __name__.replace(
".py",
"").replace(
".",
"_")
164 The action set that Peano will generate that corresponds to this class
165 should not be modified by users and can safely be overwritten every time
166 we run the Python toolkit.
175Consult petsc.Project for details
179#include "../repositories/SolverRepository.h"
180#include "tarch/la/Matrix.h"
181#include "peano4/utils/Loop.h"
196Define body of constructor
202 _spacetreeId = treeNumber;
str TemplateTouchCellFirstTime
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__init__(self, solver)
Yet to be written.
get_action_set_name(self)
Configure name of generated C++ action set.
get_constructor_body(self)
Define body of constructor.
get_includes(self)
Consult petsc.Project for details.
get_body_of_operation(self, operation_name)
Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME Provide...
Action set (reactions to events)