Peano
Loading...
Searching...
No Matches
SubcyclingFixedTimeStepWithEnclaveTasking.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_for_fixed_time_stepping_with_subcycling
15
16from .kernels import SolverVariant
17from .kernels import KernelVariant
18
19from exahype2.solvers.fv.kernels import create_halo_layer_construction_with_interpolation_for_reconstructed_patch
20from exahype2.solvers.kernels import create_abstract_solver_user_declarations_for_fixed_time_stepping
21from exahype2.solvers.kernels import create_abstract_solver_user_definitions_for_fixed_time_stepping
22from exahype2.solvers.fv.kernels import create_finish_time_step_implementation_for_fixed_time_stepping
23from exahype2.solvers.fv.kernels import create_start_time_step_implementation_for_fixed_time_stepping_with_subcycling
24
25
27 def __init__(self,
28 name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_size,
29 flux=PDETerms.User_Defined_Implementation,
30 ncp=PDETerms.None_Implementation,
31 eigenvalues=PDETerms.User_Defined_Implementation,
32 boundary_conditions=PDETerms.User_Defined_Implementation,
33 refinement_criterion=PDETerms.Empty_Implementation,
34 initial_conditions=PDETerms.User_Defined_Implementation,
35 source_term=PDETerms.None_Implementation,
36 plot_grid_properties=False,
37 interpolate_linearly_in_time=True,
38 pde_terms_without_state=False, overlap=1
39 ):
40 """
41 time_step_size: Float
42 This is the normalised time step size w.r.t. the coarsest admissible h value. If
43 the code employs AMR on top of it and refines further, it will automatically
44 downscale the time step size accordingly. So hand in a valid time step size w.r.t.
45 to max_volume_h.
46 """
47 self._interpolate_linearly_in_time = interpolate_linearly_in_time
48
49 super(SubcyclingFixedTimeStepWithEnclaveTasking,self).__init__(name,
50 patch_size,
51 overlap,
52 unknowns,
53 auxiliary_variables,
54 min_volume_h,
55 max_volume_h,
56 plot_grid_properties,
57 pde_terms_without_state,
58 kernel_namespace="rusanov")
59 self._time_step_size = time_step_size
60
61 self._flux_implementation_flux_implementation = PDETerms.None_Implementation
62 self._ncp_implementation_ncp_implementation = PDETerms.None_Implementation
65
66 self._compute_time_step_size_compute_time_step_size = create_compute_time_step_size_for_fixed_time_stepping_with_subcycling( time_step_size, name )
67 self._compute_new_time_step_size_compute_new_time_step_size = "const double newTimeStepSize = dt;"
68
70
72 ncp=ncp,
73 eigenvalues=eigenvalues,
74 boundary_conditions=boundary_conditions,
75 refinement_criterion=refinement_criterion,
76 initial_conditions=initial_conditions,
77 source_term=source_term)
78
79
81 flux=None,ncp=None,
82 eigenvalues=None,
83 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,source_term=None,
84 memory_location = None,
85 use_split_loop = False,
86 additional_action_set_includes = "",
87 additional_user_includes = ""
88 ):
89 """
90 If you pass in User_Defined, then the generator will create C++ stubs
91 that you have to befill manually. If you pass in None_Implementation, it
92 will create nop, i.e., no implementation or defaults. Any other string
93 is copied 1:1 into the implementation. If you pass in None, then the
94 set value so far won't be overwritten.
95
96 Please note that not all options are supported by all solvers.
97
98 This routine should be the very last invoked by the constructor.
99 """
100 if flux is not None: self._flux_implementation_flux_implementation = flux
101 if ncp is not None: self._ncp_implementation_ncp_implementation = ncp
102 if eigenvalues is not None: self._eigenvalues_implementation_eigenvalues_implementation = eigenvalues
103 if source_term is not None: self._source_term_implementation_source_term_implementation = source_term
104
105 create_rusanov_kernel_definitions()
106
107 self._compute_kernel_call_compute_kernel_call = create_compute_Riemann_kernel_for_Rusanov_dsl(
111 compute_max_eigenvalue_of_next_time_step = False,
112 solver_variant = SolverVariant.WithVirtualFunctions,
113 kernel_variant = KernelVariant.PatchWiseAoS
114 )
115
116 self._compute_kernel_call_stateless_compute_kernel_call_stateless = create_compute_Riemann_kernel_for_Rusanov_dsl(
120 compute_max_eigenvalue_of_next_time_step = False,
121 solver_variant = SolverVariant.Stateless,
122 kernel_variant = KernelVariant.PatchWiseAoS
123 )
124
129 compute_max_eigenvalue_of_next_time_step = False,
130 solver_variant = SolverVariant.Stateless,
131 kernel_variant = KernelVariant.PatchWiseAoS
132 )
133
138 compute_max_eigenvalue_of_next_time_step = False,
139 solver_variant = SolverVariant.Accelerator,
140 kernel_variant = KernelVariant.PatchWiseAoS
141 )
142
144 self._abstract_solver_user_declarations_abstract_solver_user_declarations += create_abstract_solver_user_declarations_for_fixed_time_stepping()
146 self._abstract_solver_user_definitions_abstract_solver_user_definitions += create_abstract_solver_user_definitions_for_fixed_time_stepping()
147
150
151 self._start_time_step_implementation_start_time_step_implementation = create_start_time_step_implementation_for_fixed_time_stepping_with_subcycling(True)
152 self._finish_time_step_implementation_finish_time_step_implementation = create_finish_time_step_implementation_for_fixed_time_stepping(self._time_step_size)
153
154 super(SubcyclingFixedTimeStepWithEnclaveTasking,self).set_implementation(boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
155
156
158 """
159 The actual action sets all are created by the superclass. So nothing
160 is to be done here. But we want to reset the actual updates and
161 projection, and these only happen if we are allowed to update
162 indeed.
163 """
164 super(SubcyclingFixedTimeStepWithEnclaveTasking, self).create_action_sets()
165
166 update_cell_guard = "::exahype2::runTimeStepOnCell( fineGridCell" + self._name_name + "CellLabel, fineGridFaces" + self._name_name + "FaceLabel, repositories::getMinTimeStamp())"
167 #updated_cell_guard = "fineGridCell" + self._name + "CellLabel.getSemaphoreNumber()!=::exahype2::EnclaveBookkeeping::NoEnclaveTaskNumber"
168 self._action_set_update_cell_action_set_update_cell.guard += " and " + update_cell_guard
169 #self._action_set_merge_enclave_task_outcome.guard = updated_cell_guard
170
172 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)
173
174 self._action_set_AMR.event_lifetime = 2*int(self._max_volume_h/self._min_volume_h+1)
175
176
177 @property
179 return super(SubcyclingFixedTimeStepWithEnclaveTasking, self).user_action_set_includes + """
180#include "exahype2/TimeStepping.h"
181#include "kernels/rusanov.h"
182"""
183
184
186 super(SubcyclingFixedTimeStepWithEnclaveTasking, self).create_data_structures()
187
188 self._patch_overlap_old.generator.send_condition = self._patch_overlap_new.generator.send_condition
189 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...
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...
__init__(self, name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_size, 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.