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