10sys.path.insert(0, os.path.abspath(
".."))
11from sweargs
import SWEArgumentParser
13initial_conditions =
"""
14 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
18 static constexpr double h0 = 0.32;
19 static constexpr double A = 0.064;
20 static constexpr double xc = 12.5;
21 static constexpr double yc = 15.0;
22 static constexpr double rc = 3.6;
23 const double gamma = std::sqrt((3.0 * A) / (4.0 * h0));
25 auto r = [](double x, double y) {
26 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
29 using s = VariableShortcuts;
30 Q[s::h] = h0 + (A / h0 * std::pow(1.0 / (std::cosh(gamma * (x(0) - 2.5))), 2));
31 Q[s::b] = r(x(0), x(1)) <= rc ? 0.93 * (1.0 - r(x(0), x(1)) / rc) : 0.0;
34boundary_conditions =
"""
35 using s = VariableShortcuts;
36 Qoutside[s::h] = Qinside[s::h];
37 Qoutside[s::hu] = -Qinside[s::hu];
38 Qoutside[s::hv] = -Qinside[s::hv];
39 Qoutside[s::b] = Qinside[s::b];
42refinement_criterion =
"""
43 static constexpr double xc = 12.5;
44 static constexpr double yc = 15.0;
45 static constexpr double rc = 3.6;
47 auto r = [](double x, double y) {
48 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
51 return r(x(0), x(1)) <= rc
52 ? ::exahype2::RefinementCommand::Refine
53 : ::exahype2::RefinementCommand::Keep;
61args = parser.parse_args()
63max_h = (1.1 * min(args.width) / (3.0**args.min_depth))
64min_h = max_h * 3.0 ** (-args.amr_levels)
65args.patch_size = args.dg_order * 2 + 1
67unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"b": 1}
69aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
70 name=
"ADERDG" + str(args.dg_order),
73 auxiliary_variables=0,
76 time_step_relaxation=args.time_step_relaxation,
77 initial_conditions=initial_conditions,
78 boundary_conditions=boundary_conditions,
79 refinement_criterion=refinement_criterion,
80 flux=
"applications::exahype2::swe::flux(Q, x, h, t, dt, normal, F);",
81 ncp=
"applications::exahype2::swe::nonconservativeProduct(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
82 eigenvalues=
"return applications::exahype2::swe::maxEigenvalue(Q, x, h, t, dt, normal);",
84aderdg_solver.plot_description =
", ".join(unknowns.keys())
85aderdg_solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
86aderdg_solver.add_kernel_optimisations(is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre)
87aderdg_solver.add_user_solver_includes(
93project = exahype2.Project(
94 namespace=[
"applications",
"exahype2",
"swe"],
95 project_name=
"CircularIsland",
97 executable=f
"CircularIsland.{args.build_mode}",
99project.add_solver(aderdg_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(
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,
121if args.load_balancing_strategy !=
"None":
122 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
123 assume_periodic_boundary_conditions = any([
124 args.periodic_boundary_conditions_x,
125 args.periodic_boundary_conditions_y,
128 f
"new ::exahype2::LoadBalancingConfiguration("
129 f
"{args.load_balancing_quality},"
131 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
135 project.set_load_balancing(strategy, configuration)
137project.set_number_of_threads(args.threads)
138project.set_timeout(3600)
139project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
140project = project.generate_Peano4_project(verbose=
True)
142 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
144project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
145project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)