Peano
Loading...
Searching...
No Matches
test.py
Go to the documentation of this file.
1import peano4, exahype2
2import os, sys
3import argparse
4import subprocess
5import mpmath as mp
6
7sys.path.insert(0, os.path.abspath("../aderdg/"))
8sys.path.insert(0, os.path.abspath("../aderdg/scenarios"))
9import scenarios
10
11modes = {
12 "release": peano4.output.CompileMode.Release,
13 "trace": peano4.output.CompileMode.Trace,
14 "assert": peano4.output.CompileMode.Asserts,
15 "stats": peano4.output.CompileMode.Stats,
16 "debug": peano4.output.CompileMode.Debug,
17}
18
19available_prec = {
20 "bf16", "fp16", "fp32", "fp64"
21}
22
23available_scenarios = {
24 "AcousticPlanarWaves": scenarios.AcousticPlanarWaves(dimensions=2),
25 "AdvectionLinear": scenarios.AdvectionLinear(),
26 "ElasticPlanarWaves": scenarios.ElasticPlanarWaves(dimensions=2),
27 "EulerGaussianBell": scenarios.EulerGaussianBell(),
28 "EulerIsotropicVortex": scenarios.EulerIsotropicVortex(),
29 "SWERadialDamBreak": scenarios.SWERadialDamBreak(),
30 "SWERestingLake": scenarios.SWERestingLake(),
31}
32
33parser = argparse.ArgumentParser(description="ExaHyPE 2 - ADER testing script")
34
35parser.add_argument(
36 "-md",
37 "--mesh-depth",
38 dest="md",
39 type=int,
40 default=3,
41 help="Depth of coarsest mesh level, i.e if 2 is specified there will be 9 cells per dimension",
42)
43parser.add_argument(
44 "-amr",
45 "--adaptive-levels",
46 dest="adaptivity_levels",
47 type=int,
48 default=0,
49 help="Number of AMR grid levels on top of hmax (0 by default)",
50)
51parser.add_argument("-o", "--order", dest="order", type=int, default=3, help="DG Order")
52parser.add_argument(
53 "-p",
54 "--p",
55 dest="polynomials",
56 type=int,
57 default=1,
58 help="Polynomial type, 0 is Gauss-Legendre, 1 is Gauss-Lobatto",
59)
60parser.add_argument(
61 "-m", "--mode", dest="mode", default="release", help="|".join(modes.keys())
62)
63parser.add_argument(
64 "-pr", "--precision", dest="precision", default="fp64", help="|".join(available_prec)
65)
66parser.add_argument(
67 "-s",
68 "--scenario",
69 dest="s",
70 default=None,
71 help="|".join(available_scenarios.keys()),
72)
73
74args = parser.parse_args()
75
76if args.s is None:
77 while True:
78 try:
79 s = input(
80 "Which of the following scenarios would you like to try out?\n"
81 + " - ".join(available_scenarios.keys())
82 + "\n"
83 )
84 scenario = available_scenarios[s]
85 except KeyError:
86 continue
87 else:
88 # User has specified a valid scenario
89 break
90else:
91 scenario = available_scenarios[args.s]
92
93order = args.order
94max_h = 1.1 * scenario._domain_size / (3.0**args.md)
95min_h = max_h * 3.0 ** (-args.adaptivity_levels)
96
97polynomials = (
98 exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
99 if args.polynomials == 0
100 else exahype2.solvers.aderdg.Polynomials.Gauss_Lobatto
101)
102
103project = exahype2.Project(
104 ["tests", "exahype2", "aderdg"],
105 ".",
106 executable=scenario.__class__.__name__,
107)
108
109solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
110 name=scenario.__class__.__name__,
111 order=order,
112 min_cell_h=min_h,
113 max_cell_h=max_h,
114 time_step_relaxation=0.9,
115 unknowns=scenario._equation.num_unknowns,
116 auxiliary_variables=scenario._equation.num_auxiliary_variables
117)
118
119solver.add_kernel_optimisations(
120 polynomials=polynomials, is_linear=scenario._equation.is_linear,
121 precision = args.precision
122)
123
124solver.set_implementation(
125 initial_conditions=scenario.initial_conditions(),
126 boundary_conditions=scenario.boundary_conditions(),
127 max_eigenvalue=scenario._equation.eigenvalues(),
128 flux=scenario._equation.flux(),
129 ncp=scenario._equation.ncp(),
130 riemann_solver=scenario._equation.riemann_solver(),
131)
132
133project.add_solver(solver)
134
135
136
137solver2 = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
138 name=scenario.__class__.__name__+"2",
139 order=order,
140 min_cell_h=min_h,
141 max_cell_h=max_h,
142 time_step_relaxation=0.9,
143 unknowns=scenario._equation.num_unknowns,
144 auxiliary_variables=scenario._equation.num_auxiliary_variables
145)
146
147solver2.add_kernel_optimisations(
148 polynomials=polynomials, is_linear=scenario._equation.is_linear,
149 precision = args.precision
150)
151
152solver2.set_implementation(
153 initial_conditions=scenario.initial_conditions(),
154 boundary_conditions=scenario.boundary_conditions(),
155 max_eigenvalue=scenario._equation.eigenvalues(),
156 flux=scenario._equation.flux(),
157 ncp=scenario._equation.ncp(),
158 riemann_solver=scenario._equation.riemann_solver(),
159)
160
161
162
163project.add_solver(solver2)
164
165from fuseADERSolvers import fuseADERSolvers
166
168 solver, solver2,
169 "\nmarker.x()[0]<=(DomainOffset[0]+0.5*DomainSize[0]+0.51*marker.h()[0])\n",
170 "\nmarker.x()[0]>=(DomainOffset[0]+0.5*DomainSize[0]+0.49*marker.h()[0])\n"
171)
172
173if scenario.analytical_solution() != exahype2.solvers.PDETerms.None_Implementation:
174 exahype2.solvers.aderdg.ErrorMeasurement(
175 solver,
176 error_measurement_implementation=scenario.analytical_solution(),
177 output_file_name="Error_" + scenario.__class__.__name__,
178 )
179 exahype2.solvers.aderdg.ErrorMeasurement(
180 solver2,
181 error_measurement_implementation=scenario.analytical_solution(),
182 output_file_name="Error2_" + scenario.__class__.__name__,
183 )
184
185
186
187project.set_output_path("solutions")
188scenario.set_global_simulation_parameters(project)
189
190project.set_Peano4_installation("../../../", modes[args.mode])
191project = project.generate_Peano4_project(verbose=False)
192project.set_fenv_handler(True)
193
194project.build(make_clean_first=True)
Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006....
Very simple scenario in which the initial value of x is shifted in each spatial dimension.
Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006....
Scenario reproduced from Ioratti, Dumbser & Loubère, https://doi.org/10.1007/s10915-020-01209-w (p.
Classic radial dam break SWE equations, with constant initial water height but a bump in the bathymet...
Resting lake scenario for the shallow water equations.