8 In touchVertexFirstTime, we set the type of vertex we see (either Interior, Boundary or Coarse),
9 as well as sending some values to the solver implementation file to be placed into the mesh.
11 In touchCellFirstTime, we just determine the type, as we don't store anything on cells in
15 templateTouchVertexFirstTime =
"""
16 // this is done inside getDofType. included here for sanity check
17 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
18 bool isOnBoundary = false;
19 for (int d=0; d<Dimensions; d++) {
20 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
21 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
26 // update min/max mesh size
27 repositories::{{SOLVER_INSTANCE}}.updateMinMaxMeshSize( marker.h() );
29 logTraceInWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
31 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexType(marker.x(),marker.h());
35 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
37 if ( marker.willBeRefined() )
39 // Coarse grid vertex. Mark it as such for later
40 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
44 // we have boundary vertex
45 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
47 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> value;
48 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> rhs;
50 // send these into init
51 repositories::{{SOLVER_INSTANCE}}.initVertex( marker.x(), marker.h(), value, rhs );
54 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
56 fineGridVertex{{SOLVER_NAME}}.setU( dof, value(dof));
57 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, rhs(dof));
64 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
66 if (isOnBoundary(marker.x()))
68 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
71 if ( marker.willBeRefined() )
73 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
78 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
81 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> value;
82 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> rhs;
84 // send these into init
85 repositories::{{SOLVER_INSTANCE}}.initVertex( marker.x(), marker.h(), value, rhs );
88 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
90 fineGridVertex{{SOLVER_NAME}}.setU( dof, value(dof));
91 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, rhs(dof));
97 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
98 assertionMsg(false, "should not be returned by user" );
101 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
102 assertionMsg(false, "should not be returned by user" );
107 logTraceOutWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
110 templateTouchCellFirstTime =
"""
111 logTraceInWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
113 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellType(marker.x(),marker.h());
117 case celldata::{{SOLVER_NAME}}::Type::Outside:
119 if ( marker.willBeRefined() ) // make it coarse
121 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
125 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
130 case celldata::{{SOLVER_NAME}}::Type::Interior:
132 if ( marker.willBeRefined() )
134 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
138 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
145 logTraceOutWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
150 super( InitDofsCollocated, self ).
__init__()
152 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
153 self.
d[
"SOLVER_NAME"] = solver.typename()
154 self.
d[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
158 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
161 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
169 Configure name of generated C++ action set
171 This action set will end up in the directory observers with a name that
172 reflects how the observer (initialisation) is mapped onto this action
173 set. The name pattern is ObserverName2ActionSetIdentifier where this
174 routine co-determines the ActionSetIdentifier. We make is reflect the
178 return __name__.replace(
".py",
"").replace(
".",
"_")
183 The action set that Peano will generate that corresponds to this class
184 should not be modified by users and can safely be overwritten every time
185 we run the Python toolkit.
193 We need the solver repository in this action set, as we directly access
194 the solver object. We also need access to Peano's d-dimensional loops.
198#include "../repositories/SolverRepository.h"
199#include "peano4/utils/Loop.h"
Action set (reactions to events)
In touchVertexFirstTime, we set the type of vertex we see (either Interior, Boundary or Coarse),...
get_action_set_name(self)
Configure name of generated C++ action set.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
str templateTouchCellFirstTime
str templateTouchVertexFirstTime