12Project solution vector from PETSc back onto vertices
14This action set works if and only if your PETSc data is associated with
15the vertices only. If runs over through the mesh. Each mesh vertex has
16a tree number and a (local) number. We take this tuple and ask the
17map what the global dof index is. With this index, we ask PETSc what the
18corresponding entry in the solution vector reads like.
23 TemplateTouchCellFirstTime =
"""
24 if ( fineGridCell{{SOLVER_NAME}}PETScData.getType() == celldata::{{SOLVER_NAME}}PETScData::Type::Interior ) {
25 logTraceIn( "touchCellFirstTime(...)" );
27 std::pair<int,int> localIndex( _spacetreeId, fineGridCell{{SOLVER_NAME}}PETScData.getUnknownBaseNumber() );
28 int globalIndex = repositories::{{SOLVER_INSTANCE}}.getLocalToGlobalMap().getGlobalIndex(localIndex, ::petsc::LocalToGlobalMap::Type::Cell);
30 for (int i=0; i<{{CELL_CARDINALITY}}; i++){
31 // place values into mesh
32 fineGridCell{{SOLVER_NAME}}.setValue( i,
33 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().get(globalIndex + i) );
36 logTraceOut( "touchCellFirstTime(...)" );
44Initialise vertex-associated degrees of freedom
46The initialisation requires a solver object, as we have to know what C++
47object this solver will produce.
49solver: petsc.solvers.CollocatedLowOrderDiscretisation or similar solver where
50 degrees of freedom are assigned exclusively to the vertices.
53 super( ProjectPETScSolutionOnCellsBackOntoMesh, self ).
__init__()
55 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
56 self.
d[
"SOLVER_NAME"] = solver.typename()
57 self.
d[
"CELL_CARDINALITY"] = solver.number_of_matrix_entries_per_cell
64Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
66Only touchVertexFirstTime is an event where this action set actually
67does something: It inserts the template TemplateInitVertex and
68replaces it with entries from the dictionary. The latter is befilled
73 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
82 Configure name of generated C++ action set
84 This action set will end up in the directory observers with a name that
85 reflects how the observer (initialisation) is mapped onto this action
86 set. The name pattern is ObserverName2ActionSetIdentifier where this
87 routine co-determines the ActionSetIdentifier. We make is reflect the
91 return __name__.replace(
".py",
"").replace(
".",
"_")
97 The action set that Peano will generate that corresponds to this class
98 should not be modified by users and can safely be overwritten every time
99 we run the Python toolkit.
108Consult petsc.Project for details
112#include "../repositories/SolverRepository.h"
127Define body of constructor
129Consult the superclass' description of the function for results. I
130basically initialise the _localMap with the correct tree number.
136 _spacetreeId = treeNumber;
143Project solution vector from PETSc back onto vertices
145This action set works if and only if your PETSc data is associated with
146the vertices only. If runs over through the mesh. Each mesh vertex has
147a tree number and a (local) number. We take this tuple and ask the
148map what the global dof index is. With this index, we ask PETSc what the
149corresponding entry in the solution vector reads like.
153 TemplateTouchVertexFirstTime =
"""
154 if (fineGridVertex{{SOLVER_NAME}}PETScData.getType() == vertexdata::{{SOLVER_NAME}}PETScData::Type::Interior) {
155 std::pair<int,int> localIndex = std::make_pair(_spacetreeId, fineGridVertex{{SOLVER_NAME}}PETScData.getUnknownBaseNumber());
156 int globalIndex = repositories::{{SOLVER_INSTANCE}}.getLocalToGlobalMap().getGlobalIndex(localIndex, ::petsc::LocalToGlobalMap::Type::Vertex);
158 for (int i=0; i<{{VERTEX_CARDINALITY}}; i++){
159 fineGridVertex{{SOLVER_NAME}}.setValue(
161 repositories::{{SOLVER_INSTANCE}}.getLinearEquationSystem().get(globalIndex+i)
172Initialise vertex-associated degrees of freedom
174The initialisation requires a solver object, as we have to know what C++
175object this solver will produce.
177solver: petsc.solvers.CollocatedLowOrderDiscretisation or similar solver where
178 degrees of freedom are assigned exclusively to the vertices.
181 super( ProjectPETScSolutionOnVerticesBackOntoMesh, self ).
__init__()
183 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
184 self.
d[
"SOLVER_NAME"] = solver.typename()
185 self.
d[
"VERTEX_CARDINALITY"] = solver.number_of_matrix_entries_per_vertex
192Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
194Only touchVertexFirstTime is an event where this action set actually
195does something: It inserts the template TemplateTouchVertexFirstTime and
196replaces it with entries from the dictionary. The latter is befilled
201 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
210 Configure name of generated C++ action set
212 This action set will end up in the directory observers with a name that
213 reflects how the observer (initialisation) is mapped onto this action
214 set. The name pattern is ObserverName2ActionSetIdentifier where this
215 routine co-determines the ActionSetIdentifier. We make is reflect the
219 return __name__.replace(
".py",
"").replace(
".",
"_")
225 The action set that Peano will generate that corresponds to this class
226 should not be modified by users and can safely be overwritten every time
227 we run the Python toolkit.
236Consult petsc.Project for details
240#include "../repositories/SolverRepository.h"
255Define body of constructor
257Consult the superclass' description of the function for results. I
258basically initialise the _localMap with the correct tree number.
264 _spacetreeId = treeNumber;
Project solution vector from PETSc back onto vertices.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
get_constructor_body(self)
Define body of constructor.
get_body_of_operation(self, operation_name)
Provide C++ code snippet for peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME
get_attributes(self)
Return attributes as copied and pasted into the generated class.
str TemplateTouchCellFirstTime
get_action_set_name(self)
Configure name of generated C++ action set.
get_includes(self)
Consult petsc.Project for details.
__init__(self, solver)
Initialise vertex-associated degrees of freedom.
Project solution vector from PETSc back onto vertices.
get_action_set_name(self)
Configure name of generated C++ action set.
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.
get_includes(self)
Consult petsc.Project for details.
get_constructor_body(self)
Define body of constructor.
str TemplateTouchVertexFirstTime
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.
Action set (reactions to events)