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 = """
565 // Load vertex {{logical_type_name}}
566 std::function<bool ()> loadVertex{{logical_type_name}} =
567 [&]()->bool {
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 return false;
653 };
654
655 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
656 tarch::multicore::Task::DontFuse,
657 tarch::multicore::Task::DefaultPriority,
658 loadVertex{{logical_type_name}}
659 ));
660
661"""
662
663 TemplateEnterCell_VertexMappingCall = """
664 // Handle vertex {{logical_type_name}}
665 {
666 peano4::datamanagement::VertexMarker marker(event);
667
668 for (int i=0; i<TwoPowerD; i++) {
669 int inVertexStack = event.getVertexDataFrom(i);
670 int pick = event.getVertexDataTo(i); // the vertex position
671
672 marker.select(pick);
673
674 logDebug( "enterCell(...)", inVertexStack << "->" << pick << " (is-local=" << marker.isLocal() << ")" );
675
676 if (
677 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
678 and
679 marker.isLocal()
680 ) {
681 // Take care about the coarse grid accesses: Faces and cells are not yet loaded.
682 // Therefore we don't use the usual shift of @f$ 2 \cdot 2d @f$ or @f$ 2 \cdot 2^d @f$
683 // but only half of it.
684 {{ACTIVE_ACTION_SET}}.createPersistentVertex(
685 marker
686 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
687 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
688 );
689 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
690 marker
691 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
692 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
693 );
694 }
695 else if (
696 inVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
697 and
698 marker.isLocal()
699 ) {
700 {{ACTIVE_ACTION_SET}}.createHangingVertex(
701 marker
702 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
703 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
704 );
705 }
706 else if (
707 peano4::grid::PeanoCurve::isInOutStack(inVertexStack)
708 and
709 marker.isLocal()
710 ) {
711 {{ACTIVE_ACTION_SET}}.touchVertexFirstTime(
712 marker
713 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
714 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
715 );
716 }
717 }
718 }
719"""
720
721 TemplateLoadCell_FaceLoad = """
722 // Load face {{logical_type_name}}
723 std::function<bool ()> loadFace{{logical_type_name}} =
724 [&]()->bool {
725 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->pushBlock( TwoTimesD );
726 for (int i=0; i<TwoTimesD; i++) {
727 int inFaceStack = event.getFaceDataFrom(i);
728 int outFaceStackPosition = event.getFaceDataTo(i);
729 logDebug("loadCell(...)", "face stack " << inFaceStack << "->pos-" << outFaceStackPosition );
730
731 peano4::datamanagement::FaceMarker marker(event,outFaceStackPosition);
732
733 bool dataResidesOnIntermediateStack =
734 not peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
735 and
736 inFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
737 and
738 inFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
739 and
740 inFaceStack!=peano4::grid::TraversalObserver::NoData;
741 bool dataResidesOnInputStack =
742 peano4::grid::PeanoCurve::isInOutStack(inFaceStack)
743 and
744 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
745 marker
746 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
747 ));
748 bool initialiseStackContentForNewData =
749 ::peano4::grid::computeOnData( {{full_qualified_type}}::loadStoreComputeFlag(
750 marker
751 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
752 ))
753 or
754 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
755 or
756 inFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
757 ;
758
759 if ( dataResidesOnIntermediateStack or dataResidesOnInputStack ) {
760 logDebug(
761 "loadCell(...)",
762 "load data of face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
763 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
764 marker
765 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
766 ))
767 );
768 assertion5(
769 not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inFaceStack))->empty(),
770 event.toString(),
771 peano4::datamanagement::FaceMarker(event).toString(),
772 _spacetreeId, inFaceStack,
773 ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
774 marker
775 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
776 ))
777 );
778 {{full_qualified_type}} data = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,inFaceStack))->pop() );
779 #if PeanoDebug>0
780 if ( peano4::grid::PeanoCurve::isInOutStack(inFaceStack) ) {
781 assertionVectorNumericalEquals5( data.getDebugX(), marker.x(outFaceStackPosition), data.getDebugX(), data.getDebugH(), marker.toString(), outFaceStackPosition, _spacetreeId );
782 assertionVectorNumericalEquals5( data.getDebugH(), marker.h(), data.getDebugX(), data.getDebugH(), marker.toString(), outFaceStackPosition, _spacetreeId );
783 }
784 #endif
785 view.set(outFaceStackPosition,data);
786 }
787 else if ( initialiseStackContentForNewData ) {
788 {{full_qualified_type}} data;
789 #if PeanoDebug>0
790 logDebug(
791 "loadCell(...)",
792 "initialise meta data of new face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
793 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
794 marker
795 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
796 ))
797 );
798 data.setDebugX( marker.x(outFaceStackPosition) );
799 data.setDebugH( marker.h() );
800 #endif
801 view.set(outFaceStackPosition,data);
802 }
803 else {
804 #if PeanoDebug>0
805 logDebug(
806 "loadCell(...)",
807 "initialise meta data of unused face {{name}} with " << marker.x(outFaceStackPosition) << " x " << marker.h() <<
808 ": " << ::peano4::grid::toString( {{full_qualified_type}}::loadStoreComputeFlag(
809 marker
810 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
811 ))
812 );
813 view.get(outFaceStackPosition).setDebugX( marker.x(outFaceStackPosition) );
814 view.get(outFaceStackPosition).setDebugH( marker.h() );
815 #endif
816 }
817 }
818 return false;
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 = """
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 = """
895 // Load cell {{logical_type_name}}
896 std::function<bool ()> loadCell{{logical_type_name}} =
897 [&]()->bool {
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 return false;
974 };
975
976 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
977 tarch::multicore::Task::DontFuse,
978 tarch::multicore::Task::DefaultPriority,
979 loadCell{{logical_type_name}}
980 ));
981
982"""
983
984 TemplateEnterCell_CellMappingCall = """
985 // Invoke creational events on cell {{logical_type_name}}
986 {
987 peano4::datamanagement::CellMarker marker( event );
988 if (
989 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
990 and
991 marker.isLocal()
992 ) {
993 {{ACTIVE_ACTION_SET}}.createCell(
994 marker,
995 {{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_}}
996 {{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_}}
997 {{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
998 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS}}
999 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS}}
1000 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1001 );
1002 }
1003 }
1004"""
1005
1006 TemplateEnterCell_MappingCall = """
1007 {
1008 peano4::datamanagement::CellMarker marker( event );
1009 if (
1010 marker.isLocal()
1011 ) {
1012 {{ACTIVE_ACTION_SET}}.touchCellFirstTime(
1013 marker
1014 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1015 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1016 );
1017 }
1018 }
1019"""
1020
1021 TemplateEnterCell_Epilogue = """
1022 logTraceOut( "enterCell(...)" );
1023}
1024
1025
1026"""
1027
1028 def generateDictEntry(self, key):
1029 """
1030 Some logic to produce new dictionary entries from existing ones.
1031 This deals mainly with having to avoid C++ code with consequtive commata
1032 as some dict entries can be an empty string.
1033 """
1034
1035 fields = key.split(",")
1036 nonempty = [self.d[f] for f in fields if not f == "" and not self.d[f] == ""]
1037 if len(nonempty) > 0:
1038 s = ",".join(nonempty)
1039 if key.startswith(",") and not s.startswith(","):
1040 s = "," + s
1041 if key.endswith(",") and not s.endswith(","):
1042 s += ","
1043 else:
1044 s = ""
1045
1046 return s
1047
1048 def mkSubDict(self, keys):
1049 """
1050
1051 Create the particular subdictionary that's used for an expression.
1052
1053 """
1054 temp = {}
1055 for k in keys:
1056 if not k in self.d:
1057 temp[k] = self.generateDictEntry(k)
1058 else:
1059 temp[k] = self.d[k]
1060 result = {}
1061 for k in temp:
1062 result[k.replace(",", "_COMMA_").strip()] = temp[k]
1063 return result
1064
1065 def __generate_loadCell(self, output_file):
1066 output_file.write(
1067 jinja2.Template(self.TemplateLoadCell_PrologueTemplateLoadCell_Prologue).render(**self.d)
1068 )
1069
1070 for vertex in self.vertices:
1071 temp = {
1072 "name": vertex.name,
1073 "enumeration_type": vertex.get_enumeration_type(),
1074 "logical_type_name": vertex.get_logical_type_name(),
1075 "full_qualified_type": vertex.get_full_qualified_type(),
1076 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
1077 "subnamespace": vertex.subnamespace,
1078 }
1079 self.d["name"] = vertex.name
1080 output_file.write(
1082 )
1083
1084 for face in self.faces:
1085 temp = {
1086 "name": face.name,
1087 "enumeration_type": face.get_enumeration_type(),
1088 "logical_type_name": face.get_logical_type_name(),
1089 "full_qualified_type": face.get_full_qualified_type(),
1090 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
1091 "subnamespace": face.subnamespace,
1092 }
1093 self.d["name"] = face.name
1094 output_file.write(
1095 jinja2.Template(self.TemplateLoadCell_FaceLoadTemplateLoadCell_FaceLoad).render(**temp)
1096 )
1097
1098 for cell in self.cells:
1099 temp = {
1100 "name": cell.name,
1101 "logical_type_name": cell.get_logical_type_name(),
1102 "full_qualified_type": cell.get_full_qualified_type(),
1103 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
1104 "subnamespace": cell.subnamespace,
1105 }
1106 self.d["name"] = cell.name
1107 output_file.write(
1108 jinja2.Template(self.TemplateLoadCell_CellLoadTemplateLoadCell_CellLoad).render(**temp)
1109 )
1110
1111 output_file.write(jinja2.Template(self.TemplateLoadCell_EpilogueTemplateLoadCell_Epilogue).render({}))
1112
1113 def __generate_enterCell(self, output_file):
1114 """
1115 Generates enter cell
1116 """
1117 output_file.write(
1118 jinja2.Template(self.TemplateEnterCell_PrologueTemplateEnterCell_Prologue).render(**self.d)
1119 )
1120
1121 if len(self.vertices) > 0:
1122 md = self.mkSubDict(
1123 [
1124 "name",
1125 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1126 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1127 ]
1128 )
1130 output_file,
1132 False,
1133 manual_dict=md,
1134 )
1135
1136 if len(self.faces) > 0:
1137 md = self.mkSubDict(
1138 [
1139 "name",
1140 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1141 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1142 "MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1143 "MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1144 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1145 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1146 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1147 ]
1148 )
1150 output_file,
1152 False,
1153 manual_dict=md,
1154 )
1155
1156 if len(self.cells) > 0:
1157 md = self.mkSubDict(
1158 [
1159 "name",
1160 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,",
1161 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,",
1162 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1163 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS",
1164 ",MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS",
1165 ",MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1166 ]
1167 )
1169 output_file,
1171 False,
1172 manual_dict=md,
1173 )
1174
1175 md = self.mkSubDict(
1176 [
1177 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1178 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1179 ]
1180 )
1181
1183 output_file, self.TemplateEnterCell_MappingCallTemplateEnterCell_MappingCall, False, manual_dict=md
1184 )
1185 output_file.write(jinja2.Template(self.TemplateEnterCell_EpilogueTemplateEnterCell_Epilogue).render({}))
1186
1187 TemplateLoadCell_Prologue = """
1188void {{FULL_QUALIFIED_CLASSNAME}}::loadCell( const peano4::grid::GridTraversalEvent& event ) {
1189 logTraceInWith2Arguments( "loadCell(...)", _spacetreeId, event.toString() );
1190
1191 std::vector< tarch::multicore::Task* > tasks;
1192"""
1193
1194 TemplateStoreCell_Prologue = """
1195void {{FULL_QUALIFIED_CLASSNAME}}::storeCell( const peano4::grid::GridTraversalEvent& event ) {
1196 logTraceInWith2Arguments( "storeCell(...)", _spacetreeId, event.toString() );
1197 std::vector< tarch::multicore::Task* > tasks;
1198"""
1199
1200 TemplateLeaveCell_Prologue = """
1201void {{FULL_QUALIFIED_CLASSNAME}}::leaveCell( const peano4::grid::GridTraversalEvent& event ) {
1202 logTraceInWith2Arguments( "leaveCell(...)", _spacetreeId, event.toString() );
1203"""
1204
1205 TemplateLeaveCell_MappingCall = """
1206 {
1207 peano4::datamanagement::CellMarker marker( event );
1208 if (
1209 marker.isLocal()
1210 ) {
1211 {{ACTIVE_ACTION_SET}}.touchCellLastTime(
1212 marker
1213 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1214 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT}}
1215 );
1216 }
1217 }
1218"""
1219
1220 TemplateLeaveCell_CellStore_MappingCall = """
1221 {
1222 peano4::datamanagement::CellMarker marker( event );
1223 if (
1224 event.getCellData()==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1225 and
1226 marker.isLocal()
1227 ) {
1228 {{ACTIVE_ACTION_SET}}.destroyCell(
1229 marker
1230 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS}}
1231 ,{{MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY}}
1232 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1233 );
1234 }
1235 }
1236"""
1237
1238 TemplateStoreCell_CellStore = """
1239 // Handle cell {{logical_type_name}}
1240 std::function<bool ()> storeCell{{logical_type_name}} =
1241 [&]()->bool {
1242 const int inCellStack = peano4::grid::PeanoCurve::CallStack;
1243 const int outCellStack = event.getCellData();
1244 logDebug("storeCell(...)", "cell stack " << inCellStack << "->pos-" << outCellStack );
1245
1246 peano4::datamanagement::CellMarker marker(event);
1247
1248 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( 1 );
1249
1250 bool dataShallBePushedOntoIntermediateStack =
1251 not peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1252 and
1253 outCellStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1254 and
1255 outCellStack!=peano4::grid::TraversalObserver::NoData;
1256 bool dataShallBePushedOntoOutputStack =
1257 peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1258 and
1259 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1260 marker
1261 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1262 ));
1263
1264 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1265 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outCellStack))->push( view.get(0) );
1266 }
1267 else {
1268 logDebug(
1269 "storeCell(...)",
1270 "do not store cell {{name}} with " << marker.x() << " x " << marker.h() << ":" <<
1271 " destroy=" << (outCellStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity) <<
1272 ", no-data=" << (outCellStack==peano4::grid::TraversalObserver::NoData) <<
1273 ", is-in/out=" << peano4::grid::PeanoCurve::isInOutStack(outCellStack)
1274 );
1275 }
1276 return false;
1277 };
1278
1279 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1280 tarch::multicore::Task::DontFuse,
1281 tarch::multicore::Task::DefaultPriority,
1282 storeCell{{logical_type_name}}
1283 ));
1284
1285"""
1286
1287 TemplateLeaveCell_FaceStore_MappingCall = """
1288 // Handle face {{logical_type_name}}
1289 {
1290 peano4::datamanagement::FaceMarker marker(event);
1291
1292 for (int i=0; i<TwoTimesD; i++) {
1293 int outFaceStack = event.getFaceDataTo(i);
1294 int pick = event.getFaceDataFrom(i);
1295
1296 marker.select(pick);
1297
1298 if (
1299 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1300 and
1301 marker.isLocal()
1302 ) {
1303 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1304 marker
1305 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1306 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1307 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1308 );
1309 {{ACTIVE_ACTION_SET}}.destroyPersistentFace(
1310 marker
1311 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1312 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1313 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1314 );
1315 }
1316 else if (
1317 outFaceStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1318 and
1319 marker.isLocal()
1320 ) {
1321 {{ACTIVE_ACTION_SET}}.destroyHangingFace(
1322 marker
1323 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1324 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1325 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1326 );
1327 }
1328 else if (
1329 peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1330 and
1331 marker.isLocal()
1332 ) {
1333 {{ACTIVE_ACTION_SET}}.touchFaceLastTime(
1334 marker
1335 {{_COMMA_MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS}}
1336 ,{{MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY}}
1337 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1338 );
1339 }
1340 }
1341 }
1342"""
1343
1344 TemplateStoreCell_FaceStore = """
1345 // Store face {{logical_type_name}}
1346 std::function<bool ()> storeFace{{logical_type_name}} =
1347 [&]()->bool {
1348 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( TwoTimesD );
1349 for (int i=0; i<TwoTimesD; i++) {
1350 int inFaceStackPosition = event.getFaceDataFrom(i);
1351 int outFaceStack = event.getFaceDataTo(i);
1352 logDebug("storeCell(...)", "pos-" << inFaceStackPosition << "->face stack " << outFaceStack );
1353
1354 peano4::datamanagement::FaceMarker marker(event,inFaceStackPosition);
1355
1356 {{full_qualified_type}}& data = view.get(inFaceStackPosition);
1357
1358 bool dataShallBePushedOntoIntermediateStack =
1359 not peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1360 and
1361 outFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1362 and
1363 outFaceStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1364 and
1365 outFaceStack!=peano4::grid::TraversalObserver::NoData;
1366 bool dataShallBePushedOntoOutputStack =
1367 peano4::grid::PeanoCurve::isInOutStack(outFaceStack)
1368 and
1369 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1370 marker
1371 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1372 ));
1373
1374 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1375 logDebug( "storeCell(...)", "store face {{name}} with " << marker.x(inFaceStackPosition) << " x " << marker.h() );
1376 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outFaceStack))->push(data);
1377 }
1378 else {
1379 logDebug( "storeCell(...)", "do not store face {{name}} with " << marker.x(inFaceStackPosition) << " x " << marker.h() );
1380 }
1381 }
1382 return false;
1383 };
1384
1385 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1386 tarch::multicore::Task::DontFuse,
1387 tarch::multicore::Task::DefaultPriority,
1388 storeFace{{logical_type_name}}
1389 ));
1390
1391"""
1392
1393 TemplateLeaveCell_VertexStore_MappingCall = """
1394 // Handle vertex {{logical_type_name}}
1395 {
1396 peano4::datamanagement::VertexMarker marker(event);
1397
1398 for (int i=0; i<TwoPowerD; i++) {
1399 int outVertexStack = event.getVertexDataTo(i);
1400 int pick = event.getVertexDataFrom(i);
1401
1402 marker.select(pick);
1403
1404 if (
1405 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1406 and
1407 marker.isLocal()
1408 ) {
1409 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1410 marker
1411 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1412 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1413 );
1414 {{ACTIVE_ACTION_SET}}.destroyPersistentVertex(
1415 marker
1416 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1417 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1418 );
1419 }
1420 else if (
1421 outVertexStack==peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1422 and
1423 marker.isLocal()
1424 ) {
1425 {{ACTIVE_ACTION_SET}}.destroyHangingVertex(
1426 marker
1427 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1428 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1429 );
1430 }
1431 else if (
1432 peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1433 and
1434 marker.isLocal()
1435 ) {
1436 {{ACTIVE_ACTION_SET}}.touchVertexLastTime(
1437 marker
1438 ,{{MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY}}
1439 {{_COMMA_MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS_COMMA_MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS}}
1440 );
1441 }
1442 }
1443 }
1444"""
1445
1446 TemplateStoreCell_VertexStore = """
1447 // Store vertex {{logical_type_name}}
1448 std::function<bool ()> storeVertex{{logical_type_name}} =
1449 [&]()->bool {
1450 auto view = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->popBlock( TwoPowerD );
1451 for (int i=0; i<TwoPowerD; i++) {
1452 int inVertexStackPosition = event.getVertexDataFrom(i);
1453 int outVertexStack = event.getVertexDataTo(i);
1454 logDebug("storeCell(...)", "pos-" << inVertexStackPosition << "->vertex stack " << outVertexStack);
1455
1456 peano4::datamanagement::VertexMarker marker(event,inVertexStackPosition);
1457
1458 {{full_qualified_type}}& data = view.get(inVertexStackPosition);
1459
1460
1461 bool dataShallBePushedOntoIntermediateStack =
1462 not peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1463 and
1464 outVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyPersistentGridEntity
1465 and
1466 outVertexStack!=peano4::grid::TraversalObserver::CreateOrDestroyHangingGridEntity
1467 and
1468 outVertexStack!=peano4::grid::TraversalObserver::NoData;
1469 bool dataShallBePushedOntoOutputStack =
1470 peano4::grid::PeanoCurve::isInOutStack(outVertexStack)
1471 and
1472 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1473 marker
1474 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1475 ));
1476
1477 if ( dataShallBePushedOntoIntermediateStack or dataShallBePushedOntoOutputStack ) {
1478 logDebug( "storeCell(...)", "store vertex {{name}} with " << marker.x(inVertexStackPosition) << " x " << marker.h() );
1479 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush({{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,outVertexStack))->push(data);
1480 }
1481 else {
1482 logDebug( "storeCell(...)", "do not store vertex {{name}} with " << marker.x(inVertexStackPosition) << " x " << marker.h() );
1483 }
1484 }
1485 return false;
1486 };
1487
1488 tasks.push_back( new tarch::multicore::TaskWithoutCopyOfFunctor(
1489 tarch::multicore::Task::DontFuse,
1490 tarch::multicore::Task::DefaultPriority,
1491 storeVertex{{logical_type_name}}
1492 ));
1493
1494"""
1495
1496 TemplateLeaveCell_Epilogue = """
1497 logTraceOutWith1Argument( "leaveCell(...)", _spacetreeId );
1498}
1499
1500
1501"""
1502
1503 TemplateLoadCell_Epilogue = """
1504 tarch::multicore::spawnAndWait(tasks);
1505 logTraceOutWith1Argument( "loadCell(...)", _spacetreeId );
1506}
1507
1508
1509"""
1510
1511 TemplateStoreCell_Epilogue = """
1512 tarch::multicore::spawnAndWait( tasks );
1513 logTraceOutWith1Argument( "storeCell(...)", _spacetreeId );
1514}
1515
1516
1517"""
1518
1519 def __generate_leaveCell(self, output_file):
1520 """
1521 Generates enter cell
1522 """
1523 output_file.write(
1525 **self.mkSubDict(["FULL_QUALIFIED_CLASSNAME"])
1526 )
1527 )
1528
1529 md = self.mkSubDict(
1530 [
1531 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1532 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS_CELL_EVENT",
1533 ]
1534 )
1537 )
1538
1539 if len(self.cells) > 0:
1540 md = self.mkSubDict(
1541 [
1542 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS",
1543 "MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS_PICK_ENTRY",
1544 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1545 ]
1546 )
1548 output_file,
1550 True,
1551 manual_dict=md,
1552 )
1553
1554 if len(self.faces) > 0:
1555 md = self.mkSubDict(
1556 [
1557 "name",
1558 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1559 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1560 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1561 ",MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS",
1562 "MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS_PICK_ENTRY",
1563 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1564 ]
1565 )
1567 output_file,
1569 True,
1570 manual_dict=md,
1571 )
1572
1573 if len(self.vertices) > 0:
1574 md = self.mkSubDict(
1575 [
1576 "name",
1577 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1578 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_FINE_GRID_CELL_ARGUMENTS",
1579 ",MAPPING_SIGNATURE_COARSE_GRID_VERTICES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_FACES_ARGUMENTS,MAPPING_SIGNATURE_COARSE_GRID_CELL_ARGUMENTS",
1580 "MAPPING_SIGNATURE_FINE_GRID_VERTICES_ARGUMENTS_PICK_ENTRY",
1581 ]
1582 )
1584 output_file,
1586 True,
1587 manual_dict=md,
1588 )
1589
1590 output_file.write(jinja2.Template(self.TemplateLeaveCell_EpilogueTemplateLeaveCell_Epilogue).render({}))
1591
1592 def __generate_storeCell(self, output_file):
1593 output_file.write(
1594 jinja2.Template(self.TemplateStoreCell_PrologueTemplateStoreCell_Prologue).render(**self.d)
1595 )
1596
1597 cells_inverted = [x for x in self.cells]
1598 faces_inverted = [x for x in self.faces]
1599 vertices_inverted = [x for x in self.vertices]
1600
1601 cells_inverted.reverse()
1602 faces_inverted.reverse()
1603 vertices_inverted.reverse()
1604
1605 for cell in cells_inverted:
1606 temp = {
1607 "name": cell.name,
1608 "logical_type_name": cell.get_logical_type_name(),
1609 "full_qualified_type": cell.get_full_qualified_type(),
1610 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
1611 "subnamespace": cell.subnamespace,
1612 }
1613 self.d["name"] = cell.name
1614 output_file.write(
1616 )
1617
1618 for face in faces_inverted:
1619 temp = {
1620 "name": face.name,
1621 "enumeration_type": face.get_enumeration_type(),
1622 "logical_type_name": face.get_logical_type_name(),
1623 "full_qualified_type": face.get_full_qualified_type(),
1624 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
1625 "subnamespace": face.subnamespace,
1626 }
1627 self.d["name"] = face.name
1628 output_file.write(
1630 )
1631
1632 for vertex in vertices_inverted:
1633 temp = {
1634 "name": vertex.name,
1635 "enumeration_type": vertex.get_enumeration_type(),
1636 "logical_type_name": vertex.get_logical_type_name(),
1637 "full_qualified_type": vertex.get_full_qualified_type(),
1638 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
1639 "subnamespace": vertex.subnamespace,
1640 }
1641 self.d["name"] = vertex.name
1642 output_file.write(
1644 )
1645
1646 output_file.write(jinja2.Template(self.TemplateStoreCell_EpilogueTemplateStoreCell_Epilogue).render({}))
1647
1648 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue = """
1649void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllVerticalDataExchangeStacks( int masterId ) {
1650 logTraceInWith2Arguments( "exchangeAllVerticalDataExchangeStacks(...)", masterId, _spacetreeId );
1651"""
1652
1653 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange = """
1654 peano4::parallel::SpacetreeSet::exchangeAllVerticalDataExchangeStacks(
1655 {{DATASET}},
1656 _spacetreeId,
1657 masterId
1658 );
1659"""
1660
1661 TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue = """
1662 logTraceOut( "exchangeAllVerticalDataExchangeStacks(...)" );
1663}
1664
1665
1666"""
1667
1668 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue = """
1669void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllHorizontalDataExchangeStacks( bool symmetricDataCardinality ) {
1670 logTraceInWith2Arguments( "exchangeAllHorizontalDataExchangeStacks(...)", symmetricDataCardinality, _spacetreeId );
1671"""
1672
1673 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange = """
1674 peano4::parallel::SpacetreeSet::exchangeAllHorizontalDataExchangeStacks(
1675 {{DATASET}},
1676 _spacetreeId,
1677 symmetricDataCardinality
1678 );
1679"""
1680
1681 TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Epilogue = """
1682 logTraceOut( "exchangeAllHorizontalDataExchangeStacks(...)" );
1683}
1684
1685
1686"""
1687
1688 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue = """
1689void {{FULL_QUALIFIED_CLASSNAME}}::exchangeAllPeriodicBoundaryDataStacks() {
1690 logTraceInWith1Argument( "exchangeAllPeriodicBoundaryDataStacks()", _spacetreeId );
1691"""
1692
1693 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange = """
1694 peano4::parallel::SpacetreeSet::exchangeAllPeriodicBoundaryDataStacks(
1695 {{DATASET}},
1696 _spacetreeId
1697 );
1698"""
1699
1700 TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue = """
1701 logTraceOut( "exchangeAllPeriodicBoundaryDataStacks()" );
1702}
1703
1704
1705"""
1706
1707 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue = """
1708void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromSplittingTreeToNewTree(int newWorker) {
1709 logTraceInWith2Arguments( "streamDataFromSplittingTreeToNewTree(int)", _spacetreeId, newWorker );
1710"""
1711
1712 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange = """
1713 peano4::parallel::SpacetreeSet::streamDataFromSplittingTreeToNewTree(
1714 {{DATASET}},
1715 _spacetreeId,
1716 newWorker
1717 );
1718"""
1719
1720 TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue = """
1721 logTraceOut( "streamDataFromSplittingTreeToNewTree(int)");
1722}
1723
1724
1725"""
1726
1727 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue = """
1728void {{FULL_QUALIFIED_CLASSNAME}}::streamDataFromJoiningTreeToMasterTree(int master) {
1729 logTraceInWith2Arguments( "streamDataFromJoiningTreeToMasterTree(int)", _spacetreeId, master );
1730"""
1731
1732 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange = """
1733 peano4::parallel::SpacetreeSet::streamDataFromJoiningTreeToMasterTree(
1734 {{DATASET}},
1735 _spacetreeId,
1736 master
1737 );
1738"""
1739
1740 TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue = """
1741 logTraceOut( "streamDataFromJoiningTreeToMasterTree(int)");
1742}
1743
1744
1745"""
1746
1747 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue = """
1748void {{FULL_QUALIFIED_CLASSNAME}}::finishAllOutstandingSendsAndReceives() {
1749 logTraceInWith1Argument( "finishAllOutstandingSendsAndReceives()", _spacetreeId );
1750"""
1751
1752 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange = """
1753 peano4::parallel::SpacetreeSet::finishAllOutstandingSendsAndReceives(
1754 {{DATASET}},
1755 _spacetreeId
1756 );
1757"""
1758
1759 TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue = """
1760 logTraceOut( "finishAllOutstandingSendsAndReceives()");
1761}
1762
1763
1764"""
1765
1766 TemplateSendVertex_Prologue = """
1767void {{FULL_QUALIFIED_CLASSNAME}}::sendVertex(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1768 logTraceInWith4Arguments( "sendVertex(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1769
1770"""
1771
1772 TemplateSendVertex_SendCall = """
1773 {
1774 peano4::datamanagement::VertexMarker marker(event,position);
1775
1776 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1777 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1778 )->top(TwoPowerD-1-position);
1779 if (
1780 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1781 marker
1782 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1783 ))
1784 and
1785 (
1786 data.send(marker)
1787 or
1788 context == TraversalObserver::SendReceiveContext::ForkDomain
1789 or
1790 context == TraversalObserver::SendReceiveContext::JoinDomain
1791 )
1792 ) {
1793 logDebug( "sendVertex(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId << " for marker " << marker.toString() );
1794
1795 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1796 _spacetreeId, toStack
1797 ) -> push(data);
1798 }
1799 }
1800"""
1801
1802 TemplateSendVertex_Epilogue = """
1803 logTraceOut( "sendVertex(int,int,int)");
1804}
1805
1806
1807"""
1808
1809 TemplateSendFace_Prologue = """
1810void {{FULL_QUALIFIED_CLASSNAME}}::sendFace(int position, int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1811 logTraceInWith4Arguments( "sendFace(int,int,int)", position, toStack, event.toString(), _spacetreeId );
1812
1813"""
1814
1815 TemplateSendFace_SendCall = """
1816 {
1817 peano4::datamanagement::FaceMarker marker(event,position);
1818 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1819 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1820 )->top(TwoTimesD-1-position);
1821 if (
1822 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1823 marker
1824 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1825 ))
1826 and
1827 (data.send(
1828 marker
1829 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1830 )
1831 or
1832 context == TraversalObserver::SendReceiveContext::ForkDomain
1833 or
1834 context == TraversalObserver::SendReceiveContext::JoinDomain
1835 )
1836 ) {
1837 logDebug( "sendFace(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId << " for marker " << marker.toString() );
1838
1839 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1840 _spacetreeId, toStack
1841 ) -> push(data);
1842 }
1843 }
1844"""
1845
1846 TemplateSendFace_Epilogue = """
1847 logTraceOut( "sendFace(int,int,int)");
1848}
1849
1850
1851"""
1852
1853 TemplateSendCell_Prologue = """
1854void {{FULL_QUALIFIED_CLASSNAME}}::sendCell(int toStack, ::peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1855 logTraceInWith3Arguments( "sendCell(int,int,int)", toStack, event.toString(), _spacetreeId );
1856
1857"""
1858
1859 TemplateSendCell_SendCall = """
1860 {
1861 peano4::datamanagement::CellMarker marker(event);
1862 const {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop( {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top();
1863 if (
1864 ::peano4::grid::storePersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1865 marker
1866 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1867 ))
1868 and
1869 (
1870 data.send(
1871 marker
1872 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1873 )
1874 or
1875 context == TraversalObserver::SendReceiveContext::ForkDomain
1876 or
1877 context == TraversalObserver::SendReceiveContext::JoinDomain
1878 )
1879 ) {
1880 logDebug( "sendCell(...)", "send out " << data.toString() << " to stack " << toStack << " on tree " << _spacetreeId );
1881
1882 {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1883 _spacetreeId, toStack
1884 ) -> push(data);
1885 }
1886 }
1887"""
1888
1889 TemplateSendCell_Epilogue = """
1890 logTraceOut( "sendCell(int,int,int)");
1891}
1892
1893
1894"""
1895
1896 TemplateReceiveAndMergeCell_Prologue = """
1897void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeCell(int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event ) {
1898 logTraceInWith3Arguments( "receiveAndMergeCell(...)", fromStack, event.toString(), _spacetreeId );
1899"""
1900
1901 TemplateReceiveAndMergeCell_Epilogue = """
1902 logTraceOut( "receiveAndMergeCell(...)");
1903}
1904
1905
1906"""
1907
1908 TemplateReceiveAndMergeVertex_Prologue = """
1909void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeVertex(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1910 logTraceInWith4Arguments( "receiveAndMergeVertex(...)", position, fromStack, event.toString(), _spacetreeId );
1911"""
1912
1913 TemplateReceiveAndMergeVertex_Epilogue = """
1914 logTraceOut( "receiveAndMergeVertex(...)");
1915}
1916
1917
1918"""
1919
1920 TemplateReceiveAndMergeFace_Epilogue = """
1921 logTraceOut( "receiveAndMergeFace(...)");
1922}
1923
1924
1925"""
1926
1927 TemplateReceiveAndMergeFace_Prologue = """
1928void {{FULL_QUALIFIED_CLASSNAME}}::receiveAndMergeFace(int position, int fromStack, peano4::grid::TraversalObserver::SendReceiveContext context, const peano4::grid::GridTraversalEvent& event) {
1929 logTraceInWith4Arguments( "receiveAndMergeFace(...)", position, fromStack, event.toString(), _spacetreeId );
1930"""
1931
1932 TemplateReceiveAndMergeVertex_ReceiveAndMergeCalls = """
1933 {
1934 peano4::datamanagement::VertexMarker marker(event,position);
1935 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1936 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1937 )->top(TwoPowerD-1-position);
1938
1939 if (
1940 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1941 marker
1942 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1943 ))
1944 and
1945 data.receiveAndMerge(
1946 marker
1947 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1948 )
1949 ) {
1950 assertion5(
1951 not {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(_spacetreeId, fromStack)->empty(),
1952 _spacetreeId, fromStack, event.toString(), position, marker.toString()
1953 );
1954
1955 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
1956 _spacetreeId, fromStack
1957 )->pop() );
1958
1959 logDebug( "receiveAndMergeVertex(...)", "merge " << incomingData.toString() << " into " << data.toString() );
1960
1961 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
1962 // @todo Different to faces. As we can have diagonal exchange, too,
1963 // we only know that it has to be unequal
1964 assertion8(
1965 data.getDebugX()!=incomingData.getDebugX(),
1966 data.getDebugX(), incomingData.getDebugX(),
1967 data.getDebugH(), incomingData.getDebugH(),
1968 fromStack, event.toString(), marker.toString(), _spacetreeId );
1969 assertionVectorNumericalEquals6(
1970 data.getDebugH(), incomingData.getDebugH(),
1971 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1972 }
1973 else {
1974 assertionVectorNumericalEquals6(
1975 data.getDebugX(), incomingData.getDebugX(),
1976 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1977 assertionVectorNumericalEquals6(
1978 data.getDebugH(), incomingData.getDebugH(),
1979 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
1980 }
1981
1982 data.merge(context, incomingData, marker, _spacetreeId);
1983 }
1984 }
1985"""
1986
1987 TemplateReceiveAndMergeFace_ReceiveAndMergeCalls = """
1988 {
1989 peano4::datamanagement::FaceMarker marker(event,position);
1990 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
1991 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
1992 )->top(TwoTimesD-1-position);
1993
1994 if (
1995 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
1996 marker
1997 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
1998 ))
1999 and
2000 data.receiveAndMerge(
2001 marker
2002 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
2003 )
2004 ) {
2005 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
2006 _spacetreeId, fromStack
2007 )->pop() );
2008
2009 logDebug( "receiveAndMergeFace(...)", "merge " << incomingData.toString() << " into " << data.toString() << " within marker " << marker.toString() );
2010
2011 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
2012 assertion8(
2013 tarch::la::countEqualEntries(data.getDebugX(), incomingData.getDebugX())==Dimensions-1,
2014 data.getDebugX(), incomingData.getDebugX(),
2015 data.getDebugH(), incomingData.getDebugH(),
2016 fromStack, event.toString(), marker.toString(), _spacetreeId );
2017 assertionVectorNumericalEquals6(
2018 data.getDebugH(), incomingData.getDebugH(),
2019 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2020 }
2021 else {
2022 assertionVectorNumericalEquals6(
2023 data.getDebugX(), incomingData.getDebugX(),
2024 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2025 assertionVectorNumericalEquals6(
2026 data.getDebugH(), incomingData.getDebugH(),
2027 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2028 }
2029
2030 data.merge(context,incomingData, marker, _spacetreeId);
2031 }
2032 }
2033"""
2034
2035 TemplateReceiveAndMergeCell_ReceiveAndMergeCalls = """
2036 {
2037 peano4::datamanagement::CellMarker marker(event);
2038
2039 {{full_qualified_type}}& data = {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPush(
2040 {{subnamespace}}repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack)
2041 )->top();
2042
2043 if (
2044 ::peano4::grid::loadPersistently( {{full_qualified_type}}::loadStoreComputeFlag(
2045 marker
2046 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
2047 ))
2048 and
2049 data.receiveAndMerge(
2050 marker
2051 {% for arg in ADDITIONAL_LOAD_STORE_ARGUMENTS %}, {{arg[0]}} {% endfor %}
2052 )
2053 ) {
2054 auto incomingData = std::move( {{subnamespace}}repositories::DataRepository::_{{logical_type_name}}Stack.getForPop(
2055 _spacetreeId, fromStack
2056 )->pop() );
2057
2058 logDebug( "receiveAndMergeCell(...)", "merge " << incomingData.toString() << " into " << data.toString() );
2059
2060 if (context==::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap) {
2061 assertion8(
2062 tarch::la::countEqualEntries(data.getDebugX(), incomingData.getDebugX())==Dimensions-1,
2063 data.getDebugX(), incomingData.getDebugX(),
2064 data.getDebugH(), incomingData.getDebugH(),
2065 fromStack, event.toString(), marker.toString(), _spacetreeId );
2066 assertionVectorNumericalEquals6(
2067 data.getDebugH(), incomingData.getDebugH(),
2068 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2069 }
2070 else {
2071 assertionVectorNumericalEquals6(
2072 data.getDebugX(), incomingData.getDebugX(),
2073 data.getDebugH(), incomingData.getDebugH(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2074 assertionVectorNumericalEquals6(
2075 data.getDebugH(), incomingData.getDebugH(),
2076 data.getDebugX(), incomingData.getDebugX(), fromStack, event.toString(), marker.toString(), _spacetreeId );
2077 }
2078
2079 data.merge(context,incomingData, marker, _spacetreeId);
2080 }
2081 }
2082"""
2083
2084 TemplateExchangeRoutines_deleteAllStacks_Prologue = """
2085void {{FULL_QUALIFIED_CLASSNAME}}::deleteAllStacks() {
2086 logTraceInWith1Argument( "deleteAllStacks()", _spacetreeId );
2087"""
2088
2089 TemplateExchangeRoutines_deleteAllStacks_Exchange = """
2090 peano4::parallel::SpacetreeSet::deleteAllStacks(
2091 {{DATASET}},
2092 _spacetreeId
2093 );
2094"""
2095
2096 TemplateExchangeRoutines_deleteAllStacks_Epilogue = """
2097 logTraceOut( "deleteAllStacks()");
2098}
2099
2100
2101"""
2102
2103 def __generate_exchange_routines(self, output_file):
2104 s = ""
2105
2106 generic_dict_for_prologue_and_epilogue = {
2107 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"]
2108 }
2109
2110 s += jinja2.Template(
2112 ).render(**generic_dict_for_prologue_and_epilogue)
2113 for cell in self.cells:
2114 s += jinja2.Template(
2116 ).render(
2117 **{
2118 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2119 + cell.get_logical_type_name()
2120 + "Stack"
2121 }
2122 )
2123 for face in self.faces:
2124 s += jinja2.Template(
2126 ).render(
2127 **{
2128 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2129 + face.get_logical_type_name()
2130 + "Stack"
2131 }
2132 )
2133 for vertex in self.vertices:
2134 s += jinja2.Template(
2136 ).render(
2137 **{
2138 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2139 + vertex.get_logical_type_name()
2140 + "Stack"
2141 }
2142 )
2143 s += jinja2.Template(
2145 ).render({})
2146
2147 s += jinja2.Template(
2149 ).render(**generic_dict_for_prologue_and_epilogue)
2150 for cell in self.cells:
2151 s += jinja2.Template(
2153 ).render(
2154 **{
2155 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2156 + cell.get_logical_type_name()
2157 + "Stack"
2158 }
2159 )
2160 for face in self.faces:
2161 s += jinja2.Template(
2163 ).render(
2164 **{
2165 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2166 + face.get_logical_type_name()
2167 + "Stack"
2168 }
2169 )
2170 for vertex in self.vertices:
2171 s += jinja2.Template(
2173 ).render(
2174 **{
2175 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2176 + vertex.get_logical_type_name()
2177 + "Stack"
2178 }
2179 )
2180 s += jinja2.Template(
2182 ).render({})
2183
2184 s += jinja2.Template(
2186 ).render(**generic_dict_for_prologue_and_epilogue)
2187 for cell in self.cells:
2188 s += jinja2.Template(
2190 ).render(
2191 **{
2192 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2193 + cell.get_logical_type_name()
2194 + "Stack"
2195 }
2196 )
2197 for face in self.faces:
2198 s += jinja2.Template(
2200 ).render(
2201 **{
2202 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2203 + face.get_logical_type_name()
2204 + "Stack"
2205 }
2206 )
2207 for vertex in self.vertices:
2208 s += jinja2.Template(
2210 ).render(
2211 **{
2212 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2213 + vertex.get_logical_type_name()
2214 + "Stack"
2215 }
2216 )
2217 s += jinja2.Template(
2219 ).render({})
2220
2221 s += jinja2.Template(
2223 ).render(**generic_dict_for_prologue_and_epilogue)
2224 for cell in self.cells:
2225 s += jinja2.Template(
2227 ).render(
2228 **{
2229 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2230 + cell.get_logical_type_name()
2231 + "Stack"
2232 }
2233 )
2234 for face in self.faces:
2235 s += jinja2.Template(
2237 ).render(
2238 **{
2239 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2240 + face.get_logical_type_name()
2241 + "Stack"
2242 }
2243 )
2244 for vertex in self.vertices:
2245 s += jinja2.Template(
2247 ).render(
2248 **{
2249 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2250 + vertex.get_logical_type_name()
2251 + "Stack"
2252 }
2253 )
2254 s += jinja2.Template(
2256 ).render({})
2257
2258 s += jinja2.Template(
2260 ).render(**generic_dict_for_prologue_and_epilogue)
2261 for cell in self.cells:
2262 s += jinja2.Template(
2264 ).render(
2265 **{
2266 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2267 + cell.get_logical_type_name()
2268 + "Stack"
2269 }
2270 )
2271 for face in self.faces:
2272 s += jinja2.Template(
2274 ).render(
2275 **{
2276 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2277 + face.get_logical_type_name()
2278 + "Stack"
2279 }
2280 )
2281 for vertex in self.vertices:
2282 s += jinja2.Template(
2284 ).render(
2285 **{
2286 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2287 + vertex.get_logical_type_name()
2288 + "Stack"
2289 }
2290 )
2291 s += jinja2.Template(
2293 ).render({})
2294
2295 s += jinja2.Template(
2297 ).render(**generic_dict_for_prologue_and_epilogue)
2298 for cell in self.cells:
2299 s += jinja2.Template(
2301 ).render(
2302 **{
2303 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2304 + cell.get_logical_type_name()
2305 + "Stack"
2306 }
2307 )
2308 for face in self.faces:
2309 s += jinja2.Template(
2311 ).render(
2312 **{
2313 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2314 + face.get_logical_type_name()
2315 + "Stack"
2316 }
2317 )
2318 for vertex in self.vertices:
2319 s += jinja2.Template(
2321 ).render(
2322 **{
2323 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2324 + vertex.get_logical_type_name()
2325 + "Stack"
2326 }
2327 )
2328 s += jinja2.Template(
2330 ).render({})
2331
2332 s += jinja2.Template(self.TemplateSendVertex_Prologue).render(
2333 **generic_dict_for_prologue_and_epilogue
2334 )
2335 for vertex in self.vertices:
2336 temp = {
2337 "name": vertex.name,
2338 "enumeration_type": vertex.get_enumeration_type(),
2339 "logical_type_name": vertex.get_logical_type_name(),
2340 "full_qualified_type": vertex.get_full_qualified_type(),
2341 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2342 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2343 "subnamespace": vertex.subnamespace,
2344 }
2345 s += jinja2.Template(self.TemplateSendVertex_SendCall).render(**temp)
2346 s += jinja2.Template(self.TemplateSendVertex_Epilogue).render(
2347 **generic_dict_for_prologue_and_epilogue
2348 )
2349
2350 s += jinja2.Template(self.TemplateSendFace_Prologue).render(
2351 **generic_dict_for_prologue_and_epilogue
2352 )
2353 for face in self.faces:
2354 temp = {
2355 "name": face.name,
2356 "enumeration_type": face.get_enumeration_type(),
2357 "logical_type_name": face.get_logical_type_name(),
2358 "full_qualified_type": face.get_full_qualified_type(),
2359 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2360 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2361 "subnamespace": face.subnamespace,
2362 }
2363 s += jinja2.Template(self.TemplateSendFace_SendCall).render(**temp)
2364 s += jinja2.Template(self.TemplateSendFace_Epilogue).render(
2365 **generic_dict_for_prologue_and_epilogue
2366 )
2367
2368 s += jinja2.Template(self.TemplateSendCell_Prologue).render(
2369 **generic_dict_for_prologue_and_epilogue
2370 )
2371 for cell in self.cells:
2372 temp = {
2373 "name": cell.name,
2374 "logical_type_name": cell.get_logical_type_name(),
2375 "full_qualified_type": cell.get_full_qualified_type(),
2376 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2377 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2378 "subnamespace": cell.subnamespace,
2379 }
2380 s += jinja2.Template(self.TemplateSendCell_SendCall).render(**temp)
2381 s += jinja2.Template(self.TemplateSendCell_Epilogue).render(
2382 **generic_dict_for_prologue_and_epilogue
2383 )
2384
2385 s += jinja2.Template(self.TemplateReceiveAndMergeCell_Prologue).render(
2386 **generic_dict_for_prologue_and_epilogue
2387 )
2388 for cell in self.cells:
2389 temp = {
2390 "name": cell.name,
2391 "logical_type_name": cell.get_logical_type_name(),
2392 "full_qualified_type": cell.get_full_qualified_type(),
2393 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2394 "ADDITIONAL_LOAD_STORE_ARGUMENTS": cell.additional_load_and_store_arguments,
2395 "subnamespace": cell.subnamespace,
2396 }
2397 s += jinja2.Template(
2399 ).render(**temp)
2400 s += jinja2.Template(self.TemplateReceiveAndMergeCell_Epilogue).render(
2401 **generic_dict_for_prologue_and_epilogue
2402 )
2403
2404 s += jinja2.Template(self.TemplateReceiveAndMergeFace_Prologue).render(
2405 **generic_dict_for_prologue_and_epilogue
2406 )
2407 for face in self.faces:
2408 temp = {
2409 "name": face.name,
2410 "enumeration_type": face.get_enumeration_type(),
2411 "logical_type_name": face.get_logical_type_name(),
2412 "full_qualified_type": face.get_full_qualified_type(),
2413 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2414 "ADDITIONAL_LOAD_STORE_ARGUMENTS": face.additional_load_and_store_arguments,
2415 "subnamespace": face.subnamespace,
2416 }
2417 s += jinja2.Template(
2419 ).render(**temp)
2420 s += jinja2.Template(self.TemplateReceiveAndMergeFace_Epilogue).render(
2421 **generic_dict_for_prologue_and_epilogue
2422 )
2423
2424 s += jinja2.Template(self.TemplateReceiveAndMergeVertex_Prologue).render(
2425 **generic_dict_for_prologue_and_epilogue
2426 )
2427 for vertex in self.vertices:
2428 temp = {
2429 "name": vertex.name,
2430 "enumeration_type": vertex.get_enumeration_type(),
2431 "logical_type_name": vertex.get_logical_type_name(),
2432 "full_qualified_type": vertex.get_full_qualified_type(),
2433 "FULL_QUALIFIED_CLASSNAME": self.d["FULL_QUALIFIED_CLASSNAME"],
2434 "ADDITIONAL_LOAD_STORE_ARGUMENTS": vertex.additional_load_and_store_arguments,
2435 "subnamespace": vertex.subnamespace,
2436 }
2437 s += jinja2.Template(
2439 ).render(**temp)
2440 s += jinja2.Template(self.TemplateReceiveAndMergeVertex_Epilogue).render(
2441 **generic_dict_for_prologue_and_epilogue
2442 )
2443
2444 s += jinja2.Template(
2446 ).render(**generic_dict_for_prologue_and_epilogue)
2447 for cell in self.cells:
2448 s += jinja2.Template(
2450 ).render(
2451 **{
2452 "DATASET": cell.subnamespace + "repositories::DataRepository::_"
2453 + cell.get_logical_type_name()
2454 + "Stack"
2455 }
2456 )
2457 for face in self.faces:
2458 s += jinja2.Template(
2460 ).render(
2461 **{
2462 "DATASET": face.subnamespace + "repositories::DataRepository::_"
2463 + face.get_logical_type_name()
2464 + "Stack"
2465 }
2466 )
2467 for vertex in self.vertices:
2468 s += jinja2.Template(
2470 ).render(
2471 **{
2472 "DATASET": vertex.subnamespace + "repositories::DataRepository::_"
2473 + vertex.get_logical_type_name()
2474 + "Stack"
2475 }
2476 )
2477 s += jinja2.Template(
2479 ).render(**generic_dict_for_prologue_and_epilogue)
2480
2481 output_file.write(s)
2482
2483 TemplateImplementationFilePrologue = """
2484#include "{{CLASSNAME}}.h"
2485{{DATAREPOSITORY_INCLUDES}}
2486
2487#include "peano4/grid/PeanoCurve.h"
2488
2489#include "peano4/datamanagement/VertexEnumerator.h"
2490#include "peano4/datamanagement/VertexMarker.h"
2491#include "peano4/datamanagement/FaceEnumerator.h"
2492#include "peano4/datamanagement/FaceMarker.h"
2493#include "peano4/datamanagement/CellMarker.h"
2494
2495#include "peano4/parallel/SpacetreeSet.h"
2496
2497
2498tarch::logging::Log {{FULL_QUALIFIED_CLASSNAME}}::_log( "{{FULL_QUALIFIED_CLASSNAME}}" );
2499
2500"""
2501
2502 def __generate_implementation(self, overwrite, full_qualified_filename):
2503 if write_file(overwrite, self.default_overwritedefault_overwrite, full_qualified_filename):
2504 import inspect, os
2505
2506 print(
2507 "{} written by {}".format(
2508 full_qualified_filename,
2509 os.path.basename(inspect.getfile(self.__class__)),
2510 )
2511 )
2512
2513 output_file = open(full_qualified_filename, "w")
2514 output_file.write(
2516 **self.d
2517 )
2518 )
2519
2520 self.__generate_constructor(output_file)
2521 self.__generate_clone(output_file)
2522 self.__generate_getGridControlEvents(output_file)
2523 self.__generate_beginTraversal(output_file)
2524 self.__generate_endTraversal(output_file)
2525 self.__generate_prepareTraversal(output_file)
2526 self.__generate_unprepareTraversal(output_file)
2527 self.__generate_loadCell(output_file)
2528 self.__generate_enterCell(output_file)
2529 self.__generate_leaveCell(output_file)
2530 self.__generate_storeCell(output_file)
2531 self.__generate_exchange_routines(output_file)
2532
2533 #
2534 # @todo Sollte man mit Jinja 2 nicht mehr brauchen
2535 #
2537 return self.subdirectory + "/" + self.classname + ".cpp"
2538
2539 def generate(self, overwrite, directory):
2540 if not os.path.exists(directory + "/" + self.subdirectory):
2541 os.mkdir(directory + "/" + self.subdirectory)
2542
2543 cpp_filename = directory + "/" + self.get_cpp_file_name()
2544
2545 self.__generate_header(overwrite, directory)
2546 self.__generate_implementation(overwrite, cpp_filename)
__generate_getGridControlEvents(self, output_file)
Definition Observer.py:543
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Prologue
Definition Observer.py:1688
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Prologue
Definition Observer.py:1727
__generate_header(self, overwrite, directory)
Definition Observer.py:248
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Exchange
Definition Observer.py:1693
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Exchange
Definition Observer.py:1732
mkSubDict(self, keys)
Create the particular subdictionary that's used for an expression.
Definition Observer.py:1048
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Epilogue
Definition Observer.py:1759
__generate_unprepareTraversal(self, output_file)
Definition Observer.py:475
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Epilogue
Definition Observer.py:1661
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Exchange
Definition Observer.py:1673
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Prologue
Definition Observer.py:1707
str TemplateExchangeRoutines_exchangeAllHorizontalDataExchangeStacks_Prologue
Definition Observer.py:1668
__generate_exchange_routines(self, output_file)
Definition Observer.py:2103
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Epilogue
Definition Observer.py:1720
__generate_clone(self, output_file)
Definition Observer.py:556
str TemplateExchangeRoutines_streamDataFromSplittingTreeToNewTree_Exchange
Definition Observer.py:1712
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Exchange
Definition Observer.py:1752
str TemplateExchangeRoutines_finishAllOutstandingSendsAndReceives_Prologue
Definition Observer.py:1747
__generate_loadCell(self, output_file)
Definition Observer.py:1065
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Prologue
Definition Observer.py:1648
__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:2502
str TemplateExchangeRoutines_exchangeAllPeriodicBoundaryDataStacks_Epilogue
Definition Observer.py:1700
str TemplateExchangeRoutines_streamDataFromJoiningTreeToMasterTree_Epilogue
Definition Observer.py:1740
__generate_leaveCell(self, output_file)
Generates enter cell.
Definition Observer.py:1519
__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:1681
__generate_storeCell(self, output_file)
Definition Observer.py:1592
generateDictEntry(self, key)
Some logic to produce new dictionary entries from existing ones.
Definition Observer.py:1028
__generate_beginTraversal(self, output_file)
Definition Observer.py:316
str TemplateExchangeRoutines_exchangeAllVerticalDataExchangeStacks_Exchange
Definition Observer.py:1653
__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:1113
__generate_prepareTraversal(self, output_file)
Definition Observer.py:455
generate(self, overwrite, directory)
Definition Observer.py:2539