9sys.path.insert(0, os.path.abspath(
".."))
10from PDE
import max_eigenvalue, flux
12initial_conditions =
"""
13 Q[Shortcuts::rho] = 0.02 * (1.0 + std::exp(-0.5 * tarch::la::norm2(x) * tarch::la::norm2(x) / 0.01));
15 Q[Shortcuts::rhoU + 0] = 1.0 * Q[Shortcuts::rho];
16 Q[Shortcuts::rhoU + 1] = 1.0 * Q[Shortcuts::rho];
18 Q[Shortcuts::rhoU + 2] = 1.0 * Q[Shortcuts::rho];
21 const tarch::la::Vector<DIMENSIONS, double> momenta(1.0 * Q[Shortcuts::rho]);
23 // Should lead to a constant pressure over the domain given the initial conditions
24 Q[Shortcuts::rhoE] = PRESSURE / (GAMMA - 1.0) + 0.5 * (momenta * momenta) / Q[Shortcuts::rho];
27analytical_solution =
"""
28 // The initial condition is transported without deformation in a periodic
29 // domain [-.5, +.5], i.e. the value at a given point is the value at the
30 // position x - v*t but accounting for periodicity.
31 // Therefore we find the point x - v*t, and then shift this by instances
32 // of 1.0 until we find the point within the domain.
34 tarch::la::Vector<DIMENSIONS, double> pos = { (x[0] - t) + (int)(t + .5 - x[0]),
35 (x[1] - t) + (int)(t + .5 - x[1]) };
37 tarch::la::Vector<DIMENSIONS, double> pos = { (x[0] - t) + (int)(t + .5 - x[0]),
38 (x[1] - t) + (int)(t + .5 - x[1]),
39 (x[2] - t) + (int)(t + .5 - x[2]) };
42 solution[Shortcuts::rho] = 0.02 * (1.0 + std::exp(-0.5 * tarch::la::norm2(pos) * tarch::la::norm2(pos) / 0.01));
43 solution[Shortcuts::rhoU + 0] = 1.0 * solution[Shortcuts::rho];
44 solution[Shortcuts::rhoU + 1] = 1.0 * solution[Shortcuts::rho];
46 solution[Shortcuts::rhoU + 2] = 1.0 * solution[Shortcuts::rho];
49 const tarch::la::Vector<DIMENSIONS, double> momenta(1.0 * solution[Shortcuts::rho]);
51 // Should lead to a constant p over the domain given the initial conditions
52 solution[Shortcuts::rhoE] = PRESSURE / (GAMMA - 1.0) + 0.5 * (momenta * momenta) / solution[Shortcuts::rho];
55parser = exahype2.ArgumentParser(
"ExaHyPE 2 - Euler Gaussian Bell Argument Parser")
59 degrees_of_freedom=16,
60 periodic_boundary_conditions_x=
True,
61 periodic_boundary_conditions_y=
True,
62 periodic_boundary_conditions_z=
True,
64args = parser.parse_args()
67max_h = 1.1 * min(size) / (3.0**args.min_depth)
68min_h = max_h * 3.0 ** (-args.amr_levels)
70riemann_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
71 name=
"MUSCLHancockSolver",
72 patch_size=args.degrees_of_freedom,
73 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
74 auxiliary_variables=0,
77 time_step_relaxation=0.5,
80riemann_solver.set_implementation(
81 initial_conditions=initial_conditions,
83 max_eigenvalue=max_eigenvalue,
84 limiter=exahype2.solvers.fv.musclhancock.Limiter.minmod,
87riemann_solver.set_plotter(args.plotter)
89exahype2.solvers.fv.ErrorMeasurement(
91 error_measurement_implementation=analytical_solution,
92 output_file_name=
"Error",
95project = exahype2.Project(
96 namespace=[
"applications",
"exahype2",
"euler"],
97 project_name=
"GaussianBell",
102project.add_solver(riemann_solver)
104if args.number_of_snapshots <= 0:
105 time_in_between_plots = 0.0
107 time_in_between_plots = args.end_time / args.number_of_snapshots
108 project.set_output_path(args.output)
110project.set_global_simulation_parameters(
111 dimensions=args.dimensions,
112 size=size[0 : args.dimensions],
113 offset=[-0.5, -0.5, -0.5][0 : args.dimensions],
114 min_end_time=args.end_time,
115 max_end_time=args.end_time,
116 first_plot_time_stamp=0.0,
117 time_in_between_plots=time_in_between_plots,
119 args.periodic_boundary_conditions_x,
120 args.periodic_boundary_conditions_y,
121 args.periodic_boundary_conditions_z,
125project.set_load_balancer(
126 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
128project.set_Peano4_installation(
129 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
131project = project.generate_Peano4_project(verbose=
False)
132project.set_fenv_handler(args.fpe)
133project.output.makefile.set_target_device(args.target_device)
134project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
135project.output.makefile.add_CXX_flag(
"-DPRESSURE=1.0")
136project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)