10sys.path.insert(0, os.path.abspath(
".."))
11from sweargs
import SWEArgumentParser
13initial_conditions =
"""
14 const double omega = sqrt(0.2 * GRAV);
16 using s = VariableShortcuts;
18 Q[s::b] = 0.1 * (std::pow(x[0], 2) + std::pow(x[1], 2));
19 Q[s::h] = std::fmax(0.0, 0.05 * (2 * x[0] * std::cos(omega * 0) + 2 * x[1] * std::sin(omega * 0)) + 0.075 - Q[s::b]);
20 Q[s::hu] = 0.5 * omega * std::sin(omega * 0) * Q[s::h];
21 Q[s::hv] = 0.5 * omega * std::cos(omega * 0) * Q[s::h];
23 //Q[s::h] = 0.025 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1))));
24 //Q[s::b] = -0.2 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1)))) - 0.1;
27boundary_conditions =
"""
28 using s = VariableShortcuts;
29 Qoutside[s::h] = Qinside[s::h];
30 Qoutside[s::hu] = -Qinside[s::hu];
31 Qoutside[s::hv] = -Qinside[s::hv];
32 Qoutside[s::b] = Qinside[s::b];
35refinement_criterion =
"""
36 return std::sqrt((x(0) * x(0)) + (x(1) * x(1))) <= 1.0
37 ? ::exahype2::RefinementCommand::Refine
38 : ::exahype2::RefinementCommand::Keep;
47args = parser.parse_args()
49max_h = (1.1 * min(args.width) / (3.0**args.min_depth))
50min_h = max_h * 3.0 ** (-args.amr_levels)
51args.patch_size = args.dg_order * 2 + 1
53unknowns={
"h": 1,
"hu": 1,
"hv": 1}
54auxiliary_variables={
"b": 1}
56riemann_solver = exahype2.solvers.fv.riemann.GlobalAdaptiveTimeStep(
57 name=
"HLLEM" + str(args.patch_size),
58 patch_size=args.patch_size,
60 auxiliary_variables=auxiliary_variables,
63 time_step_relaxation=args.time_step_relaxation,
64 pde_terms_without_state=args.stateless,
65 initial_conditions=re.sub(
r'\bx\b',
'volumeCentre', initial_conditions),
66 boundary_conditions=boundary_conditions,
67 refinement_criterion=re.sub(
r'\bx\b',
'volumeCentre', refinement_criterion),
68 riemann_solver=
"return applications::exahype2::swe::hllem(QR, QL, FR, FL, LR, LL, xR, xL, h, t, dt, normal, APDQ, AMDQ);",
70riemann_solver.plot_description =
", ".join(unknowns.keys()) +
", "
71riemann_solver.plot_description +=
", ".join(auxiliary_variables.keys())
72riemann_solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
73riemann_solver.add_user_solver_includes(
79project = exahype2.Project(
80 namespace=[
"applications",
"exahype2",
"swe"],
81 project_name=
"OscillatingLake",
83 executable=f
"OscillatingLake.{args.build_mode}",
85project.add_solver(riemann_solver)
87if args.number_of_snapshots <= 0:
88 time_in_between_plots = 0.0
90 time_in_between_plots = args.end_time / args.number_of_snapshots
91 project.set_output_path(args.output)
93project.set_global_simulation_parameters(
97 min_end_time=args.end_time,
98 max_end_time=args.end_time,
99 first_plot_time_stamp=0.0,
100 time_in_between_plots=time_in_between_plots,
102 args.periodic_boundary_conditions_x,
103 args.periodic_boundary_conditions_y,
107if args.load_balancing_strategy !=
"None":
108 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
109 assume_periodic_boundary_conditions = any([
110 args.periodic_boundary_conditions_x,
111 args.periodic_boundary_conditions_y,
114 f
"new ::exahype2::LoadBalancingConfiguration("
115 f
"{args.load_balancing_quality},"
117 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
121 project.set_load_balancing(strategy, configuration)
123project.set_number_of_threads(args.threads)
124project.set_timeout(3600)
125project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
126project = project.generate_Peano4_project(verbose=
True)
128 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
130project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
131project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)