3@page benchmarks_exagrype_gauge_wave Gauge wave
7@image html benchmarks/exagrype/gauge-wave/example-output/convergence.png
9The gauge wave is a pure gauge perturbation of flat spacetime: an analytical
10solution of the Einstein equations which travels along the x-axis with speed one.
11It is periodic over the unit cube and hence a standard first test of any numerical
12relativity code. The solution is known exactly, so we can always tell what the
13numerical error is. If the wave shape or its amplitude changes over time,
14this is due to numerical effects, and the setup is convenient to assess and compare
15numerical schemes. The picture above shows the error of the lapse over the mesh size
16for five schemes. It is the outcome of the convergence study that doubles as the
17integration test of the numerical schemes (see below).
19The script uses exagrype.api, i.e. the first-order CCZ4 solver
20exagrype.api.FOCCZ4Solver, and discretises it with
23- Finite Volumes with explicit Euler time stepping (`--scheme fv`),
24- the same with optimistic time stepping (`--scheme fv-optimistic`), or
25- fourth-order Finite Differences with a Runge-Kutta scheme of order one to four (`--scheme
26 rk1fd4`, ..., `rk4fd4`).
31Peano has to be built with ExaHyPE and ExaGRyPE, i.e. with
33~~~~~~~~~~~~~~~~~~~~~~~
34--enable-exahype --enable-blockstructured --enable-loadbalancing --enable-exagrype
35~~~~~~~~~~~~~~~~~~~~~~~
37The generated code is compiled with the compiler of your choice (we use the
38Intel compiler with its path in `PATH`), and the Python packages have to be
39on the Python path (`export PYTHONPATH=$PYTHONPATH:../../../src`).
44The script has to be told what to do. It requires a build mode and a scheme:
46~~~~~~~~~~~~~~~~~~~~~~~
47python3 gauge-wave.py --mode release --scheme rk4fd4
48python3 gauge-wave.py --mode debug --scheme fv --mesh-size 0.1
49~~~~~~~~~~~~~~~~~~~~~~~
51Use `--help` to see all options. `--mode release` builds an optimised executable
52and runs until time 1.0; `--mode debug` builds with assertions and visualises the
53task graphs. `--mesh-size` is the edge length h of one grid cell. The default is 1/27, i.e. 3x3x3
54mesh cells with patches of 9x9x9 grid cells. The mesh is regular and refined by factors of
55three, i.e. h is rounded to patch size over 3^k (the patch size can be set via
56`--patch-size`, but the root cell is refined at least once). `--compiler` switches
57between the task graph compilers (sequential, fusion which is the default, and the
58producer-consumer variants of both), `--end-time`, `--threads` and `--directory` do what
61The script generates the C++ code, the Makefile, and compiles the executable. Run the
62executable `gauge-wave` afterwards. To get rid of all the generated files, remove the
63directories `celldata facedata globaldata observers tasks vertexdata repositories`, the
64`Abstract*` files, the `Makefile` and all `*.o` files. You can recreate them any time by
65rerunning the Python script.
68## Convergence study (integration test)
70The script `convergence-study.py` builds and runs the benchmark for all schemes `fv`,
71`rk1fd4`, ..., `rk4fd4` and for the volume sizes h=1/9, 1/27 and 1/81 (patch size 9; the
72coarsest mesh needs patches of size 3, as Peano refines the root cell at least once) until time
73t=0.1. It records the maximum error of the lapse along the line y=z=0.5 in the last
74snapshot against the exact solution
76@f[ \alpha (x,t) = \sqrt{1 - A \sin (2 \pi (x-t))}, \quad A=0.1, @f]
78estimates the convergence order p ~ log(e(3h)/e(h))/log(3), and exits with a non-zero
79status if the order between the two finest meshes of a scheme falls below a threshold. It
80is run via the skill `exahype2:integration-test` (see
81documentation/exahype2/integration-test/SKILL.md). Whenever you change a numerical scheme, the
82task graph, the kernels or the code generation, this is the test to rerun.
84| scheme | h = 1/9 | h = 1/27 | order | h = 1/81 | order |
85|---|---|---|---|---|---|
86| fv | 1.58e-2 | 6.59e-3 | 0.79 | 2.34e-3 | 0.94 |
87| rk1fd4 | 1.09e-3 | 3.37e-4 | 1.06 | 1.10e-4 | 1.02 |
88| rk2fd4 | 1.46e-4 | 3.01e-6 | 3.53 | 2.39e-7 | 2.31 |
89| rk3fd4 | 1.39e-4 | 2.70e-6 | 3.59 | 3.34e-8 | 4.00 |
90| rk4fd4 | 1.39e-4 | 2.71e-6 | 3.58 | 3.39e-8 | 3.99 |
94- The Finite Volume scheme is first order, as expected. Its error is orders of magnitude
95 above the one of the Finite Difference schemes, which discretise in space with fourth order.
96- The order of the Finite Difference schemes is the smaller one of the spatial order (four)
97 and the order of the time integration. With one Runge-Kutta stage (explicit Euler),
98 the time integration error dominates from the coarsest mesh on, and the scheme is
99 first order. As the time step size shrinks with the mesh size (CFL condition), the time
100 error is tiny for higher orders on coarse meshes: rk2fd4, rk3fd4 and rk4fd4 yield the same
101 error on the two coarsest meshes, and rk2fd4 leaves the fourth-order regime as soon as its
102 second-order time error becomes visible (order 2.3 between 1/27 and 1/81). Rk3fd4 and
103 rk4fd4 show the full fourth order.
104- The estimated orders on the coarsest meshes are not asymptotic: The wave is barely
105 resolved with 9 volumes per wave length.
106- The error is measured at the last snapshot, whose time stamp overshoots the end time by less
107 than one time step and differs between meshes. This biases the orders by about 0.01.
108- The study ran on an eight-core workstation. The finest meshes are the limit of what
109 fits into 16 GB of memory: A Finite Difference run with 81 volumes per axis needs 2 to 3 GB,
110 and the memory grows with the number of volumes, i.e. h=1/243 needs 27 times more and does not fit
111 (the study tried and the runs were killed). The finest mesh, h=1/81, took between
112 3 and 11 minutes with two threads. These numbers are recorded in the table of the
113 script, but they are not an acceptance criterion; the (to-be-written) skill
114 `exahype2:performance-test` is supposed to cover that.
117## Postprocess/visualise the results
119The convergence study uses `--plot-along-x-axis`, which restricts the output to the patches along
120the line y=z=0.5 and writes them with ten digits. Without this option, the code writes
121the whole solution as Peano patch files every 0.1 time units. You can convert them into vtk and
122visualise them via Paraview:
124~~~~~~~~~~~~~~~~~~~~~~~
125pvpython ../../../python/peano4/visualisation/render.py --filter-fine-grid solution-CCZ4.peano-patch-file
126~~~~~~~~~~~~~~~~~~~~~~~
138parser = argparse.ArgumentParser(description=
"ExaGRyPE gauge wave benchmark")
141 choices=[
"release",
"debug"],
143 help=
"Build mode of the generated code. Release uses a longer simulation "
144 "and text logging; debug a very short one with visualised logging.",
150 help=
"Edge length h of one Finite Volume cell or Finite Difference grid cell "
151 "(default: 1/27, i.e. 3x3x3 mesh cells with patches of 9x9x9 cells). The mesh is "
152 "regular and is refined by factors of three from the root cell, i.e. h is "
153 "rounded to patch-size/3^k.",
159 help=
"Number of grid cells per patch and axis (default: 9). Peano refines the root "
160 "cell at least once, i.e. h can be at most patch-size/3.",
166 help=
"Final simulation time (default: 1.0 for release, 0.02 for debug)",
171 help=
"Directory for the generated code, its build and the outputs (default: the current directory)",
177 help=
"Number of threads of the generated executable (default: all cores)",
180 "--plot-along-x-axis",
182 help=
"Restrict the plots to the patches along the line y=z=0.5 and write them "
183 "with ten digits. Needed to measure the error of the lapse, see convergence-study.py. "
184 "Four plots per simulation are written.",
188 choices=[
"fv",
"fv-optimistic",
"rk1fd4",
"rk2fd4",
"rk3fd4",
"rk4fd4"],
190 help=
"Numerical scheme: Finite Volumes with explicit Euler (fv), the same "
191 "with optimistic time stepping (fv-optimistic), or fourth-order Finite "
192 "Differences with Runge-Kutta of order 1 to 4 (rk1fd4, ..., rk4fd4).",
196 choices=[
"sequential",
"fusion",
"producer-consumer",
"producer-consumer-fusion"],
198 help=
"Task graph compiler: one traversal per task (sequential), tasks fused "
199 "into as few traversals as possible (fusion, default), or the same two "
200 "variants with cell tasks spawned as producer-consumer tasks.",
202args = parser.parse_args()
205task_graph_compiler = {
206 "sequential": compilers.Sequential.translate,
207 "fusion": compilers.FuseSteps.translate,
208 "producer-consumer": compilers.CellTaskProducerConsumer.translate_with_sequential,
209 "producer-consumer-fusion": compilers.CellTaskProducerConsumer.translate_with_fusion,
216volume_size = 1.01 * args.mesh_size
218if args.mode ==
"release":
219 build_mode = peano4.api.output.CompileMode.RELEASE
221 time_in_between_plots = 0.1
222 verbosity = peano4.api.LoggerVerbosity.TEXT
224 build_mode = peano4.api.output.CompileMode.DEBUG
226 time_in_between_plots = 0.01
227 verbosity = peano4.api.LoggerVerbosity.VISUALISATION
229if args.end_time
is not None:
230 end_time = args.end_time
231if args.plot_along_x_axis:
232 time_in_between_plots = end_time / 4.0
234patch_size = args.patch_size
235plotter_arguments = {}
236if args.plot_along_x_axis:
237 plotter_arguments[
"plotter_precision"] = 10
241 namespace=[
"benchmarks",
"exagrype",
"gaugewave"],
242 project_name=
"gauge-wave",
243 directory=args.directory,
244 executable=
"gauge-wave",
250if args.scheme
in [
"fv",
"fv-optimistic"]:
251 if args.scheme ==
"fv":
257 solver, volume_size=volume_size
261 first_plot_time_stamp=0.0,
262 time_in_between_plots=time_in_between_plots,
265 if args.plot_along_x_axis:
266 solver.plotter.add_plot_filter([0.0, 0.49, 0.49], [1.0, 0.02, 0.02])
268 Kernel = exahype2.api.rkfd4.CentralDifferencesWithRungeKutta.RightHandSideKernel
272 rk_order=int(args.scheme[2]),
273 right_hand_side_kernel=Kernel.CentralDifferencesWithLopsidedAdvection,
274 advection_velocity=exagrype.api.FOCCZ4Solver.ADVECTION_VELOCITY,
275 advected_quantities=solver.advected_quantities(),
278 solver, volume_size=volume_size
282 first_plot_time_stamp=0.0,
283 time_in_between_plots=time_in_between_plots,
286 if args.plot_along_x_axis:
287 solver.plotter.add_plot_filter([0.0, 0.49, 0.49], [1.0, 0.02, 0.02])
289project.add_solver(solver)
290project.compiler = task_graph_compiler
292project.set_global_simulation_parameters(
294 offset=[0.0, 0.0, 0.0],
295 size=[1.0, 1.0, 1.0],
296 min_end_time=end_time,
297 max_end_time=end_time,
298 periodic_BC=[
True,
True,
True],
301if args.threads
is not None:
302 project.set_number_of_threads(args.threads)
304PeanoRoot = os.path.abspath(
305 os.path.join(os.path.dirname(os.path.abspath(__file__)),
"..",
"..",
"..")
307project.set_Peano4_installation(PeanoRoot, build_mode)
308peano4_project = project.generate_Peano4_project(verbosity=verbosity)
309peano4_project.generate()
310peano4_project.build(make_clean_first=
True)
Solver for the Einstein equations in the first-order CCZ4 formulation.
Plotting counterpart to RusanovWithExplicitEuler: maps the patch data of a Finite Volume scheme with ...
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
Finite Volumes with a Rusanov Riemann solver and optimistic explicit Euler time stepping,...
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
Plotting counterpart of the fourth-order Finite Differences with Runge-Kutta time stepping (exahype2....
Setup phase of the fourth-order Finite Differences with Runge-Kutta time stepping (exahype2....
exahype2.api.InitPointWisely gauge_wave()
Gauge wave along the x-axis,.
This file is part of the ExaGRyPE project.
Compilers are simple functions.