Peano
Loading...
Searching...
No Matches
gauge-wave-with-Euler.py
Go to the documentation of this file.
1"""!
2
3Gauge wave benchmark for the ExaGRyPE Python API with an additional Euler fluid
4
5The gauge wave is a pure gauge perturbation of flat spacetime, i.e. an
6analytical solution of the Einstein equations that travels along the x-axis
7with speed one. It is periodic over the unit cube. This script evolves it with
8the first-order CCZ4 solver of exagrype.api (exagrype.api.FOCCZ4Solver),
9discretised with fourth-order Finite Differences and classic Runge-Kutta 4
10(exahype2.api.rkfd4).
11
12Next to CCZ4, the compound hosts a compressible Euler solver
13(exagrype.api.euler.Euler), discretised with Finite Volumes and explicit Euler time
14stepping (exahype2.api.fv.RusanovWithExplicitEuler). Both solvers are configured
15right here, and both run on the same mesh with periodic boundary
16conditions. They are hosted by exagrype.api.euler.CCZ4WithEuler_OuterAdditiveCoupling,
17which copies the fields of each solver into auxiliary variables of the other
18one at the begin of each time step (piecewise linear interpolation between the
19two resolutions), and which synchronises the time step sizes at the end.
20
21Each mesh cell hosts a patch of p x p x p grid cells for CCZ4 and a patch of
22(2p+1) x (2p+1) x (2p+1) volumes for Euler. With p=8, Euler has 17 x 17 x 17
23volumes per cell. The Euler volumes are hence a bit smaller than half the
24size of the CCZ4 grid cells.
25
26The script requires a Peano build with
27
28 --enable-exahype --enable-blockstructured --enable-loadbalancing --enable-exagrype
29
30and is run from this directory via
31
32 python3 gauge-wave-with-Euler.py --mode release
33 python3 gauge-wave-with-Euler.py --mode debug --cell-size 0.1111 --patch-size 8
34
35"""
36
37import argparse
38import os
39
40import peano4.api
41import exahype2.api
42import exagrype.api
43
44
45parser = argparse.ArgumentParser(description="ExaGRyPE gauge wave with Euler")
46parser.add_argument(
47 "--mode",
48 choices=["release", "debug"],
49 required=True,
50 help="Build mode of the generated code. Release uses a longer simulation "
51 "and text logging; debug a very short one with visualised logging.",
52)
53parser.add_argument(
54 "--cell-size",
55 type=float,
56 default=1.0 / 3.0,
57 help="Edge length of one mesh cell (default: 1/3). The mesh is regular and "
58 "refined by factors of three from the root cell, i.e. the value is rounded "
59 "to 3^-k (k>=1).",
60)
61parser.add_argument(
62 "--patch-size",
63 type=int,
64 default=8,
65 help="Number of CCZ4 grid cells per mesh cell and axis (default: 8). "
66 "Euler hosts 2*patch-size+1 volumes per axis.",
67)
68args = parser.parse_args()
69
70if args.patch_size < 1:
71 raise ValueError("The patch size has to be positive")
72if args.cell_size <= 0.0 or args.cell_size >= 1.0:
73 raise ValueError("The cell size has to be in (0,1)")
74
75if args.mode == "release":
76 build_mode = peano4.api.output.CompileMode.RELEASE
77 end_time = 1.0
78 time_in_between_plots = 0.1
79 verbosity = peano4.api.LoggerVerbosity.TEXT
80else:
81 build_mode = peano4.api.output.CompileMode.DEBUG
82 end_time = 0.02
83 time_in_between_plots = 0.01
84 verbosity = peano4.api.LoggerVerbosity.VISUALISATION
85
86ccz4_patch_size = args.patch_size
87euler_patch_size = 2 * args.patch_size + 1
88
89
93ccz4_volume_size = 1.01 * args.cell_size / ccz4_patch_size
94euler_volume_size = 1.01 * args.cell_size / euler_patch_size
95
96
98 namespace=["benchmarks", "exagrype", "gaugewavewitheuler"],
99 project_name="gauge-wave-with-Euler",
100 directory=".",
101 executable="gauge-wave-with-Euler",
102)
103
104
108ccz4 = coupled.ccz4
109euler = coupled.euler
110ccz4.add_pde_term(exagrype.api.initialvalues.gauge_wave())
111
112
113Kernel = exahype2.api.rkfd4.CentralDifferencesWithRungeKutta.RightHandSideKernel
115 ccz4,
116 ccz4_patch_size,
117 rk_order=4,
118 right_hand_side_kernel=Kernel.CentralDifferencesWithLopsidedAdvection,
119 advection_velocity=exagrype.api.FOCCZ4Solver.ADVECTION_VELOCITY,
120 advected_quantities=ccz4.advected_quantities(),
121)
123 ccz4, volume_size=ccz4_volume_size
124)
126 ccz4, first_plot_time_stamp=0.0, time_in_between_plots=time_in_between_plots
127)
128
129
130euler.numerical_scheme = exahype2.api.fv.RusanovWithExplicitEuler(euler, euler_patch_size)
131euler.grid_construction = exahype2.api.fv.SetupSimulationOverRegularGrid(
132 euler, volume_size=euler_volume_size
133)
134euler.plotter = exahype2.api.fv.PlotAsVTKFile(
135 euler, first_plot_time_stamp=0.0, time_in_between_plots=time_in_between_plots
136)
137
138project.add_solver(coupled)
139
140project.compiler = peano4.api.taskgraph.compiler.FuseSteps.translate
141
142project.set_global_simulation_parameters(
143 dimensions=3,
144 offset=[0.0, 0.0, 0.0],
145 size=[1.0, 1.0, 1.0],
146 min_end_time=end_time,
147 max_end_time=end_time,
148 periodic_BC=[True, True, True],
149)
150
151PeanoRoot = os.path.abspath(
152 os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..")
153)
154project.set_Peano4_installation(PeanoRoot, build_mode)
155peano4_project = project.generate_Peano4_project(verbosity=verbosity)
156peano4_project.generate()
157peano4_project.build(make_clean_first=True)
First-order CCZ4 and an Euler fluid, coupled only at the begin and the end of each time step.
ExaHyPE 2 project.
Definition Project.py:15
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-...
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.
Definition __init__.py:1