3 Simple, hard-coded version of the self-similarity test of the MNRAS
4 paper. A more elegant implementation of the solver via a proper subclass
5 can be found in the actual application folder.
18ExaHyPE 2 Finite Volume version of the self-similarity tests of the MNRAS paper
20@author 2022 Han Zhang, Baojiu Li, Tobias Weinzierl
25parser = argparse.ArgumentParser(description=
'ExaHyPE 2 - Euler benchmarking script')
26parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
27parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
28parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
29parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=peano4.api.output.CompileModes, default=peano4.api.output.CompileModes[0], help=
"|".join(peano4.api.output.CompileModes) )
30parser.add_argument(
"-t",
"--type", dest=
"type", choices=[
"plot-0",
"plot-1",
"plot-2",
"plot-3",
"reg-0"], required=
True, help=
"Pick scenario" )
31parser.add_argument(
"--optimise-stateless", dest=
"optimise_stateless", action=
"store_true", default=
False, help=
"Optimise stateless/side-effect free cells (required for GPU offloading)")
32parser.add_argument(
"-s",
"--solver", dest=
"solver", choices=[
"fv-4",
"fv-6",
"fv-8",
"dg1-rk1",
"dg2-rk2",
"dg3-rk3",
"dg4-rk4",
"fd4-rk1",
"fd4-rk4"], required=
True, help=
"Pick solver type. For the Finite Volume (fv) solvers, the second index is the patch/block size. For DG, you can pick different Runge-Kutta time integration orders" )
33args = parser.parse_args()
42solver_name =
"SelfSimilarInfall"
49number_of_unknowns = sum(unknowns.values())
51if args.type==
"plot-0":
55if args.type==
"plot-1":
56 baseline_max_h = 0.005
57 baseline_min_h = 0.005
59if args.type==
"plot-2":
63if args.type==
"plot-3":
65 baseline_min_h = 0.008
67elif args.type==
"reg-0":
68 baseline_max_h = 0.008
69 baseline_min_h = 0.008
79if "dg0-" in args.solver:
80 max_h = baseline_max_h
81 min_h = baseline_min_h
82if "dg1-" in args.solver:
83 max_h = baseline_max_h
84 min_h = baseline_min_h
85if "dg2-" in args.solver:
86 max_h = baseline_max_h * 3
87 min_h = baseline_min_h * 3
88elif "dg3-" in args.solver:
89 max_h = baseline_max_h * 4
90 min_h = baseline_min_h * 4
91elif "dg4-" in args.solver:
92 max_h = baseline_max_h * 5
93 min_h = baseline_min_h * 5
94elif "fd4-" in args.solver:
95 max_h = baseline_max_h
96 min_h = baseline_min_h
97elif "fv-" in args.solver:
98 max_h = baseline_max_h
99 min_h = baseline_min_h
103auxiliary_variables = 0
106executable_name =
"benchmark-" + args.type
107if args.optimise_stateless:
108 executable_name = executable_name +
"-opt"
110 executable_name = executable_name +
"-no-opt"
113if args.mode!=
"release":
114 executable_name = executable_name +
"-" + args.mode
118if "fv" in args.solver:
119 patch_size =
int(args.solver[-1])
120 thesolver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStepWithEnclaveTasking(name = solver_name +
"FV",
121 patch_size = patch_size,
122 unknowns = number_of_unknowns,
123 auxiliary_variables = auxiliary_variables,
124 min_volume_h = min_h,
125 max_volume_h = max_h,
126 time_step_relaxation = 0.1,
127 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
128 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
129 source_term = exahype2.solvers.PDETerms.User_Defined_Implementation,
130 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
131 pde_terms_without_state = args.optimise_stateless
133 executable_name = executable_name +
"-FV-" + str(patch_size)
135 thesolver._action_set_postprocess_solution = exahype2.solvers.fv.actionsets.VolumeWisePostprocessSolution(thesolver)
136 thesolver._action_set_postprocess_solution.guard =
"""
137repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
139not repositories::{{SOLVER_INSTANCE}}.patchCanUseStatelessPDETerms(marker.x(), marker.h(), timeStamp, timeStepSize)
141 thesolver._action_set_postprocess_solution.add_postprocessing_kernel(
"""
142 repositories::{{SOLVER_INSTANCE}}.addDensity(volumeX,volumeH,value[0]);
144if "fd4" in args.solver:
146 time_order =
int(args.solver[6])
147 thesolver = exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking(name = solver_name +
"FD4",
149 patch_size = patch_size,
150 rk_order = time_order,
151 unknowns = number_of_unknowns,
152 auxiliary_variables = auxiliary_variables,
153 min_meshcell_h = min_h,
154 max_meshcell_h = max_h,
155 time_step_relaxation = 0.1,
156 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
157 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
158 source_term = exahype2.solvers.PDETerms.User_Defined_Implementation,
159 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
162 executable_name = executable_name +
"-FD4-" + str(patch_size)
164 thesolver._action_set_postprocess_solution = exahype2.solvers.rkfd.actionsets.CellWisePostprocessSolution(thesolver)
165 thesolver._action_set_postprocess_solution.guard =
"""
166repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
168//not repositories::{{SOLVER_INSTANCE}}.patchCanUseStatelessPDETerms(marker.x(), marker.h(), timeStamp, timeStepSize)
170 thesolver._action_set_postprocess_solution.add_postprocessing_kernel(
"""
171 repositories::{{SOLVER_INSTANCE}}.addDensity(volumeX,volumeH,value[0]);
174 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation( thesolver,
"TP_constant" )
175 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction( thesolver,
"TP_inject_normal_extrap" )
176if "rk" in args.solver
and "dg" in args.solver:
177 space_order =
int(args.solver[2])
178 time_order =
int(args.solver[6])
179 thesolver = exahype2.solvers.rkdg.rusanov.GlobalAdaptiveTimeStepWithEnclaveTasking(name = solver_name +
"DG",
180 rk_order = time_order,
181 polynomials = exahype2.solvers.GaussLegendreBasis(space_order),
182 face_projections = exahype2.solvers.rkdg.FaceProjections.Solution,
183 unknowns = number_of_unknowns,
184 auxiliary_variables = auxiliary_variables,
187 time_step_relaxation = 0.1,
188 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
189 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
190 source_term = exahype2.solvers.PDETerms.User_Defined_Implementation,
191 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
192 pde_terms_without_state = args.optimise_stateless
194 executable_name = executable_name +
"-RK" + str(time_order) +
"DG" + str(space_order)
196 thesolver._action_set_postprocess_solution = exahype2.solvers.rkdg.actionsets.DoFWisePostprocessSolution(thesolver)
197 thesolver._action_set_postprocess_solution.guard =
"""
198repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
200not repositories::{{SOLVER_INSTANCE}}.cellCanUseStatelessPDETerms(marker.x(), marker.h(), timeStamp, timeStepSize)
202 thesolver._action_set_postprocess_solution.add_postprocessing_kernel(
"""
203 repositories::{{SOLVER_INSTANCE}}.addDensity(x, marker.h(), index, values[0]);
210thesolver.plot_description =
"rho,j_x,j_y,j_z,E,aux"
211if "dyn" in args.type:
212 thesolver.add_solver_constants(
"static constexpr bool DynamicAMR = true;" )
214 thesolver.add_solver_constants(
"static constexpr bool DynamicAMR = false;" )
221project = exahype2.Project( [
"benchmarks",
"exahype2",
"euler",
"sphericalaccretionupscaling"],
"benchmark",
".", executable=executable_name )
222project.add_solver( thesolver )
228if "plot" in args.type:
229 plot_interval = end_time / 20.0
235project.set_global_simulation_parameters(
236 dimensions = dimensions,
237 offset = [-cube_size/2.0, -cube_size/2.0, -cube_size/2.0],
238 size = [ cube_size, cube_size, cube_size],
239 min_end_time = end_time,
240 max_end_time = end_time,
241 first_plot_time_stamp = 0.0,
242 time_in_between_plots = plot_interval,
243 periodic_BC = [
False,
False,
False]
247project.set_load_balancing(
"toolbox::loadbalancing::strategies::RecursiveBipartition",
"new ::exahype2::LoadBalancingConfiguration()" )
248project.set_Peano4_installation( args.peanodir, peano4.api.output.string_to_mode(args.mode) )
253peano4_project = project.generate_Peano4_project(args.verbose)
256peano4_project.output.makefile.add_cpp_file(
"../../../../applications/exahype2/euler/spherical-accretion/MassAccumulator.cpp" )
257peano4_project.output.makefile.add_cpp_file(
"../../../../applications/exahype2/euler/spherical-accretion/GravityModel.cpp" )
258peano4_project.output.makefile.add_header_search_path(
"../../../../applications/exahype2/euler" )
259peano4_project.generate()
261os.system(
"make clean" )
263 os.system(
"make -j{}".format(args.j) )
265 os.system(
"make -j" )