12 use this class to store some indices on each vertex inside touchCellFirstTime!
16 templateTouchCellFirstTime=
"""
17 //lambda to insert a value into first uninitialised position.
18 //these vectors attached to cells will have all their entries
19 //initialised to -1 otherwise
21 auto insertValueIntoVertex = [&](const int& vertex, const int& dofIndex){
22 //here we will insert dofIndex into the first empty position in the
23 //vector held by fineGridVertices{{SOLVER_NAME}}(vertex)
24 int indexWithinVector = 2*TwoPowerD; //deliberately set it to be too large
26 //we have TwoPowerD entries in this vector
27 for (int i=0; i<TwoPowerD; i++){
28 if ( fineGridVertices{{SOLVER_NAME}}(vertex).getDofIndices(i) == -1 )
29 indexWithinVector = std::min(i, indexWithinVector);
31 if(indexWithinVector < 0 or indexWithinVector > TwoPowerD)
32 throw std::runtime_error("error in inserting to vector!");
33 fineGridVertices{{SOLVER_NAME}}(vertex).setDofIndices(indexWithinVector,dofIndex);
36 if (not marker.willBeRefined()){
37 //get global index for the index held by this cell
38 std::pair<int,int> localIndex( _spacetreeId, fineGridCell{{SOLVER_NAME}}.getNumber() );
39 int globalIndex = repositories::getGlobalCellIndex( localIndex );
41 //vertex 0 takes the globalIndex + 0;
42 //vertex 1 takes the globalIndex + n; etc
43 static_assert(Dimensions==2, "hardcoding 2d for time being");
45 //worry about boundary when it comes to assembly time
46 insertValueIntoVertex(0, globalIndex);
47 insertValueIntoVertex(1, globalIndex + {{POLYNOMIAL_DEGREE}});
48 insertValueIntoVertex(2, globalIndex + {{DEGPLUS1POWERD}} - ({{POLYNOMIAL_DEGREE}} + 1));
49 insertValueIntoVertex(3, globalIndex + {{DEGPLUS1POWERD}} - 1);
62 super( SendDofsToVertices, self ).
__init__()
64 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
65 self.
d[
"SOLVER_NAME"] = solver.typename()
66 self.
d[
"POLYNOMIAL_DEGREE"] = solver.polynomial_degree
67 self.
d[
"DEGPLUS1POWERD"] = (solver.polynomial_degree+1) ** solver.dimensions
74 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
83Configure name of generated C++ action set
85This action set will end up in the directory observers with a name that
86reflects how the observer (initialisation) is mapped onto this action
87set. The name pattern is ObserverName2ActionSetIdentifier where this
88routine co-determines the ActionSetIdentifier. We make is reflect the
92 return __name__.replace(
".py",
"").replace(
".",
"_")
98 The action set that Peano will generate that corresponds to this class
99 should not be modified by users and can safely be overwritten every time
100 we run the Python toolkit.
111Every action set has excactly one attribute and that's an instance of
112petsc::LocalToGlobalMap. Before we run through a local mesh partition,
113the corresponding observer object will create a copy of the action set
114for this traversal. In the corresponding constructor, we initialise
115our thread-local copy of the map with the correct tree number.
126Define body of constructor
128Consult the superclass' description of the function for results. I
129basically initialise the _localMap with the correct tree number.
135 _spacetreeId = treeNumber;
143Consult petsc.Project for details
147#include "../repositories/SolverRepository.h"
use this class to store some indices on each vertex inside touchCellFirstTime!
get_action_set_name(self)
Configure name of generated C++ action set.
get_attributes(self)
Define the local map.
get_constructor_body(self)
Define body of constructor.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_includes(self)
Consult petsc.Project for details.
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...
Action set (reactions to events)