9sys.path.insert(0, os.path.abspath(
".."))
11from HLLEM
import hllem
13initial_conditions =
"""
14 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
18 constexpr double INITIAL_WATER_HEIGHT_DAM = 0.9;
20 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));
21 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));
22 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));
24 Q[Shortcuts::h] = x[0] <= 5.0 ? INITIAL_WATER_HEIGHT_DAM : 0.0;
25 Q[Shortcuts::z] = std::max({0.0, m1, m2, m3});
28boundary_conditions =
"""
29 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
30 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
31 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
32 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
35refinement_criterion =
"""
36 auto result = ::exahype2::RefinementCommand::Keep;
37 if (x(0) >= 20.0 && x(0) <= 50.0) {
38 result = ::exahype2::RefinementCommand::Refine;
43parser = exahype2.ArgumentParser()
48args = parser.parse_args()
51 "g": [9.81,
"double"],
52 "hThreshold": [1e-5,
"double"],
56max_h = 1.1 * min(size) / (3.0**args.min_depth)
57min_h = max_h * 3.0 ** (-args.amr_levels)
59fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
61 patch_size=args.degrees_of_freedom,
62 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
63 auxiliary_variables={
"z": 1},
66 time_step_relaxation=0.5,
69fv_solver.set_implementation(
70 initial_conditions=initial_conditions,
71 boundary_conditions=boundary_conditions,
72 refinement_criterion=refinement_criterion,
76fv_solver.set_plotter(args.plotter)
78project = exahype2.Project(
79 namespace=[
"applications",
"exahype2",
"swe"],
80 project_name=
"ThreeMoundsChannel",
82 executable=
"ExaHyPE-ShallowWater",
84project.add_solver(fv_solver)
86if args.number_of_snapshots <= 0:
87 time_in_between_plots = 0.0
89 time_in_between_plots = args.end_time / args.number_of_snapshots
90 project.set_output_path(args.output)
92project.set_global_simulation_parameters(
96 min_end_time=args.end_time,
97 max_end_time=args.end_time,
98 first_plot_time_stamp=0.0,
99 time_in_between_plots=time_in_between_plots,
101 args.periodic_boundary_conditions_x,
102 args.periodic_boundary_conditions_y,
106project.set_load_balancer(
107 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
109project.set_Peano4_installation(
110 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
112project = project.generate_Peano4_project(verbose=
False)
113for const_name, const_info
in constants.items():
114 const_val, const_type = const_info
115 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
116project.set_fenv_handler(args.fpe)
117project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)