9 sys.path.insert(0, os.path.abspath(
"../../../../applications/exahype2/shallow-water"))
14 offset = [-5000, -5000]
18 number_of_snapshots = 0
19 build_mode =
"Release"
22 initial_conditions =
"""
23 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
27 constexpr double INITIAL_WATER_HEIGHT = 100.0;
28 constexpr double INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE = -100.0;
30 Q[Shortcuts::h] = INITIAL_WATER_HEIGHT;
32 auto displacementX = [](double x) { return std::sin((x / 500.0 + 1.0) * tarch::la::PI); };
33 auto displacementY = [](double y) { return -std::pow(y / 500.0, 2) + 1.0; };
34 auto displacement = [&](double x, double y) { return 5.0 * displacementX(x) * displacementY(y); };
36 const double bathymetryAfterEarthquake = INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE + displacement(x(0), x(1));
38 if (std::abs(x(0)) <= 500 and std::abs(x(1)) <= 500) { // Center of domain is [0, 0]
39 Q[Shortcuts::z] = bathymetryAfterEarthquake;
41 Q[Shortcuts::z] = INITIAL_BATHYMETRY_BEFORE_EARTHQUAKE;
45 boundary_conditions =
"""
46 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
47 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
48 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
49 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
52 refinement_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;
61 "g": [9.81,
"double"],
62 "hThreshold": [1e-5,
"double"],
65 max_h = 1.1 *
min(size) / (3.0**min_depth)
66 min_h = max_h * 3.0 ** (-amr_levels)
68 aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
71 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
72 auxiliary_variables=0,
75 time_step_relaxation=0.5,
78 aderdg_solver.set_implementation(
79 initial_conditions=initial_conditions,
80 boundary_conditions=boundary_conditions,
81 refinement_criterion=refinement_criterion,
83 ncp=nonconservative_product,
84 max_eigenvalue=eigenvalue +
"""
89 aderdg_solver.add_kernel_optimisations(is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre)
91 project = exahype2.Project(
92 namespace=[
"benchmarks",
"exahype2",
"swe"],
93 project_name=
"ArtificialTsunami",
95 executable=f
"ArtificialTsunami",
97 project.add_solver(aderdg_solver)
99 if number_of_snapshots <= 0:
100 time_in_between_plots = 0.0
102 time_in_between_plots = end_time / number_of_snapshots
103 project.set_output_path(output)
105 project.set_global_simulation_parameters(
109 min_end_time=end_time,
110 max_end_time=end_time,
111 first_plot_time_stamp=0.0,
112 time_in_between_plots=time_in_between_plots,
113 periodic_BC=[
False,
False],
116 project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
117 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(build_mode))
118 project = project.generate_Peano4_project(verbose=
False)
119 for const_name, const_info
in constants.items():
120 const_val, const_type = const_info
121 project.constants.export_constexpr_with_type(
122 const_name,
str(const_val), const_type
124 project.set_fenv_handler(
True)
125 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)