Peano
Loading...
Searching...
No Matches
fv.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import sys
5
6import peano4
7import exahype2
8
9sys.path.insert(0, os.path.abspath("../../../tests/fv"))
10from PDE import max_eigenvalue, flux
11
12initial_conditions = """
13 Q[Shortcuts::rho] = 1.0;
14 Q[Shortcuts::rhoU + 0] = 0.0;
15 Q[Shortcuts::rhoU + 1] = 0.0;
16#if DIMENSIONS == 2
17 Q[Shortcuts::rhoE] = ((sqrt(pow(0.5 - x(0), 2) + pow(0.5 - x(1), 2)) < 0.2) ? (1.0) : (1.01));
18#else
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));
21#endif
22"""
23
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];
29#if DIMENSIONS == 3
30 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
31#endif
32 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
33"""
34
35parser = exahype2.ArgumentParser("ExaHyPE 2 Finite Volumes Kernel Benchmarking Script")
36parser.set_defaults(
37 min_depth=4,
38 degrees_of_freedom=16,
39)
40
41parser.add_argument(
42 "-s",
43 "--samples",
44 type=int,
45 default=0,
46 help="Set number of samples for benchmarking, if not set, run until scenario end",
47)
48
49args = parser.parse_args()
50
51size = [1.0, 1.0, 1.0]
52
53project = exahype2.Project(
54 namespace=["benchmarks", "exahype2", "kernelbenchmarks"],
55 project_name="KernelBenchmarks",
56 directory=".",
57 executable="KernelBenchmarks",
58)
59
60fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
61 name="FVSolver",
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,
69)
70
71fv_solver.set_implementation(
72 initial_conditions=initial_conditions,
73 boundary_conditions=boundary_conditions,
74 max_eigenvalue=max_eigenvalue,
75 flux=flux,
76)
77
78project.add_solver(fv_solver)
79
80if args.number_of_snapshots <= 0:
81 time_in_between_plots = 0.0
82else:
83 time_in_between_plots = args.end_time / args.number_of_snapshots
84 project.set_output_path(args.output)
85
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,
95)
96
97project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
98
99project = project.generate_Peano4_project(verbose=False)
100
101project.constants.export_constexpr_with_type(
102 "GridLength", str(3**args.min_depth), "int"
103)
104
105project.constants.export_constexpr_with_type(
106 "ShouldPlot", "true" if args.number_of_snapshots > 0 else "false", "bool"
107)
108
109project.constants.export_constexpr_with_type(
110 "UseAMR", "true" if args.amr_levels > 0 else "false", "bool"
111)
112
113project.constants.export_constexpr_with_type("Samples", str(args.samples), "int")
114
115makefile = project.output.makefile
116makefile.add_cpp_file("KernelBenchmarks-main.cpp")
117
118makefile.add_h_file("DataRepository.h")
119makefile.add_cpp_file("DataRepository.cpp")
120
121makefile.add_h_file("EnclaveDataRepository.h")
122makefile.add_cpp_file("EnclaveDataRepository.cpp")
123
124makefile.set_target_device(args.target_device)
125makefile.add_CXX_flag("-DGAMMA=1.4")
126
127project.build()