Peano
Loading...
Searching...
No Matches
GlobalFixedTimeStep.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
6
7import jinja2
8
9from .kernels import create_compute_kernel_for_FD4
10
11from exahype2.solvers.rkfd.kernels import create_abstract_solver_declarations
12from exahype2.solvers.rkfd.kernels import create_abstract_solver_definitions
13from exahype2.solvers.rkfd.kernels import create_solver_declarations
14from exahype2.solvers.rkfd.kernels import create_solver_definitions
15
16from exahype2.solvers.rkfd.kernels import SolverVariant
17from exahype2.solvers.rkfd.kernels import KernelVariant
18
19from exahype2.solvers.rkfd.FixedTimeSteppingCodeSnippets import FixedTimeSteppingCodeSnippets
20
21from .amr import switch_to_FD4_tensor_product_interpolation
22from .amr import switch_to_FD4_tensor_product_restriction
23
24
26 def __init__(self,
27 name, patch_size, rk_order, unknowns, auxiliary_variables, min_meshcell_h, max_meshcell_h, normalised_time_step_size,
28 flux=PDETerms.User_Defined_Implementation,
29 ncp=PDETerms.None_Implementation,
30 eigenvalues=PDETerms.None_Implementation,
31 boundary_conditions=PDETerms.User_Defined_Implementation,
32 refinement_criterion=PDETerms.Empty_Implementation,
33 initial_conditions=PDETerms.User_Defined_Implementation,
34 plot_grid_properties=False, KOSigma=8.0
35 ):
36 """!
37
38 Construct the solver
39
40 eigenvalues: C++ source code or from PDETerms or None
41 By default is None_Implementation, as we don't need eigenvalues as long as we
42 work with fixed time step sizes. You can change it manually. Still, the fixed
43 time stepping won't use the eigenvalues but you might have code that has it and
44 that you don't want to change.
45
46
47 normalised_time_step_size: Float
48 This is the normalised time step size w.r.t. the coarsest admissible h value
49 and the polynomial order. If
50 the code employs AMR on top of it and refines further, it will automatically
51 downscale the time step size accordingly. So hand in a valid time step size w.r.t.
52 to max_meshcell_h. The actual polynomial order enters the chosen time step size
53 as an additional @f$ p^{-2} @f$ scaling, and we expect the user to incorporate
54 such a factor into the passed normalised value.
55
56 """
57 super(GlobalFixedTimeStep,self).__init__(name,
58 patch_size,
59 3, #overlap,
60 rk_order, unknowns, auxiliary_variables, min_meshcell_h, max_meshcell_h, plot_grid_properties, kernel_namespace="fd4")
61
62 self._normalised_time_step_size = normalised_time_step_size
63
64 self._KO_Sigma = KOSigma
65
67#include "exahype2/fd/fd4/FD4.h"
68"""
69
70 switch_to_FD4_tensor_product_interpolation( self, "TP_constant")
71 switch_to_FD4_tensor_product_restriction( self, "TP_inject_normal_extrap")
72
74 ncp=ncp,
75 eigenvalues=eigenvalues,
76 boundary_conditions=boundary_conditions,
77 refinement_criterion=refinement_criterion,
78 initial_conditions=initial_conditions,
79 source_term=source_term )
80
81
83 flux=None, ncp=None, source_term=None, eigenvalues=None,
84 boundary_conditions=None,refinement_criterion=None,initial_conditions=None,
85 memory_location = None,
86 additional_action_set_includes = "",
87 additional_user_includes = "",
88 KOSigma = None
89 ):
90 """
91 If you pass in User_Defined, then the generator will create C++ stubs
92 that you have to befill manually. If you pass in None_Implementation, it
93 will create nop, i.e. no implementation or defaults. Any other string
94 is copied 1:1 into the implementation. If you pass in None, then the
95 set value so far won't be overwritten.
96
97 Please note that not all options are supported by all solvers.
98
99 This routine should be the very last invoked by the constructor.
100 """
101 super(GlobalFixedTimeStep,self).set_implementation(
102 flux, ncp, source_term, eigenvalues,
103 boundary_conditions, refinement_criterion, initial_conditions, memory_location, additional_action_set_includes, additional_user_includes)
104
105 if not KOSigma==None: self._KO_Sigma = KOSigma
106
107 self._compute_kernel_call_compute_kernel_call = create_compute_kernel_for_FD4(
111 compute_max_eigenvalue_of_next_time_step = False,
112 solver_variant = SolverVariant.WithVirtualFunctions,
113 kernel_variant = KernelVariant.PatchWiseAoSHeap,
114 KOSigma = self._KO_Sigma
115 )
116
117 solver_code_snippets = FixedTimeSteppingCodeSnippets(self._normalised_time_step_size,False)
118
120 self._abstract_solver_user_declarations_abstract_solver_user_declarations += solver_code_snippets.create_abstract_solver_user_declarations()
122 self._abstract_solver_user_definitions_abstract_solver_user_definitions += solver_code_snippets.create_abstract_solver_user_definitions()
123
124 self._compute_time_step_size_compute_time_step_size = solver_code_snippets.create_compute_time_step_size()
125 self._compute_new_time_step_size_compute_new_time_step_size = solver_code_snippets.create_compute_new_time_step_size()
126
129
130 self._start_time_step_implementation_start_time_step_implementation = solver_code_snippets.create_start_time_step_implementation()
131 self._finish_time_step_implementation_finish_time_step_implementation = solver_code_snippets.create_finish_time_step_implementation()
132 self._constructor_implementation_constructor_implementation = solver_code_snippets.create_abstract_solver_constructor_statements()
133
135
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, normalised_time_step_size, flux=PDETerms.User_Defined_Implementation, ncp=PDETerms.None_Implementation, eigenvalues=PDETerms.None_Implementation, boundary_conditions=PDETerms.User_Defined_Implementation, refinement_criterion=PDETerms.Empty_Implementation, initial_conditions=PDETerms.User_Defined_Implementation, plot_grid_properties=False, KOSigma=8.0)
Construct the solver.
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...