10 sys.path.insert(0, os.path.abspath(
".."))
14 initial_conditions =
"""
15 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
19 static tarch::reader::NetCDFFieldParser fieldParser(
20 \"Tafjord_5m_EPSG25832.nc\",
21 \"ini_3.0Mm3_5m_EPSG25832.nc\",
34 Q[Shortcuts::h] = fieldParser.sampleDisplacement(x(0), x(1));
35 Q[Shortcuts::z] = fieldParser.sampleTopology(x(0), x(1));
38 boundary_conditions =
"""
39 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
40 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
41 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
42 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
45 refinement_criterion =
"""
46 auto result = ::exahype2::RefinementCommand::Keep;
50 limiting_criterion =
"""
52 if (!std::isfinite(Qh)) {
56 // Try not to limit untouched cells initialised with 0.0
57 if ((Qh < hThreshold) and (Qh > -hThreshold)) {
61 // Low values of h are resolved on FV layer
62 if (Qh <= -hThreshold) {
66 // Limit close to boundaries
68 if (std::abs(x[0] - DomainOffset[0]) < h[0] or std::abs(x[0] - DomainOffset[0] - DomainSize[0]) < h[0]) {
72 if (std::abs(x[1] - DomainOffset[1]) < h[1] or std::abs(x[1] - DomainOffset[1] - DomainSize[1]) < h[1]) {
79 adjust_solution =
r"""
80 if (Q[Shortcuts::h] < hThreshold) {
81 Q[Shortcuts::h] = std::fmax(0.0, Q[Shortcuts::h]);
82 Q[Shortcuts::hu] = 0.0;
83 Q[Shortcuts::hv] = 0.0;
87 parser = exahype2.ArgumentParser()
91 help=
"Friction parameter.",
96 time_step_relaxation=0.45,
100 args = parser.parse_args()
103 "g": [9.81,
"double"],
104 "phi": [25.0,
"double"],
105 "invXi": [1.0 / args.friction,
"double"],
106 "hThreshold": [1e-1,
"double"],
109 math.tan(math.pi / 180.0 * constants[
"phi"][0]),
114 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
115 min_h = max_h * 3.0 ** (-args.amr_levels)
116 dg_order = args.degrees_of_freedom - 1
118 regular_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
121 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
122 auxiliary_variables=0,
125 time_step_relaxation=args.time_step_relaxation,
128 regular_solver.set_implementation(
129 initial_conditions=initial_conditions,
130 boundary_conditions=boundary_conditions,
131 refinement_criterion=refinement_criterion,
133 ncp=nonconservative_product,
134 max_eigenvalue=eigenvalue + stiff_eigenvalue +
"""
135 return std::fmax(sFlux, h[normal] * sSource);
137 diffusive_source_term=stiff_source_term_aderdg,
138 riemann_solver=rusanov_aderdg,
141 regular_solver.set_plotter(args.plotter)
142 regular_solver.add_user_solver_includes(
144 #include "tarch/reader/NetCDFFieldParser.h"
147 regular_solver.add_kernel_optimisations(
149 polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
152 limiting_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
154 patch_size=dg_order * 2 + 1,
155 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
156 auxiliary_variables={
"z": 1},
159 time_step_relaxation=args.time_step_relaxation,
162 limiting_solver.set_implementation(
163 initial_conditions=initial_conditions,
164 boundary_conditions=boundary_conditions,
165 refinement_criterion=refinement_criterion,
167 max_eigenvalue=eigenvalue +
"""
170 ncp=nonconservative_product + stiff_nonconservative_product,
171 riemann_solver=rusanov_fv,
172 diffusive_source_term=stiff_source_term_fv,
173 adjust_solution=adjust_solution,
176 limiting_solver.set_plotter(args.plotter)
177 limiting_solver.add_user_solver_includes(
179 #include "tarch/reader/NetCDFFieldParser.h"
183 limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
184 name=
"LimiterSolver",
185 regular_solver=regular_solver,
186 limiting_solver=limiting_solver,
187 number_of_dmp_observables=3,
188 dmp_relaxation_parameter=1.0,
189 dmp_differences_scaling=0.01,
190 physical_admissibility_criterion=limiting_criterion,
193 project = exahype2.Project(
194 namespace=[
"applications",
"exahype2",
"swe"],
195 project_name=
"TafjordLandslide",
197 executable=
"ExaHyPE-ShallowWater",
200 project.add_solver(regular_solver)
201 project.add_solver(limiting_solver)
202 project.add_solver(limiter_solver)
204 if args.number_of_snapshots <= 0:
205 time_in_between_plots = 0.0
207 time_in_between_plots = args.end_time / args.number_of_snapshots
208 project.set_output_path(args.output)
210 project.set_global_simulation_parameters(
213 offset=[414895.5, 6904495.5],
214 min_end_time=args.end_time,
215 max_end_time=args.end_time,
216 first_plot_time_stamp=0.0,
217 time_in_between_plots=time_in_between_plots,
219 args.periodic_boundary_conditions_x,
220 args.periodic_boundary_conditions_y,
224 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
225 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
226 project = project.generate_Peano4_project(verbose=
False)
227 for const_name, const_info
in constants.items():
228 const_val, const_type = const_info
229 project.constants.export_constexpr_with_type(
230 const_name,
str(const_val), const_type
232 project.output.makefile.set_target_device(args.target_device)
233 project.set_fenv_handler(args.fpe)
234 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)