9 sys.path.insert(0, os.path.abspath(
".."))
10 from PDE
import max_eigenvalue, flux
12 initial_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];
27 analytical_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];
55 parser = exahype2.ArgumentParser(
56 "ExaHyPE 2 Euler Gaussian Bell Argument Parser"
61 degrees_of_freedom=16,
62 periodic_boundary_conditions_x=
True,
63 periodic_boundary_conditions_y=
True,
64 periodic_boundary_conditions_z=
True,
66 args = parser.parse_args()
68 size = [1.0, 1.0, 1.0]
69 max_h = 1.1 *
min(size) / (3.0**args.min_depth)
70 min_h = max_h * 3.0 ** (-args.amr_levels)
72 riemann_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
73 name=
"MUSCLHancockSolver",
74 patch_size=args.degrees_of_freedom,
75 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
76 auxiliary_variables=0,
79 time_step_relaxation=args.time_step_relaxation,
82 riemann_solver.set_implementation(
83 initial_conditions=initial_conditions,
85 max_eigenvalue=max_eigenvalue,
86 limiter=exahype2.solvers.fv.musclhancock.Limiter.minmod,
89 riemann_solver.set_plotter(args.plotter)
91 exahype2.solvers.fv.ErrorMeasurement(
93 error_measurement_implementation=analytical_solution,
94 output_file_name=
"Error",
97 project = exahype2.Project(
98 namespace=[
"applications",
"exahype2",
"euler"],
99 project_name=
"GaussianBell",
104 project.add_solver(riemann_solver)
106 if args.number_of_snapshots <= 0:
107 time_in_between_plots = 0.0
109 time_in_between_plots = args.end_time / args.number_of_snapshots
110 project.set_output_path(args.output)
112 project.set_global_simulation_parameters(
113 dimensions=args.dimensions,
114 size=size[0 : args.dimensions],
115 offset=[-0.5, -0.5, -0.5][0 : args.dimensions],
116 min_end_time=args.end_time,
117 max_end_time=args.end_time,
118 first_plot_time_stamp=0.0,
119 time_in_between_plots=time_in_between_plots,
121 args.periodic_boundary_conditions_x,
122 args.periodic_boundary_conditions_y,
123 args.periodic_boundary_conditions_z,
127 project.set_load_balancer(
128 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
130 project.set_Peano4_installation(
131 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
133 project = project.generate_Peano4_project(verbose=
False)
134 project.set_fenv_handler(args.fpe)
135 project.output.makefile.set_target_device(args.target_device)
136 project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
137 project.output.makefile.add_CXX_flag(
"-DPRESSURE=1.0")
138 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)