15 SolveRiemannProblemsOverPatch = jinja2.Template(
"""
16 double timeStamp = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStamp();
19 // double timeStepSize
20 {{COMPUTE_TIME_STEP_SIZE}}
22 {{PREPROCESS_RECONSTRUCTED_PATCH}}
24 assertion2(tarch::la::greaterEquals(timeStamp, 0.0), timeStamp, timeStepSize);
25 assertion2(tarch::la::greaterEquals(timeStepSize, 0.0), timeStamp, timeStepSize);
27 ::exahype2::fv::validatePatch(
29 {{NUMBER_OF_UNKNOWNS}},
30 {{NUMBER_OF_AUXILIARY_VARIABLES}},
31 {{NUMBER_OF_VOLUMES_PER_AXIS}},
33 std::string(__FILE__) + "(" + std::to_string(__LINE__) + "): " + marker.toString()
34 ); // Previous time step has to be valid
36 ::exahype2::CellData patchData(oldQWithHalo, marker.x(), marker.h(), timeStamp, timeStepSize, newQ);
38 {% if STATELESS_PDE_TERMS %}
39 if (repositories::{{SOLVER_INSTANCE}}.patchCanUseStatelessPDETerms(
45 ::exahype2::fv::{{KERNEL_NAMESPACE}}::{{COMPUTE_KERNEL_CALL_STATELESS}}
49 ::exahype2::fv::{{KERNEL_NAMESPACE}}::{{COMPUTE_KERNEL_CALL}}
51 {{POSTPROCESS_UPDATED_PATCH}}
53 ::exahype2::fv::validatePatch(
55 {{NUMBER_OF_UNKNOWNS}},
56 {{NUMBER_OF_AUXILIARY_VARIABLES}},
57 {{NUMBER_OF_VOLUMES_PER_AXIS}},
59 std::string(__FILE__) + "(" + std::to_string(__LINE__) + "): " + marker.toString()
60 ); // Outcome has to be valid
62 {% if COMPUTE_MAX_EIGENVALUE %}
63 const double maxEigenvalue = patchData.maxEigenvalue[0];
67 // double newTimeStepSize
68 {{COMPUTE_NEW_TIME_STEP_SIZE}}
70 fineGridCell{{SOLVER_NAME}}CellLabel.setTimeStamp(timeStamp+timeStepSize);
71 fineGridCell{{SOLVER_NAME}}CellLabel.setTimeStepSize(newTimeStepSize);
72 fineGridCell{{SOLVER_NAME}}CellLabel.setHasUpdated(true);
74 repositories::{{SOLVER_INSTANCE}}.update(newTimeStepSize, timeStamp+timeStepSize, marker.h()(0));
81 ReconstructPatchAndApplyFunctor.__init__(self,
82 patch = solver._patch,
83 patch_overlap = solver._patch_overlap_new,
84 functor_implementation =
"""
85#error Please switch to your Riemann solver of choice
87 reconstructed_array_memory_location = solver._reconstructed_array_memory_location,
88 guard =
"not marker.willBeRefined() and not marker.hasBeenRefined()",
89 add_assertions_to_halo_exchange =
False
94 else if (not marker.willBeRefined() and not marker.hasBeenRefined()) {{
95 const double timeStamp = fineGridCell{SOLVER_NAME}CellLabel.getTimeStamp();
96 const double timeStepSize = fineGridCell{SOLVER_NAME}CellLabel.getTimeStepSize();
98 assertion2(tarch::la::greaterEquals( timeStepSize, 0.0 ), timeStepSize, timeStamp);
99 assertion2(tarch::la::greaterEquals( timeStamp, 0.0 ), timeStepSize, timeStamp);
101 repositories::{SOLVER_INSTANCE}.update(0.0, timeStamp, marker.h()(0) );
106 fineGridCell""" + solver._name +
"""CellLabel.setHasUpdated(false);
112 This is our plug-in point to alter the underlying dictionary
116 self.
_solver._init_dictionary_with_default_parameters(d)
117 self.
_solver.add_entries_to_text_replacement_dictionary(d)
124#include "exahype2/fv/BoundaryConditions.h"
125#include "tarch/NonCriticalAssertions.h"
126""" + self.
_solver._get_default_includes() + self.
_solver.user_action_set_includes
131 Probably the simplest solver you could think off.
133 :: Write your own specialisation ::
135 self._preprocess_reconstructed_patch
136 Has to hold any preprocessing, but it also has to set the doubles
137 timeStepSize and timeStamp to valid data.
139 self._postprocess_updated_patch
140 You don't have to redefine this one, but if you want to alter the
141 time step size, then this is the right place to do so. If you don't
142 alter timeStepSize, the code will automatically continue with
143 the current one subject to a preprocessing in the next step.
155 pde_terms_without_state: bool,
156 plot_grid_properties: bool,
159 Instantiate a generic FV scheme with an overlap of 1.
161 super(SingleSweep, self).
__init__(name,
168 pde_terms_without_state,
169 plot_grid_properties,
177 Call the superclass' create_data_structures() to ensure that all the data
178 structures are in place, i.e., each cell can host a patch, that each face hosts
179 patch overlaps, and so forth. These quantities are all set to defaults. See
180 FV.create_data_structures().
182 After that, take the patch overlap (that's the data stored within the faces)
183 and ensure that these are sent and received via MPI whenever they are also
184 stored persistently. The default in FV is that no domain boundary data exchange
185 is active. Finally, ensure that the old data is only exchanged between the
186 initialisation sweep and the first first grid run-through.
190 initialisation_sweep_guard =
"(" + \
193 first_iteration_after_initialisation_guard =
"(" + \
202 self.
_patch_overlap_old.generator.receive_and_merge_condition = first_iteration_after_initialisation_guard
207 Call superclass routine and then reconfigure the update cell call.
208 Only the UpdateCell action set is specific to a single sweep.
210 This operation is implicitly called via the superconstructor.
219#include "exahype2/CellData.h"
220""" + super(SingleSweep, self).user_action_set_includes
226 refinement_criterion,
230 additional_action_set_includes,
231 additional_user_includes
234 If you pass in User_Defined, then the generator will create C++ stubs
235 that you have to befill manually. If you pass in None_Implementation, it
236 will create nop, i.e., no implementation or defaults. Any other string
237 is copied 1:1 into the implementation. If you pass in None, then the
238 set value so far won't be overwritten.
246 if refinement_criterion==exahype2.solvers.PDETerms.None_Implementation:
247 assert False,
"Refinement criterion cannot be none"
248 if initial_conditions==exahype2.solvers.PDETerms.None_Implementation:
249 assert False,
"Initial conditions cannot be none"
254 raise Exception(
"Memory mode without appropriate delete chosen, i.e. this will lead to a memory leak" )
264 d: Dictionary of string to string
Abstract finite volume solver step sizes that works on patch-based AMR with a halo layer of one.
_solver_template_file_class_name
_boundary_conditions_implementation
create_action_sets(self)
Create all the action sets.
_user_action_set_includes
get_name_of_global_instance(self)
_initial_conditions_implementation
_reconstructed_array_memory_location
_refinement_criterion_implementation
Probably the simplest solver you could think off.
create_data_structures(self)
Call the superclass' create_data_structures() to ensure that all the data structures are in place,...
__init__(self, name, patch_size, overlap, unknowns, auxiliary_variables, min_volume_h, max_volume_h, bool pde_terms_without_state, bool plot_grid_properties, kernel_namespace)
Instantiate a generic FV scheme with an overlap of 1.
_refinement_criterion_implementation
set_implementation(self, boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
If you pass in User_Defined, then the generator will create C++ stubs that you have to befill manuall...
_reconstructed_array_memory_location
user_action_set_includes(self)
Add further includes to this property, if your action sets require some additional routines from othe...
_solver_template_file_class_name
_boundary_conditions_implementation
_initial_conditions_implementation
add_entries_to_text_replacement_dictionary(self, d)
d: Dictionary of string to string in/out argument
create_action_sets(self)
Call superclass routine and then reconfigure the update cell call.
__init__(self, solver)
patch: peano4.datamodel.Patch Patch which is to be used
SolveRiemannProblemsOverPatch
get_includes(self)
Return include statements that you need.
_Template_TouchCellFirstTime_Preamble
_add_action_set_entries_to_dictionary(self, d)
This is our plug-in point to alter the underlying dictionary.