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,
16 number_of_snapshots=0,
18args = parser.parse_args()
20max_h = 1.1 / 3.0**args.min_depth
21min_h = max_h * 3.0 ** (-args.amr_levels)
23initial_conditions =
"""
24 Q[Shortcuts::rho] = 1.0;
25 Q[Shortcuts::rhoU + 0] = 0.0;
26 Q[Shortcuts::rhoU + 1] = 0.0;
28 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));
30 Q[Shortcuts::rhoU + 2] = 0.0;
31 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));
35boundary_conditions =
"""
36 // Reflective boundary conditions
37 Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
38 Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
39 Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
41 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
43 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
46refinement_criterion =
"""
47 auto result = ::exahype2::RefinementCommand::Keep;
50 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5, 0.5};
52 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5};
55 if (tarch::la::equals(t, 0.0)) {
56 if (tarch::la::norm2(x - circleCentre) < 0.1) {
57 result = ::exahype2::RefinementCommand::Refine;
64compute_primitive_variables =
r"""
65 const auto irho = 1.0 / Q[Shortcuts::rho];
66 const auto u0 = Q[Shortcuts::rhoU + 0] * irho;
67 const auto u1 = Q[Shortcuts::rhoU + 1] * irho;
69 const auto u2 = Q[Shortcuts::rhoU + 2] * irho;
73 const auto uSq = u0 * u0 + u1 * u1 + u2 * u2;
74 const auto u_n = (normal == 0) ? u0 : (normal == 1) ? u1 : u2;
76 const auto uSq = u0 * u0 + u1 * u1;
77 const auto u_n = (normal == 0) ? u0 : u1;
80 const auto internalE = Q[Shortcuts::rhoE] - 0.5 * Q[Shortcuts::rho] * uSq;
81 const auto p = (GAMMA - 1.0) * internalE;
85 {compute_primitive_variables}
86 const auto speedOfSound = std::sqrt(GAMMA * p * irho);
87 auto result = std::fmax(0.0, std::fabs(u_n - speedOfSound));
88 result = std::fmax(result, std::fabs(u_n + speedOfSound));
91 compute_primitive_variables=compute_primitive_variables
95 {compute_primitive_variables}
97 F[Shortcuts::rho] = Q[Shortcuts::rhoU + normal];
99 F[Shortcuts::rhoU + 0] = Q[Shortcuts::rhoU + 0] * u_n;
100 F[Shortcuts::rhoU + 1] = Q[Shortcuts::rhoU + 1] * u_n;
102 F[Shortcuts::rhoU + 2] = Q[Shortcuts::rhoU + 2] * u_n;
105 F[Shortcuts::rhoU + normal] += p;
107 F[Shortcuts::rhoE] = (Q[Shortcuts::rhoE] + p) * u_n;
109 compute_primitive_variables=compute_primitive_variables
112fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
114 patch_size=args.degrees_of_freedom,
115 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
116 auxiliary_variables=0,
119 time_step_relaxation=0.5,
120 use_enclave_tasking=args.enclave_tasking,
121 number_of_enclave_tasks=args.ntasks,
124fv_solver.set_implementation(
125 initial_conditions=initial_conditions,
126 boundary_conditions=boundary_conditions,
127 refinement_criterion=refinement_criterion,
128 max_eigenvalue=max_eigenvalue,
132fv_solver.set_solver_precisions(
133 storage_precision=args.precision, compute_precision=args.precision
136project = exahype2.Project(
137 namespace=[
"tests",
"exahype2",
"fv"],
140 executable=
"ExaHyPE",
142project.add_solver(fv_solver)
144if args.number_of_snapshots <= 0:
145 time_in_between_plots = 0.0
147 time_in_between_plots = args.end_time / args.number_of_snapshots
148 project.set_output_path(args.output)
150project.set_global_simulation_parameters(
151 dimensions=args.dimensions,
152 size=[1.0, 1.0, 1.0][0 : args.dimensions],
153 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
154 min_end_time=args.end_time,
155 max_end_time=args.end_time,
156 first_plot_time_stamp=0.0,
157 time_in_between_plots=time_in_between_plots,
159 args.periodic_boundary_conditions_x,
160 args.periodic_boundary_conditions_y,
161 args.periodic_boundary_conditions_z,
165project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
166project.set_Peano4_installation(
167 "../../../", mode=peano4.output.string_to_mode(args.build_mode)
169project = project.generate_Peano4_project(verbose=
False)
170project.set_fenv_handler(args.fpe)
171project.output.makefile.set_target_device(args.target_device)
172project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
173project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)