Peano
Loading...
Searching...
No Matches
PreprocessSolution.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3
4from .AbstractFVActionSet import AbstractFVActionSet
5
6import peano4
7import jinja2
8
10 """
11
12 PreprocessSolution differs from other action sets, as I only create it once. See
13 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
14 can also completely overwrite it.
15
16 """
17 def __init__(self,solver):
18 AbstractFVActionSet.__init__(self,solver)
19 # Is there for compatibility reasons
20 self.guard = "true"
22
23
24 def get_body_of_operation(self,operation_name):
25 result = ""
26 return result
27
28
30 return __name__.replace(".py", "").replace(".", "_")
31
32
33
34
35
37 """!
38
39 Run over solution volume by volume
40
41 PreprocessSolution differs from other action sets, as I only create it once. See
42 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
43 can also completely overwrite it.
44
45 See also FV.postprocess_updated_patch(self, kernel) for a discussion what options
46 ExaHyPE offers for postprocessing. This volume-wise postprocessing might be too
47 heavy-weight for some applications.
48
49 The postprocessing plugs into touch cell last time. It is the last action set added
50 by the default implementation. Therefore, it is the first action set of which
51 touchCellLastTime() is called. The reason why I plug into the leaving of the cell
52 is that some solvers may add further action sets to the solve. Enclave tasking for
53 example adds the merger as additional action set. These action sets plug into
54 touchCellFirstTime() - and consequently their first time is called after the
55 postprocessing's first time. By making the postprocessing use touchCellLastTime(),
56 I ensure that any additional action set added by a subclass can still precede the
57 postprocessing.
58
59
60 """
61 def __init__(self,solver):
62 AbstractFVActionSet.__init__(self,solver)
63 self.guard = "true"
66
67
68 def add_postprocessing_kernel(self, operation_per_point):
69 """
70
71 Add a code snippet which is applied to each and every point. You have the following
72 variables which are well-defined:
73
74 - value: Is a pointer to the current finite volume's data
75 - volumeX: A tarch::la::Vector over doubles
76 - volumeH: A tarch::la::Vector over doubles
77
78
79 operation_per_point: String
80 C/C++ code snippet
81
82 """
83 self._compute_kernel += """
84{
85 {{COMPUTE_TIME_STEP_SIZE}}
86 const double timeStamp = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStamp();
87
88 if (
89 not marker.hasBeenRefined()
90 and
91 {{PREDICATE}}
92 ) {
93 logTraceIn( "touchCellFirstTime(...)" );
94
95 int index = 0;
96 dfor( volume, {{NUMBER_OF_VOLUMES_PER_AXIS}} ) {
97 double* value = fineGridCell{{UNKNOWN_IDENTIFIER}}.value + index;
98 auto volumeX = ::exahype2::fv::getVolumeCentre( marker.x(), marker.h(), {{NUMBER_OF_VOLUMES_PER_AXIS}}, volume);
99 auto volumeH = ::exahype2::fv::getVolumeSize( marker.h(), {{NUMBER_OF_VOLUMES_PER_AXIS}});
100
101 """ + operation_per_point + """
102
103 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
104 }
105 logTraceOut( "touchCellFirstTime(...)" );
106 }
107}
108"""
109
110
111
112 def get_body_of_operation(self,operation_name):
113 result = ""
114 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
115 d = {}
116 self._solver._init_dictionary_with_default_parameters(d)
117 self._solver.add_entries_to_text_replacement_dictionary(d)
118 d[ "PREDICATE" ] = jinja2.Template(self.guard, undefined=jinja2.DebugUndefined).render(**d)
119 result = jinja2.Template(self._compute_kernel, undefined=jinja2.DebugUndefined).render(**d)
120 pass
121 return result
122
123
125 return __name__.replace(".py", "").replace(".", "_")
PreprocessSolution differs from other action sets, as I only create it once.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
__init__(self, solver)
solver: ADERDG Reference to creating class
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, solver)
solver: ADERDG Reference to creating class
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
add_postprocessing_kernel(self, operation_per_point)
Add a code snippet which is applied to each and every point.