15 def __init__(self, particle_set, filename, scale_factor=1.0):
18 particle_set: ParticleSet
21 Name of the sample point table, currently we have: t-design (948 points), Gauss_Legendre_quadrature (800 points)
24 scale factor for all coordinates, used for scale up/down the sample table from unit sphere to certain radius.
25 set to 1 if your table is exact.
30 self.
d[
"PARTICLE"] = particle_set.particle_model.name
31 self.
d[
"PARTICLES_CONTAINER"] = particle_set.name
35 __Template_TouchCellFirstTime = jinja2.Template(
37 if (not marker.willBeRefined()) {
38 tarch::multicore::Lock lock( _semaphore );
40 std::list< tarch::la::Vector<Dimensions,double> > coords = _fileReader.getParticlesWithinVoxel(marker.x(), marker.h(), true);
41 std::list< tarch::la::Vector<Dimensions,double> >::iterator p = coords.begin();
42 //for (auto* p: coords) {
43 while ( p!=coords.end() ) {
44 globaldata::{{PARTICLE}}* newParticle = new globaldata::{{PARTICLE}}();
46 newParticle->setNumber(0, _spacetreeId);
47 newParticle->setNumber(1, _particleNumberOnThisTree);
48 _particleNumberOnThisTree++;
50 logInfo( "touchVertexFirstTime(...)", "insert particle " << newParticle->toString() << " into " << marker.toString() );
52 toolbox::particles::init(*newParticle,*p,0.0);
54 toolbox::particles::insertParticleIntoCell(
57 fineGridVertices{{PARTICLES_CONTAINER}}
62 logDebug( "touchVertexFirstTime(...)", "assigned " << coords.size() << " particle(s) to vertex " << marker.toString() << " on tree " << _spacetreeId );
67 __Template_EndTraversal = jinja2.Template(
69 if (_particleNumberOnThisTree==0) {
70 logWarning( "endIteration()", "inserted " << _particleNumberOnThisTree << " particle(s) on tree " << _spacetreeId );
73 logInfo( "endIteration()", "inserted " << _particleNumberOnThisTree << " particle(s) on tree " << _spacetreeId << " (boundary vertices might host redundant particle data)" );
75 #if !defined(Parallel) and !defined(SharedMemoryParallelisation)
76 assertion( _particleNumberOnThisTree>0 );
83 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
85 if operation_name == ActionSet.OPERATION_END_TRAVERSAL:
90 return " return std::vector< peano4::grid::GridControlEvent >();\n"
93 return __name__.replace(
".py",
"").replace(
".",
"_")
99 result = jinja2.Template(
101#include "tarch/multicore/Lock.h"
102#include "tarch/multicore/multicore.h"
103#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
104#include "globaldata/{{PARTICLE}}.h"
105#include "toolbox/particles/FileReader.h"
106#include "toolbox/particles/particles.h"
107#include "toolbox/particles/ParticleFactory.h"
113 return result.render(**self.
d)
118tarch::multicore::BooleanSemaphore """
119 + full_qualified_classname
121toolbox::particles::FileReader """
122 + full_qualified_classname
131 _particleNumberOnThisTree = 0;
132 _spacetreeId = treeNumber;
134 tarch::multicore::Lock lock( _semaphore );
136 if ( _fileReader.empty() )
137 _fileReader.readDatFile( \""""
152 static tarch::multicore::BooleanSemaphore _semaphore;
154 int _particleNumberOnThisTree;
156 static toolbox::particles::FileReader _fileReader;
get_includes(self)
Return include statements that you need.
__init__(self, particle_set, filename, scale_factor=1.0)
particle_set: ParticleSet
__Template_TouchCellFirstTime
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_action_set_name(self)
Return unique action set name.
get_static_initialisations(self, full_qualified_classname)
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_body_of_getGridControlEvents(self)
get_constructor_body(self)
Define a tailored constructor body.
user_should_modify_template(self)
Is the user allowed to modify the output.
Default superclass for any data model in Peano which is stored within the grid.
Action set (reactions to events)