6from PDE
import max_eigenvalue, flux
8initial_conditions =
"""
9 Q[Shortcuts::rho] = 0.02 * (1.0 + std::exp(-0.5 * tarch::la::norm2(x) * tarch::la::norm2(x) / 0.01));
11 Q[Shortcuts::rhoU + 0] = 1.0 * Q[Shortcuts::rho];
12 Q[Shortcuts::rhoU + 1] = 1.0 * Q[Shortcuts::rho];
14 Q[Shortcuts::rhoU + 2] = 1.0 * Q[Shortcuts::rho];
17 const tarch::la::Vector<DIMENSIONS, double> momenta(1.0 * Q[Shortcuts::rho]);
19 // Should lead to a constant pressure over the domain given the initial conditions
20 Q[Shortcuts::rhoE] = PRESSURE / (GAMMA - 1.0) + 0.5 * (momenta * momenta) / Q[Shortcuts::rho];
23analytical_solution =
"""
24 // The initial condition is transported without deformation in a periodic
25 // domain [-.5, +.5], i.e. the value at a given point is the value at the
26 // position x - v*t but accounting for periodicity.
27 // Therefore we find the point x - v*t, and then shift this by instances
28 // of 1.0 until we find the point within the domain.
30 tarch::la::Vector<DIMENSIONS, double> pos = { (x[0] - t) + (int)(t + .5 - x[0]),
31 (x[1] - t) + (int)(t + .5 - x[1]) };
33 tarch::la::Vector<DIMENSIONS, double> pos = { (x[0] - t) + (int)(t + .5 - x[0]),
34 (x[1] - t) + (int)(t + .5 - x[1]),
35 (x[2] - t) + (int)(t + .5 - x[2]) };
38 solution[Shortcuts::rho] = 0.02 * (1.0 + std::exp(-0.5 * tarch::la::norm2(pos) * tarch::la::norm2(pos) / 0.01));
39 solution[Shortcuts::rhoU + 0] = 1.0 * solution[Shortcuts::rho];
40 solution[Shortcuts::rhoU + 1] = 1.0 * solution[Shortcuts::rho];
42 solution[Shortcuts::rhoU + 2] = 1.0 * solution[Shortcuts::rho];
45 const tarch::la::Vector<DIMENSIONS, double> momenta(1.0 * solution[Shortcuts::rho]);
47 // Should lead to a constant p over the domain given the initial conditions
48 solution[Shortcuts::rhoE] = PRESSURE / (GAMMA - 1.0) + 0.5 * (momenta * momenta) / solution[Shortcuts::rho];
51parser = exahype2.ArgumentParser(
"ExaHyPE 2 - Finite Volumes Testing Script")
55 degrees_of_freedom=16,
56 number_of_snapshots=0,
57 periodic_boundary_conditions_x=
True,
58 periodic_boundary_conditions_y=
True,
59 periodic_boundary_conditions_z=
True,
61args = parser.parse_args()
64max_h = 1.1 * min(size) / (3.0**args.min_depth)
65min_h = max_h * 3.0 ** (-args.amr_levels)
67fv_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
68 name=
"MUSCLHancockSolver",
69 patch_size=args.degrees_of_freedom,
70 unknowns={
"rho": 1,
"rhoU": args.dimensions,
"rhoE": 1},
71 auxiliary_variables=0,
74 time_step_relaxation=0.5,
77fv_solver.set_implementation(
78 initial_conditions=initial_conditions,
80 max_eigenvalue=max_eigenvalue,
81 limiter=exahype2.solvers.fv.musclhancock.Limiter.minmod,
84fv_solver.set_plotter(peano4.plotter.VTUPatchAMRPlotter)
86exahype2.solvers.fv.ErrorMeasurement(
88 error_measurement_implementation=analytical_solution,
89 output_file_name=
"Error",
92project = exahype2.Project(
93 namespace=[
"tests",
"exahype2",
"fv"],
94 project_name=
"GaussianBell",
99project.add_solver(fv_solver)
101if args.number_of_snapshots <= 0:
102 time_in_between_plots = 0.0
104 time_in_between_plots = args.end_time / args.number_of_snapshots
105 project.set_output_path(args.output)
107project.set_global_simulation_parameters(
108 dimensions=args.dimensions,
109 size=size[0 : args.dimensions],
110 offset=[-0.5, -0.5, -0.5][0 : args.dimensions],
111 min_end_time=args.end_time,
112 max_end_time=args.end_time,
113 first_plot_time_stamp=0.0,
114 time_in_between_plots=time_in_between_plots,
116 args.periodic_boundary_conditions_x,
117 args.periodic_boundary_conditions_y,
118 args.periodic_boundary_conditions_z,
122project.set_load_balancer(
123 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
125project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
126project = project.generate_Peano4_project(verbose=
False)
127project.output.makefile.set_target_device(args.target_device)
128project.output.makefile.add_CXX_flag(
"-DGAMMA=1.4")
129project.output.makefile.add_CXX_flag(
"-DPRESSURE=1.0")
130project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)