6parser = exahype2.ArgumentParser(
"ExaHyPE 2 - Finite Volumes Static AMR Testing Script")
7available_precisions = [
"float",
"double"]
9 "-pr",
"--precision", default=
"double", help=
"|".join(available_precisions)
14 degrees_of_freedom=16,
17args = parser.parse_args()
19max_h = 1.1 / 3.0**args.min_depth
20min_h = max_h * 3.0 ** (-args.amr_levels)
22initial_conditions =
"""
23 Q[Shortcuts::rho] = 1.0;
24 Q[Shortcuts::rhoU + 0] = 0.0;
25 Q[Shortcuts::rhoU + 1] = 0.0;
27 Q[Shortcuts::rhoE] = ((std::sqrt(std::pow(0.5 - x(0), 2) + std::pow(0.5 - x(1), 2)) < 0.2) ? (1.0) : (1.01));
29 Q[Shortcuts::rhoU + 2] = 0.0;
30 Q[Shortcuts::rhoE] = ((std::sqrt(std::pow(0.5 - x(0), 2) + std::pow(0.5 - x(1), 2) + std::pow(0.5 - x(2), 2)) < 0.2) ? (1.0) : (1.01));
34boundary_conditions =
"""
35 // Reflective boundary conditions
36 Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
37 Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
38 Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
40 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
42 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
45refinement_criterion =
"""
46 auto result = ::exahype2::RefinementCommand::Keep;
49 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5, 0.5};
51 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5};
54 if (tarch::la::equals(t, 0.0)) {
55 if (tarch::la::norm2(x - circleCentre) < 0.1) {
56 result = ::exahype2::RefinementCommand::Refine;
63compute_primitive_variables =
r"""
64 const auto irho = 1.0 / Q[Shortcuts::rho];
65 const auto u0 = Q[Shortcuts::rhoU + 0] * irho;
66 const auto u1 = Q[Shortcuts::rhoU + 1] * irho;
68 const auto u2 = Q[Shortcuts::rhoU + 2] * irho;
72 const auto uSq = u0 * u0 + u1 * u1 + u2 * u2;
73 const auto u_n = (normal == 0) ? u0 : (normal == 1) ? u1 : u2;
75 const auto uSq = u0 * u0 + u1 * u1;
76 const auto u_n = (normal == 0) ? u0 : u1;
79 const auto internalE = Q[Shortcuts::rhoE] - 0.5 * Q[Shortcuts::rho] * uSq;
80 const auto p = (GAMMA - 1.0) * internalE;
84 {compute_primitive_variables}
85 const auto speedOfSound = std::sqrt(GAMMA * p * irho);
86 auto result = std::fmax(0.0, std::fabs(u_n - speedOfSound));
87 result = std::fmax(result, std::fabs(u_n + speedOfSound));
90 compute_primitive_variables=compute_primitive_variables
94 {compute_primitive_variables}
96 F[Shortcuts::rho] = Q[Shortcuts::rhoU + normal];
98 F[Shortcuts::rhoU + 0] = Q[Shortcuts::rhoU + 0] * u_n;
99 F[Shortcuts::rhoU + 1] = Q[Shortcuts::rhoU + 1] * u_n;
101 F[Shortcuts::rhoU + 2] = Q[Shortcuts::rhoU + 2] * u_n;
104 F[Shortcuts::rhoU + normal] += p;
106 F[Shortcuts::rhoE] = (Q[Shortcuts::rhoE] + p) * u_n;
108 compute_primitive_variables=compute_primitive_variables
111fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
113 patch_size=args.degrees_of_freedom,
114 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
115 auxiliary_variables=0,
118 time_step_relaxation=0.5,
119 use_enclave_tasking=args.enclave_tasking,
120 number_of_enclave_tasks=args.ntasks,
123fv_solver.set_implementation(
124 initial_conditions=initial_conditions,
125 boundary_conditions=boundary_conditions,
126 refinement_criterion=refinement_criterion,
127 max_eigenvalue=max_eigenvalue,
131fv_solver.set_solver_precisions(
132 storage_precision=args.precision, compute_precision=args.precision
135project = exahype2.Project(
136 namespace=[
"tests",
"exahype2",
"fv"],
139 executable=
"ExaHyPE",
141project.add_solver(fv_solver)
143if args.number_of_snapshots <= 0:
144 time_in_between_plots = 0.0
146 time_in_between_plots = args.end_time / args.number_of_snapshots
147 project.set_output_path(args.output)
149project.set_global_simulation_parameters(
150 dimensions=args.dimensions,
151 size=[1.0, 1.0, 1.0][0 : args.dimensions],
152 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
153 min_end_time=args.end_time,
154 max_end_time=args.end_time,
155 first_plot_time_stamp=0.0,
156 time_in_between_plots=time_in_between_plots,
158 args.periodic_boundary_conditions_x,
159 args.periodic_boundary_conditions_y,
160 args.periodic_boundary_conditions_z,
164project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
165project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
166project = project.generate_Peano4_project(verbose=
False)
167project.output.makefile.set_target_device(args.target_device)
168project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
169project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)