8initial_conditions =
"""
9 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
13 static tarch::reader::NetCDFFieldParser fieldParser(
14 \"Tafjord_5m_EPSG25832.nc\",
15 \"ini_3.0Mm3_5m_EPSG25832.nc\",
28 Q[Shortcuts::h] = fieldParser.sampleDisplacement(x(0), x(1));
29 Q[Shortcuts::z] = fieldParser.sampleTopology(x(0), x(1));
32boundary_conditions =
"""
33 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
34 Qoutside[i] = Qinside[i];
38refinement_criterion =
"""
39 auto result = ::exahype2::RefinementCommand::Keep;
43limiting_criterion =
"""
45 if (!std::isfinite(Qh)) {
49 // Try not to limit untouched cells initialised with 0.0
50 if ((Qh < hThreshold) and (Qh > -hThreshold)) {
54 // Low values of h are resolved on FV layer
55 if (Qh <= -hThreshold) {
59 // Limit close to boundaries
61 if (std::abs(x[0] - DomainOffset[0]) < h[0] or std::abs(x[0] - DomainOffset[0] - DomainSize[0]) < h[0]) {
65 if (std::abs(x[1] - DomainOffset[1]) < h[1] or std::abs(x[1] - DomainOffset[1] - DomainSize[1]) < h[1]) {
73 if (Q[Shortcuts::h] < hThreshold) {
74 Q[Shortcuts::h] = std::fmax(0.0, Q[Shortcuts::h]);
75 Q[Shortcuts::hu] = 0.0;
76 Q[Shortcuts::hv] = 0.0;
80parser = exahype2.ArgumentParser()
84 help=
"Friction parameter.",
92args = parser.parse_args()
94if args.build_mode ==
"Debug":
98 "g": [9.81,
"double"],
99 "phi": [25.0,
"double"],
100 "invXi": [1.0 / args.friction,
"double"],
101 "hThreshold": [1e-1,
"double"],
104 math.tan(math.pi / 180.0 * constants[
"phi"][0]),
109max_h = 1.1 * min(size) / (3.0**args.min_depth)
110min_h = max_h * 3.0 ** (-args.amr_levels)
111dg_order = args.degrees_of_freedom - 1
113aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
116 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
117 auxiliary_variables=0,
120 time_step_relaxation=0.20,
123aderdg_solver.set_implementation(
124 initial_conditions=initial_conditions,
125 boundary_conditions=boundary_conditions,
126 refinement_criterion=refinement_criterion,
127 flux=f
"ShallowWater::flux<double, Shortcuts, {aderdg_solver.unknowns}>(Q, x, h, t, dt, normal, F);",
128 max_eigenvalue=
"return FrictionLaws::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
129 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
130 diffusive_source_term=f
"FrictionLaws::sourceTermADERDG<double, Shortcuts, {aderdg_solver.unknowns}, {aderdg_solver.auxiliary_variables}>(Q, deltaQ, x, h, t, dt, S);",
131 riemann_solver=f
"rusanovRiemannSolverADERDG<double, Shortcuts, kernels::{aderdg_solver.name}::Quadrature<double>, {aderdg_solver.unknowns}, {aderdg_solver.auxiliary_variables}, {aderdg_solver.order}>(QL, QR, x, h, t, dt, direction, FL, FR);",
134aderdg_solver.add_kernel_optimisations(
135 is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
137aderdg_solver.add_user_solver_includes(
140#include "../FrictionLaws.h"
141#include "../RusanovRiemannSolver.h"
142#include "tarch/reader/NetCDFFieldParser.h"
146fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
148 patch_size=dg_order * 2 + 1,
149 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
150 auxiliary_variables={
"z": 1},
153 time_step_relaxation=0.20,
156fv_solver.set_implementation(
157 initial_conditions=initial_conditions,
158 boundary_conditions=boundary_conditions,
159 refinement_criterion=refinement_criterion,
160 adjust_solution=adjust_solution,
161 diffusive_source_term=f
"FrictionLaws::sourceTermFV<double, Shortcuts, {fv_solver.unknowns}, {fv_solver.auxiliary_variables}>(Q, deltaQ, x, h, t, dt, S);",
162 riemann_solver=f
"return rusanovRiemannSolverFV<double, Shortcuts, {fv_solver.unknowns}, {fv_solver.auxiliary_variables}>(QL, QR, x, h, t, dt, normal, FL, FR);",
165fv_solver.add_user_solver_includes(
168#include "../FrictionLaws.h"
169#include "../RusanovRiemannSolver.h"
170#include "tarch/reader/NetCDFFieldParser.h"
174limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
175 name=
"LimiterSolver",
176 regular_solver=aderdg_solver,
177 limiting_solver=fv_solver,
178 number_of_dmp_observables=3,
179 dmp_relaxation_parameter=0.001,
180 dmp_differences_scaling=0.0001,
181 physical_admissibility_criterion=limiting_criterion,
184project = exahype2.Project(
185 namespace=[
"applications",
"exahype2",
"ShallowWater"],
186 project_name=
"TafjordLandslide",
188 executable=
"ExaHyPE",
191fv_solver.set_plotter(peano4.plotter.NetCDFPatchAMRPlotter)
192aderdg_solver.set_plotter(peano4.plotter.NetCDFPatchNodalPlotter)
194project.add_solver(aderdg_solver)
195project.add_solver(fv_solver)
196project.add_solver(limiter_solver)
198if args.number_of_snapshots <= 0:
199 time_in_between_plots = 0.0
201 time_in_between_plots = args.end_time / args.number_of_snapshots
202 project.set_output_path(args.output)
204project.set_global_simulation_parameters(
207 offset=[414895.5, 6904495.5],
208 min_end_time=args.end_time,
209 max_end_time=args.end_time,
210 first_plot_time_stamp=0.0,
211 time_in_between_plots=time_in_between_plots,
213 args.periodic_boundary_conditions_x,
214 args.periodic_boundary_conditions_y,
218project.set_load_balancer(
219 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
221project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
222project = project.generate_Peano4_project(verbose=
False)
223for const_name, const_info
in constants.items():
224 const_val, const_type = const_info
225 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
226project.output.makefile.set_target_device(args.target_device)
227project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)