Peano
Loading...
Searching...
No Matches
LocalTimeStepWithEnclaveTasking.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_compute_Riemann_kernel_for_Rusanov
9from .kernels import create_abstract_solver_declarations
10from .kernels import create_abstract_solver_definitions
11from .kernels import create_solver_declarations
12from .kernels import create_solver_definitions
13from .kernels import create_compute_time_step_size_kernel_for_local_time_stepping
14from .kernels import create_compute_new_time_step_size_kernel_for_local_time_stepping
15from .kernels import create_abstract_solver_user_declarations_for_local_time_stepping
16from .kernels import create_abstract_solver_user_definitions_for_local_time_stepping
17
18from .kernels import SolverVariant
19from .kernels import KernelVariant
20
21from exahype2.solvers.fv.kernels import create_halo_layer_construction_with_interpolation_for_reconstructed_patch
22from exahype2.solvers.kernels import create_abstract_solver_user_declarations_for_fixed_time_stepping
23from exahype2.solvers.fv.kernels import create_finish_time_step_implementation_for_local_time_stepping
24from exahype2.solvers.fv.kernels import create_start_time_step_implementation_for_local_time_stepping
25
26from .kernels import create_constructor_implementation_for_local_time_stepping
27from .kernels import create_finish_time_step_implementation_for_local_time_stepping
28
29import math
30
31
33 def __init__(self,
34 name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_relaxation,
35 flux=PDETerms.User_Defined_Implementation,
36 ncp=PDETerms.None_Implementation,
37 eigenvalues=PDETerms.User_Defined_Implementation,
38 boundary_conditions=PDETerms.User_Defined_Implementation,
39 refinement_criterion=PDETerms.Empty_Implementation,
40 initial_conditions=PDETerms.User_Defined_Implementation,
41 source_term=PDETerms.None_Implementation,
42 plot_grid_properties=False,
43 interpolate_linearly_in_time=True,
44 pde_terms_without_state=False,
45 avoid_staircase_effect=True,
46 discretisation_steps=8, overlap=1
47 ):
48 """
49 time_step_size: Float
50 This is the normalised time step size w.r.t. the coarsest admissible h value. If
51 the code employs AMR on top of it and refines further, it will automatically
52 downscale the time step size accordingly. So hand in a valid time step size w.r.t.
53 to max_volume_h.
54
55 avoid_staircase_effect: Boolean
56 Please consult create_compute_new_time_step_size_kernel_for_local_time_stepping() for a
57 discussion of this flag.
58
59 discretisation_steps: Float
60 This routine discretises (buckets) the time step sizes. You find more information
61 in the C++ code in exahype2::TimeStepping.
62 """
63 self._interpolate_linearly_in_time = interpolate_linearly_in_time
64
65 super(LocalTimeStepWithEnclaveTasking,self).__init__(name,
66 patch_size,
67 overlap,
68 unknowns,
69 auxiliary_variables,
70 min_volume_h,
71 max_volume_h,
72 plot_grid_properties,
73 pde_terms_without_state,
74 kernel_namespace="rusanov")
75 self._time_step_relaxation = time_step_relaxation
76
77 self._flux_implementation_flux_implementation = PDETerms.None_Implementation
78 self._ncp_implementation_ncp_implementation = PDETerms.None_Implementation
81
83
84 self._compute_time_step_size_compute_time_step_size = create_compute_time_step_size_kernel_for_local_time_stepping( name, time_step_relaxation )
85 self._compute_new_time_step_size_compute_new_time_step_size = create_compute_new_time_step_size_kernel_for_local_time_stepping(time_step_relaxation,avoid_staircase_effect,discretisation_steps)
86
88 ncp=ncp,
89 eigenvalues=eigenvalues,
90 boundary_conditions=boundary_conditions,
91 refinement_criterion=refinement_criterion,
92 initial_conditions=initial_conditions,
93 source_term=source_term)
94
95
97 flux=None,ncp=None,
98 eigenvalues=None,
99 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,source_term=None,
100 memory_location = None,
101 use_split_loop = False,
102 additional_action_set_includes = "",
103 additional_user_includes = ""
104 ):
105 """
106 If you pass in User_Defined, then the generator will create C++ stubs
107 that you have to befill manually. If you pass in None_Implementation, it
108 will create nop, i.e., no implementation or defaults. Any other string
109 is copied 1:1 into the implementation. If you pass in None, then the
110 set value so far won't be overwritten.
111
112 Please note that not all options are supported by all solvers.
113
114 This routine should be the very last invoked by the constructor.
115 """
116 if flux is not None: self._flux_implementation_flux_implementation = flux
117 if ncp is not None: self._ncp_implementation_ncp_implementation = ncp
118 if eigenvalues is not None: self._eigenvalues_implementation_eigenvalues_implementation = eigenvalues
119 if source_term is not None: self._source_term_implementation_source_term_implementation = source_term
120
121 self._compute_kernel_call_compute_kernel_call = create_compute_Riemann_kernel_for_Rusanov(
125 compute_max_eigenvalue_of_next_time_step = True,
126 solver_variant = SolverVariant.WithVirtualFunctions,
127 kernel_variant = KernelVariant.PatchWiseAoS
128 )
129
130 self._compute_kernel_call_stateless_compute_kernel_call_stateless = create_compute_Riemann_kernel_for_Rusanov(
134 compute_max_eigenvalue_of_next_time_step = True,
135 solver_variant = SolverVariant.Stateless,
136 kernel_variant = KernelVariant.PatchWiseAoS
137 )
138
143 compute_max_eigenvalue_of_next_time_step = True,
144 solver_variant = SolverVariant.Stateless,
145 kernel_variant = KernelVariant.PatchWiseAoS
146 )
147
152 compute_max_eigenvalue_of_next_time_step = True,
153 solver_variant = SolverVariant.Accelerator,
154 kernel_variant = KernelVariant.PatchWiseAoS
155 )
156
159
160 self._constructor_implementation_constructor_implementation = create_constructor_implementation_for_local_time_stepping()
161
162 self._abstract_solver_user_declarations_abstract_solver_user_declarations += create_abstract_solver_user_declarations_for_local_time_stepping()
163 self._abstract_solver_user_definitions_abstract_solver_user_definitions += create_abstract_solver_user_definitions_for_local_time_stepping()
164
167
168 self._start_time_step_implementation_start_time_step_implementation = create_start_time_step_implementation_for_local_time_stepping(True)
169 self._finish_time_step_implementation_finish_time_step_implementation = create_finish_time_step_implementation_for_local_time_stepping()
170
171 super(LocalTimeStepWithEnclaveTasking,self).set_implementation(boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
172
173
175 """
176 The actual action sets all are created by the superclass. So nothing
177 is to be done here. But we want to reset the actual updates and
178 projection, and these only happen if we are allowed to update
179 indeed.
180 """
181 super(LocalTimeStepWithEnclaveTasking, self).create_action_sets()
182
183 update_cell_guard = "::exahype2::runTimeStepOnCell( fineGridCell" + self._name_name + "CellLabel, fineGridFaces" + self._name_name + "FaceLabel, repositories::getMinTimeStamp())"
184 updated_cell_guard = "fineGridCell" + self._name_name + "CellLabel.getSemaphoreNumber()!=::exahype2::EnclaveBookkeeping::NoEnclaveTaskNumber"
185 self._action_set_update_cell_action_set_update_cell.guard += " and " + update_cell_guard
186 self._action_set_merge_enclave_task_outcome.guard = updated_cell_guard
187
189 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)
190
191 self._action_set_AMR.event_lifetime = 2*3*int(self._max_volume_h/self._min_volume_h+1)
192
193
194 @property
196 return super(LocalTimeStepWithEnclaveTasking, self).user_action_set_includes + """
197#include "exahype2/TimeStepping.h"
198#include "exahype2/fv/rusanov/rusanov.h"
199"""
200
201
203 super(LocalTimeStepWithEnclaveTasking, self).create_data_structures()
204
205 self._patch_overlap_old.generator.send_condition = self._patch_overlap_new.generator.send_condition
206 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...
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...
create_data_structures(self)
This routine does not really add new data, but it heavily tailors when data are stored,...
__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, avoid_staircase_effect=True, discretisation_steps=8, overlap=1)
time_step_size: Float This is the normalised time step size w.r.t.
user_action_set_includes(self)
Add further includes to this property, if your action sets require some additional routines from othe...