Peano
Loading...
Searching...
No Matches
SynchroniseVerticesWithPreviousMeshSweep.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
3from peano4.solversteps.ActionSet import ActionSet
4
5import jinja2
6import peano4
7
8
11 self,
12 particle_set,
13 ):
14 """!
15
16 Ensure that touchVertexLastTime() on vertex terminates prior to subsequent touchVertexLastTime()
17
18 This action set is used by MultisweepTaskGraph, where we run through
19 the mesh, spawn graphs and immediately switch to the next mesh traversal.
20 This way, we produce the whole task graph of multiple logical steps
21 on-the-fly. To make the whole thing work, we have to ensure that the
22 task of touchVertexLastTime() of one traversal finishes before the one
23 spawned by touchVertexFirstTime() is activated.
24
25 In prinicple, we can embed this into the task creation by creating
26 the corresponding in-dependency. I tried this in the TaskGraphKernelWrapper.
27 However, when we write the touchVertexFirstTime() task, we really do not
28 know if there has been another touchVertexFirstTime() task before. So
29 instead of having complicated logic, I use an empty task to create that
30 dependency once and for all.
31
32 """
33 self._particle_set = particle_set
34 self.d = {}
35 self.d["PARTICLE"] = particle_set.particle_model.name
36 self.d["PARTICLES_CONTAINER"] = particle_set.name
37 self.d[
38 "MARKER_NAME"
40 particle_set.name
41 )
42
43 return
44
46 return False
47
48 __Template_TouchVertexFirstTime = jinja2.Template(
49 """
50 const std::set<::swift2::TaskNumber> inTaskNumber{ ::swift2::TaskNumber(
51 fineGridVertex{{MARKER_NAME}}.getNumber(),
52 ::swift2::TaskNumber::TaskAssociation::TouchVertexLastTime
53 )};
54
55 const ::swift2::TaskNumber outTaskNumber{
56 fineGridVertex{{MARKER_NAME}}.getNumber(),
57 ::swift2::TaskNumber::TaskAssociation::TouchVertexFirstTime
58 };
59
60 tarch::multicore::Task* newTask = new tarch::multicore::EmptyTask(
61 tarch::multicore::Task::DefaultPriority
62 );
63
64 tarch::multicore::spawnTask( newTask, ::swift2::flatten(inTaskNumber), ::swift2::flatten(outTaskNumber) );
65 """
66 )
67
68 def get_body_of_operation(self, operation_name):
69 result = "\n"
70 if operation_name == ActionSet.OPERATION_TOUCH_VERTEX_FIRST_TIME:
71 result = self.__Template_TouchVertexFirstTime.render(**self.d)
72 return result
73
75 return __name__.replace(".py", "").replace(".", "_")
76
77 def get_includes(self):
78 result = jinja2.Template(
79 """
80#include "tarch/multicore/Task.h"
81#include "swift2/swift2.h"
82#include "swift2/TaskNumber.h"
83
84#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
85#include "globaldata/{{PARTICLE}}.h"
86"""
87 )
88 return result.render(**self.d)
Action set (reactions to events)
Definition ActionSet.py:6
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, particle_set)
Ensure that touchVertexLastTime() on vertex terminates prior to subsequent touchVertexLastTime()