9 sys.path.insert(0, os.path.abspath(
".."))
10 from HLLEM
import hllem
12 initial_conditions =
"""
13 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
17 constexpr double INITIAL_WATER_HEIGHT_DAM = 0.9;
19 const double m1 = 1.0 - 0.10 * std::sqrt((x(0) - 15.0) * (x(0) - 15.0) + (x(1) - 22.5) * (x(1) - 22.5));
20 const double m2 = 1.0 - 0.10 * std::sqrt((x(0) - 15.0) * (x(0) - 15.0) + (x(1) - 7.50) * (x(1) - 7.50));
21 const double m3 = 1.0 - 0.28 * std::sqrt((x(0) - 30.0) * (x(0) - 30.0) + (x(1) - 15.0) * (x(1) - 15.0));
23 Q[Shortcuts::h] = x[0] <= 5.0 ? INITIAL_WATER_HEIGHT_DAM : 0.0;
24 Q[Shortcuts::z] = std::max({0.0, m1, m2, m3});
27 boundary_conditions =
"""
28 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
29 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
30 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
31 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
34 refinement_criterion =
"""
35 auto result = ::exahype2::RefinementCommand::Keep;
36 if (x(0) >= 20.0 && x(0) <= 50.0) {
37 result = ::exahype2::RefinementCommand::Refine;
42 parser = exahype2.ArgumentParser()
47 args = parser.parse_args()
50 "g": [9.81,
"double"],
51 "hThreshold": [1e-5,
"double"],
55 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
56 min_h = max_h * 3.0 ** (-args.amr_levels)
58 fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
60 patch_size=args.degrees_of_freedom,
61 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
62 auxiliary_variables={
"z": 1},
65 time_step_relaxation=args.time_step_relaxation,
68 fv_solver.set_implementation(
69 initial_conditions=initial_conditions,
70 boundary_conditions=boundary_conditions,
71 refinement_criterion=refinement_criterion,
75 fv_solver.set_plotter(args.plotter)
77 project = exahype2.Project(
78 namespace=[
"applications",
"exahype2",
"swe"],
79 project_name=
"ThreeMoundsChannel",
81 executable=
"ExaHyPE-ShallowWater",
83 project.add_solver(fv_solver)
85 if args.number_of_snapshots <= 0:
86 time_in_between_plots = 0.0
88 time_in_between_plots = args.end_time / args.number_of_snapshots
89 project.set_output_path(args.output)
91 project.set_global_simulation_parameters(
95 min_end_time=args.end_time,
96 max_end_time=args.end_time,
97 first_plot_time_stamp=0.0,
98 time_in_between_plots=time_in_between_plots,
100 args.periodic_boundary_conditions_x,
101 args.periodic_boundary_conditions_y,
105 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
106 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
107 project = project.generate_Peano4_project(verbose=
False)
108 for const_name, const_info
in constants.items():
109 const_val, const_type = const_info
110 project.constants.export_constexpr_with_type(
111 const_name,
str(const_val), const_type
113 project.set_fenv_handler(args.fpe)
114 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)