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