Peano
Loading...
Searching...
No Matches
Observer.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import re
5import jinja2
6
7
8from .Helper import write_file
9
10from .Overwrite import Overwrite
11
12from .Jinja2TemplatedHeaderFile import Jinja2TemplatedHeaderFile
13
14
15class Observer(object):
16 default_overwrite = True
17
19 self,
20 classname,
21 namespace,
22 subdirectory,
23 included_actions,
24 vertices,
25 faces,
26 cells,
27 ):
28 """
29 Included actions is a list of qualified actions which are used
30 """
31 self.classname = classname
32 self.namespace = namespace
33 self.subdirectory = subdirectory
34
35 self.included_actions = included_actions
36 self.vertices = vertices
37 self.faces = faces
38 self.cells = cells
39
40 self.d = {}
41 self.d["OPEN_NAMESPACE"] = ""
42 self.d["CLOSE_NAMESPACE"] = ""
43 self.d["FULL_QUALIFIED_CLASSNAME"] = ""
44 for i in namespace:
45 self.d["OPEN_NAMESPACE"] += "namespace " + i + "{\n"
46 self.d["CLOSE_NAMESPACE"] += "}\n"
47 self.d["FULL_QUALIFIED_CLASSNAME"] += i + "::"
48 self.d["CLASSNAME"] = classname
49 self.d["FULL_QUALIFIED_CLASSNAME"] += classname
50 self.d["INCLUDE_GUARD"] = (
51 "_" + self.d["FULL_QUALIFIED_CLASSNAME"].replace("::", "_").upper() + "_H_"
52 )
53 self.d["INCLUDES"] = ""
54 self.d["ATTRIBUTES"] = ""
55
56 for action in self.included_actions:
57 self.d["INCLUDES"] += '#include "'
58 self.d["INCLUDES"] += action.replace("::", "/")
59 self.d["INCLUDES"] += '.h"\n'
60 self.d["ATTRIBUTES"] += " "
61 self.d["ATTRIBUTES"] += action
62 self.d["ATTRIBUTES"] += " _actionSet"
63 self.d["ATTRIBUTES"] += str(self.included_actions.index(action))
64 self.d["ATTRIBUTES"] += "; \n"
65
66 subdirectories = set()
67
68 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] = ""
69 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] = ""
70 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] = ""
71 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] = ""
72 for cell in cells:
73 if cells.index(cell) != 0:
74 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] += ","
75 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] += ","
76 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += ","
77 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += ","
78 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"] += (
79 cell.subnamespace +
80 "repositories::DataRepository::_"
81 + cell.get_logical_type_name()
82 + "Stack.getForPop( " +
83 cell.subnamespace +
84 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(0)"
85 )
86 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"] += (
87 cell.subnamespace +
88 "repositories::DataRepository::_"
89 + cell.get_logical_type_name()
90 + "Stack.getForPop( " +
91 cell.subnamespace +
92 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(1)"
93 )
94 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += (
95 cell.subnamespace +
96 "repositories::DataRepository::_"
97 + cell.get_logical_type_name()
98 + "Stack.getForPop( " +
99 cell.subnamespace +
100 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(0)"
101 )
102 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_PICK_ENTRY"] += (
103 cell.subnamespace +
104 "repositories::DataRepository::_"
105 + cell.get_logical_type_name()
106 + "Stack.getForPop( " +
107 cell.subnamespace +
108 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(1)"
109 )
110 if cell.subdirectory:
111 subdirectories.add(cell.subdirectory)
112
113 self.d["MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT"] = self.d[
114 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS"
115 ]
116 self.d["MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT"] = self.d[
117 "MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS"
118 ]
119
120 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] = ""
121 self.d["MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] = ""
122 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] = ""
123 self.d["MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] = ""
124 for face in faces:
125 if faces.index(face) != 0:
126 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] += ","
127 self.d["MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] += ","
128 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] += ","
129 self.d[
130 "MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"
131 ] += ","
132 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS"] += (
133 "peano4::datamanagement::FaceEnumerator<"
134 + face.get_full_qualified_type()
135 + ">( &" +
136 face.subnamespace +
137 "repositories::DataRepository::_"
138 + face.get_logical_type_name()
139 + "Stack.getForPop( " +
140 face.subnamespace +
141 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD-1) )"
142 )
143 self.d["MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS"] += (
144 "peano4::datamanagement::FaceEnumerator<"
145 + face.get_full_qualified_type()
146 + ">( &" +
147 face.subnamespace +
148 "repositories::DataRepository::_"
149 + face.get_logical_type_name()
150 + "Stack.getForPop( " +
151 face.subnamespace +
152 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD*2-1) )"
153 )
154 self.d["MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] += (
155 "peano4::datamanagement::FaceEnumerator<"
156 + face.get_full_qualified_type()
157 + ">( &" +
158 face.subnamespace +
159 "repositories::DataRepository::_"
160 + face.get_logical_type_name()
161 + "Stack.getForPop( " +
162 face.subnamespace +
163 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD-1) )(pick)"
164 )
165 self.d["MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_PICK_ENTRY"] += (
166 "peano4::datamanagement::FaceEnumerator<"
167 + face.get_full_qualified_type()
168 + ">( &" +
169 face.subnamespace +
170 "repositories::DataRepository::_"
171 + face.get_logical_type_name()
172 + "Stack.getForPop( " +
173 face.subnamespace +
174 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoTimesD*2-1) )(pick)"
175 )
176 if face.subdirectory:
177 subdirectories.add(face.subdirectory)
178
179 self.d["MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] = ""
180 self.d["MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] = ""
181 self.d["MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] = ""
182 self.d["MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] = ""
183 for vertex in vertices:
184 if vertices.index(vertex) != 0:
185 self.d["MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] += ","
186 self.d["MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] += ","
187 self.d[
188 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"
189 ] += ","
190 self.d[
191 "MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"
192 ] += ","
193 self.d["MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS"] += (
194 "peano4::datamanagement::VertexEnumerator<"
195 + vertex.get_full_qualified_type()
196 + ">( &" +
197 vertex.subnamespace +
198 "repositories::DataRepository::_"
199 + vertex.get_logical_type_name()
200 + "Stack.getForPop( " +
201 vertex.subnamespace +
202 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD-1) )"
203 )
204 self.d["MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS"] += (
205 "peano4::datamanagement::VertexEnumerator<"
206 + vertex.get_full_qualified_type()
207 + ">( &" +
208 vertex.subnamespace +
209 "repositories::DataRepository::_"
210 + vertex.get_logical_type_name()
211 + "Stack.getForPop( " +
212 vertex.subnamespace +
213 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD*2-1) )"
214 )
215 self.d["MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] += (
216 "peano4::datamanagement::VertexEnumerator<"
217 + vertex.get_full_qualified_type()
218 + ">( &" +
219 vertex.subnamespace +
220 "repositories::DataRepository::_"
221 + vertex.get_logical_type_name()
222 + "Stack.getForPop( " +
223 vertex.subnamespace +
224 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD-1) )(pick)"
225 )
226 self.d["MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY"] += (
227 "peano4::datamanagement::VertexEnumerator<"
228 + vertex.get_full_qualified_type()
229 + ">( &" +
230 vertex.subnamespace +
231 "repositories::DataRepository::_"
232 + vertex.get_logical_type_name()
233 + "Stack.getForPop( " +
234 vertex.subnamespace +
235 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top(TwoPowerD*2-1) )(pick)"
236 )
237 if vertex.subdirectory:
238 subdirectories.add(vertex.subdirectory)
239
240 self.d["DATAREPOSITORY_INCLUDES"] = ""
241 if subdirectories:
242 for subdir in subdirectories:
243 self.d["INCLUDES"] = "#include \"../" + subdir + "repositories/DataRepository.h\"\n" + self.d["INCLUDES"]
244 self.d["DATAREPOSITORY_INCLUDES"] += "#include \"../../" + subdir + "repositories/DataRepository.h\"\n"
245 else:
246 self.d["DATAREPOSITORY_INCLUDES"] = "#include \"../repositories/DataRepository.h\"\n"
247
248 def __generate_header(self, overwrite, directory):
249 headerfile_template = (
250 os.path.realpath(__file__)
251 .replace(".pyc", ".template.h")
252 .replace(".py", ".template.h")
253 )
254 md = self.mkSubDict(["ATTRIBUTES", "INCLUDES"])
256 headerfile_template,
257 self.classname,
258 self.namespace,
259 self.subdirectory,
260 md,
262 )
263 header.generate(overwrite, directory)
264 del header
265
266 TemplateConstructor = """
267
268{{FULL_QUALIFIED_CLASSNAME}}::{{CLASSNAME}}(int spacetreeId):
269 _spacetreeId( spacetreeId ) {{MAPPING_INITIALISATION_LIST}}
270{}
271
272
273 """
274
275 def __generate_constructor(self, output_file):
276 #
277 # Constructor
278 #
279 self.d["MAPPING_INITIALISATION_LIST"] = ""
280 for actions in self.included_actions:
281 self.d["MAPPING_INITIALISATION_LIST"] += ", _actionSet"
282 self.d["MAPPING_INITIALISATION_LIST"] += str(
283 self.included_actions.index(actions)
284 )
285 self.d["MAPPING_INITIALISATION_LIST"] += "(spacetreeId)"
286 output_file.write(jinja2.Template(self.TemplateConstructorTemplateConstructor).render(**self.d))
287
288 TemplateClone = """
289
290peano4::grid::TraversalObserver* {{FULL_QUALIFIED_CLASSNAME}}::clone(int spacetreeId) {
291 return new {{CLASSNAME}}(spacetreeId);
292}
293
294 """
295
296 TemplateBeginTraversal = """
297
298void {{FULL_QUALIFIED_CLASSNAME}}::beginTraversal( const tarch::la::Vector<Dimensions,double>& x, const tarch::la::Vector<Dimensions,double>& h ) {
299 logTraceInWith2Arguments( "beginTraversal(...)", x, h );
300 //
301 // Invoke beginTraversal() on the actions
302 //
303{{MAPPING_BEGIN_TRAVERSAL_CALLS}}
304
305 //
306 // Fill call stacks with dummies which represent level 0 such that we can
307 // call standard action routines on level 1 with parents. Without these
308 // statements, a top(1) call would raise an assertion.
309 //
310{{INITIAL_PUSH_TO_OUTPUT_STREAMS}}
311 logTraceOutWith2Arguments( "beginTraversal(...)", x, h );
312}
313
314 """
315
316 def __generate_beginTraversal(self, output_file):
317 self.d["MAPPING_BEGIN_TRAVERSAL_CALLS"] = ""
318 for action in self.included_actions:
319 self.d["MAPPING_BEGIN_TRAVERSAL_CALLS"] += " _actionSet"
320 self.d["MAPPING_BEGIN_TRAVERSAL_CALLS"] += str(
321 self.included_actions.index(action)
322 )
323 self.d["MAPPING_BEGIN_TRAVERSAL_CALLS"] += ".beginTraversal();\n"
324
325 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] = ""
326 for cell in self.cells:
327 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
328 " " +
329 cell.subnamespace +
330 "repositories::DataRepository::_"
331 + cell.get_logical_type_name()
332 + "Stack.getForPush( " +
333 cell.subnamespace +
334 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
335 + cell.get_full_qualified_type()
336 + "() );\n"
337 )
338 pass
339
340 for face in self.faces:
341 self.d[
342 "INITIAL_PUSH_TO_OUTPUT_STREAMS"
343 ] += " for (int i=0; i<TwoTimesD; i++) {\n"
344 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
345 " " +
346 face.subnamespace +
347 "repositories::DataRepository::_"
348 + face.get_logical_type_name()
349 + "Stack.getForPush( " +
350 face.subnamespace +
351 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
352 + face.get_full_qualified_type()
353 + "() );\n"
354 )
355 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] += " }\n"
356 pass
357
358 for vertex in self.vertices:
359 self.d[
360 "INITIAL_PUSH_TO_OUTPUT_STREAMS"
361 ] += " for (int i=0; i<TwoPowerD; i++) {\n"
362 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] += (
363 " " +
364 vertex.subnamespace +
365 "repositories::DataRepository::_"
366 + vertex.get_logical_type_name()
367 + "Stack.getForPush( " +
368 vertex.subnamespace +
369 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->push( "
370 + vertex.get_full_qualified_type()
371 + "() );\n"
372 )
373 self.d["INITIAL_PUSH_TO_OUTPUT_STREAMS"] += " }\n"
374 pass
375
376 output_file.write(jinja2.Template(self.TemplateBeginTraversalTemplateBeginTraversal).render(**self.d))
377
378 TemplateEndTraversal = """
379
380void {{FULL_QUALIFIED_CLASSNAME}}::endTraversal( const tarch::la::Vector<Dimensions,double>& x, const tarch::la::Vector<Dimensions,double>& h ) {
381 logTraceInWith2Arguments( "endTraversal(...)", x, h );
382 {{MAPPING_END_TRAVERSAL_CALLS}}
383 {{FINAL_POP_FROM_INPUT_STREAMS}}
384 logTraceOutWith2Arguments( "endTraversal(...)", x, h );
385}
386
387 """
388
389 def __generate_endTraversal(self, output_file):
390 self.d["MAPPING_END_TRAVERSAL_CALLS"] = ""
391 for action in self.included_actions:
392 self.d["MAPPING_END_TRAVERSAL_CALLS"] += " _actionSet"
393 self.d["MAPPING_END_TRAVERSAL_CALLS"] += str(
394 self.included_actions.index(action)
395 )
396 self.d["MAPPING_END_TRAVERSAL_CALLS"] += ".endTraversal();\n"
397
398 self.d["FINAL_POP_FROM_INPUT_STREAMS"] = ""
399 for cell in self.cells:
400 self.d["FINAL_POP_FROM_INPUT_STREAMS"] += (
401 " " +
402 cell.subnamespace +
403 "repositories::DataRepository::_"
404 + cell.get_logical_type_name()
405 + "Stack.getForPop( " +
406 cell.subnamespace +
407 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
408 )
409 pass
410
411 for face in self.faces:
412 self.d[
413 "FINAL_POP_FROM_INPUT_STREAMS"
414 ] += " for (int i=0; i<TwoTimesD; i++) {\n"
415 self.d["FINAL_POP_FROM_INPUT_STREAMS"] += (
416 " " +
417 face.subnamespace +
418 "repositories::DataRepository::_"
419 + face.get_logical_type_name()
420 + "Stack.getForPop( " +
421 face.subnamespace +
422 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
423 )
424 self.d["FINAL_POP_FROM_INPUT_STREAMS"] += " }\n"
425 pass
426
427 for vertex in self.vertices:
428 self.d[
429 "FINAL_POP_FROM_INPUT_STREAMS"
430 ] += " for (int i=0; i<TwoPowerD; i++) {\n"
431 self.d["FINAL_POP_FROM_INPUT_STREAMS"] += (
432 " " +
433 vertex.subnamespace +
434 "repositories::DataRepository::_"
435 + vertex.get_logical_type_name()
436 + "Stack.getForPop( " +
437 vertex.subnamespace +
438 "repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pop();\n"
439 )
440 self.d["FINAL_POP_FROM_INPUT_STREAMS"] += " }\n"
441 pass
442
443 output_file.write(jinja2.Template(self.TemplateEndTraversalTemplateEndTraversal).render(**self.d))
444
445 TemplatePrepareTraversal = """
446
447void {{FULL_QUALIFIED_CLASSNAME}}::prepareTraversal() {
448 logTraceIn( "prepareTraversal(...)" );
449 {{MAPPING_PREPARE_TRAVERSAL_CALLS}}
450 logTraceOut( "prepareTraversal(...)" );
451}
452
453 """
454
455 def __generate_prepareTraversal(self, output_file):
456 self.d["MAPPING_PREPARE_TRAVERSAL_CALLS"] = ""
457 for action in self.included_actions:
458 self.d["MAPPING_PREPARE_TRAVERSAL_CALLS"] += " "
459 self.d["MAPPING_PREPARE_TRAVERSAL_CALLS"] += action
460 self.d["MAPPING_PREPARE_TRAVERSAL_CALLS"] += "::prepareTraversal();\n"
461 output_file.write(
462 jinja2.Template(self.TemplatePrepareTraversalTemplatePrepareTraversal).render(**self.d)
463 )
464
465 TemplateUnprepareTraversal = """
466
467void {{FULL_QUALIFIED_CLASSNAME}}::unprepareTraversal() {
468 logTraceIn( "unprepareTraversal(...)" );
469 {{MAPPING_UNPREPARE_TRAVERSAL_CALLS}}
470 logTraceOut( "unprepareTraversal(...)" );
471}
472
473 """
474
475 def __generate_unprepareTraversal(self, output_file):
476 self.d["MAPPING_UNPREPARE_TRAVERSAL_CALLS"] = ""
477 for action in self.included_actions:
478 self.d["MAPPING_UNPREPARE_TRAVERSAL_CALLS"] += " "
479 self.d["MAPPING_UNPREPARE_TRAVERSAL_CALLS"] += action
480 self.d["MAPPING_UNPREPARE_TRAVERSAL_CALLS"] += "::unprepareTraversal();\n"
481 output_file.write(
482 jinja2.Template(self.TemplateUnprepareTraversalTemplateUnprepareTraversal).render(**self.d)
483 )
484
486 self, output_file, template, reverse_order=False, manual_dict=None
487 ):
488 """
489
490 Takes the specified template file, iterates over actions and pastes
491 the template into the output file once per action. Per action, the dictionary's
492 entries are updated. Otherwise, the dictionary remains unchanged.
493
494
495 output_file:
496 Handle on output file
497
498 """
499 local_actions = [x for x in self.included_actions]
500 if reverse_order:
501 local_actions.reverse()
502
503 for action in local_actions:
504 if manual_dict is None:
505 self.d["ACTIVE_ACTION_SET"] = "_actionSet" + str(
506 self.included_actions.index(action)
507 )
508 self.d["ACTIVE_ACTION_SET_FULL_QUALIFIED_NAME"] = action
509 if output_file is not None:
510 output_file.write(jinja2.Template(template).render(**self.d))
511 else:
512 return jinja2.Template(template).render(**self.d)
513 else:
514 manual_dict["ACTIVE_ACTION_SET"] = "_actionSet" + str(
515 self.included_actions.index(action)
516 )
517 manual_dict["ACTIVE_ACTION_SET_FULL_QUALIFIED_NAME"] = action
518 if output_file is not None:
519 output_file.write(jinja2.Template(template).render(**manual_dict))
520 else:
521 return jinja2.Template(template).render(**manual_dict)
522
523 TemplateGetGridControlEvents_Prologue = """
524
525std::vector< peano4::grid::GridControlEvent > {{FULL_QUALIFIED_CLASSNAME}}::getGridControlEvents() const {
526 std::vector< peano4::grid::GridControlEvent > result;
527"""
528
529 TemplateGetGridControlEvents_MappingCall = """
530 {
531 const std::vector< peano4::grid::GridControlEvent > actionResult = {{ACTIVE_ACTION_SET}}.getGridControlEvents();
532 result.insert(result.begin(),actionResult.begin(),actionResult.end());
533 }
534"""
535
536 TemplateGetGridControlEvents_Epilogue = """
537 return result;
538}
539
540
541"""
542
543 def __generate_getGridControlEvents(self, output_file):
544 output_file.write(
546 **{"FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"]}
547 )
548 )
551 )
552 output_file.write(
554 )
555
556 def __generate_clone(self, output_file):
557 output_file.write(jinja2.Template(self.TemplateCloneTemplateClone).render(**self.d))
558
559 TemplateEnterCell_Prologue = """
560void {{FULL_QUALIFIED_CLASSNAME}}::enterCell( const peano4::grid::GridTraversalEvent& event ) {
561 logTraceInWith2Arguments( "enterCell(...)", _spacetreeId, event.toString() );
562"""
563
564 TemplateLoadCell_VertexLoad = r"""
565 // Load vertex {{logical_type_name}}
566 std::function<void ()> loadVertex{{logical_type_name}} =
567 [&]()->void {
568 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pushBlock( TwoPowerD );
569 for (int i=0; i<TwoPowerD; i++) {
570 int inVertexStack = event.getVertexDataFrom(i);
571 int outVertexStackPosition = event.getVertexDataTo(i);
572 logDebug("loadCell(...)", "vertex stack " << inVertexStack << "->pos-" << outVertexStackPosition );
573
574 peano4::datamanagement::VertexMarker marker(event,outVertexStackPosition);
575
576 bool dataResidesOnIntermediateStack =
577 not peano4::grid::PeanoCurve::isInOutStack(inVertexStack)
578 and
579 inVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
580 and
581 inVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
582 and
583 inVertexStack!=peano4::grid::TraversalObserver::NoData;
584 bool dataResidesOnInputStack =
585 peano4::grid::PeanoCurve::isInOutStack(inVertexStack)
586 and
587 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
588 marker
589 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
590 ));
591 bool initialiseStackContentForNewData =
592 ::peano4::grid::computeOnData( {{full_qualified_type}}::loadStoreComputeFlag(
593 marker
594 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
595 ))
596 or
597 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
598 or
599 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
600 ;
601
602 if ( dataResidesOnIntermediateStack or dataResidesOnInputStack ) {
603 logDebug(
604 "loadCell(...)",
605 "load data of vertex {{name}} with " << marker.x(outVertexStackPosition) << " x " << marker.h() <<
606 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
607 marker
608 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
609 ))
610 );
611 assertion4( not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inVertexStack))->empty(), event.toString(), peano4::datamanagement::VertexMarker(event).toString(), _spacetreeId, inVertexStack);
612 {{full_qualified_type}} data = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inVertexStack))->pop() );
613 #if PeanoDebug>0
614 if ( peano4::grid::PeanoCurve::isInOutStack(inVertexStack) ) {
615 assertionVectorNumericalEquals7( data.getDebugX(), marker.x(outVertexStackPosition), event.toString(), data.getDebugX(), marker.toString(), inVertexStack, i, outVertexStackPosition, _spacetreeId );
616 assertionVectorNumericalEquals6( data.getDebugH(), marker.h(), event.toString(), data.getDebugX(), marker.toString(), inVertexStack, i, _spacetreeId );
617 }
618 #endif
619 view.set(outVertexStackPosition,data);
620 }
621 else if ( initialiseStackContentForNewData ) {
622 {{full_qualified_type}} data;
623 #if PeanoDebug>0
624 logDebug(
625 "loadCell(...)",
626 "initialise meta data of new vertex {{name}} with " << marker.x(outVertexStackPosition) << " x " << marker.h() <<
627 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
628 marker
629 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
630 ))
631 );
632 data.setDebugX( marker.x(outVertexStackPosition) );
633 data.setDebugH( marker.h() );
634 #endif
635 view.set(outVertexStackPosition,data);
636 }
637 else {
638 #if PeanoDebug>0
639 logDebug(
640 "loadCell(...)",
641 "initialise meta data of unused vertex {{name}} with " << marker.x(outVertexStackPosition) << " x " << marker.h() <<
642 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
643 marker
644 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
645 ))
646 );
647 view.get(outVertexStackPosition).setDebugX( marker.x(outVertexStackPosition) );
648 view.get(outVertexStackPosition).setDebugH( marker.h() );
649 #endif
650 }
651 }
652 };
653
654 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
655 tarch::multicore::Task::DontFuse,
656 tarch::multicore::Task::DefaultPriority,
657 loadVertex{{logical_type_name}}
658 ));
659
660"""
661
662 TemplateEnterCell_VertexMappingCall = r"""
663 // Handle vertex {{logical_type_name}}
664 {
665 peano4::datamanagement::VertexMarker marker(event);
666
667 for (int i=0; i<TwoPowerD; i++) {
668 int inVertexStack = event.getVertexDataFrom(i);
669 int pick = event.getVertexDataTo(i); // the vertex position
670
671 marker.select(pick);
672
673 logDebug( "enterCell(...)", inVertexStack << "->" << pick << " (is-local=" << marker.isLocal() << ")" );
674
675 if (
676 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
677 and
678 marker.isLocal()
679 ) {
680 // Take care about the coarse grid accesses: Faces and cells are not yet loaded.
681 // Therefore we don't use the usual shift of 2*2d or 2*2**d (don't use LaTeX here
682 // as this is within a Python document and the Python interpreter doesn't fancy
683 // escape chars here, even though these escape chars are actually within a TeX
684 // formula) but only half of it.
685 {{ACTIVE_ACTION_SET}}.createPersistentVertex(
686 marker
687 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
688 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
689 );
690 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
691 marker
692 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
693 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
694 );
695 }
696 else if (
697 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
698 and
699 marker.isLocal()
700 ) {
701 {{ACTIVE_ACTION_SET}}.createHangingVertex(
702 marker
703 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
704 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
705 );
706 }
707 else if (
708 peano4::grid::PeanoCurve::isInOutStack(inVertexStack)
709 and
710 marker.isLocal()
711 ) {
712 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
713 marker
714 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
715 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
716 );
717 }
718 }
719 }
720"""
721
722 TemplateLoadCell_FaceLoad = r"""
723 // Load face {{logical_type_name}}
724 std::function<void ()> loadFace{{logical_type_name}} =
725 [&]()->void {
726 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pushBlock( TwoTimesD );
727 for (int i=0; i<TwoTimesD; i++) {
728 int inFaceStack = event.getFaceDataFrom(i);
729 int outFaceStackPosition = event.getFaceDataTo(i);
730 logDebug("loadCell(...)", "face stack " << inFaceStack << "->pos-" << outFaceStackPosition );
731
732 peano4::datamanagement::FaceMarker marker(event,outFaceStackPosition);
733
734 bool dataResidesOnIntermediateStack =
735 not peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
736 and
737 inFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
738 and
739 inFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
740 and
741 inFaceStack!=peano4::grid::TraversalObserver::NoData;
742 bool dataResidesOnInputStack =
743 peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
744 and
745 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
746 marker
747 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
748 ));
749 bool initialiseStackContentForNewData =
750 ::peano4::grid::computeOnData( {{full_qualified_type}}::loadStoreComputeFlag(
751 marker
752 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
753 ))
754 or
755 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
756 or
757 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
758 ;
759
760 if ( dataResidesOnIntermediateStack or dataResidesOnInputStack ) {
761 logDebug(
762 "loadCell(...)",
763 "load data of face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
764 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
765 marker
766 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
767 ))
768 );
769 assertion5(
770 not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inFaceStack))->empty(),
771 event.toString(),
772 peano4::datamanagement::FaceMarker(event).toString(),
773 _spacetreeId, inFaceStack,
774 ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
775 marker
776 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
777 ))
778 );
779 {{full_qualified_type}} data = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inFaceStack))->pop() );
780 #if PeanoDebug>0
781 if ( peano4::grid::PeanoCurve::isInOutStack(inFaceStack) ) {
782 assertionVectorNumericalEquals5( data.getDebugX(), marker.x(outFaceStackPosition), data.getDebugX(), data.getDebugH(), marker.toString(), outFaceStackPosition, _spacetreeId );
783 assertionVectorNumericalEquals5( data.getDebugH(), marker.h(), data.getDebugX(), data.getDebugH(), marker.toString(), outFaceStackPosition, _spacetreeId );
784 }
785 #endif
786 view.set(outFaceStackPosition,data);
787 }
788 else if ( initialiseStackContentForNewData ) {
789 {{full_qualified_type}} data;
790 #if PeanoDebug>0
791 logDebug(
792 "loadCell(...)",
793 "initialise meta data of new face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
794 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
795 marker
796 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
797 ))
798 );
799 data.setDebugX( marker.x(outFaceStackPosition) );
800 data.setDebugH( marker.h() );
801 #endif
802 view.set(outFaceStackPosition,data);
803 }
804 else {
805 #if PeanoDebug>0
806 logDebug(
807 "loadCell(...)",
808 "initialise meta data of unused face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
809 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
810 marker
811 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
812 ))
813 );
814 view.get(outFaceStackPosition).setDebugX( marker.x(outFaceStackPosition) );
815 view.get(outFaceStackPosition).setDebugH( marker.h() );
816 #endif
817 }
818 }
819 };
820
821
822 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
823 tarch::multicore::Task::DontFuse,
824 tarch::multicore::Task::DefaultPriority,
825 loadFace{{logical_type_name}}
826 ));
827
828"""
829
830 TemplateEnterCell_FaceMappingCall = r"""
831 // Handle face {{logical_type_name}}
832 {
833 peano4::datamanagement::FaceMarker marker( event );
834 for (int i=0; i<TwoTimesD; i++) {
835 int inFaceStack = event.getFaceDataFrom(i);
836 int pick = event.getFaceDataTo(i);
837
838 marker.select(pick);
839
840 assertion4(
841 marker.isLocal() or not event.getIsCellLocal(),
842 marker.toString(),
843 event.toString(),
844 i,
845 _spacetreeId
846 );
847
848 if (
849 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
850 and
851 marker.isLocal()
852 ) {
853 {{ACTIVE_ACTION_SET}}.createPersistentFace(
854 marker
855 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
856 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
857 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
858 );
859 {{ACTIVE_ACTION_SET}}.touchFaceFirstTime(
860 marker
861 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
862 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
863 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
864 );
865 }
866 else if (
867 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
868 and
869 marker.isLocal()
870 ) {
871 {{ACTIVE_ACTION_SET}}.createHangingFace(
872 marker
873 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
874 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
875 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
876 );
877 }
878 else if (
879 peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
880 and
881 marker.isLocal()
882 ) {
883 {{ACTIVE_ACTION_SET}}.touchFaceFirstTime(
884 marker
885 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
886 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
887 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
888 );
889 }
890 }
891 }
892"""
893
894 TemplateLoadCell_CellLoad = r"""
895 // Load cell {{logical_type_name}}
896 std::function<void ()> loadCell{{logical_type_name}} =
897 [&]()->void {
898 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pushBlock( 1 );
899
900 peano4::datamanagement::CellMarker marker(event);
901
902 const int inCellStack = event.getCellData();
903 const int outCellStack = peano4::grid::PeanoCurve::CallStack;
904
905 bool dataResidesOnInputStack =
906 inCellStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
907 and
908 inCellStack!=peano4::grid::TraversalObserver::NoData
909 and
910 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
911 marker
912 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
913 ));
914 bool initialiseStackContentForNewData =
915 ::peano4::grid::computeOnData( {{full_qualified_type}}::loadStoreComputeFlag(
916 marker
917 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
918 ))
919 or
920 inCellStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
921 ;
922
923 if ( dataResidesOnInputStack ) {
924 logDebug(
925 "loadCell(...)",
926 "load data of cell {{name}} with " << marker.toString() <<
927 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
928 marker
929 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
930 ))
931 );
932 assertion3( not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inCellStack))->empty(), event.toString(), _spacetreeId, inCellStack);
933 {{full_qualified_type}} data = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inCellStack))->pop() );
934
935 #if PeanoDebug>0
936 assertionVectorNumericalEquals4( data.getDebugX(), marker.x(), data.getDebugX(), data.getDebugH(), marker.toString(), _spacetreeId );
937 assertionVectorNumericalEquals4( data.getDebugH(), marker.h(), data.getDebugX(), data.getDebugH(), marker.toString(), _spacetreeId );
938 #endif
939
940 view.set(0,data);
941 }
942 else if ( initialiseStackContentForNewData ) {
943 {{full_qualified_type}} data;
944
945 #if PeanoDebug>0
946 logDebug(
947 "loadCell(...)",
948 "initialise meta data of new cell {{name}} with " << marker.toString() <<
949 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
950 marker
951 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
952 ))
953 );
954 data.setDebugX( marker.x() );
955 data.setDebugH( marker.h() );
956 #endif
957 view.set(0,data);
958 }
959 else {
960 #if PeanoDebug>0
961 logDebug(
962 "loadCell(...)",
963 "initialise meta data of unused cell {{name}} with " << marker.toString() <<
964 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
965 marker
966 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
967 ))
968 );
969 view.get(0).setDebugX( marker.x() );
970 view.get(0).setDebugH( marker.h() );
971 #endif
972 }
973 };
974
975 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
976 tarch::multicore::Task::DontFuse,
977 tarch::multicore::Task::DefaultPriority,
978 loadCell{{logical_type_name}}
979 ));
980
981"""
982
983 TemplateEnterCell_CellMappingCall = r"""
984 // Invoke creational events on cell {{logical_type_name}}
985 {
986 peano4::datamanagement::CellMarker marker( event );
987 if (
988 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
989 and
990 marker.isLocal()
991 ) {
992 {{ACTIVE_ACTION_SET}}.createCell(
993 marker,
994 {{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_}}
995 {{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_}}
996 {{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
997 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS}}
998 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS}}
999 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1000 );
1001 }
1002 }
1003"""
1004
1005 TemplateEnterCell_MappingCall = r"""
1006 {
1007 peano4::datamanagement::CellMarker marker( event );
1008 if (
1009 marker.isLocal()
1010 ) {
1011 {{ACTIVE_ACTION_SET}}.touchCellFirstTime(
1012 marker
1013 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1014 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1015 );
1016 }
1017 }
1018"""
1019
1020 TemplateEnterCell_Epilogue = """
1021 logTraceOut( "enterCell(...)" );
1022}
1023
1024
1025"""
1026
1027 def generateDictEntry(self, key):
1028 """
1029 Some logic to produce new dictionary entries from existing ones.
1030 This deals mainly with having to avoid C++ code with consequtive commata
1031 as some dict entries can be an empty string.
1032 """
1033
1034 fields = key.split(",")
1035 nonempty = [self.d[f] for f in fields if not f == "" and not self.d[f] == ""]
1036 if len(nonempty) > 0:
1037 s = ",".join(nonempty)
1038 if key.startswith(",") and not s.startswith(","):
1039 s = "," + s
1040 if key.endswith(",") and not s.endswith(","):
1041 s += ","
1042 else:
1043 s = ""
1044
1045 return s
1046
1047 def mkSubDict(self, keys):
1048 """
1049
1050 Create the particular subdictionary that's used for an expression.
1051
1052 """
1053 temp = {}
1054 for k in keys:
1055 if not k in self.d:
1056 temp[k] = self.generateDictEntry(k)
1057 else:
1058 temp[k] = self.d[k]
1059 result = {}
1060 for k in temp:
1061 result[k.replace(",", "_COMMA_").strip()] = temp[k]
1062 return result
1063
1064 def __generate_loadCell(self, output_file):
1065 output_file.write(
1066 jinja2.Template(self.TemplateLoadCell_PrologueTemplateLoadCell_Prologue).render(**self.d)
1067 )
1068
1069 for vertex in self.vertices:
1070 temp = {
1071 "name": vertex.name,
1072 "enumeration_type": vertex.get_enumeration_type(),
1073 "logical_type_name": vertex.get_logical_type_name(),
1074 "full_qualified_type": vertex.get_full_qualified_type(),
1075 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
1076 "subnamespace": vertex.subnamespace,
1077 }
1078 self.d["name"] = vertex.name
1079 output_file.write(
1081 )
1082
1083 for face in self.faces:
1084 temp = {
1085 "name": face.name,
1086 "enumeration_type": face.get_enumeration_type(),
1087 "logical_type_name": face.get_logical_type_name(),
1088 "full_qualified_type": face.get_full_qualified_type(),
1089 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
1090 "subnamespace": face.subnamespace,
1091 }
1092 self.d["name"] = face.name
1093 output_file.write(
1094 jinja2.Template(self.TemplateLoadCell_FaceLoadTemplateLoadCell_FaceLoad).render(**temp)
1095 )
1096
1097 for cell in self.cells:
1098 temp = {
1099 "name": cell.name,
1100 "logical_type_name": cell.get_logical_type_name(),
1101 "full_qualified_type": cell.get_full_qualified_type(),
1102 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
1103 "subnamespace": cell.subnamespace,
1104 }
1105 self.d["name"] = cell.name
1106 output_file.write(
1107 jinja2.Template(self.TemplateLoadCell_CellLoadTemplateLoadCell_CellLoad).render(**temp)
1108 )
1109
1110 output_file.write(jinja2.Template(self.TemplateLoadCell_EpilogueTemplateLoadCell_Epilogue).render({}))
1111
1112 def __generate_enterCell(self, output_file):
1113 """
1114 Generates enter cell
1115 """
1116 output_file.write(
1117 jinja2.Template(self.TemplateEnterCell_PrologueTemplateEnterCell_Prologue).render(**self.d)
1118 )
1119
1120 if len(self.vertices) > 0:
1121 md = self.mkSubDict(
1122 [
1123 "name",
1124 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1125 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1126 ]
1127 )
1129 output_file,
1131 False,
1132 manual_dict=md,
1133 )
1134
1135 if len(self.faces) > 0:
1136 md = self.mkSubDict(
1137 [
1138 "name",
1139 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1140 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1141 "MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1142 "MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1143 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1144 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1145 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1146 ]
1147 )
1149 output_file,
1151 False,
1152 manual_dict=md,
1153 )
1154
1155 if len(self.cells) > 0:
1156 md = self.mkSubDict(
1157 [
1158 "name",
1159 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,",
1160 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,",
1161 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1162 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1163 ",MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1164 ",MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1165 ]
1166 )
1168 output_file,
1170 False,
1171 manual_dict=md,
1172 )
1173
1174 md = self.mkSubDict(
1175 [
1176 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1177 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1178 ]
1179 )
1180
1182 output_file, self.TemplateEnterCell_MappingCallTemplateEnterCell_MappingCall, False, manual_dict=md
1183 )
1184 output_file.write(jinja2.Template(self.TemplateEnterCell_EpilogueTemplateEnterCell_Epilogue).render({}))
1185
1186 TemplateLoadCell_Prologue = """
1187void {{FULL_QUALIFIED_CLASSNAME}}::loadCell( const peano4::grid::GridTraversalEvent& event ) {
1188 logTraceInWith2Arguments( "loadCell(...)", _spacetreeId, event.toString() );
1189
1190 std::vector< tarch::multicore::Task* > tasks;
1191"""
1192
1193 TemplateStoreCell_Prologue = """
1194void {{FULL_QUALIFIED_CLASSNAME}}::storeCell( const peano4::grid::GridTraversalEvent& event ) {
1195 logTraceInWith2Arguments( "storeCell(...)", _spacetreeId, event.toString() );
1196 std::vector< tarch::multicore::Task* > tasks;
1197"""
1198
1199 TemplateLeaveCell_Prologue = """
1200void {{FULL_QUALIFIED_CLASSNAME}}::leaveCell( const peano4::grid::GridTraversalEvent& event ) {
1201 logTraceInWith2Arguments( "leaveCell(...)", _spacetreeId, event.toString() );
1202"""
1203
1204 TemplateLeaveCell_MappingCall = """
1205 {
1206 peano4::datamanagement::CellMarker marker( event );
1207 if (
1208 marker.isLocal()
1209 ) {
1210 {{ACTIVE_ACTION_SET}}.touchCellLastTime(
1211 marker
1212 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1213 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1214 );
1215 }
1216 }
1217"""
1218
1219 TemplateLeaveCell_CellStore_MappingCall = """
1220 {
1221 peano4::datamanagement::CellMarker marker( event );
1222 if (
1223 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1224 and
1225 marker.isLocal()
1226 ) {
1227 {{ACTIVE_ACTION_SET}}.destroyCell(
1228 marker
1229 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS}}
1230 ,{{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
1231 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1232 );
1233 }
1234 }
1235"""
1236
1237 TemplateStoreCell_CellStore = """
1238 // Handle cell {{logical_type_name}}
1239 std::function<void ()> storeCell{{logical_type_name}} =
1240 [&]()->void {
1241 const int inCellStack = peano4::grid::PeanoCurve::CallStack;
1242 const int outCellStack = event.getCellData();
1243 logDebug("storeCell(...)", "cell stack " << inCellStack << "->pos-" << outCellStack );
1244
1245 peano4::datamanagement::CellMarker marker(event);
1246
1247 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( 1 );
1248
1249 bool dataShallBePushedOntoIntermediateStack =
1250 not peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1251 and
1252 outCellStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1253 and
1254 outCellStack!=peano4::grid::TraversalObserver::NoData;
1255 bool dataShallBePushedOntoOutputStack =
1256 peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1257 and
1258 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1259 marker
1260 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1261 ));
1262
1263 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1264 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outCellStack))->push( view.get(0) );
1265 }
1266 else {
1267 logDebug(
1268 "storeCell(...)",
1269 "do not store cell {{name}} with " << marker.x() << " x " << marker.h() << ":" <<
1270 " destroy=" << (outCellStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity) <<
1271 ", no-data=" << (outCellStack==peano4::grid::TraversalObserver::NoData) <<
1272 ", is-in/out=" << peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1273 );
1274 }
1275 };
1276
1277 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1278 tarch::multicore::Task::DontFuse,
1279 tarch::multicore::Task::DefaultPriority,
1280 storeCell{{logical_type_name}}
1281 ));
1282
1283"""
1284
1285 TemplateLeaveCell_FaceStore_MappingCall = """
1286 // Handle face {{logical_type_name}}
1287 {
1288 peano4::datamanagement::FaceMarker marker(event);
1289
1290 for (int i=0; i<TwoTimesD; i++) {
1291 int outFaceStack = event.getFaceDataTo(i);
1292 int pick = event.getFaceDataFrom(i);
1293
1294 marker.select(pick);
1295
1296 if (
1297 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1298 and
1299 marker.isLocal()
1300 ) {
1301 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1302 marker
1303 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1304 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1305 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1306 );
1307 {{ACTIVE_ACTION_SET}}.destroyPersistentFace(
1308 marker
1309 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1310 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1311 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1312 );
1313 }
1314 else if (
1315 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1316 and
1317 marker.isLocal()
1318 ) {
1319 {{ACTIVE_ACTION_SET}}.destroyHangingFace(
1320 marker
1321 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1322 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1323 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1324 );
1325 }
1326 else if (
1327 peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1328 and
1329 marker.isLocal()
1330 ) {
1331 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1332 marker
1333 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1334 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1335 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1336 );
1337 }
1338 }
1339 }
1340"""
1341
1342 TemplateStoreCell_FaceStore = """
1343 // Store face {{logical_type_name}}
1344 std::function<void ()> storeFace{{logical_type_name}} =
1345 [&]()->void {
1346 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( TwoTimesD );
1347 for (int i=0; i<TwoTimesD; i++) {
1348 int inFaceStackPosition = event.getFaceDataFrom(i);
1349 int outFaceStack = event.getFaceDataTo(i);
1350 logDebug("storeCell(...)", "pos-" << inFaceStackPosition << "->face stack " << outFaceStack );
1351
1352 peano4::datamanagement::FaceMarker marker(event,inFaceStackPosition);
1353
1354 {{full_qualified_type}}& data = view.get(inFaceStackPosition);
1355
1356 bool dataShallBePushedOntoIntermediateStack =
1357 not peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1358 and
1359 outFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1360 and
1361 outFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1362 and
1363 outFaceStack!=peano4::grid::TraversalObserver::NoData;
1364 bool dataShallBePushedOntoOutputStack =
1365 peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1366 and
1367 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1368 marker
1369 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1370 ));
1371
1372 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1373 logDebug( "storeCell(...)", "store face {{name}} with " << marker.x(inFaceStackPosition) << " x " << marker.h() );
1374 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outFaceStack))->push(data);
1375 }
1376 else {
1377 logDebug( "storeCell(...)", "do not store face {{name}} with " << marker.x(inFaceStackPosition) << " x " << marker.h() );
1378 }
1379 }
1380 };
1381
1382 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1383 tarch::multicore::Task::DontFuse,
1384 tarch::multicore::Task::DefaultPriority,
1385 storeFace{{logical_type_name}}
1386 ));
1387
1388"""
1389
1390 TemplateLeaveCell_VertexStore_MappingCall = """
1391 // Handle vertex {{logical_type_name}}
1392 {
1393 peano4::datamanagement::VertexMarker marker(event);
1394
1395 for (int i=0; i<TwoPowerD; i++) {
1396 int outVertexStack = event.getVertexDataTo(i);
1397 int pick = event.getVertexDataFrom(i);
1398
1399 marker.select(pick);
1400
1401 if (
1402 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1403 and
1404 marker.isLocal()
1405 ) {
1406 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1407 marker
1408 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1409 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1410 );
1411 {{ACTIVE_ACTION_SET}}.destroyPersistentVertex(
1412 marker
1413 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1414 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1415 );
1416 }
1417 else if (
1418 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1419 and
1420 marker.isLocal()
1421 ) {
1422 {{ACTIVE_ACTION_SET}}.destroyHangingVertex(
1423 marker
1424 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1425 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1426 );
1427 }
1428 else if (
1429 peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1430 and
1431 marker.isLocal()
1432 ) {
1433 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1434 marker
1435 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1436 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1437 );
1438 }
1439 }
1440 }
1441"""
1442
1443 TemplateStoreCell_VertexStore = """
1444 // Store vertex {{logical_type_name}}
1445 std::function<void ()> storeVertex{{logical_type_name}} =
1446 [&]()->void {
1447 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( TwoPowerD );
1448 for (int i=0; i<TwoPowerD; i++) {
1449 int inVertexStackPosition = event.getVertexDataFrom(i);
1450 int outVertexStack = event.getVertexDataTo(i);
1451 logDebug("storeCell(...)", "pos-" << inVertexStackPosition << "->vertex stack " << outVertexStack);
1452
1453 peano4::datamanagement::VertexMarker marker(event,inVertexStackPosition);
1454
1455 {{full_qualified_type}}& data = view.get(inVertexStackPosition);
1456
1457 bool dataShallBePushedOntoIntermediateStack =
1458 not peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1459 and
1460 outVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1461 and
1462 outVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1463 and
1464 outVertexStack!=peano4::grid::TraversalObserver::NoData;
1465 bool dataShallBePushedOntoOutputStack =
1466 peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1467 and
1468 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1469 marker
1470 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1471 ));
1472
1473 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1474 logDebug( "storeCell(...)", "store vertex {{name}} with " << marker.x(inVertexStackPosition) << " x " << marker.h() );
1475 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush({{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outVertexStack))->push(data);
1476 }
1477 else {
1478 logDebug( "storeCell(...)", "do not store vertex {{name}} with " << marker.x(inVertexStackPosition) << " x " << marker.h() );
1479 }
1480 }
1481 };
1482
1483 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1484 tarch::multicore::Task::DontFuse,
1485 tarch::multicore::Task::DefaultPriority,
1486 storeVertex{{logical_type_name}}
1487 ));
1488
1489"""
1490
1491 TemplateLeaveCell_Epilogue = """
1492 logTraceOutWith1Argument( "leaveCell(...)", _spacetreeId );
1493}
1494
1495
1496"""
1497
1498 TemplateLoadCell_Epilogue = """
1499 tarch::multicore::spawnAndWait(tasks);
1500 logTraceOutWith1Argument( "loadCell(...)", _spacetreeId );
1501}
1502
1503
1504"""
1505
1506 TemplateStoreCell_Epilogue = """
1507 tarch::multicore::spawnAndWait( tasks );
1508 logTraceOutWith1Argument( "storeCell(...)", _spacetreeId );
1509}
1510
1511
1512"""
1513
1514 def __generate_leaveCell(self, output_file):
1515 """
1516 Generates enter cell
1517 """
1518 output_file.write(
1520 **self.mkSubDict(["FULL_QUALIFIED_CLASSNAME"])
1521 )
1522 )
1523
1524 md = self.mkSubDict(
1525 [
1526 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1527 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1528 ]
1529 )
1532 )
1533
1534 if len(self.cells) > 0:
1535 md = self.mkSubDict(
1536 [
1537 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS",
1538 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1539 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1540 ]
1541 )
1543 output_file,
1545 True,
1546 manual_dict=md,
1547 )
1548
1549 if len(self.faces) > 0:
1550 md = self.mkSubDict(
1551 [
1552 "name",
1553 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1554 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1555 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1556 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1557 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1558 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1559 ]
1560 )
1562 output_file,
1564 True,
1565 manual_dict=md,
1566 )
1567
1568 if len(self.vertices) > 0:
1569 md = self.mkSubDict(
1570 [
1571 "name",
1572 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1573 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1574 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1575 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1576 ]
1577 )
1579 output_file,
1581 True,
1582 manual_dict=md,
1583 )
1584
1585 output_file.write(jinja2.Template(self.TemplateLeaveCell_EpilogueTemplateLeaveCell_Epilogue).render({}))
1586
1587 def __generate_storeCell(self, output_file):
1588 output_file.write(
1589 jinja2.Template(self.TemplateStoreCell_PrologueTemplateStoreCell_Prologue).render(**self.d)
1590 )
1591
1592 cells_inverted = [x for x in self.cells]
1593 faces_inverted = [x for x in self.faces]
1594 vertices_inverted = [x for x in self.vertices]
1595
1596 cells_inverted.reverse()
1597 faces_inverted.reverse()
1598 vertices_inverted.reverse()
1599
1600 for cell in cells_inverted:
1601 temp = {
1602 "name": cell.name,
1603 "logical_type_name": cell.get_logical_type_name(),
1604 "full_qualified_type": cell.get_full_qualified_type(),
1605 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
1606 "subnamespace": cell.subnamespace,
1607 }
1608 self.d["name"] = cell.name
1609 output_file.write(
1611 )
1612
1613 for face in faces_inverted:
1614 temp = {
1615 "name": face.name,
1616 "enumeration_type": face.get_enumeration_type(),
1617 "logical_type_name": face.get_logical_type_name(),
1618 "full_qualified_type": face.get_full_qualified_type(),
1619 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
1620 "subnamespace": face.subnamespace,
1621 }
1622 self.d["name"] = face.name
1623 output_file.write(
1625 )
1626
1627 for vertex in vertices_inverted:
1628 temp = {
1629 "name": vertex.name,
1630 "enumeration_type": vertex.get_enumeration_type(),
1631 "logical_type_name": vertex.get_logical_type_name(),
1632 "full_qualified_type": vertex.get_full_qualified_type(),
1633 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
1634 "subnamespace": vertex.subnamespace,
1635 }
1636 self.d["name"] = vertex.name
1637 output_file.write(
1639 )
1640
1641 output_file.write(jinja2.Template(self.TemplateStoreCell_EpilogueTemplateStoreCell_Epilogue).render({}))
1642
1643 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue = """
1644void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllVerticalDataExchangeStacks( int masterId ) {
1645 logTraceInWith2Arguments( "exchangeAllVerticalDataExchangeStacks(...)", masterId, _spacetreeId );
1646"""
1647
1648 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange = """
1649 peano4::parallel::SpacetreeSet::exchangeAllVerticalDataExchangeStacks(
1650 {{DATASET}},
1651 _spacetreeId,
1652 masterId
1653 );
1654"""
1655
1656 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue = """
1657 logTraceOut( "exchangeAllVerticalDataExchangeStacks(...)" );
1658}
1659
1660
1661"""
1662
1663 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue = """
1664void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllHorizontalDataExchangeStacks( bool symmetricDataCardinality ) {
1665 logTraceInWith2Arguments( "exchangeAllHorizontalDataExchangeStacks(...)", symmetricDataCardinality, _spacetreeId );
1666"""
1667
1668 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange = """
1669 peano4::parallel::SpacetreeSet::exchangeAllHorizontalDataExchangeStacks(
1670 {{DATASET}},
1671 _spacetreeId,
1672 symmetricDataCardinality
1673 );
1674"""
1675
1676 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Epilogue = """
1677 logTraceOut( "exchangeAllHorizontalDataExchangeStacks(...)" );
1678}
1679
1680
1681"""
1682
1683 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue = """
1684void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllPeriodicBoundaryDataStacks() {
1685 logTraceInWith1Argument( "exchangeAllPeriodicBoundaryDataStacks()", _spacetreeId );
1686"""
1687
1688 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange = """
1689 peano4::parallel::SpacetreeSet::exchangeAllPeriodicBoundaryDataStacks(
1690 {{DATASET}},
1691 _spacetreeId
1692 );
1693"""
1694
1695 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue = """
1696 logTraceOut( "exchangeAllPeriodicBoundaryDataStacks()" );
1697}
1698
1699
1700"""
1701
1702 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue = """
1703void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromSplittingTreeToNewTree(int newWorker) {
1704 logTraceInWith2Arguments( "streamDataFromSplittingTreeToNewTree(int)", _spacetreeId, newWorker );
1705"""
1706
1707 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange = """
1708 peano4::parallel::SpacetreeSet::streamDataFromSplittingTreeToNewTree(
1709 {{DATASET}},
1710 _spacetreeId,
1711 newWorker
1712 );
1713"""
1714
1715 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue = """
1716 logTraceOut( "streamDataFromSplittingTreeToNewTree(int)");
1717}
1718
1719
1720"""
1721
1722 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue = """
1723void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromJoiningTreeToMasterTree(int master) {
1724 logTraceInWith2Arguments( "streamDataFromJoiningTreeToMasterTree(int)", _spacetreeId, master );
1725"""
1726
1727 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange = """
1728 peano4::parallel::SpacetreeSet::streamDataFromJoiningTreeToMasterTree(
1729 {{DATASET}},
1730 _spacetreeId,
1731 master
1732 );
1733"""
1734
1735 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue = """
1736 logTraceOut( "streamDataFromJoiningTreeToMasterTree(int)");
1737}
1738
1739
1740"""
1741
1742 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue = """
1743void {{FULL_QUALIFIED_CLASSNAME}}::finishAllOutstandingSendsAndReceives() {
1744 logTraceInWith1Argument( "finishAllOutstandingSendsAndReceives()", _spacetreeId );
1745"""
1746
1747 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange = """
1748 peano4::parallel::SpacetreeSet::finishAllOutstandingSendsAndReceives(
1749 {{DATASET}},
1750 _spacetreeId
1751 );
1752"""
1753
1754 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue = """
1755 logTraceOut( "finishAllOutstandingSendsAndReceives()");
1756}
1757
1758
1759"""
1760
1761 TemplateSendVertex_Prologue = """
1762void {{FULL_QUALIFIED_CLASSNAME}}::sendVertex(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1763 logTraceInWith4Arguments( "sendVertex(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1764
1765"""
1766
1767 TemplateSendVertex_SendCall = """
1768 {
1769 peano4::datamanagement::VertexMarker marker(event,position);
1770
1771 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1772 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1773 )->top(TwoPowerD-1-position);
1774 if (
1775 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1776 marker
1777 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1778 ))
1779 and
1780 (
1781 data.send(marker)
1782 or
1783 context == TraversalObserver::SendReceiveContext::ForkDomain
1784 or
1785 context == TraversalObserver::SendReceiveContext::JoinDomain
1786 )
1787 ) {
1788 logDebug( "sendVertex(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId << " for marker " << marker.toString() );
1789
1790 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1791 _spacetreeId, toStack
1792 ) -> push(data);
1793 }
1794 }
1795"""
1796
1797 TemplateSendVertex_Epilogue = """
1798 logTraceOut( "sendVertex(int,int,int)");
1799}
1800
1801
1802"""
1803
1804 TemplateSendFace_Prologue = """
1805void {{FULL_QUALIFIED_CLASSNAME}}::sendFace(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1806 logTraceInWith4Arguments( "sendFace(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1807
1808"""
1809
1810 TemplateSendFace_SendCall = """
1811 {
1812 peano4::datamanagement::FaceMarker marker(event,position);
1813 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1814 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1815 )->top(TwoTimesD-1-position);
1816 if (
1817 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1818 marker
1819 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1820 ))
1821 and
1822 (data.send(
1823 marker
1824 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1825 )
1826 or
1827 context == TraversalObserver::SendReceiveContext::ForkDomain
1828 or
1829 context == TraversalObserver::SendReceiveContext::JoinDomain
1830 )
1831 ) {
1832 logDebug( "sendFace(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId << " for marker " << marker.toString() );
1833
1834 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1835 _spacetreeId, toStack
1836 ) -> push(data);
1837 }
1838 }
1839"""
1840
1841 TemplateSendFace_Epilogue = """
1842 logTraceOut( "sendFace(int,int,int)");
1843}
1844
1845
1846"""
1847
1848 TemplateSendCell_Prologue = """
1849void {{FULL_QUALIFIED_CLASSNAME}}::sendCell(int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1850 logTraceInWith3Arguments( "sendCell(int,int,int)", toStack, event.toString(), _spacetreeId );
1851
1852"""
1853
1854 TemplateSendCell_SendCall = """
1855 {
1856 peano4::datamanagement::CellMarker marker(event);
1857 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top();
1858 if (
1859 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1860 marker
1861 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1862 ))
1863 and
1864 (
1865 data.send(
1866 marker
1867 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1868 )
1869 or
1870 context == TraversalObserver::SendReceiveContext::ForkDomain
1871 or
1872 context == TraversalObserver::SendReceiveContext::JoinDomain
1873 )
1874 ) {
1875 logDebug( "sendCell(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId );
1876
1877 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1878 _spacetreeId, toStack
1879 ) -> push(data);
1880 }
1881 }
1882"""
1883
1884 TemplateSendCell_Epilogue = """
1885 logTraceOut( "sendCell(int,int,int)");
1886}
1887
1888
1889"""
1890
1891 TemplateReceiveAndMergeCell_Prologue = """
1892void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeCell(int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event ) {
1893 logTraceInWith3Arguments( "receiveAndMergeCell(...)", fromStack, event.toString(), _spacetreeId );
1894"""
1895
1896 TemplateReceiveAndMergeCell_Epilogue = """
1897 logTraceOut( "receiveAndMergeCell(...)");
1898}
1899
1900
1901"""
1902
1903 TemplateReceiveAndMergeVertex_Prologue = """
1904void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeVertex(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1905 logTraceInWith4Arguments( "receiveAndMergeVertex(...)", position, fromStack, event.toString(), _spacetreeId );
1906"""
1907
1908 TemplateReceiveAndMergeVertex_Epilogue = """
1909 logTraceOut( "receiveAndMergeVertex(...)");
1910}
1911
1912
1913"""
1914
1915 TemplateReceiveAndMergeFace_Epilogue = """
1916 logTraceOut( "receiveAndMergeFace(...)");
1917}
1918
1919
1920"""
1921
1922 TemplateReceiveAndMergeFace_Prologue = """
1923void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeFace(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1924 logTraceInWith4Arguments( "receiveAndMergeFace(...)", position, fromStack, event.toString(), _spacetreeId );
1925"""
1926
1927 TemplateReceiveAndMergeVertex_ReceiveAndMergeCalls = """
1928 {
1929 peano4::datamanagement::VertexMarker marker(event,position);
1930 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1931 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1932 )->top(TwoPowerD-1-position);
1933
1934 if (
1935 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1936 marker
1937 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1938 ))
1939 and
1940 data.receiveAndMerge(
1941 marker
1942 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1943 )
1944 ) {
1945 assertion5(
1946 not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(_spacetreeId, fromStack)->empty(),
1947 _spacetreeId, fromStack, event.toString(), position, marker.toString()
1948 );
1949
1950 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1951 _spacetreeId, fromStack
1952 )->pop() );
1953
1954 logDebug( "receiveAndMergeVertex(...)", "merge " << incomingData.toString() << " into " << data.toString() );
1955
1956 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
1957 // @todo Different to faces. As we can have diagonal exchange, too,
1958 // we only know that it has to be unequal
1959 assertion8(
1960 data.getDebugX()!=incomingData.getDebugX(),
1961 data.getDebugX(), incomingData.getDebugX(),
1962 data.getDebugH(), incomingData.getDebugH(),
1963 fromStack, event.toString(), marker.toString(), _spacetreeId );
1964 assertionVectorNumericalEquals6(
1965 data.getDebugH(), incomingData.getDebugH(),
1966 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1967 }
1968 else {
1969 assertionVectorNumericalEquals6(
1970 data.getDebugX(), incomingData.getDebugX(),
1971 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1972 assertionVectorNumericalEquals6(
1973 data.getDebugH(), incomingData.getDebugH(),
1974 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1975 }
1976
1977 data.merge(context, incomingData, marker, _spacetreeId);
1978 }
1979 }
1980"""
1981
1982 TemplateReceiveAndMergeFace_ReceiveAndMergeCalls = """
1983 {
1984 peano4::datamanagement::FaceMarker marker(event,position);
1985 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1986 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1987 )->top(TwoTimesD-1-position);
1988
1989 if (
1990 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1991 marker
1992 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1993 ))
1994 and
1995 data.receiveAndMerge(
1996 marker
1997 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1998 )
1999 ) {
2000 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
2001 _spacetreeId, fromStack
2002 )->pop() );
2003
2004 logDebug( "receiveAndMergeFace(...)", "merge " << incomingData.toString() << " into " << data.toString() << " within marker " << marker.toString() );
2005
2006 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
2007 assertion8(
2008 tarch::la::countEqualEntries(data.getDebugX(), incomingData.getDebugX())==Dimensions-1,
2009 data.getDebugX(), incomingData.getDebugX(),
2010 data.getDebugH(), incomingData.getDebugH(),
2011 fromStack, event.toString(), marker.toString(), _spacetreeId );
2012 assertionVectorNumericalEquals6(
2013 data.getDebugH(), incomingData.getDebugH(),
2014 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2015 }
2016 else {
2017 assertionVectorNumericalEquals6(
2018 data.getDebugX(), incomingData.getDebugX(),
2019 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2020 assertionVectorNumericalEquals6(
2021 data.getDebugH(), incomingData.getDebugH(),
2022 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2023 }
2024
2025 data.merge(context,incomingData, marker, _spacetreeId);
2026 }
2027 }
2028"""
2029
2030 TemplateReceiveAndMergeCell_ReceiveAndMergeCalls = """
2031 {
2032 peano4::datamanagement::CellMarker marker(event);
2033
2034 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
2035 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
2036 )->top();
2037
2038 if (
2039 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
2040 marker
2041 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
2042 ))
2043 and
2044 data.receiveAndMerge(
2045 marker
2046 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
2047 )
2048 ) {
2049 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
2050 _spacetreeId, fromStack
2051 )->pop() );
2052
2053 logDebug( "receiveAndMergeCell(...)", "merge " << incomingData.toString() << " into " << data.toString() );
2054
2055 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
2056 assertion8(
2057 tarch::la::countEqualEntries(data.getDebugX(), incomingData.getDebugX())==Dimensions-1,
2058 data.getDebugX(), incomingData.getDebugX(),
2059 data.getDebugH(), incomingData.getDebugH(),
2060 fromStack, event.toString(), marker.toString(), _spacetreeId );
2061 assertionVectorNumericalEquals6(
2062 data.getDebugH(), incomingData.getDebugH(),
2063 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2064 }
2065 else {
2066 assertionVectorNumericalEquals6(
2067 data.getDebugX(), incomingData.getDebugX(),
2068 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2069 assertionVectorNumericalEquals6(
2070 data.getDebugH(), incomingData.getDebugH(),
2071 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2072 }
2073
2074 data.merge(context,incomingData, marker, _spacetreeId);
2075 }
2076 }
2077"""
2078
2079 TemplateExchangeRoutines_deleteAllStacks_Prologue = """
2080void {{FULL_QUALIFIED_CLASSNAME}}::deleteAllStacks() {
2081 logTraceInWith1Argument( "deleteAllStacks()", _spacetreeId );
2082"""
2083
2084 TemplateExchangeRoutines_deleteAllStacks_Exchange = """
2085 peano4::parallel::SpacetreeSet::deleteAllStacks(
2086 {{DATASET}},
2087 _spacetreeId
2088 );
2089"""
2090
2091 TemplateExchangeRoutines_deleteAllStacks_Epilogue = """
2092 logTraceOut( "deleteAllStacks()");
2093}
2094
2095
2096"""
2097
2098 def __generate_exchange_routines(self, output_file):
2099 s = ""
2100
2101 generic_dict_for_prologue_and_epilogue = {
2102 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"]
2103 }
2104
2105 s += jinja2.Template(
2107 ).render(**generic_dict_for_prologue_and_epilogue)
2108 for cell in self.cells:
2109 s += jinja2.Template(
2111 ).render(
2112 **{
2113 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2114 + cell.get_logical_type_name()
2115 + "Stack"
2116 }
2117 )
2118 for face in self.faces:
2119 s += jinja2.Template(
2121 ).render(
2122 **{
2123 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2124 + face.get_logical_type_name()
2125 + "Stack"
2126 }
2127 )
2128 for vertex in self.vertices:
2129 s += jinja2.Template(
2131 ).render(
2132 **{
2133 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2134 + vertex.get_logical_type_name()
2135 + "Stack"
2136 }
2137 )
2138 s += jinja2.Template(
2140 ).render({})
2141
2142 s += jinja2.Template(
2144 ).render(**generic_dict_for_prologue_and_epilogue)
2145 for cell in self.cells:
2146 s += jinja2.Template(
2148 ).render(
2149 **{
2150 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2151 + cell.get_logical_type_name()
2152 + "Stack"
2153 }
2154 )
2155 for face in self.faces:
2156 s += jinja2.Template(
2158 ).render(
2159 **{
2160 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2161 + face.get_logical_type_name()
2162 + "Stack"
2163 }
2164 )
2165 for vertex in self.vertices:
2166 s += jinja2.Template(
2168 ).render(
2169 **{
2170 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2171 + vertex.get_logical_type_name()
2172 + "Stack"
2173 }
2174 )
2175 s += jinja2.Template(
2177 ).render({})
2178
2179 s += jinja2.Template(
2181 ).render(**generic_dict_for_prologue_and_epilogue)
2182 for cell in self.cells:
2183 s += jinja2.Template(
2185 ).render(
2186 **{
2187 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2188 + cell.get_logical_type_name()
2189 + "Stack"
2190 }
2191 )
2192 for face in self.faces:
2193 s += jinja2.Template(
2195 ).render(
2196 **{
2197 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2198 + face.get_logical_type_name()
2199 + "Stack"
2200 }
2201 )
2202 for vertex in self.vertices:
2203 s += jinja2.Template(
2205 ).render(
2206 **{
2207 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2208 + vertex.get_logical_type_name()
2209 + "Stack"
2210 }
2211 )
2212 s += jinja2.Template(
2214 ).render({})
2215
2216 s += jinja2.Template(
2218 ).render(**generic_dict_for_prologue_and_epilogue)
2219 for cell in self.cells:
2220 s += jinja2.Template(
2222 ).render(
2223 **{
2224 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2225 + cell.get_logical_type_name()
2226 + "Stack"
2227 }
2228 )
2229 for face in self.faces:
2230 s += jinja2.Template(
2232 ).render(
2233 **{
2234 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2235 + face.get_logical_type_name()
2236 + "Stack"
2237 }
2238 )
2239 for vertex in self.vertices:
2240 s += jinja2.Template(
2242 ).render(
2243 **{
2244 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2245 + vertex.get_logical_type_name()
2246 + "Stack"
2247 }
2248 )
2249 s += jinja2.Template(
2251 ).render({})
2252
2253 s += jinja2.Template(
2255 ).render(**generic_dict_for_prologue_and_epilogue)
2256 for cell in self.cells:
2257 s += jinja2.Template(
2259 ).render(
2260 **{
2261 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2262 + cell.get_logical_type_name()
2263 + "Stack"
2264 }
2265 )
2266 for face in self.faces:
2267 s += jinja2.Template(
2269 ).render(
2270 **{
2271 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2272 + face.get_logical_type_name()
2273 + "Stack"
2274 }
2275 )
2276 for vertex in self.vertices:
2277 s += jinja2.Template(
2279 ).render(
2280 **{
2281 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2282 + vertex.get_logical_type_name()
2283 + "Stack"
2284 }
2285 )
2286 s += jinja2.Template(
2288 ).render({})
2289
2290 s += jinja2.Template(
2292 ).render(**generic_dict_for_prologue_and_epilogue)
2293 for cell in self.cells:
2294 s += jinja2.Template(
2296 ).render(
2297 **{
2298 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2299 + cell.get_logical_type_name()
2300 + "Stack"
2301 }
2302 )
2303 for face in self.faces:
2304 s += jinja2.Template(
2306 ).render(
2307 **{
2308 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2309 + face.get_logical_type_name()
2310 + "Stack"
2311 }
2312 )
2313 for vertex in self.vertices:
2314 s += jinja2.Template(
2316 ).render(
2317 **{
2318 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2319 + vertex.get_logical_type_name()
2320 + "Stack"
2321 }
2322 )
2323 s += jinja2.Template(
2325 ).render({})
2326
2327 s += jinja2.Template(self.TemplateSendVertex_Prologue).render(
2328 **generic_dict_for_prologue_and_epilogue
2329 )
2330 for vertex in self.vertices:
2331 temp = {
2332 "name": vertex.name,
2333 "enumeration_type": vertex.get_enumeration_type(),
2334 "logical_type_name": vertex.get_logical_type_name(),
2335 "full_qualified_type": vertex.get_full_qualified_type(),
2336 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2337 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2338 "subnamespace": vertex.subnamespace,
2339 }
2340 s += jinja2.Template(self.TemplateSendVertex_SendCall).render(**temp)
2341 s += jinja2.Template(self.TemplateSendVertex_Epilogue).render(
2342 **generic_dict_for_prologue_and_epilogue
2343 )
2344
2345 s += jinja2.Template(self.TemplateSendFace_Prologue).render(
2346 **generic_dict_for_prologue_and_epilogue
2347 )
2348 for face in self.faces:
2349 temp = {
2350 "name": face.name,
2351 "enumeration_type": face.get_enumeration_type(),
2352 "logical_type_name": face.get_logical_type_name(),
2353 "full_qualified_type": face.get_full_qualified_type(),
2354 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2355 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2356 "subnamespace": face.subnamespace,
2357 }
2358 s += jinja2.Template(self.TemplateSendFace_SendCall).render(**temp)
2359 s += jinja2.Template(self.TemplateSendFace_Epilogue).render(
2360 **generic_dict_for_prologue_and_epilogue
2361 )
2362
2363 s += jinja2.Template(self.TemplateSendCell_Prologue).render(
2364 **generic_dict_for_prologue_and_epilogue
2365 )
2366 for cell in self.cells:
2367 temp = {
2368 "name": cell.name,
2369 "logical_type_name": cell.get_logical_type_name(),
2370 "full_qualified_type": cell.get_full_qualified_type(),
2371 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2372 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2373 "subnamespace": cell.subnamespace,
2374 }
2375 s += jinja2.Template(self.TemplateSendCell_SendCall).render(**temp)
2376 s += jinja2.Template(self.TemplateSendCell_Epilogue).render(
2377 **generic_dict_for_prologue_and_epilogue
2378 )
2379
2380 s += jinja2.Template(self.TemplateReceiveAndMergeCell_Prologue).render(
2381 **generic_dict_for_prologue_and_epilogue
2382 )
2383 for cell in self.cells:
2384 temp = {
2385 "name": cell.name,
2386 "logical_type_name": cell.get_logical_type_name(),
2387 "full_qualified_type": cell.get_full_qualified_type(),
2388 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2389 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2390 "subnamespace": cell.subnamespace,
2391 }
2392 s += jinja2.Template(
2394 ).render(**temp)
2395 s += jinja2.Template(self.TemplateReceiveAndMergeCell_Epilogue).render(
2396 **generic_dict_for_prologue_and_epilogue
2397 )
2398
2399 s += jinja2.Template(self.TemplateReceiveAndMergeFace_Prologue).render(
2400 **generic_dict_for_prologue_and_epilogue
2401 )
2402 for face in self.faces:
2403 temp = {
2404 "name": face.name,
2405 "enumeration_type": face.get_enumeration_type(),
2406 "logical_type_name": face.get_logical_type_name(),
2407 "full_qualified_type": face.get_full_qualified_type(),
2408 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2409 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2410 "subnamespace": face.subnamespace,
2411 }
2412 s += jinja2.Template(
2414 ).render(**temp)
2415 s += jinja2.Template(self.TemplateReceiveAndMergeFace_Epilogue).render(
2416 **generic_dict_for_prologue_and_epilogue
2417 )
2418
2419 s += jinja2.Template(self.TemplateReceiveAndMergeVertex_Prologue).render(
2420 **generic_dict_for_prologue_and_epilogue
2421 )
2422 for vertex in self.vertices:
2423 temp = {
2424 "name": vertex.name,
2425 "enumeration_type": vertex.get_enumeration_type(),
2426 "logical_type_name": vertex.get_logical_type_name(),
2427 "full_qualified_type": vertex.get_full_qualified_type(),
2428 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2429 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2430 "subnamespace": vertex.subnamespace,
2431 }
2432 s += jinja2.Template(
2434 ).render(**temp)
2435 s += jinja2.Template(self.TemplateReceiveAndMergeVertex_Epilogue).render(
2436 **generic_dict_for_prologue_and_epilogue
2437 )
2438
2439 s += jinja2.Template(
2441 ).render(**generic_dict_for_prologue_and_epilogue)
2442 for cell in self.cells:
2443 s += jinja2.Template(
2445 ).render(
2446 **{
2447 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2448 + cell.get_logical_type_name()
2449 + "Stack"
2450 }
2451 )
2452 for face in self.faces:
2453 s += jinja2.Template(
2455 ).render(
2456 **{
2457 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2458 + face.get_logical_type_name()
2459 + "Stack"
2460 }
2461 )
2462 for vertex in self.vertices:
2463 s += jinja2.Template(
2465 ).render(
2466 **{
2467 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2468 + vertex.get_logical_type_name()
2469 + "Stack"
2470 }
2471 )
2472 s += jinja2.Template(
2474 ).render(**generic_dict_for_prologue_and_epilogue)
2475
2476 output_file.write(s)
2477
2478 TemplateImplementationFilePrologue = """
2479#include "{{CLASSNAME}}.h"
2480{{DATAREPOSITORY_INCLUDES}}
2481
2482#include "peano4/grid/PeanoCurve.h"
2483
2484#include "peano4/datamanagement/VertexEnumerator.h"
2485#include "peano4/datamanagement/VertexMarker.h"
2486#include "peano4/datamanagement/FaceEnumerator.h"
2487#include "peano4/datamanagement/FaceMarker.h"
2488#include "peano4/datamanagement/CellMarker.h"
2489
2490#include "peano4/parallel/SpacetreeSet.h"
2491
2492
2493tarch::logging::Log {{FULL_QUALIFIED_CLASSNAME}}::_log( "{{FULL_QUALIFIED_CLASSNAME}}" );
2494
2495"""
2496
2497 def __generate_implementation(self, overwrite, full_qualified_filename):
2498 if write_file(overwrite, self.default_overwritedefault_overwrite, full_qualified_filename):
2499 import inspect, os
2500
2501 print(
2502 "{} written by {}".format(
2503 full_qualified_filename,
2504 os.path.basename(inspect.getfile(self.__class__)),
2505 )
2506 )
2507
2508 output_file = open(full_qualified_filename, "w")
2509 output_file.write(
2511 **self.d
2512 )
2513 )
2514
2515 self.__generate_constructor(output_file)
2516 self.__generate_clone(output_file)
2517 self.__generate_getGridControlEvents(output_file)
2518 self.__generate_beginTraversal(output_file)
2519 self.__generate_endTraversal(output_file)
2520 self.__generate_prepareTraversal(output_file)
2521 self.__generate_unprepareTraversal(output_file)
2522 self.__generate_loadCell(output_file)
2523 self.__generate_enterCell(output_file)
2524 self.__generate_leaveCell(output_file)
2525 self.__generate_storeCell(output_file)
2526 self.__generate_exchange_routines(output_file)
2527
2528 #
2529 # @todo Sollte man mit Jinja 2 nicht mehr brauchen
2530 #
2532 return self.subdirectory + "/" + self.classname + ".cpp"
2533
2534 def generate(self, overwrite, directory):
2535 if not os.path.exists(directory + "/" + self.subdirectory):
2536 os.mkdir(directory + "/" + self.subdirectory)
2537
2538 cpp_filename = directory + "/" + self.get_cpp_file_name()
2539
2540 self.__generate_header(overwrite, directory)
2541 self.__generate_implementation(overwrite, cpp_filename)
__generate_getGridControlEvents(self, output_file)
Definition Observer.py:543
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue
Definition Observer.py:1683
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue
Definition Observer.py:1722
__generate_header(self, overwrite, directory)
Definition Observer.py:248
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange
Definition Observer.py:1688
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange
Definition Observer.py:1727
mkSubDict(self, keys)
Create the particular subdictionary that's used for an expression.
Definition Observer.py:1047
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue
Definition Observer.py:1754
__generate_unprepareTraversal(self, output_file)
Definition Observer.py:475
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue
Definition Observer.py:1656
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange
Definition Observer.py:1668
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue
Definition Observer.py:1702
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue
Definition Observer.py:1663
__generate_exchange_routines(self, output_file)
Definition Observer.py:2098
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue
Definition Observer.py:1715
__generate_clone(self, output_file)
Definition Observer.py:556
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange
Definition Observer.py:1707
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange
Definition Observer.py:1747
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue
Definition Observer.py:1742
__generate_loadCell(self, output_file)
Definition Observer.py:1064
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue
Definition Observer.py:1643
__init__(self, classname, namespace, subdirectory, included_actions, vertices, faces, cells)
Included actions is a list of qualified actions which are used.
Definition Observer.py:27
__generate_implementation(self, overwrite, full_qualified_filename)
Definition Observer.py:2497
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue
Definition Observer.py:1695
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue
Definition Observer.py:1735
__generate_leaveCell(self, output_file)
Generates enter cell.
Definition Observer.py:1514
__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...
Definition Observer.py:487
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Epilogue
Definition Observer.py:1676
__generate_storeCell(self, output_file)
Definition Observer.py:1587
generateDictEntry(self, key)
Some logic to produce new dictionary entries from existing ones.
Definition Observer.py:1027
__generate_beginTraversal(self, output_file)
Definition Observer.py:316
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange
Definition Observer.py:1648
__generate_constructor(self, output_file)
Definition Observer.py:275
__generate_endTraversal(self, output_file)
Definition Observer.py:389
__generate_enterCell(self, output_file)
Generates enter cell.
Definition Observer.py:1112
__generate_prepareTraversal(self, output_file)
Definition Observer.py:455
generate(self, overwrite, directory)
Definition Observer.py:2534