Peano
Loading...
Searching...
No Matches
GlobalAdaptiveTimeStep.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.rkfd.SeparateSweeps import SeparateSweeps
5
6import jinja2
7
8from .kernels import create_compute_kernel_for_FD4
9
10from exahype2.solvers.rkfd.kernels import create_abstract_solver_declarations
11from exahype2.solvers.rkfd.kernels import create_abstract_solver_definitions
12from exahype2.solvers.rkfd.kernels import create_solver_declarations
13from exahype2.solvers.rkfd.kernels import create_solver_definitions
14#
15from exahype2.solvers.rkfd.kernels import SolverVariant
16from exahype2.solvers.rkfd.kernels import KernelVariant
17
18from exahype2.solvers.rkfd.AdaptiveTimeSteppingCodeSnippets import AdaptiveTimeSteppingCodeSnippets
19
20
22 def __init__(self,
23 name, patch_size, rk_order, unknowns, auxiliary_variables, min_meshcell_h, max_meshcell_h, time_step_relaxation,
24 reconstruction_with_rk=False,
25 flux=PDETerms.User_Defined_Implementation,
26 ncp=PDETerms.None_Implementation,
27 point_source=PDETerms.None_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 eigenvalues=PDETerms.User_Defined_Implementation,
33 plot_grid_properties=False, KOSigma=8.0
34 ):
35 """!
36
37 Construct solver
38
39 time_step_relaxation: Float
40 Calibration factor of CFL condition. The Runge-Kutta order is multiplied
41 with this value following the formula for Cockburn-Shu damping. However,
42 also the actual polynomial order has to enter the chosen time step size
43 through an additional @f$ p^{-2} @f$ scaling. We expect the user to
44 incorporate such an additional scaling within time_step_relaxation.
45
46 """
47
48 if reconstruction_with_rk:
50 else:
52
53 super(GlobalAdaptiveTimeStep,self).__init__(name,
54 patch_size,
55 3, #overlap,
56 rk_order,
57 unknowns,
58 auxiliary_variables,
59 min_meshcell_h,
60 max_meshcell_h,
61 plot_grid_properties,
62 kernel_namespace="fd4"
63 )
64
65 self._time_step_relaxation = time_step_relaxation
67
68 self._KO_Sigma = KOSigma
69
71 ncp=ncp,
72 eigenvalues=eigenvalues,
73 boundary_conditions=boundary_conditions,
74 refinement_criterion=refinement_criterion,
75 initial_conditions=initial_conditions,
76 source_term=source_term )
77
78
80 flux=None, ncp=None, source_term=None, eigenvalues=None,
81 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,
82 memory_location = None,
83 additional_action_set_includes = "",
84 additional_user_includes = "",
85 KOSigma = None
86 ):
87 """
88 If you pass in User_Defined, then the generator will create C++ stubs
89 that you have to befill manually. If you pass in None_Implementation, it
90 will create nop, i.e. no implementation or defaults. Any other string
91 is copied 1:1 into the implementation. If you pass in None, then the
92 set value so far won't be overwritten.
93
94 Please note that not all options are supported by all solvers.
95
96 This routine should be the very last invoked by the constructor.
97 """
98 super(GlobalAdaptiveTimeStep,self).set_implementation(
99 flux, ncp, source_term, eigenvalues,
100 boundary_conditions, refinement_criterion, initial_conditions, memory_location, additional_action_set_includes, additional_user_includes)
101
102 if not KOSigma==None: self._KO_Sigma = KOSigma
103
104 self._compute_kernel_call_compute_kernel_call = create_compute_kernel_for_FD4(
108 compute_max_eigenvalue_of_next_time_step = True,
109 solver_variant = SolverVariant.WithVirtualFunctions,
110 kernel_variant = KernelVariant.PatchWiseAoSHeap,
111 KOSigma = self._KO_Sigma
112 )
113
114 solver_code_snippets = AdaptiveTimeSteppingCodeSnippets(self._time_step_relaxation, adaptive_starting_timeStep_size="soft")
115
117 self._abstract_solver_user_declarations_abstract_solver_user_declarations += solver_code_snippets.create_abstract_solver_user_declarations()
119 self._abstract_solver_user_definitions_abstract_solver_user_definitions += solver_code_snippets.create_abstract_solver_user_definitions()
120
121 self._compute_time_step_size_compute_time_step_size = solver_code_snippets.create_compute_time_step_size()
122 self._compute_new_time_step_size_compute_new_time_step_size = solver_code_snippets.create_compute_new_time_step_size()
123
126
127 self._start_time_step_implementation_start_time_step_implementation = solver_code_snippets.create_start_time_step_implementation()
128 self._finish_time_step_implementation_finish_time_step_implementation = solver_code_snippets.create_finish_time_step_implementation()
129 self._constructor_implementation_constructor_implementation = solver_code_snippets.create_abstract_solver_constructor_statements()
130
132
133
134 @property
136 return super(GlobalAdaptiveTimeStep, self).user_action_set_includes + """
137#include "exahype2/fd/fd4/FD4.h"
138"""
139
140
Code snippet generator for fixed time stepping in the Runge-Kutta schemes.
Probably the simplest solver you could think off.
set_implementation(self, flux, ncp, source_term, eigenvalues, boundary_conditions, refinement_criterion, initial_conditions, memory_location, 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)
Call superclass routine and then reconfigure the update cell call.
__init__(self, name, patch_size, rk_order, unknowns, auxiliary_variables, min_meshcell_h, max_meshcell_h, time_step_relaxation, reconstruction_with_rk=False, flux=PDETerms.User_Defined_Implementation, ncp=PDETerms.None_Implementation, point_source=PDETerms.None_Implementation, boundary_conditions=PDETerms.User_Defined_Implementation, refinement_criterion=PDETerms.Empty_Implementation, initial_conditions=PDETerms.User_Defined_Implementation, source_term=PDETerms.None_Implementation, eigenvalues=PDETerms.User_Defined_Implementation, plot_grid_properties=False, KOSigma=8.0)
Construct solver.
add_entries_to_text_replacement_dictionary(self, d)
d: Dictionary of string to string in/out argument
set_implementation(self, flux=None, ncp=None, source_term=None, eigenvalues=None, boundary_conditions=None, refinement_criterion=None, initial_conditions=None, memory_location=None, additional_action_set_includes="", additional_user_includes="", KOSigma=None)
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...