Peano
Loading...
Searching...
No Matches
DiscontinuousGalerkinTracing.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.api.solversteps.ActionSet import ActionSet
4
6
7import jinja2
8
9
12):
13 """!
14
15 Particle tracing over the DG solver.
16
17 Please consult the class FiniteVolumesTracing for details on the semantics
18 of this type. It is an exact analogon for DG.
19
20 ## Update plug-in points
21
22 We only update cells which are marked with getHasUpdated(). For enclave solvers,
23 we assume that this flag is only set after a cell has updated. For Runge-Kutta
24 type solvers, I assume that this flag is set by the computation of the final
25 linear combination of estimates.
26
27
28
29 """
30
32 self,
33 particle_set,
34 solver,
35 project_on_tracer_properties_kernel,
36 projection_kernel_arguments="""
37 marker,
38 {{ORDER}},
39 repositories::{{SOLVER_INSTANCE}}.QuadraturePoints1d,
40 {{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},
41 fineGridCell{{SOLVER_NAME}}Q.value,
42 *p
43""",
44 ):
45 """
46
47 @see FiniteVolumesTracing.__init()__.
48
49 """
50
51 self.tracerDict = {}
52 # Don't overwrite hte dictionary of hte superclass. We'll need it
53 self.tracerDict["PARTICLE"] = particle_set.particle_model.name
54 self.tracerDict["PARTICLES_CONTAINER"] = particle_set.name
55 self.tracerDict["SOLVER_NAME"] = solver._name
56 self.tracerDict["SOLVER_INSTANCE"] = solver.get_name_of_global_instance()
57 self.tracerDict["ORDER"] = solver._basis.order
58 self.tracerDict["NUMBER_OF_UNKNOWNS"] = solver._unknowns
59 self.tracerDict["NUMBER_OF_AUXILIARY_VARIABLES"] = solver._auxiliary_variables
60 self.tracerDict["PROJECTION_KERNEL"] = project_on_tracer_properties_kernel
61 self.tracerDict["PROJECTION_KERNEL_ARGUMENTS"] = jinja2.Template(
62 projection_kernel_arguments
63 ).render(**self.tracerDict)
64
65 cell_compute_kernel = """
66if (
67 fineGridCell{{SOLVER_NAME}}CellLabel.getHasUpdated()
68 and
69 (
70 repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
71 or
72 repositories::{{SOLVER_INSTANCE}}.getSolverState()=={{SOLVER_NAME}}::SolverState::GridInitialisation
73 )
74) {
75 for (auto* p: localParticles) {
76 if (
77 p->getMoveState()==globaldata::{{PARTICLE}}::MoveState::NotMovedYet and marker.isContained(p->getX())
78 ) {
79 {{PROJECTION_KERNEL}}(
80 {{PROJECTION_KERNEL_ARGUMENTS}}
81 );
82
83 p->setMoveState( globaldata::{{PARTICLE}}::MoveState::Moved );
84 }
85 }
86}
87"""
88
89 touch_vertex_first_time_compute_kernel = """
90 for (auto* p: assignedParticles) {
91 p->setMoveState(globaldata::{{PARTICLE}}::MoveState::NotMovedYet);
92 }
93"""
94
95 super(DiscontinuousGalerkinTracing,self).__init__(
96 particle_set,
97 jinja2.Template(cell_compute_kernel).render(**self.tracerDict),
98 jinja2.Template(touch_vertex_first_time_compute_kernel).render(
99 **self.tracerDict
100 ),
101 )
102
103 # def get_body_of_operation(self,operation_name):
104 # result = peano4.api.toolbox.particles.UpdateParticle_MultiLevelInteraction_StackOfLists_ContiguousParticles.get_body_of_operation(self,operation_name)
105 # if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
106 # result = self.__Template_BeginIteration.render(**self.tracerDict)
107 # return result
108
109 def get_action_set_name(self):
110 return __name__.replace(".py", "").replace(".", "_")
111
112 def user_should_modify_template(self):
113 return False
114
115 def get_includes(self):
116 result = jinja2.Template(
117 """
118#include "tarch/multicore/Lock.h"
119#include "peano4/utils/Loop.h"
120#include "vertexdata/{{PARTICLES_CONTAINER}}.h"
121#include "globaldata/{{PARTICLE}}.h"
122#include "repositories/SolverRepository.h"
123#include "exahype2/dg/Tracer.h"
124"""
125 )
126 return (super(DiscontinuousGalerkinTracing,self).get_includes()
127 + "\n"
128 + result.render(**self.tracerDict)
129 )
130
131 def get_attributes(self):
132 return (
133 super(DiscontinuousGalerkinTracing,self).get_attributes()
134 + """
135double _timeStepSize;
136"""
137 )
Action set (reactions to events)
Definition ActionSet.py:6
__init__(self, particle_set, solver, project_on_tracer_properties_kernel, projection_kernel_arguments="""marker,{{ORDER}},repositories::{{SOLVER_INSTANCE}}.QuadraturePoints1d,{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},fineGridCell{{SOLVER_NAME}}Q.value,*p""")