Peano 4
Loading...
Searching...
No Matches
convergence-study.py
Go to the documentation of this file.
1import os
2import argparse
3
4import peano4
5import exahype2
6import dastgen2
7
9import numpy as np
10
11# See comments in README.dox
12from CCZ4Solver import CCZ4Solver_FV_GlobalAdaptiveTimeStep
13from CCZ4Solver import CCZ4Solver_FV_GlobalAdaptiveTimeStepWithEnclaveTasking
14from CCZ4Solver import CCZ4Solver_FD4_GlobalAdaptiveTimeStepWithEnclaveTasking
15from CCZ4Solver import CCZ4Solver_FD4_GlobalAdaptiveTimeStep
16from CCZ4Solver import CCZ4Solver_RKDG_GlobalAdaptiveTimeStepWithEnclaveTasking
17from CCZ4Solver import (
18 CCZ4Solver_FD4_SecondOrderFormulation_GlobalAdaptiveTimeStepWithEnclaveTasking,
19)
20
21from ComputeFirstDerivatives import ComputeFirstDerivativesFD4RK
22
23parser = argparse.ArgumentParser(
24 description="ExaHyPE 2 - CCZ4-GaugeWave benchmarking script"
25)
26parser.add_argument(
27 "-j", "--parallel-builds", dest="j", type=int, default=-1, help="Parallel builds"
28)
29parser.add_argument(
30 "-pd",
31 "--peano-dir",
32 dest="peanodir",
33 default="../../../../",
34 help="Peano4 directory",
35)
36parser.add_argument(
37 "-v",
38 "--verbose",
39 dest="verbose",
40 action="store_true",
41 default=False,
42 help="Verbose",
43)
44parser.add_argument(
45 "-s",
46 "--solver",
47 dest="solver",
48 choices=[
49 "fv",
50 "fd4-rk1", "sofd4-rk1",
51 "fd4-rk2", "sofd4-rk2",
52 "fd4-rk3", "sofd4-rk3",
53 "fd4-rk4", "sofd4-rk4",
54 "dg0-rk1",
55 "dg0-rk2",
56 "dg0-rk3",
57 "dg0-rk4",
58 "dg1-rk1",
59 "dg2-rk1",
60 "dg2-rk2",
61 "dg3-rk1",
62 "dg3-rk3",
63 "dg4-rk4",
64 "dg4-rk1",
65 "dg4-rk2",
66 "dg4-rk3"
67 ],
68 required=True,
69 help="Pick solver type",
70)
71parser.add_argument(
72 "-enclave",
73 "--enclave",
74 dest="enclave",
75 action="store_true",
76 default=False,
77 help="switch on the enclave tasking solver",
78)
79parser.add_argument(
80 "-et",
81 "--end-time",
82 dest="end_time",
83 type=float,
84 default=1.0,
85 help="End of simulation",
86)
87parser.add_argument(
88 "-cs",
89 "--cell-size",
90 dest="cell_size",
91 type=float,
92 default=0.3,
93 help="Cell size (default 0.3)",
94)
95parser.add_argument(
96 "-asserts",
97 "--asserts",
98 dest="asserts",
99 action="store_true",
100 default=False,
101 help="Switch on assertions",
102)
103parser.add_argument(
104 "-tracer",
105 "--tracer",
106 dest="tracer",
107 action="store_true",
108 default=False,
109 help="Activate tracer",
110)
111parser.add_argument(
112 "-hs",
113 "--heap-storage",
114 dest="use_heap_storage",
115 action="store_true",
116 default=False,
117 help="Store user data on heap via smart pointers",
118)
119
120args = parser.parse_args()
121
122
124 ["benchmarks", "exahype2", "ccz4"],
125 "ccz4",
126 executable=args.solver + "-" + str(args.cell_size),
127)
128
129
130#
131# Create solver class
132#
133# For FV and FD schemes, I pick patches of 9x9x9 here, as I then can match stuff exactly
134# with the DG solver of DG order 0. This helps me to debug stuff.
135#
136my_solver = None
137
138if args.solver == "fv" and args.enclave:
140 name="CCZ4FV",
141 patch_size=9,
142 min_volume_h=args.cell_size / 5,
143 max_volume_h=args.cell_size / 5,
144 use_heap_storage=args.use_heap_storage,
145 pde_terms_without_state=True,
146 )
147 my_solver.set_implementation(
148 initial_conditions="""
149 for (int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) Q[i] = 0.0;
150 ::applications::exahype2::ccz4::gaugeWave(Q, volumeCentre, 0);
151 """
152 )
153if args.solver == "fv" and not args.enclave:
155 name="CCZ4FV",
156 patch_size=9,
157 min_volume_h=args.cell_size / 5,
158 max_volume_h=args.cell_size / 5,
159 use_heap_storage=args.use_heap_storage,
160 pde_terms_without_state=True,
161 )
162 my_solver.set_implementation(
163 initial_conditions="""
164 for (int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) Q[i] = 0.0;
165 ::applications::exahype2::ccz4::gaugeWave(Q, volumeCentre, 0);
166 """
167 )
168if "fd4-rk" in args.solver or "sofd4-rk" in args.solver:
169 order = int(args.solver[-1])
170 second_order_formulation = "sofd4" in args.solver
171 if args.enclave==True:
173 name="CCZ4FD4RK" + str(order) + "Enclave",
174 patch_size=9,
175 rk_order=order,
176 min_meshcell_h=args.cell_size / 3,
177 max_meshcell_h=args.cell_size / 3,
178 second_order = second_order_formulation,
179 use_heap_storage=args.use_heap_storage,
180 pde_terms_without_state=False
181 )
182 else:
184 name="CCZ4FD4RK" + str(order),
185 patch_size=9,
186 rk_order=order,
187 min_meshcell_h=args.cell_size / 3,
188 max_meshcell_h=args.cell_size / 3,
189 second_order = second_order_formulation
190 )
191 my_solver.set_implementation(
192 initial_conditions="""
193 for (int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) Q[i] = 0.0;
194 ::applications::exahype2::ccz4::gaugeWave(Q, meshCellCentre, 0);
195 """
196 )
197
198if "rk" in args.solver and "dg" in args.solver and not args.enclave_solver:
199 space_order = int(args.solver[2])
200 time_order = int(args.solver[6])
202 name="CCZ4DG" + str(space_order) + "RK" + str(time_order),
203 polynomials=exahype2.solvers.GaussLegendreBasis(space_order),
204 rk_order=time_order,
205 min_cell_h=args.cell_size * space_order,
206 max_cell_h=args.cell_size * space_order,
207 use_heap_storage=args.use_heap_storage,
208 pde_terms_without_state=True,
209 )
210 my_solver.set_implementation(
211 initial_conditions="""
212 for (int i=0; i<NumberOfUnknowns+NumberOfAuxiliaryVariables; i++) Q[i] = 0.0;
213 ::applications::exahype2::ccz4::gaugeWave(Q, x, 0);
214 """
215 )
216
217
218assert my_solver != None
219
220my_solver.add_all_solver_constants()
221project.add_solver(my_solver)
222
223
226if args.tracer:
227 if args.asserts:
228 time_delta_between_two_snapsots = 1e-4
229 else:
230 time_delta_between_two_snapsots = 0.1
231 my_solver.add_tracer(
232 name="Tracer",
233 coordinates=[[-0.4251, 0, 0], [0, 0, 0], [0.4251, 0, 0]],
234 project=project,
235 number_of_entries_between_two_db_flushes = 100,
236 data_delta_between_two_snapsots = 1e-8,
237 time_delta_between_two_snapsots = time_delta_between_two_snapsots,
238 clear_database_after_flush = False,
239 tracer_unknowns = None
240 )
241
242
243
246
247if args.asserts:
248 build_mode = peano4.output.CompileMode.Asserts
249else:
250 build_mode = peano4.output.CompileMode.Release
251
252if args.asserts:
253 delta_plot = 1.0 / 100
254else:
255 delta_plot = 1.0 / 20
256
257dimensions = 3
258offset = [-0.5, -0.5, -0.5]
259domain_size = [1, 1, 1]
260
261periodic_boundary_conditions = [True, True, True] # Periodic BC
262
263project.set_global_simulation_parameters(
264 dimensions, # dimensions
265 offset,
266 domain_size,
267 args.end_time,
268 0.0,
269 delta_plot,
270 periodic_boundary_conditions,
271 8, # plotter precision
272)
273
274probe_point = [-12,-12,0.0]
275project.add_plot_filter( probe_point,[24.0,24.0,0.01],1 )
276
277project.set_Peano4_installation(args.peanodir, build_mode)
278
279# project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveBipartition","(new ::exahype2::LoadBalancingConfiguration(0.98,0))" )
280project.set_load_balancing(
281 "toolbox::loadbalancing::strategies::SpreadOutHierarchically",
282 "(new ::exahype2::LoadBalancingConfiguration(0.98))",
283)
284
285peano4_project = project.generate_Peano4_project(verbose=args.verbose)
286
287if "sofd4" in args.solver:
288 additional_mesh_traversal = peano4.solversteps.Step( name = "AdditionalMeshTraversal",
289 add_user_defined_actions=False,
290 )
291
292 #
293 # We misuse the projection. See @ref benchmarks_exahype2_ccz4_gauge_wave for details
294 #
295 project_patch_onto_faces = exahype2.solvers.rkfd.actionsets.ProjectPatchOntoFaces(my_solver)
296 project_patch_onto_faces.guards = [ "false" for x in range(0,my_solver.number_of_Runge_Kutta_steps()+1) ]
297 project_patch_onto_faces.guards[-1] = my_solver._store_cell_data_default_guard()
298
299 roll_over_projected_faces = exahype2.solvers.rkfd.actionsets.RollOverUpdatedFace(my_solver,
300 my_solver._store_face_data_default_guard(),
301 )
302
303#
304# @todo Han: I don't think this is good that we switch off enclave solvers always
305#
306 additional_mesh_traversal.add_action_set( ComputeFirstDerivativesFD4RK(solver=my_solver,
307 is_enclave_solver = False,
308 ))
309 additional_mesh_traversal.add_action_set( project_patch_onto_faces )
310 additional_mesh_traversal.add_action_set( roll_over_projected_faces )
311
312 project.register_new_user_defined_algorithmic_step( additional_mesh_traversal )
313
314 #
315 # Consult remarks in README.dox on the additional step and how it is
316 # integrated into the main routine.
317 #
318 peano4_project.solversteps.add_step( additional_mesh_traversal )
319 peano4_project.constants.define( "USE_ADDITIONAL_MESH_TRAVERSAL" )
320
321
322my_solver.add_makefile_parameters(
323 peano4_project, "../../../../applications/exahype2/ccz4"
324)
325
326peano4_project.generate(throw_away_data_after_generation=False)
327peano4_project.build(make_clean_first=True, number_of_parallel_builds=args.j)
CCZ4 solver using fourth-order finite differences and global adaptive time stepping incl enclave task...
CCZ4 solver using fourth-order finite differences and global adaptive time stepping without enclave t...
CCZ4 solver using finite volumes and global adaptive time stepping incl enclave tasking.
CCZ4 solver using finite volumes and global adaptive time stepping incl enclave tasking.
CCZ4 solver using Runge-Kutta Discontinuous Galerkin and global adaptive time stepping incl enclave t...
Explicit reconstruction of first derivatives for FD4 discretisation.
ExaHyPE 2 project.
Definition Project.py:18
The Gauss-Legendre Basis is by construction the only basis which yields diagonal mass matrices.
Project patch data onto faces, so the faces hold valid data which can feed into the subsequent Runge-...