12Initialise degrees of freedom associated with the mesh
14This simple action set plugs into the situations where we touch a vertex
15for the first time throughout a mesh traversal. Of these events, it ignores
16all those for refined vertices, i.e. it solely handles the unrefined
17vertices in the spacetree. If focuses on the fine grid. The same is done
18for the cells and the vertices.
20The injected code snippet is simple and basically asks if a vertex will be
21refined. If not, it invokes the initialisation routine of the solver. For
22this, the action set has to know the typename and the instance name of the
23solver. Besides the actual behaviour, the action set also has to include
24the solver in the first place. This happens in get_includes().
27 TemplateInitVertex =
"""
28 if ( fineGridVertex{{SOLVER_NAME}}PETScData.getType() != vertexdata::{{SOLVER_NAME}}PETScData::Type::Coarse ) {
30 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> value;
31 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> rhs;
33 // use initVertex to get all the values we want to place
34 // into each vertex dof
35 repositories::{{SOLVER_INSTANCE}}.initVertex(
42 for (int i=0; i<{{VERTEX_CARDINALITY}}; i++)
44 fineGridVertex{{SOLVER_NAME}}.setValue(i, value[i]);
45 fineGridVertex{{SOLVER_NAME}}.setRhs(i, rhs[i]);
54Initialise vertex-associated degrees of freedom
56The initialisation requires a solver object, as we have to know what C++
57object this solver will produce.
59solver: petsc.solvers.CollocatedLowOrderDiscretisation or similar solver where
60 degrees of freedom are assigned exclusively to the vertices.
63 super( InitVertexDoFs, self ).
__init__()
65 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
66 self.
d[
"SOLVER_NAME"] = solver.typename()
67 self.
d[
"VERTEX_CARDINALITY"] = solver.number_of_matrix_entries_per_vertex
68 self.
d[
"FACE_CARDINALITY"] = solver.number_of_matrix_entries_per_face
69 self.
d[
"CELL_CARDINALITY"] = solver.number_of_matrix_entries_per_cell
75Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
77Only touchVertexFirstTime is an event where this action set actually
78does something: It inserts the template TemplateInitVertex and
79replaces it with entries from the dictionary. The latter is befilled
84 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
93 Configure name of generated C++ action set
95 This action set will end up in the directory observers with a name that
96 reflects how the observer (initialisation) is mapped onto this action
97 set. The name pattern is ObserverName2ActionSetIdentifier where this
98 routine co-determines the ActionSetIdentifier. We make is reflect the
102 return __name__.replace(
".py",
"").replace(
".",
"_")
108 The action set that Peano will generate that corresponds to this class
109 should not be modified by users and can safely be overwritten every time
110 we run the Python toolkit.
119 Add some additional includes
121 We need the solver repository here as we access hte solver object, and we
122 also need access to all of Peano's d-dimensional for loops.
126#include "../repositories/SolverRepository.h"
127#include "peano4/utils/Loop.h"
Initialise degrees of freedom associated with the mesh.
get_action_set_name(self)
Configure name of generated C++ action set.
get_includes(self)
Add some additional includes.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
get_body_of_operation(self, operation_name)
Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
__init__(self, solver)
Initialise vertex-associated degrees of freedom.
Action set (reactions to events)