6initial_conditions_with_input_file =
"""
7 static tarch::reader::NetCDFFieldParser fieldParser(
8 \"artificial_bath_1000.nc\",
9 \"artificial_displ_1000.nc\",
16 const double bathymetryBeforeEarthquake = fieldParser.sampleTopology(x(0), x(1));
17 const double displacement = fieldParser.sampleDisplacement(x(0), x(1));
18 const double bathymetryAfterEarthquake = bathymetryBeforeEarthquake + displacement;
20 Q[Shortcuts::h] = -std::min(bathymetryBeforeEarthquake, 0.0);
21 Q[Shortcuts::hu] = 0.0;
22 Q[Shortcuts::hv] = 0.0;
23 Q[Shortcuts::z] = bathymetryAfterEarthquake;
26initial_conditions_without_input_file =
"""
27 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
31 constexpr double InitialWaterHeight = 100.0;
32 constexpr double InitialBathymetryBeforeEarthquake = -100.0;
34 Q[Shortcuts::h] = InitialWaterHeight;
36 auto displacementX = [](double x) { return std::sin((x / 500.0 + 1.0) * tarch::la::PI); };
37 auto displacementY = [](double y) { return -std::pow(y / 500.0, 2) + 1.0; };
38 auto displacement = [&](double x, double y) { return 5.0 * displacementX(x) * displacementY(y); };
40 const double bathymetryAfterEarthquake = InitialBathymetryBeforeEarthquake + displacement(x(0), x(1));
42 // Assumes offset to be [-5000, -5000]
43 if (std::abs(x(0)) <= 500 and std::abs(x(1)) <= 500) { // Center of domain is [0, 0]
44 Q[Shortcuts::z] = bathymetryAfterEarthquake;
46 Q[Shortcuts::z] = InitialBathymetryBeforeEarthquake;
50boundary_conditions =
"""
51 Qoutside[0] = Qinside[0];
54 Qoutside[3] = Qinside[3];
57refinement_criterion =
"""
58 auto result = ::exahype2::RefinementCommand::Keep;
59 //if (std::abs(x(0)) <= 500 and std::abs(x(1)) <= 500) { // Center of domain is [0, 0]
60 if (x[0] >= 4500.0 && x[1] >= 4500.0 && x[0] <= 5500.0 && x[1] <= 5500.0) {
61 result = ::exahype2::RefinementCommand::Refine;
66parser = exahype2.ArgumentParser()
71args = parser.parse_args()
74 "g": [9.81,
"double"],
75 "hThreshold": [1e-5,
"double"],
80size = [10000.0, 10000.0]
81max_h = 1.1 * min(size) / (3.0**args.min_depth)
82min_h = max_h * 3.0 ** (-args.amr_levels)
84aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
86 order=args.degrees_of_freedom,
87 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
88 auxiliary_variables=0,
91 time_step_relaxation=0.5,
94aderdg_solver.set_implementation(
95 initial_conditions=initial_conditions_with_input_file,
96 boundary_conditions=boundary_conditions,
97 refinement_criterion=refinement_criterion,
98 flux=f
"ShallowWater::flux<double, Shortcuts, {aderdg_solver.unknowns}>(Q, x, h, t, dt, normal, F);",
99 max_eigenvalue=
"return ShallowWater::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
100 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
103aderdg_solver.add_kernel_optimisations(
104 is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
106aderdg_solver.add_user_solver_includes(
109#include "tarch/reader/NetCDFFieldParser.h"
113project = exahype2.Project(
114 namespace=[
"applications",
"exahype2",
"ShallowWater"],
115 project_name=
"ArtificialTsunami",
117 executable=
"ExaHyPE",
119project.add_solver(aderdg_solver)
121if args.number_of_snapshots <= 0:
122 time_in_between_plots = 0.0
124 time_in_between_plots = args.end_time / args.number_of_snapshots
125 project.set_output_path(args.output)
127project.set_global_simulation_parameters(
131 min_end_time=args.end_time,
132 max_end_time=args.end_time,
133 first_plot_time_stamp=0.0,
134 time_in_between_plots=time_in_between_plots,
136 args.periodic_boundary_conditions_x,
137 args.periodic_boundary_conditions_y,
141project.set_load_balancer(
142 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
144project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
145project = project.generate_Peano4_project(verbose=
False)
146for const_name, const_info
in constants.items():
147 const_val, const_type = const_info
148 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
149project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)