16load_balancing_strategy=
"SpreadOutOnceGridStagnates"
17load_balancing_quality=0.99
20initial_conditions =
"""
21 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
25 constexpr double INITIAL_WATER_HEIGHT = 100.0;
26 constexpr double INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE = -100.0;
28 using s = VariableShortcuts;
29 Q[s::h] = INITIAL_WATER_HEIGHT;
31 auto displacementX = [](double x) { return std::sin((x / 500.0 + 1.0) * std::numbers::pi); };
32 auto displacementY = [](double y) { return -std::pow(y / 500.0, 2) + 1.0; };
33 auto displacement = [&](double x, double y) { return 5.0 * displacementX(x) * displacementY(y); };
35 const double bathymetryAfterEarthquake = INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE + displacement(x(0), x(1));
37 if (std::abs(x(0)) <= 500 and std::abs(x(1)) <= 500) { // Center of domain is [0, 0]
38 Q[s::b] = bathymetryAfterEarthquake;
40 Q[s::b] = INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE;
44boundary_conditions =
"""
45 using s = VariableShortcuts;
46 Qoutside[s::h] = Qinside[s::h];
47 Qoutside[s::hu] = -Qinside[s::hu];
48 Qoutside[s::hv] = -Qinside[s::hv];
49 Qoutside[s::b] = Qinside[s::b];
52refinement_criterion =
"""
53 auto result = ::exahype2::RefinementCommand::Keep;
54 if (std::abs(x(0)) <= 500 and std::abs(x(1)) <= 500) { // Center of domain is [0, 0]
55 result = ::exahype2::RefinementCommand::Refine;
60max_h = (1.1 * min(width) / (3.0**min_depth))
61min_h = max_h * 3.0 ** (-amr_levels)
63aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
64 name=
"ADERDG" + str(dg_order),
66 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"b": 1},
67 auxiliary_variables=0,
70 time_step_relaxation=0.5,
71 initial_conditions=initial_conditions,
72 boundary_conditions=boundary_conditions,
73 refinement_criterion=refinement_criterion,
74 flux=
"applications::exahype2::swe::flux(Q, x, h, t, dt, normal, F);",
75 ncp=
"applications::exahype2::swe::nonconservativeProduct(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
76 eigenvalues=
"return applications::exahype2::swe::maxEigenvalue(Q, x, h, t, dt, normal);",
78aderdg_solver.plot_description =
", ".join({
"h": 1,
"hu": 1,
"hv": 1,
"b": 1}.keys())
79aderdg_solver.switch_storage_scheme(exahype2.solvers.Storage[storage], exahype2.solvers.Storage[storage])
80aderdg_solver.add_kernel_optimisations(is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre)
81aderdg_solver.add_user_solver_includes(
83#include "../../../../applications/exahype2/shallow-water/SWE.h"
87project = exahype2.Project(
88 namespace=[
"benchmarks",
"exahype2",
"swe"],
89 project_name=
"ArtificialTsunami",
91 executable=f
"ArtificialTsunami.{build_mode}",
93project.add_solver(aderdg_solver)
95if number_of_snapshots <= 0:
96 time_in_between_plots = 0.0
98 time_in_between_plots = end_time / number_of_snapshots
99 project.set_output_path(output)
101project.set_global_simulation_parameters(
105 min_end_time=end_time,
106 max_end_time=end_time,
107 first_plot_time_stamp=0.0,
108 time_in_between_plots=time_in_between_plots,
109 periodic_BC=[
False,
False]
112if load_balancing_strategy !=
"None":
113 strategy = f
"toolbox::loadbalancing::strategies::{load_balancing_strategy}"
115 f
"new ::exahype2::LoadBalancingConfiguration("
116 f
"{load_balancing_quality},"
122 project.set_load_balancing(strategy, configuration)
124project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(build_mode))
125project = project.generate_Peano4_project(verbose=
True)
126project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
128project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
129project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)