Peano
Loading...
Searching...
No Matches
fv.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
3import sys, os, argparse
4import peano4, exahype2
5
6sys.path.insert(0, os.path.abspath("../../../../tests/exahype2/aderdg"))
7import scenarios
8
9available_scenarios = {
10 "AcousticPlanarWaves2D": scenarios.AcousticPlanarWaves(dimensions=2),
11 "AcousticPlanarWaves3D": scenarios.AcousticPlanarWaves(dimensions=3),
12 "AdvectionLinear": scenarios.AdvectionLinear(),
13 "EulerGaussianBell": scenarios.EulerGaussianBell(),
14 "EulerIsentropicVortex": scenarios.EulerIsentropicVortex(),
15 "SWERadialDamBreak": scenarios.SWERadialDamBreak(),
16 "SWERestingLake": scenarios.SWERestingLake(),
17}
18parser = argparse.ArgumentParser(
19 description="ExaHyPE 2 - Finite Volumes Kernel Benchmarking Script"
20)
21
22parser.add_argument(
23 "-m",
24 "--build-mode",
25 choices=peano4.output.CompileModes,
26 default=peano4.output.CompileModes[0], # Release
27 help="|".join(peano4.output.CompileModes),
28)
29
30parser.add_argument(
31 "-d",
32 "--depth",
33 type=int,
34 default=3,
35 help="Number of levels in the tree. Must be > 1.",
36)
37
38parser.add_argument(
39 "-ps",
40 "--patch-size",
41 type=int,
42 default=16,
43 help="Number of finite volumes in a patch",
44)
45
46parser.add_argument(
47 "-sc",
48 "--scenario",
49 choices=available_scenarios.keys(),
50 default="SWERadialDamBreak",
51 help="Scenario that should be used as a base for the benchmarking",
52)
53
54parser.add_argument(
55 "-p",
56 "--plot",
57 action="store_true",
58 help="Set if you want the simulation output",
59)
60
61args = parser.parse_args()
62scenario = available_scenarios[args.scenario]
63dimensions = scenario._dimensions
64depth = args.depth
65end_time = scenario._end_time
66should_plot = args.plot
67size = [scenario._domain_size, scenario._domain_size, scenario._domain_size]
68offset = [scenario._offset, scenario._offset, scenario._offset]
69plot_description = ""
70variable_names = []
71
72if type(scenario._equation.num_unknowns) is dict:
73 variable_names += list(scenario._equation.num_unknowns.keys())
74if type(scenario._equation.num_auxiliary_variables) is dict:
75 variable_names += list(scenario._equation.num_auxiliary_variables.keys())
76
77plot_description = ", ".join(variable_names)
78
79project = exahype2.Project(
80 namespace=["benchmarks", "exahype2", "kernelbenchmarks"],
81 project_name="KernelBenchmarks",
82 directory=".",
83 executable="KernelBenchmarks",
84)
85
86fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
87 name="FVSolver",
88 patch_size=int(args.patch_size),
89 unknowns=scenario._equation.num_unknowns,
90 auxiliary_variables=scenario._equation.num_auxiliary_variables,
91 min_volume_h=(1.1 * min(size[0:dimensions]) / (3.0**depth)),
92 max_volume_h=(1.1 * min(size[0:dimensions]) / (3.0**depth)),
93 time_step_relaxation=0.5,
94 use_enclave_tasking=True,
95)
96
97fv_solver.set_implementation(
98 initial_conditions=scenario.initial_conditions(),
99 boundary_conditions="""
100 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
101 Qoutside[i] = Qinside[i];
102 }
103""",
104 flux=scenario._equation.flux(),
105 max_eigenvalue=scenario._equation.eigenvalues(),
106)
107
108project.add_solver(fv_solver)
109
110project.set_global_simulation_parameters(
111 dimensions=dimensions,
112 size=size[0:dimensions],
113 offset=offset[0:dimensions],
114 min_end_time=scenario._end_time,
115 max_end_time=scenario._end_time,
116 first_plot_time_stamp=0.0,
117 time_in_between_plots=0.1,
118 periodic_BC=[False] * dimensions,
119)
120
121project.set_Peano4_installation(
122 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
123)
124
125project.set_output_path("solutions")
126
127project = project.generate_Peano4_project(verbose=False)
128
129project.constants.export_constexpr_with_type("GridLength", str(3**depth), "int")
130project.constants.export_const_with_type(
131 "PlotDescription",
132 f'"{plot_description}"',
133 "std::string",
134)
135project.constants.export_constexpr_with_type(
136 "ShouldPlot", "true" if should_plot else "false", "bool"
137)
138
139makefile = project.output.makefile
140makefile.add_cpp_file("KernelBenchmarks-main.cpp")
141makefile.add_h_file("DataRepository.h")
142makefile.add_cpp_file("DataRepository.cpp")
143project.build()
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 Ioratti, Dumbser & Loubère, https://doi.org/10.1007/s10915-020-01209-w (p.
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.
type
Definition fv.py:33