Peano
Loading...
Searching...
No Matches
SubcyclingFixedTimeStep.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.SingleSweep import SingleSweep
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
13
14from exahype2.solvers.fv.FixedSubcyclingTimeSteppingCodeSnippets import FixedSubcyclingTimeSteppingCodeSnippets
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
20
21
23 def __init__(self,
24 name, patch_size, unknowns, auxiliary_variables, min_volume_h, max_volume_h, time_step_size,
25 flux=PDETerms.User_Defined_Implementation,
26 ncp=PDETerms.None_Implementation,
27 eigenvalues=PDETerms.User_Defined_Implementation,
28 boundary_conditions=PDETerms.User_Defined_Implementation,
29 refinement_criterion=PDETerms.Empty_Implementation,
30 initial_conditions=PDETerms.User_Defined_Implementation,
31 source_term=PDETerms.None_Implementation,
32 plot_grid_properties=False,
33 interpolate_linearly_in_time=True, overlap=1
34 ):
35 """
36 time_step_size: Float
37 This is the normalised time step size w.r.t. the coarsest admissible h value. If
38 the code employs AMR on top of it and refines further, it will automatically
39 downscale the time step size accordingly. So hand in a valid time step size w.r.t.
40 to max_volume_h.
41 """
42 self._interpolate_linearly_in_time = interpolate_linearly_in_time
43
44 super(SubcyclingFixedTimeStep,self).__init__(name,
45 patch_size,
46 overlap,
47 unknowns,
48 auxiliary_variables,
49 min_volume_h,
50 max_volume_h,
51 plot_grid_properties,
52 kernel_namespace="rusanov")
53 self._time_step_size = time_step_size
54
55 self._flux_implementation_flux_implementation = PDETerms.None_Implementation
56 self._ncp_implementation_ncp_implementation = PDETerms.None_Implementation
59
61 ncp=ncp,
62 eigenvalues=eigenvalues,
63 boundary_conditions=boundary_conditions,
64 refinement_criterion=refinement_criterion,
65 initial_conditions=initial_conditions,
66 source_term=source_term )
67
68
70 flux=None,ncp=None,
71 eigenvalues=None,
72 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,source_term=None,
73 memory_location = None,
74 use_split_loop = False,
75 additional_action_set_includes = "",
76 additional_user_includes = ""
77 ):
78 """
79 If you pass in User_Defined, then the generator will create C++ stubs
80 that you have to befill manually. If you pass in None_Implementation, it
81 will create nop, i.e., no implementation or defaults. Any other string
82 is copied 1:1 into the implementation. If you pass in None, then the
83 set value so far won't be overwritten.
84
85 Please note that not all options are supported by all solvers.
86
87 This routine should be the very last invoked by the constructor.
88 """
89 if flux is not None: self._flux_implementation_flux_implementation = flux
90 if ncp is not None: self._ncp_implementation_ncp_implementation = ncp
91 if eigenvalues is not None: self._eigenvalues_implementation_eigenvalues_implementation = eigenvalues
92 if source_term is not None: self._source_term_implementation_source_term_implementation = source_term
93
94 self._compute_kernel_call_compute_kernel_call = create_compute_Riemann_kernel_for_Rusanov(
98 compute_max_eigenvalue_of_next_time_step = False,
99 solver_variant = SolverVariant.WithVirtualFunctions,
100 kernel_variant = KernelVariant.PatchWiseAoS
101 )
102
103 self._compute_kernel_call_stateless_compute_kernel_call_stateless = create_compute_Riemann_kernel_for_Rusanov(
107 compute_max_eigenvalue_of_next_time_step = False,
108 solver_variant = SolverVariant.Stateless,
109 kernel_variant = KernelVariant.PatchWiseAoS
110 )
111
112 solver_code_snippets = FixedSubcyclingTimeSteppingCodeSnippets(self._time_step_size,False,True)
113
115 self._abstract_solver_user_declarations_abstract_solver_user_declarations += solver_code_snippets.create_abstract_solver_user_declarations()
117 self._abstract_solver_user_definitions_abstract_solver_user_definitions += solver_code_snippets.create_abstract_solver_user_definitions()
118
121
122 self._compute_time_step_size_compute_time_step_size = solver_code_snippets.create_compute_time_step_size()
123 self._compute_new_time_step_size_compute_new_time_step_size = solver_code_snippets.create_compute_new_time_step_size()
124
125 self._start_time_step_implementation_start_time_step_implementation = solver_code_snippets.create_start_time_step_implementation()
126 self._finish_time_step_implementation_finish_time_step_implementation = solver_code_snippets.create_finish_time_step_implementation()
127 self._constructor_implementation_constructor_implementation = solver_code_snippets.create_abstract_solver_constructor_statements()
128
129 self._user_action_set_includes += """
130#include "exahype2/TimeStepping.h"
131#include "exahype2/fv/rusanov/rusanov.h"
132"""
133
134 super(SubcyclingFixedTimeStep,self).set_implementation(boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
135
136
138 """
139 The actual action sets all are created by the superclass. So nothing
140 is to be done here. But we want to reset the actual updates and
141 projection, and these only happen if we are allowed to update
142 indeed.
143 """
144 super(SubcyclingFixedTimeStep, self).create_action_sets()
145
146 self._action_set_update_cell_action_set_update_cell.guard += " and ::exahype2::runTimeStepOnCell( fineGridCell" + self._name + "CellLabel, fineGridFaces" + self._name + "FaceLabel, repositories::getMinTimeStamp())"
147
149 self._action_set_update_cell_action_set_update_cell._Template_TouchCellFirstTime_Fill_Halos = create_halo_layer_construction_with_interpolation_for_reconstructed_patch(self._name)
150
151 self._action_set_AMR.event_lifetime = int(self._max_volume_h/self._min_volume_h+1)
152
153
155 super(SubcyclingFixedTimeStep, self).create_data_structures()
156
157 self._patch_overlap_old.generator.send_condition = "true"
158 self._patch_overlap_old.generator.receive_and_merge_condition = "true"
Probably the simplest solver you could think off.
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_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, overlap=1)
time_step_size: Float This is the normalised time step size w.r.t.
create_data_structures(self)
Call the superclass' create_data_structures() to ensure that all the data structures are in place,...
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_action_sets(self)
The actual action sets all are created by the superclass.