10sys.path.insert(0, os.path.abspath(
".."))
11from sweargs
import SWEArgumentParser
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 using s = VariableShortcuts;
25 Q[s::h] = x[0] <= 5.0 ? INITIAL_WATER_HEIGHT_DAM : 0.0;
26 Q[s::b] = std::max({0.0, m1, m2, m3});
29boundary_conditions =
"""
30 using s = VariableShortcuts;
31 Qoutside[s::h] = Qinside[s::h];
32 Qoutside[s::hu] = -Qinside[s::hu];
33 Qoutside[s::hv] = -Qinside[s::hv];
34 Qoutside[s::b] = Qinside[s::b];
37refinement_criterion =
"""
38 auto result = ::exahype2::RefinementCommand::Keep;
39 if (x(0) >= 20.0 && x(0) <= 50.0) {
40 result = ::exahype2::RefinementCommand::Refine;
50args = parser.parse_args()
52max_h = (1.1 * min(args.width) / (3.0**args.min_depth))
53min_h = max_h * 3.0 ** (-args.amr_levels)
54args.patch_size = args.dg_order * 2 + 1
56unknowns={
"h": 1,
"hu": 1,
"hv": 1}
57auxiliary_variables={
"b": 1}
59riemann_solver = exahype2.solvers.fv.riemann.GlobalAdaptiveTimeStep(
60 name=
"HLLEM" + str(args.patch_size),
61 patch_size=args.patch_size,
63 auxiliary_variables=auxiliary_variables,
66 time_step_relaxation=args.time_step_relaxation,
67 pde_terms_without_state=args.stateless,
68 initial_conditions=re.sub(
r'\bx\b',
'volumeCentre', initial_conditions),
69 boundary_conditions=boundary_conditions,
70 refinement_criterion=re.sub(
r'\bx\b',
'volumeCentre', refinement_criterion),
71 riemann_solver=
"return applications::exahype2::swe::hllem(QR, QL, FR, FL, LR, LL, xR, xL, h, t, dt, normal, APDQ, AMDQ);",
73riemann_solver.plot_description =
", ".join(unknowns.keys()) +
", "
74riemann_solver.plot_description +=
", ".join(auxiliary_variables.keys())
75riemann_solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
76riemann_solver.add_user_solver_includes(
82project = exahype2.Project(
83 namespace=[
"applications",
"exahype2",
"swe"],
84 project_name=
"ThreeMoundsChannel",
86 executable=f
"ThreeMoundsChannel.{args.build_mode}",
88project.add_solver(riemann_solver)
90if args.number_of_snapshots <= 0:
91 time_in_between_plots = 0.0
93 time_in_between_plots = args.end_time / args.number_of_snapshots
94 project.set_output_path(args.output)
96project.set_global_simulation_parameters(
100 min_end_time=args.end_time,
101 max_end_time=args.end_time,
102 first_plot_time_stamp=0.0,
103 time_in_between_plots=time_in_between_plots,
105 args.periodic_boundary_conditions_x,
106 args.periodic_boundary_conditions_y,
110if args.load_balancing_strategy !=
"None":
111 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
112 assume_periodic_boundary_conditions = any([
113 args.periodic_boundary_conditions_x,
114 args.periodic_boundary_conditions_y,
117 f
"new ::exahype2::LoadBalancingConfiguration("
118 f
"{args.load_balancing_quality},"
120 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
124 project.set_load_balancing(strategy, configuration)
126project.set_number_of_threads(args.threads)
127project.set_timeout(3600)
128project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
129project = project.generate_Peano4_project(verbose=
True)
131 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
133project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
134project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)