8from .Helper
import write_file
10from .Overwrite
import Overwrite
12from .Jinja2TemplatedHeaderFile
import Jinja2TemplatedHeaderFile
14from ..Logger
import Logger
20 C++ observer of one mesh traversal
24 The observer invokes its action sets one by one: Per event, such as
25 touchVertexFirstTime() or createCell(), it runs through the action sets
26 and invokes the event on each of them. The action sets can be split
27 into task groups, i.e. consecutive action sets which may run in parallel
28 (@ref peano4.api.solversteps.SynchroniseActionSets.get_task_groups()).
29 Within enterCell() and leaveCell(), the observer embeds the code which
30 invokes the events of a group's action sets into one task per action
31 set, spawns these tasks and waits for them
32 (tarch::multicore::spawnAndWait()) before it continues with the next
33 group. This holds for all events, i.e. the create, touch and destroy
34 events of vertices, faces and cells. The tasks capture everything by
35 reference, which is safe, as the observer waits for them. A group with
36 one action set yields exactly the same code as an observer without task
41 default_overwrite =
True
56 @param included_actions: [str]
57 Full qualified names of the action sets in invocation order.
59 @param task_groups: [[int]] or None
60 Groups of indices into included_actions. The groups are invoked
61 one after the other, the action sets within a group in parallel.
62 Concatenated, the groups have to yield 0, 1, 2, ..., i.e. every
63 action set exactly once and in invocation order. If None, every
64 action set forms a group of its own.
72 if task_groups
is None:
73 task_groups = [[index]
for index
in range(len(included_actions))]
74 if [index
for group
in task_groups
for index
in group] != list(range(len(included_actions))):
76 f
"Task groups {task_groups} of observer {classname} do not enumerate its {len(included_actions)} action sets in order"
84 self.
d[
"OPEN_NAMESPACE"] =
""
85 self.
d[
"CLOSE_NAMESPACE"] =
""
86 self.
d[
"FULL_QUALIFIED_CLASSNAME"] =
""
88 self.
d[
"OPEN_NAMESPACE"] +=
"namespace " + i +
"{\n"
89 self.
d[
"CLOSE_NAMESPACE"] +=
"}\n"
90 self.
d[
"FULL_QUALIFIED_CLASSNAME"] += i +
"::"
91 self.
d[
"CLASSNAME"] = classname
92 self.
d[
"FULL_QUALIFIED_CLASSNAME"] += classname
93 self.
d[
"INCLUDE_GUARD"] = (
94 "_" + self.
d[
"FULL_QUALIFIED_CLASSNAME"].replace(
"::",
"_").upper() +
"_H_"
96 self.
d[
"INCLUDES"] =
""
97 self.
d[
"ATTRIBUTES"] =
""
100 self.
d[
"INCLUDES"] +=
'#include "'
101 self.
d[
"INCLUDES"] += action.replace(
"::",
"/")
102 self.
d[
"INCLUDES"] +=
'.h"\n'
103 self.
d[
"ATTRIBUTES"] +=
" "
104 self.
d[
"ATTRIBUTES"] += action
105 self.
d[
"ATTRIBUTES"] +=
" _actionSet"
107 self.
d[
"ATTRIBUTES"] +=
"; \n"
109 subdirectories = set()
111 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] =
""
112 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] =
""
113 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] =
""
114 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] =
""
116 if cells.index(cell) != 0:
117 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] +=
","
118 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] +=
","
119 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] +=
","
120 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] +=
","
121 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] += (
123 "repositories::DataRepository::_"
124 + cell.get_logical_type_name()
125 +
"Stack.getForPop( " +
127 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(0)"
129 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] += (
131 "repositories::DataRepository::_"
132 + cell.get_logical_type_name()
133 +
"Stack.getForPop( " +
135 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(1)"
137 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += (
139 "repositories::DataRepository::_"
140 + cell.get_logical_type_name()
141 +
"Stack.getForPop( " +
143 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(0)"
145 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += (
147 "repositories::DataRepository::_"
148 + cell.get_logical_type_name()
149 +
"Stack.getForPop( " +
151 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(1)"
153 if cell.subdirectory:
154 subdirectories.add(cell.subdirectory)
156 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT"] = self.
d[
157 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"
159 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT"] = self.
d[
160 "MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"
163 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] =
""
164 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] =
""
165 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] =
""
166 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] =
""
168 if faces.index(face) != 0:
169 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] +=
","
170 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] +=
","
171 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] +=
","
173 "MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"
175 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] += (
176 "peano4::datamanagement::FaceEnumerator<"
177 + face.get_full_qualified_type()
180 "repositories::DataRepository::_"
181 + face.get_logical_type_name()
182 +
"Stack.getForPop( " +
184 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD-1) )"
186 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] += (
187 "peano4::datamanagement::FaceEnumerator<"
188 + face.get_full_qualified_type()
191 "repositories::DataRepository::_"
192 + face.get_logical_type_name()
193 +
"Stack.getForPop( " +
195 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD*2-1) )"
197 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] += (
198 "peano4::datamanagement::FaceEnumerator<"
199 + face.get_full_qualified_type()
202 "repositories::DataRepository::_"
203 + face.get_logical_type_name()
204 +
"Stack.getForPop( " +
206 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD-1) )(pick)"
208 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] += (
209 "peano4::datamanagement::FaceEnumerator<"
210 + face.get_full_qualified_type()
213 "repositories::DataRepository::_"
214 + face.get_logical_type_name()
215 +
"Stack.getForPop( " +
217 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD*2-1) )(pick)"
219 if face.subdirectory:
220 subdirectories.add(face.subdirectory)
222 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] =
""
223 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] =
""
224 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] =
""
225 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] =
""
226 for vertex
in vertices:
227 if vertices.index(vertex) != 0:
228 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] +=
","
229 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] +=
","
231 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"
234 "MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"
236 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] += (
237 "peano4::datamanagement::VertexEnumerator<"
238 + vertex.get_full_qualified_type()
240 vertex.subnamespace +
241 "repositories::DataRepository::_"
242 + vertex.get_logical_type_name()
243 +
"Stack.getForPop( " +
244 vertex.subnamespace +
245 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD-1) )"
247 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] += (
248 "peano4::datamanagement::VertexEnumerator<"
249 + vertex.get_full_qualified_type()
251 vertex.subnamespace +
252 "repositories::DataRepository::_"
253 + vertex.get_logical_type_name()
254 +
"Stack.getForPop( " +
255 vertex.subnamespace +
256 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD*2-1) )"
258 self.
d[
"MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] += (
259 "peano4::datamanagement::VertexEnumerator<"
260 + vertex.get_full_qualified_type()
262 vertex.subnamespace +
263 "repositories::DataRepository::_"
264 + vertex.get_logical_type_name()
265 +
"Stack.getForPop( " +
266 vertex.subnamespace +
267 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD-1) )(pick)"
269 self.
d[
"MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] += (
270 "peano4::datamanagement::VertexEnumerator<"
271 + vertex.get_full_qualified_type()
273 vertex.subnamespace +
274 "repositories::DataRepository::_"
275 + vertex.get_logical_type_name()
276 +
"Stack.getForPop( " +
277 vertex.subnamespace +
278 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD*2-1) )(pick)"
280 if vertex.subdirectory:
281 subdirectories.add(vertex.subdirectory)
283 self.
d[
"DATAREPOSITORY_INCLUDES"] =
""
285 for subdir
in subdirectories:
286 self.
d[
"INCLUDES"] =
"#include \"../" + subdir +
"repositories/DataRepository.h\"\n" + self.
d[
"INCLUDES"]
287 self.
d[
"DATAREPOSITORY_INCLUDES"] +=
"#include \"../../" + subdir +
"repositories/DataRepository.h\"\n"
289 self.
d[
"DATAREPOSITORY_INCLUDES"] =
"#include \"../repositories/DataRepository.h\"\n"
292 headerfile_template = (
293 os.path.realpath(__file__)
294 .replace(
".pyc",
".template.h")
295 .replace(
".py",
".template.h")
297 md = self.
mkSubDict([
"ATTRIBUTES",
"INCLUDES"])
307 header.generate(overwrite, directory)
310 TemplateConstructor =
"""
312{{FULL_QUALIFIED_CLASSNAME}}::{{CLASSNAME}}(int spacetreeId):
313 _spacetreeId( spacetreeId ) {{MAPPING_INITIALISATION_LIST}}
323 self.
d[
"MAPPING_INITIALISATION_LIST"] =
""
325 self.
d[
"MAPPING_INITIALISATION_LIST"] +=
", _actionSet"
326 self.
d[
"MAPPING_INITIALISATION_LIST"] += str(
329 self.
d[
"MAPPING_INITIALISATION_LIST"] +=
"(spacetreeId)"
334peano4::grid::TraversalObserver* {{FULL_QUALIFIED_CLASSNAME}}::clone(int spacetreeId) {
335 return new {{CLASSNAME}}(spacetreeId);
340 TemplateBeginTraversal =
"""
342void {{FULL_QUALIFIED_CLASSNAME}}::beginTraversal( const tarch::la::Vector<Dimensions,double>& x, const tarch::la::Vector<Dimensions,double>& h ) {
343 logTraceInWith2Arguments( "beginTraversal(...)", x, h );
345 // Invoke beginTraversal() on the actions
347{{MAPPING_BEGIN_TRAVERSAL_CALLS}}
350 // Fill call stacks with dummies which represent level 0 such that we can
351 // call standard action routines on level 1 with parents. Without these
352 // statements, a top(1) call would raise an assertion.
354{{INITIAL_PUSH_TO_OUTPUT_STREAMS}}
355 logTraceOutWith2Arguments( "beginTraversal(...)", x, h );
361 self.
d[
"MAPPING_BEGIN_TRAVERSAL_CALLS"] =
""
363 self.
d[
"MAPPING_BEGIN_TRAVERSAL_CALLS"] +=
" _actionSet"
364 self.
d[
"MAPPING_BEGIN_TRAVERSAL_CALLS"] += str(
367 self.
d[
"MAPPING_BEGIN_TRAVERSAL_CALLS"] +=
".beginTraversal();\n"
369 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] =
""
370 for cell
in self.
cells:
371 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
374 "repositories::DataRepository::_"
375 + cell.get_logical_type_name()
376 +
"Stack.getForPush( " +
378 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
379 + cell.get_full_qualified_type()
384 for face
in self.
faces:
386 "INITIAL_PUSH_TO_OUTPUT_STREAMS"
387 ] +=
" for (int i=0; i<TwoTimesD; i++) {\n"
388 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
391 "repositories::DataRepository::_"
392 + face.get_logical_type_name()
393 +
"Stack.getForPush( " +
395 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
396 + face.get_full_qualified_type()
399 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] +=
" }\n"
404 "INITIAL_PUSH_TO_OUTPUT_STREAMS"
405 ] +=
" for (int i=0; i<TwoPowerD; i++) {\n"
406 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
408 vertex.subnamespace +
409 "repositories::DataRepository::_"
410 + vertex.get_logical_type_name()
411 +
"Stack.getForPush( " +
412 vertex.subnamespace +
413 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
414 + vertex.get_full_qualified_type()
417 self.
d[
"INITIAL_PUSH_TO_OUTPUT_STREAMS"] +=
" }\n"
422 TemplateEndTraversal =
"""
424void {{FULL_QUALIFIED_CLASSNAME}}::endTraversal( const tarch::la::Vector<Dimensions,double>& x, const tarch::la::Vector<Dimensions,double>& h ) {
425 logTraceInWith2Arguments( "endTraversal(...)", x, h );
426 {{MAPPING_END_TRAVERSAL_CALLS}}
427 {{FINAL_POP_FROM_INPUT_STREAMS}}
428 logTraceOutWith2Arguments( "endTraversal(...)", x, h );
434 self.
d[
"MAPPING_END_TRAVERSAL_CALLS"] =
""
436 self.
d[
"MAPPING_END_TRAVERSAL_CALLS"] +=
" _actionSet"
437 self.
d[
"MAPPING_END_TRAVERSAL_CALLS"] += str(
440 self.
d[
"MAPPING_END_TRAVERSAL_CALLS"] +=
".endTraversal();\n"
442 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] =
""
443 for cell
in self.
cells:
444 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] += (
447 "repositories::DataRepository::_"
448 + cell.get_logical_type_name()
449 +
"Stack.getForPop( " +
451 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
455 for face
in self.
faces:
457 "FINAL_POP_FROM_INPUT_STREAMS"
458 ] +=
" for (int i=0; i<TwoTimesD; i++) {\n"
459 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] += (
462 "repositories::DataRepository::_"
463 + face.get_logical_type_name()
464 +
"Stack.getForPop( " +
466 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
468 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] +=
" }\n"
473 "FINAL_POP_FROM_INPUT_STREAMS"
474 ] +=
" for (int i=0; i<TwoPowerD; i++) {\n"
475 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] += (
477 vertex.subnamespace +
478 "repositories::DataRepository::_"
479 + vertex.get_logical_type_name()
480 +
"Stack.getForPop( " +
481 vertex.subnamespace +
482 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
484 self.
d[
"FINAL_POP_FROM_INPUT_STREAMS"] +=
" }\n"
489 TemplatePrepareTraversal =
"""
491void {{FULL_QUALIFIED_CLASSNAME}}::prepareTraversal() {
492 logTraceIn( "prepareTraversal(...)" );
493 {{MAPPING_PREPARE_TRAVERSAL_CALLS}}
494 logTraceOut( "prepareTraversal(...)" );
500 self.
d[
"MAPPING_PREPARE_TRAVERSAL_CALLS"] =
""
502 self.
d[
"MAPPING_PREPARE_TRAVERSAL_CALLS"] +=
" "
503 self.
d[
"MAPPING_PREPARE_TRAVERSAL_CALLS"] += action
504 self.
d[
"MAPPING_PREPARE_TRAVERSAL_CALLS"] +=
"::prepareTraversal();\n"
509 TemplateUnprepareTraversal =
"""
511void {{FULL_QUALIFIED_CLASSNAME}}::unprepareTraversal() {
512 logTraceIn( "unprepareTraversal(...)" );
513 {{MAPPING_UNPREPARE_TRAVERSAL_CALLS}}
514 logTraceOut( "unprepareTraversal(...)" );
520 self.
d[
"MAPPING_UNPREPARE_TRAVERSAL_CALLS"] =
""
522 self.
d[
"MAPPING_UNPREPARE_TRAVERSAL_CALLS"] +=
" "
523 self.
d[
"MAPPING_UNPREPARE_TRAVERSAL_CALLS"] += action
524 self.
d[
"MAPPING_UNPREPARE_TRAVERSAL_CALLS"] +=
"::unprepareTraversal();\n"
530 self, output_file, template, reverse_order=False, manual_dict=None
534 Takes the specified template file, iterates over actions and pastes
535 the template into the output file once per action. Per action, the dictionary's
536 entries are updated. Otherwise, the dictionary remains unchanged.
538 @todo It is not clear what manual_dict really means, and I think it is never none. Documentation might have to be updated, too.
541 Handle on output file
546 local_actions.reverse()
548 for action
in local_actions:
549 if manual_dict
is None:
550 self.
d[
"ACTIVE_ACTION_SET"] =
"_actionSet" + str(
553 self.
d[
"ACTIVE_ACTION_SET_FULL_QUALIFIED_NAME"] = action
554 if output_file
is not None:
555 output_file.write(jinja2.Template(template).render(**self.
d))
557 return jinja2.Template(template).render(**self.
d)
559 manual_dict[
"ACTIVE_ACTION_SET"] =
"_actionSet" + str(
562 manual_dict[
"ACTIVE_ACTION_SET_FULL_QUALIFIED_NAME"] = action
563 if output_file
is not None:
564 output_file.write(jinja2.Template(template).render(**manual_dict))
566 return jinja2.Template(template).render(**manual_dict)
571 Render template for the action set with the given index, i.e. the
572 C++ code with which the observer invokes this action set's events
575 dictionary = self.
d if manual_dict
is None else manual_dict
576 dictionary[
"ACTIVE_ACTION_SET"] =
"_actionSet" + str(action_index)
577 dictionary[
"ACTIVE_ACTION_SET_FULL_QUALIFIED_NAME"] = self.
included_actions[action_index]
578 return jinja2.Template(template).render(**dictionary)
581 self, output_file, template, reverse_order=False, manual_dict=None
585 Counterpart of __format_template_per_action() which takes the task
588 The groups are handled one after the other. A group with one action
589 set yields exactly the code of __format_template_per_action(). For a
590 group with several action sets, the code of each action set is
591 embedded into a lambda which captures everything by reference. Each
592 lambda is spawned as a task, and the code waits for all of them
593 before it continues. See the class documentation.
595 @param reverse_order: bool
596 Invoke the groups, and the action sets within each group, in
597 reversed order, as we do for all events of leaveCell().
600 groups = [list(group)
for group
in self.
task_groups]
602 groups = [list(reversed(group))
for group
in reversed(groups)]
610 code +=
" // Action sets " +
", ".join(str(index)
for index
in group) +
" run in parallel\n"
611 code +=
" std::vector< tarch::multicore::Task* > parallelActionSets;\n"
613 code += f
" std::function<void()> invokeActionSet{index} = [&]() -> void {{\n"
616 code +=
" parallelActionSets.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(\n"
617 code +=
" tarch::multicore::Task::DontFuse,\n"
618 code +=
" tarch::multicore::Task::DefaultPriority,\n"
619 code += f
" invokeActionSet{index}\n"
621 code +=
" tarch::multicore::spawnAndWait( parallelActionSets );\n"
623 output_file.write(code)
625 TemplateGetGridControlEvents_Prologue =
"""
627std::vector< peano4::grid::GridControlEvent > {{FULL_QUALIFIED_CLASSNAME}}::createGridControlEventsForNextTraversal() const {
628 std::vector< peano4::grid::GridControlEvent > result;
631 TemplateGetGridControlEvents_MappingCall =
"""
633 const std::vector< peano4::grid::GridControlEvent > actionResult = {{ACTIVE_ACTION_SET}}.createGridControlEventsForNextTraversal();
634 result.insert(result.begin(),actionResult.begin(),actionResult.end());
638 TemplateGetGridControlEvents_Epilogue =
"""
648 **{
"FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"]}
661 TemplateEnterCell_Prologue =
"""
662void {{FULL_QUALIFIED_CLASSNAME}}::enterCell( const peano4::grid::GridTraversalEvent& event ) {
663 logTraceInWith2Arguments( "enterCell(...)", _spacetreeId, event.toString() );
665 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
666 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
667 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
670 TemplateLoadCell_VertexLoad =
r"""
671 // Load vertex {{logical_type_name}}
672 std::function<void ()> loadVertex{{logical_type_name}} =
674 ::peano4::datamanagement::loadVertexData<{{full_qualified_type}}>(
675 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
680 [&](const peano4::datamanagement::VertexMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
681 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
686 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
687 tarch::multicore::Task::DontFuse,
688 tarch::multicore::Task::DefaultPriority,
689 loadVertex{{logical_type_name}}
693 TemplateEnterCell_VertexMappingCall =
r"""
694 // Handle vertex {{logical_type_name}}
696 peano4::datamanagement::VertexMarker marker = vertexMarker;
698 for (int i=0; i<TwoPowerD; i++) {
699 int inVertexStack = event.getVertexDataFrom(i);
700 int pick = event.getVertexDataTo(i); // the vertex position
704 logDebug( "enterCell(...)", inVertexStack << "->" << pick << " (is-local=" << marker.isLocal() << ")" );
707 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
711 // Take care about the coarse grid accesses: Faces and cells are not yet loaded.
712 // Therefore we don't use the usual shift of 2*2d or 2*2**d (don't use LaTeX here
713 // as this is within a Python document and the Python interpreter doesn't fancy
714 // escape chars here, even though these escape chars are actually within a TeX
715 // formula) but only half of it.
716 {{ACTIVE_ACTION_SET}}.createPersistentVertex(
718 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
719 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
721 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
723 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
724 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
728 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
732 {{ACTIVE_ACTION_SET}}.createHangingVertex(
734 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
735 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
739 peano4::grid::PeanoCurve::isInOutStack(inVertexStack)
743 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
745 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
746 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
753 TemplateLoadCell_FaceLoad =
r"""
754 // Load face {{logical_type_name}}
755 std::function<void ()> loadFace{{logical_type_name}} =
757 ::peano4::datamanagement::loadFaceData<{{full_qualified_type}}>(
758 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
763 [&](const peano4::datamanagement::FaceMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
764 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
769 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
770 tarch::multicore::Task::DontFuse,
771 tarch::multicore::Task::DefaultPriority,
772 loadFace{{logical_type_name}}
776 TemplateEnterCell_FaceMappingCall =
r"""
777 // Handle face {{logical_type_name}}
779 peano4::datamanagement::FaceMarker marker = faceMarker;
781 for (int i=0; i<TwoTimesD; i++) {
782 int inFaceStack = event.getFaceDataFrom(i);
783 int pick = event.getFaceDataTo(i);
788 marker.isLocal() or not event.getIsCellLocal(),
796 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
800 {{ACTIVE_ACTION_SET}}.createPersistentFace(
802 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
803 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
804 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
806 {{ACTIVE_ACTION_SET}}.touchFaceFirstTime(
808 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
809 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
810 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
814 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
818 {{ACTIVE_ACTION_SET}}.createHangingFace(
820 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
821 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
822 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
826 peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
830 {{ACTIVE_ACTION_SET}}.touchFaceFirstTime(
832 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
833 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
834 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
841 TemplateLoadCell_CellLoad =
r"""
842 // Load cell {{logical_type_name}}
843 std::function<void ()> loadCell{{logical_type_name}} =
845 ::peano4::datamanagement::loadCellData<{{full_qualified_type}}>(
846 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
851 [&](const peano4::datamanagement::CellMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
852 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
857 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
858 tarch::multicore::Task::DontFuse,
859 tarch::multicore::Task::DefaultPriority,
860 loadCell{{logical_type_name}}
864 TemplateEnterCell_CellMappingCall =
r"""
865 // Invoke creational events on cell {{logical_type_name}}
867 peano4::datamanagement::CellMarker marker = cellMarker;
870 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
874 {{ACTIVE_ACTION_SET}}.createCell(
876 {{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_}}
877 {{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_}}
878 {{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
879 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS}}
880 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS}}
881 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
887 TemplateEnterCell_MappingCall =
r"""
889 peano4::datamanagement::CellMarker marker( event );
893 {{ACTIVE_ACTION_SET}}.touchCellFirstTime(
895 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
896 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
902 TemplateEnterCell_Epilogue =
"""
903 logTraceOut( "enterCell(...)" );
911 Some logic to produce new dictionary entries from existing ones.
912 This deals mainly with having to avoid C++ code with consequtive commata
913 as some dict entries can be an empty string.
916 fields = key.split(
",")
917 nonempty = [self.
d[f]
for f
in fields
if not f ==
"" and not self.
d[f] ==
""]
918 if len(nonempty) > 0:
919 s =
",".join(nonempty)
920 if key.startswith(
",")
and not s.startswith(
","):
922 if key.endswith(
",")
and not s.endswith(
","):
932 Create the particular subdictionary that's used for an expression.
943 result[k.replace(
",",
"_COMMA_").strip()] = temp[k]
954 "enumeration_type": vertex.get_enumeration_type(),
955 "logical_type_name": vertex.get_logical_type_name(),
956 "full_qualified_type": vertex.get_full_qualified_type(),
957 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
958 "subnamespace": vertex.subnamespace,
960 self.
d[
"name"] = vertex.name
965 for face
in self.
faces:
968 "enumeration_type": face.get_enumeration_type(),
969 "logical_type_name": face.get_logical_type_name(),
970 "full_qualified_type": face.get_full_qualified_type(),
971 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
972 "subnamespace": face.subnamespace,
974 self.
d[
"name"] = face.name
979 for cell
in self.
cells:
982 "logical_type_name": cell.get_logical_type_name(),
983 "full_qualified_type": cell.get_full_qualified_type(),
984 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
985 "subnamespace": cell.subnamespace,
987 self.
d[
"name"] = cell.name
1006 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1007 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1017 if len(self.
faces) > 0:
1021 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1022 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1023 "MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1024 "MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1025 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1026 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1027 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1037 if len(self.
cells) > 0:
1041 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,",
1042 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,",
1043 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1044 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1045 ",MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1046 ",MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1058 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1059 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1068 TemplateLoadCell_Prologue =
"""
1069void {{FULL_QUALIFIED_CLASSNAME}}::loadCell( const peano4::grid::GridTraversalEvent& event ) {
1070 logTraceInWith2Arguments( "loadCell(...)", _spacetreeId, event.toString() );
1072 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
1073 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
1074 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
1076 std::vector< tarch::multicore::Task* > tasks;
1079 TemplateStoreCell_Prologue =
"""
1080void {{FULL_QUALIFIED_CLASSNAME}}::storeCell( const peano4::grid::GridTraversalEvent& event ) {
1081 logTraceInWith2Arguments( "storeCell(...)", _spacetreeId, event.toString() );
1083 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
1084 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
1085 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
1087 std::vector< tarch::multicore::Task* > tasks;
1090 TemplateLeaveCell_Prologue =
"""
1091void {{FULL_QUALIFIED_CLASSNAME}}::leaveCell( const peano4::grid::GridTraversalEvent& event ) {
1092 logTraceInWith2Arguments( "leaveCell(...)", _spacetreeId, event.toString() );
1094 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
1095 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
1096 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
1099 TemplateLeaveCell_MappingCall =
"""
1101 peano4::datamanagement::CellMarker marker = cellMarker;
1106 {{ACTIVE_ACTION_SET}}.touchCellLastTime(
1108 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1109 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1115 TemplateLeaveCell_CellStore_MappingCall =
"""
1117 peano4::datamanagement::CellMarker marker = cellMarker;
1120 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1124 {{ACTIVE_ACTION_SET}}.destroyCell(
1126 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS}}
1127 ,{{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
1128 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1134 TemplateStoreCell_CellStore =
"""
1135 // Store cell {{logical_type_name}}
1136 std::function<void ()> storeCell{{logical_type_name}} =
1138 ::peano4::datamanagement::storeCellData<{{full_qualified_type}}>(
1139 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1144 [&](const peano4::datamanagement::CellMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1145 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1150 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1151 tarch::multicore::Task::DontFuse,
1152 tarch::multicore::Task::DefaultPriority,
1153 storeCell{{logical_type_name}}
1157 TemplateLeaveCell_FaceStore_MappingCall =
"""
1158 // Handle face {{logical_type_name}}
1160 peano4::datamanagement::FaceMarker marker = faceMarker;
1162 for (int i=0; i<TwoTimesD; i++) {
1163 int outFaceStack = event.getFaceDataTo(i);
1164 int pick = event.getFaceDataFrom(i);
1166 marker.select(pick);
1169 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1173 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1175 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1176 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1177 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1179 {{ACTIVE_ACTION_SET}}.destroyPersistentFace(
1181 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1182 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1183 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1187 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1191 {{ACTIVE_ACTION_SET}}.destroyHangingFace(
1193 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1194 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1195 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1199 peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1203 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1205 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1206 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1207 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1214 TemplateStoreCell_FaceStore =
"""
1215 // Store face {{logical_type_name}}
1216 std::function<void ()> storeFace{{logical_type_name}} =
1218 ::peano4::datamanagement::storeFaceData<{{full_qualified_type}}>(
1219 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1224 [&](const peano4::datamanagement::FaceMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1225 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1230 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1231 tarch::multicore::Task::DontFuse,
1232 tarch::multicore::Task::DefaultPriority,
1233 storeFace{{logical_type_name}}
1237 TemplateLeaveCell_VertexStore_MappingCall =
"""
1238 // Handle vertex {{logical_type_name}}
1240 peano4::datamanagement::VertexMarker marker = vertexMarker;
1242 for (int i=0; i<TwoPowerD; i++) {
1243 int outVertexStack = event.getVertexDataTo(i);
1244 int pick = event.getVertexDataFrom(i);
1246 marker.select(pick);
1249 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1253 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1255 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1256 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1258 {{ACTIVE_ACTION_SET}}.destroyPersistentVertex(
1260 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1261 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1265 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1269 {{ACTIVE_ACTION_SET}}.destroyHangingVertex(
1271 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1272 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1276 peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1280 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1282 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1283 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1290 TemplateStoreCell_VertexStore =
"""
1291 // Store vertex {{logical_type_name}}
1292 std::function<void ()> storeVertex{{logical_type_name}} =
1294 ::peano4::datamanagement::storeVertexData<{{full_qualified_type}}>(
1295 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1300 [&](const peano4::datamanagement::VertexMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1301 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1306 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1307 tarch::multicore::Task::DontFuse,
1308 tarch::multicore::Task::DefaultPriority,
1309 storeVertex{{logical_type_name}}
1313 TemplateLeaveCell_Epilogue =
"""
1314 logTraceOutWith1Argument( "leaveCell(...)", _spacetreeId );
1320 TemplateLoadCell_Epilogue =
"""
1321 tarch::multicore::spawnAndWait(tasks);
1322 logTraceOutWith1Argument( "loadCell(...)", _spacetreeId );
1328 TemplateStoreCell_Epilogue =
"""
1329 tarch::multicore::spawnAndWait( tasks );
1330 logTraceOutWith1Argument( "storeCell(...)", _spacetreeId );
1338 Generates enter cell
1342 **self.
mkSubDict([
"FULL_QUALIFIED_CLASSNAME"])
1348 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1349 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1356 if len(self.
cells) > 0:
1359 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS",
1360 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1361 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1371 if len(self.
faces) > 0:
1375 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1376 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1377 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1378 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1379 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1380 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1394 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1395 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1396 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1397 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1414 cells_inverted = [x
for x
in self.
cells]
1415 faces_inverted = [x
for x
in self.
faces]
1416 vertices_inverted = [x
for x
in self.
vertices]
1418 cells_inverted.reverse()
1419 faces_inverted.reverse()
1420 vertices_inverted.reverse()
1422 for cell
in cells_inverted:
1425 "logical_type_name": cell.get_logical_type_name(),
1426 "full_qualified_type": cell.get_full_qualified_type(),
1427 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
1428 "subnamespace": cell.subnamespace,
1430 self.
d[
"name"] = cell.name
1435 for face
in faces_inverted:
1438 "enumeration_type": face.get_enumeration_type(),
1439 "logical_type_name": face.get_logical_type_name(),
1440 "full_qualified_type": face.get_full_qualified_type(),
1441 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
1442 "subnamespace": face.subnamespace,
1444 self.
d[
"name"] = face.name
1449 for vertex
in vertices_inverted:
1451 "name": vertex.name,
1452 "enumeration_type": vertex.get_enumeration_type(),
1453 "logical_type_name": vertex.get_logical_type_name(),
1454 "full_qualified_type": vertex.get_full_qualified_type(),
1455 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
1456 "subnamespace": vertex.subnamespace,
1458 self.
d[
"name"] = vertex.name
1465 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue =
"""
1466void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllVerticalDataExchangeStacks( int masterId ) {
1467 logTraceInWith2Arguments( "exchangeAllVerticalDataExchangeStacks(...)", masterId, _spacetreeId );
1470 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange =
"""
1471 peano4::parallel::SpacetreeSet::exchangeAllVerticalDataExchangeStacks(
1478 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue =
"""
1479 logTraceOut( "exchangeAllVerticalDataExchangeStacks(...)" );
1485 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue =
"""
1486void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllHorizontalDataExchangeStacks( bool symmetricDataCardinality ) {
1487 logTraceInWith2Arguments( "exchangeAllHorizontalDataExchangeStacks(...)", symmetricDataCardinality, _spacetreeId );
1490 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange =
"""
1491 peano4::parallel::SpacetreeSet::exchangeAllHorizontalDataExchangeStacks(
1494 symmetricDataCardinality
1498 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Epilogue =
"""
1499 logTraceOut( "exchangeAllHorizontalDataExchangeStacks(...)" );
1505 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue =
"""
1506void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllPeriodicBoundaryDataStacks() {
1507 logTraceInWith1Argument( "exchangeAllPeriodicBoundaryDataStacks()", _spacetreeId );
1510 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange =
"""
1511 peano4::parallel::SpacetreeSet::exchangeAllPeriodicBoundaryDataStacks(
1517 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue =
"""
1518 logTraceOut( "exchangeAllPeriodicBoundaryDataStacks()" );
1524 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue =
"""
1525void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromSplittingTreeToNewTree(int newWorker) {
1526 logTraceInWith2Arguments( "streamDataFromSplittingTreeToNewTree(int)", _spacetreeId, newWorker );
1529 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange =
"""
1530 peano4::parallel::SpacetreeSet::streamDataFromSplittingTreeToNewTree(
1537 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue =
"""
1538 logTraceOut( "streamDataFromSplittingTreeToNewTree(int)");
1544 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue =
"""
1545void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromJoiningTreeToMasterTree(int master) {
1546 logTraceInWith2Arguments( "streamDataFromJoiningTreeToMasterTree(int)", _spacetreeId, master );
1549 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange =
"""
1550 peano4::parallel::SpacetreeSet::streamDataFromJoiningTreeToMasterTree(
1557 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue =
"""
1558 logTraceOut( "streamDataFromJoiningTreeToMasterTree(int)");
1564 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue =
"""
1565void {{FULL_QUALIFIED_CLASSNAME}}::finishAllOutstandingSendsAndReceives() {
1566 logTraceInWith1Argument( "finishAllOutstandingSendsAndReceives()", _spacetreeId );
1569 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange =
"""
1570 peano4::parallel::SpacetreeSet::finishAllOutstandingSendsAndReceives(
1576 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue =
"""
1577 logTraceOut( "finishAllOutstandingSendsAndReceives()");
1583 TemplateSendVertex_Prologue =
"""
1584void {{FULL_QUALIFIED_CLASSNAME}}::sendVertex(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1585 logTraceInWith4Arguments( "sendVertex(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1587 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
1590 TemplateSendVertex_SendCall =
"""
1591 ::peano4::datamanagement::sendVertexData<{{full_qualified_type}}>(
1592 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1598 [&](const peano4::datamanagement::VertexMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1599 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1601 [&](const {{full_qualified_type}}& data, const peano4::datamanagement::VertexMarker& marker) -> bool {
1602 return data.send(marker);
1607 TemplateSendVertex_Epilogue =
"""
1608 logTraceOut( "sendVertex(int,int,int)");
1614 TemplateSendFace_Prologue =
"""
1615void {{FULL_QUALIFIED_CLASSNAME}}::sendFace(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1616 logTraceInWith4Arguments( "sendFace(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1618 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
1621 TemplateSendFace_SendCall =
"""
1622 ::peano4::datamanagement::sendFaceData<{{full_qualified_type}}>(
1623 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1629 [&](const peano4::datamanagement::FaceMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1630 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1632 [&](const {{full_qualified_type}}& data, const peano4::datamanagement::FaceMarker& marker) -> bool {
1633 return data.send(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1638 TemplateSendFace_Epilogue =
"""
1639 logTraceOut( "sendFace(int,int,int)");
1645 TemplateSendCell_Prologue =
"""
1646void {{FULL_QUALIFIED_CLASSNAME}}::sendCell(int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1647 logTraceInWith3Arguments( "sendCell(int,int,int)", toStack, event.toString(), _spacetreeId );
1649 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
1652 TemplateSendCell_SendCall =
"""
1653 ::peano4::datamanagement::sendCellData<{{full_qualified_type}}>(
1654 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1659 [&](const peano4::datamanagement::CellMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1660 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1662 [&](const {{full_qualified_type}}& data, const peano4::datamanagement::CellMarker& marker) -> bool {
1663 return data.send(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1668 TemplateSendCell_Epilogue =
"""
1669 logTraceOut( "sendCell(int,int,int)");
1675 TemplateReceiveAndMergeCell_Prologue =
"""
1676void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeCell(int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event ) {
1677 logTraceInWith3Arguments( "receiveAndMergeCell(...)", fromStack, event.toString(), _spacetreeId );
1679 [[maybe_unused]] const peano4::datamanagement::CellMarker cellMarker( event );
1682 TemplateReceiveAndMergeCell_Epilogue =
"""
1683 logTraceOut( "receiveAndMergeCell(...)");
1689 TemplateReceiveAndMergeVertex_Prologue =
"""
1690void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeVertex(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1691 logTraceInWith4Arguments( "receiveAndMergeVertex(...)", position, fromStack, event.toString(), _spacetreeId );
1693 [[maybe_unused]] const peano4::datamanagement::VertexMarker vertexMarker(event);
1696 TemplateReceiveAndMergeVertex_Epilogue =
"""
1697 logTraceOut( "receiveAndMergeVertex(...)");
1703 TemplateReceiveAndMergeFace_Epilogue =
"""
1704 logTraceOut( "receiveAndMergeFace(...)");
1710 TemplateReceiveAndMergeFace_Prologue =
"""
1711void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeFace(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1712 logTraceInWith4Arguments( "receiveAndMergeFace(...)", position, fromStack, event.toString(), _spacetreeId );
1714 [[maybe_unused]] const peano4::datamanagement::FaceMarker faceMarker( event );
1717 TemplateReceiveAndMergeVertex_ReceiveAndMergeCalls =
"""
1718 ::peano4::datamanagement::receiveAndMergeVertexData<{{full_qualified_type}}>(
1719 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1726 [&](const peano4::datamanagement::VertexMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1727 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1729 [&]({{full_qualified_type}}& data, const peano4::datamanagement::VertexMarker& marker) -> bool {
1730 return data.receiveAndMerge(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1735 TemplateReceiveAndMergeFace_ReceiveAndMergeCalls =
"""
1736 ::peano4::datamanagement::receiveAndMergeFaceData<{{full_qualified_type}}>(
1737 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1744 [&](const peano4::datamanagement::FaceMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1745 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1747 [&]({{full_qualified_type}}& data, const peano4::datamanagement::FaceMarker& marker) -> bool {
1748 return data.receiveAndMerge(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1753 TemplateReceiveAndMergeCell_ReceiveAndMergeCalls =
"""
1754 ::peano4::datamanagement::receiveAndMergeCellData<{{full_qualified_type}}>(
1755 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack,
1761 [&](const peano4::datamanagement::CellMarker& marker) -> ::peano4::grid::LoadStoreComputeFlag {
1762 return {{full_qualified_type}}::loadStoreComputeFlag(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1764 [&]({{full_qualified_type}}& data, const peano4::datamanagement::CellMarker& marker) -> bool {
1765 return data.receiveAndMerge(marker{% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}}{% endfor %});
1770 TemplateExchangeRoutines_deleteAllStacks_Prologue =
"""
1771void {{FULL_QUALIFIED_CLASSNAME}}::deleteAllStacks() {
1772 logTraceInWith1Argument( "deleteAllStacks()", _spacetreeId );
1775 TemplateExchangeRoutines_deleteAllStacks_Exchange =
"""
1776 peano4::parallel::SpacetreeSet::deleteAllStacks(
1782 TemplateExchangeRoutines_deleteAllStacks_Epilogue =
"""
1783 logTraceOut( "deleteAllStacks()");
1792 generic_dict_for_prologue_and_epilogue = {
1793 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"]
1796 s += jinja2.Template(
1798 ).render(**generic_dict_for_prologue_and_epilogue)
1799 for cell
in self.
cells:
1800 s += jinja2.Template(
1804 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1805 + cell.get_logical_type_name()
1809 for face
in self.
faces:
1810 s += jinja2.Template(
1814 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
1815 + face.get_logical_type_name()
1820 s += jinja2.Template(
1824 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
1825 + vertex.get_logical_type_name()
1829 s += jinja2.Template(
1833 s += jinja2.Template(
1835 ).render(**generic_dict_for_prologue_and_epilogue)
1836 for cell
in self.
cells:
1837 s += jinja2.Template(
1841 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1842 + cell.get_logical_type_name()
1846 for face
in self.
faces:
1847 s += jinja2.Template(
1851 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
1852 + face.get_logical_type_name()
1857 s += jinja2.Template(
1861 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
1862 + vertex.get_logical_type_name()
1866 s += jinja2.Template(
1870 s += jinja2.Template(
1872 ).render(**generic_dict_for_prologue_and_epilogue)
1873 for cell
in self.
cells:
1874 s += jinja2.Template(
1878 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1879 + cell.get_logical_type_name()
1883 for face
in self.
faces:
1884 s += jinja2.Template(
1888 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
1889 + face.get_logical_type_name()
1894 s += jinja2.Template(
1898 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
1899 + vertex.get_logical_type_name()
1903 s += jinja2.Template(
1907 s += jinja2.Template(
1909 ).render(**generic_dict_for_prologue_and_epilogue)
1910 for cell
in self.
cells:
1911 s += jinja2.Template(
1915 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1916 + cell.get_logical_type_name()
1920 for face
in self.
faces:
1921 s += jinja2.Template(
1925 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
1926 + face.get_logical_type_name()
1931 s += jinja2.Template(
1935 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
1936 + vertex.get_logical_type_name()
1940 s += jinja2.Template(
1944 s += jinja2.Template(
1946 ).render(**generic_dict_for_prologue_and_epilogue)
1947 for cell
in self.
cells:
1948 s += jinja2.Template(
1952 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1953 + cell.get_logical_type_name()
1957 for face
in self.
faces:
1958 s += jinja2.Template(
1962 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
1963 + face.get_logical_type_name()
1968 s += jinja2.Template(
1972 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
1973 + vertex.get_logical_type_name()
1977 s += jinja2.Template(
1981 s += jinja2.Template(
1983 ).render(**generic_dict_for_prologue_and_epilogue)
1984 for cell
in self.
cells:
1985 s += jinja2.Template(
1989 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
1990 + cell.get_logical_type_name()
1994 for face
in self.
faces:
1995 s += jinja2.Template(
1999 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
2000 + face.get_logical_type_name()
2005 s += jinja2.Template(
2009 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
2010 + vertex.get_logical_type_name()
2014 s += jinja2.Template(
2019 **generic_dict_for_prologue_and_epilogue
2023 "name": vertex.name,
2024 "enumeration_type": vertex.get_enumeration_type(),
2025 "logical_type_name": vertex.get_logical_type_name(),
2026 "full_qualified_type": vertex.get_full_qualified_type(),
2027 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2028 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2029 "subnamespace": vertex.subnamespace,
2033 **generic_dict_for_prologue_and_epilogue
2037 **generic_dict_for_prologue_and_epilogue
2039 for face
in self.
faces:
2042 "enumeration_type": face.get_enumeration_type(),
2043 "logical_type_name": face.get_logical_type_name(),
2044 "full_qualified_type": face.get_full_qualified_type(),
2045 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2046 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2047 "subnamespace": face.subnamespace,
2051 **generic_dict_for_prologue_and_epilogue
2055 **generic_dict_for_prologue_and_epilogue
2057 for cell
in self.
cells:
2060 "logical_type_name": cell.get_logical_type_name(),
2061 "full_qualified_type": cell.get_full_qualified_type(),
2062 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2063 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2064 "subnamespace": cell.subnamespace,
2068 **generic_dict_for_prologue_and_epilogue
2072 **generic_dict_for_prologue_and_epilogue
2074 for cell
in self.
cells:
2077 "logical_type_name": cell.get_logical_type_name(),
2078 "full_qualified_type": cell.get_full_qualified_type(),
2079 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2080 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2081 "subnamespace": cell.subnamespace,
2083 s += jinja2.Template(
2087 **generic_dict_for_prologue_and_epilogue
2091 **generic_dict_for_prologue_and_epilogue
2093 for face
in self.
faces:
2096 "enumeration_type": face.get_enumeration_type(),
2097 "logical_type_name": face.get_logical_type_name(),
2098 "full_qualified_type": face.get_full_qualified_type(),
2099 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2100 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2101 "subnamespace": face.subnamespace,
2103 s += jinja2.Template(
2107 **generic_dict_for_prologue_and_epilogue
2111 **generic_dict_for_prologue_and_epilogue
2115 "name": vertex.name,
2116 "enumeration_type": vertex.get_enumeration_type(),
2117 "logical_type_name": vertex.get_logical_type_name(),
2118 "full_qualified_type": vertex.get_full_qualified_type(),
2119 "FULL_QUALIFIED_CLASSNAME": self.
d[
"FULL_QUALIFIED_CLASSNAME"],
2120 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2121 "subnamespace": vertex.subnamespace,
2123 s += jinja2.Template(
2127 **generic_dict_for_prologue_and_epilogue
2130 s += jinja2.Template(
2132 ).render(**generic_dict_for_prologue_and_epilogue)
2133 for cell
in self.
cells:
2134 s += jinja2.Template(
2138 "DATASET": cell.subnamespace +
"repositories::DataRepository::_"
2139 + cell.get_logical_type_name()
2143 for face
in self.
faces:
2144 s += jinja2.Template(
2148 "DATASET": face.subnamespace +
"repositories::DataRepository::_"
2149 + face.get_logical_type_name()
2154 s += jinja2.Template(
2158 "DATASET": vertex.subnamespace +
"repositories::DataRepository::_"
2159 + vertex.get_logical_type_name()
2163 s += jinja2.Template(
2165 ).render(**generic_dict_for_prologue_and_epilogue)
2167 output_file.write(s)
2169 TemplateImplementationFilePrologue =
"""
2170#include "{{CLASSNAME}}.h"
2171{{DATAREPOSITORY_INCLUDES}}
2173#include "peano4/grid/PeanoCurve.h"
2175#include "peano4/datamanagement/VertexEnumerator.h"
2176#include "peano4/datamanagement/VertexMarker.h"
2177#include "peano4/datamanagement/FaceEnumerator.h"
2178#include "peano4/datamanagement/FaceMarker.h"
2179#include "peano4/datamanagement/CellMarker.h"
2180#include "peano4/datamanagement/VertexDataMovement.h"
2181#include "peano4/datamanagement/FaceDataMovement.h"
2182#include "peano4/datamanagement/CellDataMovement.h"
2184#include "peano4/parallel/SpacetreeSet.h"
2187tarch::logging::Log {{FULL_QUALIFIED_CLASSNAME}}::_log( "{{FULL_QUALIFIED_CLASSNAME}}" );
2193 output_file = open(full_qualified_filename,
"w")
2220 if not os.path.exists(directory +
"/" + self.
subdirectory):
2229 if header_written
and cpp_written:
2230 Logger().log(
"write " + header_filename +
" and " + cpp_filename)
2231 elif header_written:
2232 Logger().log(
"write " + header_filename)
2234 Logger().log(
"write " + cpp_filename)
Singleton logger for the Peano 4 Python API.
C++ observer of one mesh traversal.
__generate_loadCell(self, output_file)
str TemplateSendCell_Prologue
TemplateEnterCell_VertexMappingCall
mkSubDict(self, keys)
Create the particular subdictionary that's used for an expression.
str TemplateReceiveAndMergeVertex_Prologue
str TemplateExchangeRoutines_deleteAllStacks_Exchange
__generate_constructor(self, output_file)
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue
TemplateStoreCell_Prologue
__generate_prepareTraversal(self, output_file)
str TemplateExchangeRoutines_deleteAllStacks_Prologue
str TemplateLeaveCell_Prologue
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue
str TemplateReceiveAndMergeVertex_ReceiveAndMergeCalls
TemplateLeaveCell_FaceStore_MappingCall
str TemplateGetGridControlEvents_MappingCall
TemplateStoreCell_CellStore
str TemplateSendVertex_Epilogue
str TemplateSendVertex_SendCall
str TemplateLeaveCell_MappingCall
generateDictEntry(self, key)
Some logic to produce new dictionary entries from existing ones.
str TemplateSendCell_Epilogue
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange
str TemplateEnterCell_Prologue
str TemplateReceiveAndMergeCell_Prologue
str TemplateEnterCell_VertexMappingCall
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange
TemplateLeaveCell_Epilogue
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue
str TemplateUnprepareTraversal
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue
str TemplateStoreCell_FaceStore
TemplateEnterCell_FaceMappingCall
__generate_enterCell(self, output_file)
Generates enter cell.
str TemplateLeaveCell_Epilogue
TemplateLeaveCell_CellStore_MappingCall
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue
str TemplateLoadCell_CellLoad
str TemplateSendFace_Epilogue
TemplateGetGridControlEvents_MappingCall
__render_template_for_action(self, template, action_index, manual_dict)
Render template for the action set with the given index, i.e.
str TemplateReceiveAndMergeVertex_Epilogue
TemplateEnterCell_MappingCall
str TemplateLoadCell_VertexLoad
TemplateImplementationFilePrologue
str TemplateImplementationFilePrologue
str TemplateSendFace_SendCall
TemplateLoadCell_Epilogue
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange
str TemplateStoreCell_CellStore
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue
str TemplateStoreCell_Prologue
__generate_leaveCell(self, output_file)
Generates enter cell.
str TemplateSendCell_SendCall
TemplateStoreCell_VertexStore
TemplateGetGridControlEvents_Epilogue
TemplateLoadCell_VertexLoad
TemplateStoreCell_FaceStore
str TemplateLoadCell_FaceLoad
str TemplateReceiveAndMergeCell_Epilogue
str TemplateLoadCell_Prologue
str TemplateEnterCell_CellMappingCall
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Epilogue
__init__(self, classname, namespace, subdirectory, included_actions, vertices, faces, cells, task_groups=None)
str TemplateGetGridControlEvents_Epilogue
TemplateEnterCell_Epilogue
str TemplateReceiveAndMergeCell_ReceiveAndMergeCalls
TemplateUnprepareTraversal
str TemplateLeaveCell_CellStore_MappingCall
__format_template_per_action(self, output_file, template, reverse_order=False, manual_dict=None)
Takes the specified template file, iterates over actions and pastes the template into the output file...
__generate_beginTraversal(self, output_file)
TemplateLoadCell_CellLoad
TemplateGetGridControlEvents_Prologue
str TemplateLeaveCell_FaceStore_MappingCall
TemplateLeaveCell_MappingCall
str TemplateStoreCell_Epilogue
str TemplateReceiveAndMergeFace_Epilogue
str TemplateEnterCell_Epilogue
str TemplateReceiveAndMergeFace_ReceiveAndMergeCalls
__generate_createGridControlEventsForNextTraversal(self, output_file)
__generate_endTraversal(self, output_file)
TemplateLeaveCell_Prologue
str TemplateSendFace_Prologue
TemplateLoadCell_Prologue
TemplateEnterCell_CellMappingCall
__generate_implementation(self, overwrite, full_qualified_filename)
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue
__format_template_per_task_group(self, output_file, template, reverse_order=False, manual_dict=None)
Counterpart of __format_template_per_action() which takes the task groups into account.
TemplateLeaveCell_VertexStore_MappingCall
str TemplateLeaveCell_VertexStore_MappingCall
str TemplateReceiveAndMergeFace_Prologue
__generate_header(self, overwrite, directory)
str TemplateEnterCell_FaceMappingCall
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue
__generate_unprepareTraversal(self, output_file)
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue
TemplateLoadCell_FaceLoad
str TemplateEnterCell_MappingCall
TemplateStoreCell_Epilogue
generate(self, overwrite, directory)
__generate_exchange_routines(self, output_file)
str TemplateSendVertex_Prologue
__generate_storeCell(self, output_file)
__generate_clone(self, output_file)
str TemplateBeginTraversal
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange
str TemplateStoreCell_VertexStore
str TemplateExchangeRoutines_deleteAllStacks_Epilogue
str TemplateLoadCell_Epilogue
TemplateEnterCell_Prologue
str TemplateGetGridControlEvents_Prologue
str TemplatePrepareTraversal
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange