6from PDE
import max_eigenvalue, flux
8initial_conditions =
"""
9 constexpr double U0 = 1.0; // Initial amplitude of velocity
10 constexpr double Pressure0 = 100 / GAMMA; // Reference pressure
12 Q[Shortcuts::rho] = 1.0;
13 Q[Shortcuts::rhoU + 0] = U0 * std::sin(x(0)) * std::cos(x(1));
14 Q[Shortcuts::rhoU + 1] = -U0 * std::cos(x(0)) * std::sin(x(1));
16 Q[Shortcuts::rhoU + 2] = 0.0;
19 const double pressure = Pressure0 + (Q[Shortcuts::rho] * U0) * (1.0 / 4.0) * (std::cos(2.0 * x(0)) + std::cos(2.0 * x(1)));
20 // Total energy: internal energy + kinetic energy
21 Q[Shortcuts::rhoE] = pressure / (GAMMA - 1.0) + 0.5 * (Q[Shortcuts::rhoU + 0] * Q[Shortcuts::rhoU + 0] + Q[Shortcuts::rhoU + 1] * Q[Shortcuts::rhoU + 1]);
24boundary_conditions =
"""
27refinement_criterion =
"""
28 auto result = ::exahype2::RefinementCommand::Keep;
32analytical_solution =
"""
33 constexpr double Viscosity = 1.0;
34 const double C = 100.0 / GAMMA;
36 // Time decay factors for velocity and pressure
37 const double expVelocityFactor = std::exp(-2.0 * Viscosity * t); // Time decay factor for velocity
38 const double expPressureFactor = std::exp(-4.0 * Viscosity * t); // Time decay factor for pressure
40 // Set the initial conditions for the Taylor-Green vortex
41 solution[Shortcuts::rho] = 1.0; // Constant density
43 // Velocity components with time decay
44 solution[Shortcuts::rhoU + 0] = expVelocityFactor * std::sin(x(0)) * std::cos(x(1));
45 solution[Shortcuts::rhoU + 1] = -expVelocityFactor * std::cos(x(0)) * std::sin(x(1));
47 solution[Shortcuts::rhoU + 2] = 0.0;
50 // Pressure with time decay and the given formula
51 double pressure = expPressureFactor * (std::cos(2.0 * x(0)) + std::cos(2.0 * x(1)))*(1.0 / 4.0) + C;
53 // Total energy: internal energy + kinetic energy
54 solution[Shortcuts::rhoE] = pressure / (GAMMA - 1.0) + 0.5 * (Q[Shortcuts::rhoU + 0] * Q[Shortcuts::rhoU + 0] + Q[Shortcuts::rhoU + 1] * Q[Shortcuts::rhoU + 1]);
57parser = exahype2.ArgumentParser(
"ExaHyPE 2 - Finite Volumes Testing Script")
60 degrees_of_freedom=16,
61 number_of_snapshots=0,
62 periodic_boundary_conditions_x=
True,
63 periodic_boundary_conditions_y=
True,
64 periodic_boundary_conditions_z=
True,
66args = parser.parse_args()
68size = [2 * 3.14159265359, 2 * 3.14159265359, 2 * 3.14159265359]
69max_h = 1.1 * min(size) / (3.0**args.min_depth)
70min_h = max_h * 3.0 ** (-args.amr_levels)
72fv_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
74 patch_size=args.degrees_of_freedom,
75 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
76 auxiliary_variables=0,
79 time_step_relaxation=0.5,
80 use_enclave_tasking=args.enclave_tasking,
81 number_of_enclave_tasks=args.ntasks,
84fv_solver.set_implementation(
85 initial_conditions=initial_conditions,
86 boundary_conditions=boundary_conditions,
87 refinement_criterion=refinement_criterion,
88 max_eigenvalue=max_eigenvalue,
90 limiter=exahype2.solvers.fv.musclhancock.Limiter.vanalbada,
93fv_solver.set_plotter(peano4.plotter.VTUPatchAMRPlotter)
95exahype2.solvers.fv.ErrorMeasurement(
97 error_measurement_implementation=analytical_solution,
98 output_file_name=
"Error",
101project = exahype2.Project(
102 namespace=[
"tests",
"exahype2",
"fv"],
103 project_name=
"TaylorGreenVortex",
105 executable=
"ExaHyPE",
107project.add_solver(fv_solver)
109if args.number_of_snapshots <= 0:
110 time_in_between_plots = 0.0
112 time_in_between_plots = args.end_time / args.number_of_snapshots
113 project.set_output_path(args.output)
115project.set_global_simulation_parameters(
116 dimensions=args.dimensions,
117 size=size[0 : args.dimensions],
118 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
119 min_end_time=args.end_time,
120 max_end_time=args.end_time,
121 first_plot_time_stamp=0.0,
122 time_in_between_plots=time_in_between_plots,
124 args.periodic_boundary_conditions_x,
125 args.periodic_boundary_conditions_y,
126 args.periodic_boundary_conditions_z,
130project.set_load_balancer(
131 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
133project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
134project = project.generate_Peano4_project(verbose=
False)
135project.output.makefile.set_target_device(args.target_device)
136project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
137project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)