10 In touchVertexFirstTime, we set the type of vertex we see (either Interior, Boundary or Coarse),
11 as well as sending some values to the solver implementation file to be placed into the mesh.
13 In touchCellFirstTime, we just determine the type, as we don't store anything on cells in
17 templateTouchVertexFirstTime =
"""
20 extremely hacky static random number generator
22 static std::mt19937 rng(0); // seed with 0 for reproducibility
23 static std::uniform_real_distribution<> dis(0.0, 1.0);
26 // this is done inside getDofType. included here for sanity check
27 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
28 bool isOnBoundary = false;
29 for (int d=0; d<Dimensions; d++) {
30 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
31 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
36 auto isCorner = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
38 for (int d=0; d<Dimensions; d++) {
39 isCorner &= tarch::la::smallerEquals( x(d), DomainOffset(d) );
40 isCorner &= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
45 logTraceInWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
47 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
51 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
53 if ( marker.willBeRefined() )
55 // Coarse grid vertex. Mark it as such for later
56 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
60 // we have boundary vertex
61 if ( isOnBoundary( marker.x() ) )
62 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
65 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
67 fineGridVertex{{SOLVER_NAME}}.setU( dof, 0.0);
68 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
69 fineGridVertex{{SOLVER_NAME}}.setRand( dof, 0.0); // vector v_random is set to 0 on the boundary
75 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
77 if (isOnBoundary(marker.x()))
79 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
82 if ( marker.willBeRefined() )
84 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
89 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
92 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
94 fineGridVertex{{SOLVER_NAME}}.setU(dof, 0.0);
95 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
96 fineGridVertex{{SOLVER_NAME}}.setRand( dof, dis(rng)); // vector v_random receives random values in the interior vertices
103 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
104 assertionMsg(false, "should not be returned by user" );
107 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
108 assertionMsg(false, "should not be returned by user" );
113 logTraceOutWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
116 templateTouchCellFirstTime =
"""
117 logTraceInWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
119 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellDoFType(marker.x(),marker.h());
123 case celldata::{{SOLVER_NAME}}::Type::Outside:
125 if ( marker.willBeRefined() ) // make it coarse
127 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
131 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
136 case celldata::{{SOLVER_NAME}}::Type::Interior:
138 if ( marker.willBeRefined() )
140 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
144 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
145 // perform initialisation proc
146 // this does not work for more than one unknown per vertex
148 tarch::la::Vector<TwoPowerD, double> randValues;
149 for (int i=0; i<TwoPowerD; i++){
150 randValues[i] = fineGridVertices{{SOLVER_NAME}}(i).getRand(0);
153 // multiply v_random by A_cg
154 randValues = repositories::{{SOLVER_INSTANCE}}.getLocalAssemblyMatrix(marker.x(), marker.h()) * randValues;
156 // place this into rhs
157 for (int i=0; i<TwoPowerD; i++){
158 fineGridVertices{{SOLVER_NAME}}(i).setRhs(
159 fineGridVertices{{SOLVER_NAME}}(i).getRhs() + randValues(i)
169 logTraceOutWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
172 templateTouchVertexLastTime=
"""
178 super( InitDofsCollocatedRandomRhs, self ).
__init__()
180 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
181 self.
d[
"SOLVER_NAME"] = solver.typename()
182 self.
d[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
186 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
189 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
192 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_VERTEX_LAST_TIME:
199 Configure name of generated C++ action set
201 This action set will end up in the directory observers with a name that
202 reflects how the observer (initialisation) is mapped onto this action
203 set. The name pattern is ObserverName2ActionSetIdentifier where this
204 routine co-determines the ActionSetIdentifier. We make is reflect the
208 return __name__.replace(
".py",
"").replace(
".",
"_")
213 The action set that Peano will generate that corresponds to this class
214 should not be modified by users and can safely be overwritten every time
215 we run the Python toolkit.
223 We need the solver repository in this action set, as we directly access
224 the solver object. We also need access to Peano's d-dimensional loops.
228#include "repositories/SolverRepository.h"
230#include "peano4/utils/Loop.h"
236 Exactly the same as above, with slightly modified templateTouchVertexFirstTime
238 Don't specialise anything apart from one template. Everything else
239 will be exactly the same
244 super( InitDofsCollocatedRandomTest2, self ).
__init__( solver )
246 templateTouchVertexFirstTime =
"""
249 extremely hacky static random number generator
251 static std::mt19937 rng(0); // seed with 0 for reproducibility
252 static std::uniform_real_distribution<> dis(0.0, 1.0);
255 // this is done inside getDofType. included here for sanity check
256 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
257 bool isOnBoundary = false;
258 for (int d=0; d<Dimensions; d++) {
259 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
260 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
265 auto isCorner = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
266 bool isCorner = true;
267 for (int d=0; d<Dimensions; d++) {
268 isCorner &= tarch::la::smallerEquals( x(d), DomainOffset(d) );
269 isCorner &= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
274 logTraceInWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
276 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
280 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
282 if ( marker.willBeRefined() )
284 // Coarse grid vertex. Mark it as such for later
285 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
289 // we have boundary vertex
290 if ( isOnBoundary( marker.x() ) )
291 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
294 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
296 fineGridVertex{{SOLVER_NAME}}.setU( dof, 0.0); // vector v_random is set to 0 on the boundary as the initial guess
297 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
298 fineGridVertex{{SOLVER_NAME}}.setRand( dof, 0.0); // vector v_random is set to 0 on the boundary
304 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
306 if (isOnBoundary(marker.x()))
308 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
311 if ( marker.willBeRefined() )
313 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
318 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
321 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
323 double randVal = dis(rng);
324 fineGridVertex{{SOLVER_NAME}}.setU(dof, randVal); // vector v_random receives random values in the interior vertices
325 // and used as the initial guess for the CG solver
326 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
327 fineGridVertex{{SOLVER_NAME}}.setRand( dof, randVal); // the same vector v_random will be used to compute rhs = A_CG * v_random,
328 // see templateTouchCellFirstTime in the parent class
330 // use a continuous distribution x*y*(1-x)*(1-y) for "u_random" instead of the random one
331 //fineGridVertex{{SOLVER_NAME}}.setRand( dof, marker.x()(0)*marker.x()(1)*(1.0-marker.x()(0))*(1.0-marker.x()(1)) );
337 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
338 assertionMsg(false, "should not be returned by user" );
341 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
342 assertionMsg(false, "should not be returned by user" );
347 logTraceOutWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
352 templateTouchVertexFirstTime=
"""
354 extremely hacky static random number generator
356 static std::mt19937 rng(0); // seed with 0 for reproducibility
357 static std::uniform_real_distribution<> dis(0.0, 1.0);
360 // this is done inside getDofType. included here for sanity check
361 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
362 bool isOnBoundary = false;
363 for (int d=0; d<Dimensions; d++) {
364 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
365 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
370 auto isCorner = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
371 bool isCorner = true;
372 for (int d=0; d<Dimensions; d++) {
373 isCorner &= tarch::la::smallerEquals( x(d), DomainOffset(d) );
374 isCorner &= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
379 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
383 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
385 if ( marker.willBeRefined() )
387 // Coarse grid vertex. Mark it as such for later
388 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
392 // we have boundary vertex
393 if ( isOnBoundary( marker.x() ) )
394 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
397 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
399 fineGridVertex{{SOLVER_NAME}}.setU( dof, dis(rng)); // vector v_random is set to 0 on the boundary as the initial guess
400 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
401 fineGridVertex{{SOLVER_NAME}}.setVector2( dof, 0.0); // vector v_random is set to 0 on the boundary
407 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
409 if (isOnBoundary(marker.x()))
411 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
414 if ( marker.willBeRefined() )
416 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
421 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
424 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
426 // give it a random number
427 fineGridVertex{{SOLVER_NAME}}.setU(dof, dis(rng)); // vector v_random receives random values in the interior vertices
428 // and used as the initial guess for the CG solver
429 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
430 fineGridVertex{{SOLVER_NAME}}.setVector2( dof, 0.0);
436 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
437 assertionMsg(false, "should not be returned by user" );
440 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
441 assertionMsg(false, "should not be returned by user" );
446 templateTouchCellFirstTime=
"""
447 logTraceInWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
449 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellDoFType(marker.x(),marker.h());
453 case celldata::{{SOLVER_NAME}}::Type::Outside:
455 if ( marker.willBeRefined() ) // make it coarse
457 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
461 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
466 case celldata::{{SOLVER_NAME}}::Type::Interior:
468 if ( marker.willBeRefined() )
470 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
474 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
481 logTraceOutWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
486 super( InitCollocatedTest4, self ).
__init__(solver)
488 self.
dd[
"SOLVER_INSTANCE"] = solver.instance_name()
489 self.
dd[
"SOLVER_NAME"] = solver.typename()
490 self.
dd[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
493 templateTouchVertexFirstTime=
"""
495 extremely hacky static random number generator
497 static std::mt19937 rng(0); // seed with 0 for reproducibility
498 static std::uniform_real_distribution<> dis(0.0, 1.0);
501 // this is done inside getDofType. included here for sanity check
502 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
503 bool isOnBoundary = false;
504 for (int d=0; d<Dimensions; d++) {
505 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
506 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
511 auto isCorner = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
512 bool isCorner = true;
513 for (int d=0; d<Dimensions; d++) {
514 isCorner &= tarch::la::smallerEquals( x(d), DomainOffset(d) );
515 isCorner &= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
520 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
524 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
526 if ( marker.willBeRefined() )
528 // Coarse grid vertex. Mark it as such for later
529 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
533 // we have boundary vertex
534 if ( isOnBoundary( marker.x() ) )
535 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
538 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
540 fineGridVertex{{SOLVER_NAME}}.setRand( dof, dis(rng)); // vector v_random is set to 0 on the boundary as the initial guess
541 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
547 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
549 if (isOnBoundary(marker.x()))
551 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
554 if ( marker.willBeRefined() )
556 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
561 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
564 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
566 // give it a random number
567 fineGridVertex{{SOLVER_NAME}}.setRand(dof, dis(rng)); // vector v_random receives random values in the interior vertices
568 // and used as the initial guess for the CG solver
569 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
575 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
576 assertionMsg(false, "should not be returned by user" );
579 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
580 assertionMsg(false, "should not be returned by user" );
585 templateTouchCellFirstTime=
"""
587 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellDoFType(marker.x(),marker.h());
591 case celldata::{{SOLVER_NAME}}::Type::Outside:
593 if ( marker.willBeRefined() ) // make it coarse
595 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
599 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
604 case celldata::{{SOLVER_NAME}}::Type::Interior:
606 if ( marker.willBeRefined() )
608 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
612 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
614 // also set the extras
615 // start by fetching the random values from the cg vertices
616 tarch::la::Vector<TwoPowerD, double> randoms;
617 for (int i=0; i<TwoPowerD; i++) randoms(i) = fineGridVertices{{SOLVER_NAME}}(i).getRand(0);
619 auto ACGValues = repositories::{{SOLVER_INSTANCE}}.getLocalAssemblyMatrix( marker.x(), marker.h() ) * randoms;
620 auto MCGValues = repositories::{{SOLVER_INSTANCE}}.getMassMatrix( marker.x(), marker.h() ) * randoms;
622 for (int i=0; i<TwoPowerD; i++) {
623 fineGridVertices{{SOLVER_NAME}}(i).setAcg( 0, ACGValues(i) + fineGridVertices{{SOLVER_NAME}}(i).getAcg(0) );
624 fineGridVertices{{SOLVER_NAME}}(i).setMcg( 0, MCGValues(i) + fineGridVertices{{SOLVER_NAME}}(i).getMcg(0) );
636 super( InitCollocatedTest5, self ).
__init__(solver)
638 self.
dd[
"SOLVER_INSTANCE"] = solver.instance_name()
639 self.
dd[
"SOLVER_NAME"] = solver.typename()
640 self.
dd[
"VERTEX_CARDINALITY"] = solver._unknowns_per_vertex_node
644 We just need random numbers in the inital guess and elsewhere zeroess
647 templateTouchVertexFirstTime =
"""
650 extremely hacky static random number generator
652 static std::mt19937 rng(0); // seed with 0 for reproducibility
653 static std::uniform_real_distribution<> dis(0.0, 1.0);
656 // this is done inside getDofType. included here for sanity check
657 auto isOnBoundary = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
658 bool isOnBoundary = false;
659 for (int d=0; d<Dimensions; d++) {
660 isOnBoundary |= tarch::la::smallerEquals( x(d), DomainOffset(d) );
661 isOnBoundary |= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
666 auto isCorner = [&]( const tarch::la::Vector< Dimensions, double > & x ) -> bool{
667 bool isCorner = true;
668 for (int d=0; d<Dimensions; d++) {
669 isCorner &= tarch::la::smallerEquals( x(d), DomainOffset(d) );
670 isCorner &= tarch::la::greaterEquals( x(d), DomainOffset(d)+DomainSize(d) );
675 logTraceInWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
677 vertexdata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getVertexDoFType(marker.x(),marker.h());
681 case vertexdata::{{SOLVER_NAME}}::Type::Boundary:
683 if ( marker.willBeRefined() )
685 // Coarse grid vertex. Mark it as such for later
686 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
690 // we have boundary vertex
691 if ( isOnBoundary( marker.x() ) )
692 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Boundary );
695 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
697 fineGridVertex{{SOLVER_NAME}}.setU( dof, 0.0);
698 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
700 fineGridVertex{{SOLVER_NAME}}.setRand( dof, 0.0); // vector v_random is set to 0 on the boundary
706 case vertexdata::{{SOLVER_NAME}}::Type::Interior:
708 if (isOnBoundary(marker.x()))
710 logWarning( "touchVertexFirstTime(...)", "vertex at " << marker.toString() << " labelled as interior even though it is located at global domain boundary" );
713 if ( marker.willBeRefined() )
715 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Coarse );
720 fineGridVertex{{SOLVER_NAME}}.setType( vertexdata::{{SOLVER_NAME}}::Type::Interior );
723 for (int dof=0; dof<{{VERTEX_CARDINALITY}}; dof++)
725 fineGridVertex{{SOLVER_NAME}}.setU(dof, 0.0);
726 fineGridVertex{{SOLVER_NAME}}.setRhs( dof, 0.0);
729 double randVal = dis(rng);
730 // set the ref. solution instead of random for debugging
731 // double randVal = std::sin( 2.0*tarch::la::PI * marker.x()(0) ) * std::sin( 2.0*tarch::la::PI * marker.x()(1) );
733 // save the random vector separately
734 fineGridVertex{{SOLVER_NAME}}.setRand( dof, randVal);
740 case vertexdata::{{SOLVER_NAME}}::Type::Coarse:
741 assertionMsg(false, "should not be returned by user" );
744 case vertexdata::{{SOLVER_NAME}}::Type::Undefined:
745 assertionMsg(false, "should not be returned by user" );
750 logTraceOutWith3Arguments("InitDofs::touchVertexFirstTime", marker.toString(), isOnBoundary(marker.x()), fineGridVertex{{SOLVER_NAME}}.toString());
753 templateTouchCellFirstTime=
"""
754 logTraceInWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
756 celldata::{{SOLVER_NAME}}::Type dofType = repositories::{{SOLVER_INSTANCE}}.getCellDoFType(marker.x(),marker.h());
760 case celldata::{{SOLVER_NAME}}::Type::Outside:
762 if ( marker.willBeRefined() ) // make it coarse
764 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
768 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Outside );
773 case celldata::{{SOLVER_NAME}}::Type::Interior:
775 if ( marker.willBeRefined() )
777 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Coarse );
781 fineGridCell{{SOLVER_NAME}}.setType( celldata::{{SOLVER_NAME}}::Type::Interior );
788 logTraceOutWith2Arguments("InitDofs::touchCellFirstTime", marker.toString(), fineGridCell{{SOLVER_NAME}}.toString());
792 templateTouchVertexLastTime=
"""
We just need random numbers in the inital guess and elsewhere zeroess.
In touchVertexFirstTime, we set the type of vertex we see (either Interior, Boundary or Coarse),...
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)
Return actual C++ code snippets to be inserted into C++ code.
get_action_set_name(self)
Configure name of generated C++ action set.
str templateTouchVertexFirstTime
str templateTouchVertexLastTime
get_includes(self)
We need the solver repository in this action set, as we directly access the solver object.
str templateTouchCellFirstTime
Exactly the same as above, with slightly modified templateTouchVertexFirstTime.
Action set (reactions to events)