Peano
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
3 import sys, os, argparse
4 import peano4, exahype2
5 
6 sys.path.insert(0, os.path.abspath("../../../../tests/exahype2/aderdg"))
7 import scenarios
8 
9 available_scenarios = {
10  "AcousticPlanarWaves2D": scenarios.AcousticPlanarWaves(dimensions=2),
11  "AcousticPlanarWaves3D": scenarios.AcousticPlanarWaves(dimensions=3),
12  "AdvectionLinear": scenarios.AdvectionLinear(),
13  "EulerGaussianBell": scenarios.EulerGaussianBell(),
14  "EulerIsotropicVortex": scenarios.EulerIsotropicVortex(),
15  "SWERadialDamBreak": scenarios.SWERadialDamBreak(),
16  "SWERestingLake": scenarios.SWERestingLake(),
17 }
18 parser = argparse.ArgumentParser(
19  description="ExaHyPE 2 - Finite Volumes Kernel Benchmarking Script"
20 )
21 
22 parser.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 
30 parser.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 
38 parser.add_argument(
39  "-ps",
40  "--patch-size",
41  type=int,
42  default=16,
43  help="Number of finite volumes in a patch",
44 )
45 
46 parser.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 
54 parser.add_argument(
55  "-p",
56  "--plot",
57  action="store_true",
58  help="Set if you want the simulation output",
59 )
60 
61 args = parser.parse_args()
62 scenario = available_scenarios[args.scenario]
63 dimensions = scenario._dimensions
64 depth = args.depth
65 end_time = scenario._end_time
66 should_plot = args.plot
67 size = [scenario._domain_size, scenario._domain_size, scenario._domain_size]
68 offset = [scenario._offset, scenario._offset, scenario._offset]
69 plot_description = ""
70 variable_names = []
71 
72 if type(scenario._equation.num_unknowns) is dict:
73  variable_names += list(scenario._equation.num_unknowns.keys())
74 if type(scenario._equation.num_auxiliary_variables) is dict:
75  variable_names += list(scenario._equation.num_auxiliary_variables.keys())
76 
77 plot_description = ", ".join(variable_names)
78 
79 project = exahype2.Project(
80  namespace=["benchmarks", "exahype2", "kernelbenchmarks"],
81  project_name="KernelBenchmarks",
82  directory=".",
83  executable="KernelBenchmarks",
84 )
85 
86 fv_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 
97 fv_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 
108 project.add_solver(fv_solver)
109 
110 project.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 
121 project.set_Peano4_installation(
122  "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
123 )
124 
125 project.set_output_path("solutions")
126 
127 project = project.generate_Peano4_project(verbose=False)
128 
129 project.constants.export_constexpr_with_type("GridLength", str(3**depth), "int")
130 project.constants.export_const_with_type(
131  "PlotDescription",
132  f'"{plot_description}"',
133  "std::string",
134 )
135 project.constants.export_constexpr_with_type(
136  "ShouldPlot", "true" if should_plot else "false", "bool"
137 )
138 
139 makefile = project.output.makefile
140 makefile.add_cpp_file("KernelBenchmarks-main.cpp")
141 makefile.add_h_file("DataRepository.h")
142 makefile.add_cpp_file("DataRepository.cpp")
143 project.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.
static double min(double const x, double const y)
str
Definition: ccz4.py:55
type
Definition: fv.py:33