9sys.path.insert(0, os.path.abspath(
".."))
10from PDE
import max_eigenvalue, flux
12initial_conditions =
"""
13 constexpr double U0 = 1.0; // Initial amplitude of velocity
14 constexpr double Pressure0 = 100 / GAMMA; // Reference pressure
16 Q[Shortcuts::rho] = 1.0;
17 Q[Shortcuts::rhoU + 0] = U0 * std::sin(x(0)) * std::cos(x(1));
18 Q[Shortcuts::rhoU + 1] = -U0 * std::cos(x(0)) * std::sin(x(1));
20 Q[Shortcuts::rhoU + 2] = 0.0;
23 const double pressure = Pressure0 + (Q[Shortcuts::rho] * U0) * (1.0 / 4.0) * (std::cos(2.0 * x(0)) + std::cos(2.0 * x(1)));
24 // Total energy: internal energy + kinetic energy
25 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]);
28boundary_conditions =
"""
31refinement_criterion =
"""
32 auto result = ::exahype2::RefinementCommand::Keep;
36analytical_solution =
"""
37 constexpr double Viscosity = 1.0;
38 const double C = 100.0 / GAMMA;
40 // Time decay factors for velocity and pressure
41 const double expVelocityFactor = std::exp(-2.0 * Viscosity * t); // Time decay factor for velocity
42 const double expPressureFactor = std::exp(-4.0 * Viscosity * t); // Time decay factor for pressure
44 // Set the initial conditions for the Taylor-Green vortex
45 solution[Shortcuts::rho] = 1.0; // Constant density
47 // Velocity components with time decay
48 solution[Shortcuts::rhoU + 0] = expVelocityFactor * std::sin(x(0)) * std::cos(x(1));
49 solution[Shortcuts::rhoU + 1] = -expVelocityFactor * std::cos(x(0)) * std::sin(x(1));
51 solution[Shortcuts::rhoU + 2] = 0.0;
54 // Pressure with time decay and the given formula
55 double pressure = expPressureFactor * (std::cos(2.0 * x(0)) + std::cos(2.0 * x(1)))*(1.0 / 4.0) + C;
57 // Total energy: internal energy + kinetic energy
58 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]);
61parser = exahype2.ArgumentParser(
"ExaHyPE 2 Euler Taylor-Green Vortex Argument Parser")
64 degrees_of_freedom=16,
65 periodic_boundary_conditions_x=
True,
66 periodic_boundary_conditions_y=
True,
67 periodic_boundary_conditions_z=
True,
69args = parser.parse_args()
71size = [2 * 3.14159265359, 2 * 3.14159265359, 2 * 3.14159265359]
72max_h = 1.1 * min(size) / (3.0**args.min_depth)
73min_h = max_h * 3.0 ** (-args.amr_levels)
75riemann_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
77 patch_size=args.degrees_of_freedom,
78 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
79 auxiliary_variables=0,
82 time_step_relaxation=0.5,
83 use_enclave_tasking=args.enclave_tasking,
84 number_of_enclave_tasks=args.ntasks,
87riemann_solver.set_implementation(
88 initial_conditions=initial_conditions,
89 boundary_conditions=boundary_conditions,
90 refinement_criterion=refinement_criterion,
91 max_eigenvalue=max_eigenvalue,
93 limiter=exahype2.solvers.fv.musclhancock.Limiter.vanalbada,
96riemann_solver.set_plotter(args.plotter)
98exahype2.solvers.fv.ErrorMeasurement(
100 error_measurement_implementation=analytical_solution,
101 output_file_name=
"Error",
104project = exahype2.Project(
105 namespace=[
"applications",
"exahype2",
"euler"],
106 project_name=
"TaylorGreenVortex",
110project.add_solver(riemann_solver)
112if args.number_of_snapshots <= 0:
113 time_in_between_plots = 0.0
115 time_in_between_plots = args.end_time / args.number_of_snapshots
116 project.set_output_path(args.output)
118project.set_global_simulation_parameters(
119 dimensions=args.dimensions,
120 size=size[0 : args.dimensions],
121 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
122 min_end_time=args.end_time,
123 max_end_time=args.end_time,
124 first_plot_time_stamp=0.0,
125 time_in_between_plots=time_in_between_plots,
127 args.periodic_boundary_conditions_x,
128 args.periodic_boundary_conditions_y,
129 args.periodic_boundary_conditions_z,
133project.set_load_balancer(
134 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
136project.set_Peano4_installation(
137 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
139project = project.generate_Peano4_project(verbose=
False)
140project.set_fenv_handler(args.fpe)
141project.output.makefile.set_target_device(args.target_device)
142project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
143project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)