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 logTraceInWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
28 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
32 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
34 if ( marker.willBeRefined() )
36 // Coarse grid vertex. Mark it as such for later
37 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
41 // we have boundary vertex
42 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
44 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> value;
45 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> rhs;
47 // send these into init
48 repositories::{{SOLVER_INSTANCE}}.initVertex( marker.x(), marker.h(), value, rhs );
51 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
53 fineGridVertex{{SOLVER_NAME}}.setU( dof, value(dof));
54 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, rhs(dof));
60 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
62 if (isOnBoundary(marker.x()))
64 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
67 if ( marker.willBeRefined() )
69 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
74 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
77 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> value;
78 tarch::la::Vector<{{VERTEX_CARDINALITY}}, double> rhs;
80 // send these into init
81 repositories::{{SOLVER_INSTANCE}}.initVertex( marker.x(), marker.h(), value, rhs );
84 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
86 fineGridVertex{{SOLVER_NAME}}.setU( dof, value(dof));
87 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, rhs(dof));
93 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
94 assertionMsg(false, "should not be returned by user" );
97 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
98 assertionMsg(false, "should not be returned by user" );
103 logTraceOutWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
106 templateTouchCellFirstTime =
"""
107 logTraceInWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
109 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellDoFType(marker.x(),marker.h());
113 case celldata::{{SOLVER_NAME}}::Type::Outside:
115 if ( marker.willBeRefined() ) // make it coarse
117 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
121 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
126 case celldata::{{SOLVER_NAME}}::Type::Interior:
128 if ( marker.willBeRefined() )
130 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
134 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
141 logTraceOutWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
146 super( InitDofsCollocated, self ).
__init__()
148 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
149 self.
d[
"SOLVER_NAME"] = solver.typename()
150 self.
d[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
154 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
157 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
165 Configure name of generated C++ action set
167 This action set will end up in the directory observers with a name that
168 reflects how the observer (initialisation) is mapped onto this action
169 set. The name pattern is ObserverName2ActionSetIdentifier where this
170 routine co-determines the ActionSetIdentifier. We make is reflect the
174 return __name__.replace(
".py",
"").replace(
".",
"_")
179 The action set that Peano will generate that corresponds to this class
180 should not be modified by users and can safely be overwritten every time
181 we run the Python toolkit.
189 We need the solver repository in this action set, as we directly access
190 the solver object. We also need access to Peano's d-dimensional loops.
194#include "../repositories/SolverRepository.h"
195#include "peano4/utils/Loop.h"
In touchVertexFirstTime, we set the type of vertex we see (either Interior, Boundary or Coarse),...
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
str templateTouchVertexFirstTime
get_action_set_name(self)
Configure name of generated C++ action set.
user_should_modify_template(self)
The action set that Peano will generate that corresponds to this class should not be modified by user...
str templateTouchCellFirstTime
Action set (reactions to events)