Peano
Loading...
Searching...
No Matches
SubcyclingAdaptiveTimeStepWithEnclaveTasking.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
3from exahype2.solvers.PDETerms import PDETerms
4from exahype2.solvers.fv.EnclaveTasking import EnclaveTasking
5
6import jinja2
7
8from .kernels import create_abstract_solver_declarations
9from .kernels import create_abstract_solver_definitions
10from .kernels import create_solver_declarations
11from .kernels import create_solver_definitions
12from .kernels import create_rusanov_kernel_definitions
13from .kernels import create_compute_Riemann_kernel_for_Rusanov_dsl
14from .kernels import create_compute_time_step_size_kernel_for_adaptive_time_stepping_with_subcycling
15
16from .kernels import create_compute_new_time_step_size_kernel_for_adaptive_time_stepping
17from .kernels import create_constructor_implementation_for_adaptive_time_stepping
18
19from .kernels import SolverVariant
20from .kernels import KernelVariant
21
22from .kernels import create_abstract_solver_user_declarations_for_adaptive_time_stepping
23from .kernels import create_abstract_solver_user_definitions_for_adaptive_time_stepping
24from .kernels import create_finish_time_step_implementation_for_adaptive_time_stepping
25from exahype2.solvers.fv.kernels import create_start_time_step_implementation_for_adaptive_time_stepping_with_subcycling
26
27from exahype2.solvers.fv.kernels import create_halo_layer_construction_with_interpolation_for_reconstructed_patch
28
29
31 def __init__(self,
32 name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_relaxation,
33 flux=PDETerms.User_Defined_Implementation,
34 ncp=PDETerms.None_Implementation,
35 eigenvalues=PDETerms.User_Defined_Implementation,
36 boundary_conditions=PDETerms.User_Defined_Implementation,
37 refinement_criterion=PDETerms.Empty_Implementation,
38 initial_conditions=PDETerms.User_Defined_Implementation,
39 source_term=PDETerms.None_Implementation,
40 plot_grid_properties=False,
41 interpolate_linearly_in_time=True,
42 pde_terms_without_state=False, overlap=1
43 ):
44 """
45 time_step_size: Float
46 This is the normalised time step size w.r.t. the coarsest admissible h value. If
47 the code employs AMR on top of it and refines further, it will automatically
48 downscale the time step size accordingly. So hand in a valid time step size w.r.t.
49 to max_volume_h.
50 """
51 self._interpolate_linearly_in_time = interpolate_linearly_in_time
52
53 super(SubcyclingAdaptiveTimeStepWithEnclaveTasking,self).__init__(name,
54 patch_size,
55 overlap,
56 unknowns,
57 auxiliary_variables,
58 min_volume_h,
59 max_volume_h,
60 plot_grid_properties,
61 pde_terms_without_state,
62 kernel_namespace="rusanov")
63 self._time_step_relaxation = time_step_relaxation
64
65 self._flux_implementation_flux_implementation = PDETerms.None_Implementation
66 self._ncp_implementation_ncp_implementation = PDETerms.None_Implementation
69
71
72 self._compute_time_step_size_compute_time_step_size = create_compute_time_step_size_kernel_for_adaptive_time_stepping_with_subcycling( name )
73 #self._compute_new_time_step_size = """
74# const double timeStepSize = dt;
75# const double timeStamp = t;
76#""" + create_compute_new_time_step_size_kernel_for_adaptive_time_stepping()
77 self._compute_new_time_step_size_compute_new_time_step_size = create_compute_new_time_step_size_kernel_for_adaptive_time_stepping()
78
80 ncp=ncp,
81 eigenvalues=eigenvalues,
82 boundary_conditions=boundary_conditions,
83 refinement_criterion=refinement_criterion,
84 initial_conditions=initial_conditions,
85 source_term=source_term)
86
87
89 flux=None,ncp=None,
90 eigenvalues=None,
91 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,source_term=None,
92 memory_location = None,
93 use_split_loop = False,
94 additional_action_set_includes = "",
95 additional_user_includes = ""
96 ):
97 """
98 If you pass in User_Defined, then the generator will create C++ stubs
99 that you have to befill manually. If you pass in None_Implementation, it
100 will create nop, i.e., no implementation or defaults. Any other string
101 is copied 1:1 into the implementation. If you pass in None, then the
102 set value so far won't be overwritten.
103
104 Please note that not all options are supported by all solvers.
105
106 This routine should be the very last invoked by the constructor.
107 """
108 if flux is not None: self._flux_implementation_flux_implementation = flux
109 if ncp is not None: self._ncp_implementation_ncp_implementation = ncp
110 if eigenvalues is not None: self._eigenvalues_implementation_eigenvalues_implementation = eigenvalues
111 if source_term is not None: self._source_term_implementation_source_term_implementation = source_term
112
113 create_rusanov_kernel_definitions()
114
115 self._compute_kernel_call_compute_kernel_call = create_compute_Riemann_kernel_for_Rusanov_dsl(
119 compute_max_eigenvalue_of_next_time_step = True,
120 solver_variant = SolverVariant.WithVirtualFunctions,
121 kernel_variant = KernelVariant.PatchWiseAoS
122 )
123
124 self._compute_kernel_call_stateless_compute_kernel_call_stateless = create_compute_Riemann_kernel_for_Rusanov_dsl(
128 compute_max_eigenvalue_of_next_time_step = True,
129 solver_variant = SolverVariant.Stateless,
130 kernel_variant = KernelVariant.PatchWiseAoS
131 )
132
137 compute_max_eigenvalue_of_next_time_step = True,
138 solver_variant = SolverVariant.Stateless,
139 kernel_variant = KernelVariant.PatchWiseAoS
140 )
141
146 compute_max_eigenvalue_of_next_time_step = True,
147 solver_variant = SolverVariant.Accelerator,
148 kernel_variant = KernelVariant.VolumeWiseAoS
149 )
150
152 self._abstract_solver_user_declarations_abstract_solver_user_declarations += create_abstract_solver_user_declarations_for_adaptive_time_stepping()
154 self._abstract_solver_user_definitions_abstract_solver_user_definitions += create_abstract_solver_user_definitions_for_adaptive_time_stepping()
155
156 self._constructor_implementation_constructor_implementation = create_constructor_implementation_for_adaptive_time_stepping()
157
160
161 self._start_time_step_implementation_start_time_step_implementation = create_start_time_step_implementation_for_adaptive_time_stepping_with_subcycling(True)
162 self._finish_time_step_implementation_finish_time_step_implementation = """if (_solverState==SolverState::Secondary) {
163""" + create_finish_time_step_implementation_for_adaptive_time_stepping(self._time_step_relaxation) + """
164}
165"""
166
167 super(SubcyclingAdaptiveTimeStepWithEnclaveTasking,self).set_implementation(boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
168
169
171 """
172 The actual action sets all are created by the superclass. So nothing
173 is to be done here. But we want to reset the actual updates and
174 projection, and these only happen if we are allowed to update
175 indeed.
176 """
177 super(SubcyclingAdaptiveTimeStepWithEnclaveTasking, self).create_action_sets()
178
179 update_cell_guard = "::exahype2::runTimeStepOnCell( fineGridCell" + self._name_name + "CellLabel, fineGridFaces" + self._name_name + "FaceLabel, repositories::getMinTimeStamp())"
180 #updated_cell_guard = "fineGridCell" + self._name + "CellLabel.getSemaphoreNumber()!=::exahype2::EnclaveBookkeeping::NoEnclaveTaskNumber"
181 self._action_set_update_cell_action_set_update_cell.guard += " and " + update_cell_guard
182 #self._action_set_merge_enclave_task_outcome.guard = updated_cell_guard
183
185 self._action_set_update_cell_action_set_update_cell._Template_TouchCellFirstTime_Fill_Halos = create_halo_layer_construction_with_interpolation_for_reconstructed_patch(self._name_name)
186
187 self._action_set_AMR.event_lifetime = 2*int(self._max_volume_h/self._min_volume_h+1)
188
189
190 @property
192 return super(SubcyclingAdaptiveTimeStepWithEnclaveTasking, self).user_action_set_includes + """
193#include "exahype2/TimeStepping.h"
194#include "kernels/rusanov.h"
195"""
196
197
199 super(SubcyclingAdaptiveTimeStepWithEnclaveTasking, self).create_data_structures()
200
201 self._patch_overlap_old.generator.send_condition = self._patch_overlap_new.generator.send_condition
202 self._patch_overlap_old.generator.receive_and_merge_condition = self._patch_overlap_new.generator.receive_and_merge_condition
Enclave tasking variant of the Finite Volume scheme.
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...
__init__(self, name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_relaxation, flux=PDETerms.User_Defined_Implementation, ncp=PDETerms.None_Implementation, eigenvalues=PDETerms.User_Defined_Implementation, boundary_conditions=PDETerms.User_Defined_Implementation, refinement_criterion=PDETerms.Empty_Implementation, initial_conditions=PDETerms.User_Defined_Implementation, source_term=PDETerms.None_Implementation, plot_grid_properties=False, interpolate_linearly_in_time=True, pde_terms_without_state=False, overlap=1)
time_step_size: Float This is the normalised time step size w.r.t.
create_data_structures(self)
This routine does not really add new data, but it heavily tailors when data are stored,...
set_implementation(self, flux=None, ncp=None, eigenvalues=None, boundary_conditions=None, refinement_criterion=None, initial_conditions=None, source_term=None, memory_location=None, use_split_loop=False, 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...
user_action_set_includes(self)
Add further includes to this property, if your action sets require some additional routines from othe...