9sys.path.insert(0, os.path.abspath(
"../../../tests/fv"))
10from PDE
import max_eigenvalue, flux
12initial_conditions =
"""
13 Q[Shortcuts::rho] = 1.0;
14 Q[Shortcuts::rhoU + 0] = 0.0;
15 Q[Shortcuts::rhoU + 1] = 0.0;
17 Q[Shortcuts::rhoE] = ((sqrt(pow(0.5 - x(0), 2) + pow(0.5 - x(1), 2)) < 0.2) ? (1.0) : (1.01));
19 Q[Shortcuts::rhoU + 2] = 0.0;
20 Q[Shortcuts::rhoE] = ((sqrt(pow(0.5 - x(0), 2) + pow(0.5 - x(1), 2) + pow(0.5 - x(2), 2)) < 0.2) ? (1.0) : (1.01));
24boundary_conditions =
"""
25 // Reflective boundary conditions
26 Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
27 Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
28 Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
30 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
32 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
35parser = exahype2.ArgumentParser(
"ExaHyPE 2 Finite Volumes Kernel Benchmarking Script")
38 degrees_of_freedom=16,
46 help=
"Set number of samples for benchmarking, if not set, run until scenario end",
49args = parser.parse_args()
53project = exahype2.Project(
54 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
55 project_name=
"KernelBenchmarks",
57 executable=
"KernelBenchmarks",
60fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
62 patch_size=args.degrees_of_freedom,
63 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
64 auxiliary_variables=0,
65 min_volume_h=(1.1 * min(size[0 : args.dimensions]) / (3.0**args.min_depth)),
66 max_volume_h=(1.1 * min(size[0 : args.dimensions]) / (3.0**args.min_depth)),
67 time_step_relaxation=0.5,
68 use_enclave_tasking=
True,
71fv_solver.set_implementation(
72 initial_conditions=initial_conditions,
73 boundary_conditions=boundary_conditions,
74 max_eigenvalue=max_eigenvalue,
78project.add_solver(fv_solver)
80if args.number_of_snapshots <= 0:
81 time_in_between_plots = 0.0
83 time_in_between_plots = args.end_time / args.number_of_snapshots
84 project.set_output_path(args.output)
86project.set_global_simulation_parameters(
87 dimensions=args.dimensions,
88 size=size[0 : args.dimensions],
89 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
90 min_end_time=args.end_time,
91 max_end_time=args.end_time,
92 first_plot_time_stamp=0.0,
93 time_in_between_plots=time_in_between_plots,
94 periodic_BC=[
False] * args.dimensions,
97project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
99project = project.generate_Peano4_project(verbose=
False)
101project.constants.export_constexpr_with_type(
102 "GridLength", str(3**args.min_depth),
"int"
105project.constants.export_constexpr_with_type(
106 "ShouldPlot",
"true" if args.number_of_snapshots > 0
else "false",
"bool"
109project.constants.export_constexpr_with_type(
110 "UseAMR",
"true" if args.amr_levels > 0
else "false",
"bool"
113project.constants.export_constexpr_with_type(
"Samples", str(args.samples),
"int")
115makefile = project.output.makefile
116makefile.add_cpp_file(
"KernelBenchmarks-main.cpp")
118makefile.add_h_file(
"DataRepository.h")
119makefile.add_cpp_file(
"DataRepository.cpp")
121makefile.add_h_file(
"EnclaveDataRepository.h")
122makefile.add_cpp_file(
"EnclaveDataRepository.cpp")
124makefile.set_target_device(args.target_device)
125makefile.add_CXX_flag(
"-DGAMMA=1.4")