10sys.path.insert(0, os.path.abspath(
".."))
14initial_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));
38boundary_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];
45refinement_criterion =
"""
46 auto result = ::exahype2::RefinementCommand::Keep;
50limiting_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]) {
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;
87parser = exahype2.ArgumentParser()
91 help=
"Friction parameter.",
96 time_step_relaxation=0.45,
100args = parser.parse_args()
102if args.build_mode ==
"Debug":
106 "g": [9.81,
"double"],
107 "phi": [25.0,
"double"],
108 "invXi": [1.0 / args.friction,
"double"],
109 "hThreshold": [1e-1,
"double"],
112 math.tan(math.pi / 180.0 * constants[
"phi"][0]),
117max_h = 1.1 * min(size) / (3.0**args.min_depth)
118min_h = max_h * 3.0 ** (-args.amr_levels)
119dg_order = args.degrees_of_freedom - 1
121regular_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
124 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
125 auxiliary_variables=0,
128 time_step_relaxation=0.5,
131regular_solver.set_implementation(
132 initial_conditions=initial_conditions,
133 boundary_conditions=boundary_conditions,
134 refinement_criterion=refinement_criterion,
136 ncp=nonconservative_product,
137 max_eigenvalue=eigenvalue
140 return std::fmax(sFlux, h[normal] * sSource);
142 diffusive_source_term=stiff_source_term_aderdg,
143 riemann_solver=rusanov_aderdg,
146regular_solver.set_plotter(args.plotter)
147regular_solver.add_user_solver_includes(
149#include "tarch/reader/NetCDFFieldParser.h"
152regular_solver.add_kernel_optimisations(
154 polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
157limiting_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
159 patch_size=dg_order * 2 + 1,
160 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
161 auxiliary_variables={
"z": 1},
164 time_step_relaxation=0.5,
167limiting_solver.set_implementation(
168 initial_conditions=initial_conditions,
169 boundary_conditions=boundary_conditions,
170 refinement_criterion=refinement_criterion,
172 max_eigenvalue=eigenvalue
176 ncp=nonconservative_product + stiff_nonconservative_product,
177 riemann_solver=rusanov_fv,
178 diffusive_source_term=stiff_source_term_fv,
179 adjust_solution=adjust_solution,
182limiting_solver.set_plotter(args.plotter)
183limiting_solver.add_user_solver_includes(
185#include "tarch/reader/NetCDFFieldParser.h"
189limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
190 name=
"LimiterSolver",
191 regular_solver=regular_solver,
192 limiting_solver=limiting_solver,
193 number_of_dmp_observables=3,
194 dmp_relaxation_parameter=1.0,
195 dmp_differences_scaling=0.01,
196 physical_admissibility_criterion=limiting_criterion,
199project = exahype2.Project(
200 namespace=[
"applications",
"exahype2",
"swe"],
201 project_name=
"TafjordLandslide",
203 executable=
"ExaHyPE-ShallowWater",
206project.add_solver(regular_solver)
207project.add_solver(limiting_solver)
208project.add_solver(limiter_solver)
210if args.number_of_snapshots <= 0:
211 time_in_between_plots = 0.0
213 time_in_between_plots = args.end_time / args.number_of_snapshots
214 project.set_output_path(args.output)
216project.set_global_simulation_parameters(
219 offset=[414895.5, 6904495.5],
220 min_end_time=args.end_time,
221 max_end_time=args.end_time,
222 first_plot_time_stamp=0.0,
223 time_in_between_plots=time_in_between_plots,
225 args.periodic_boundary_conditions_x,
226 args.periodic_boundary_conditions_y,
230project.set_load_balancer(
231 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
233project.set_Peano4_installation(
234 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
236project = project.generate_Peano4_project(verbose=
False)
237for const_name, const_info
in constants.items():
238 const_val, const_type = const_info
239 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
240project.output.makefile.set_target_device(args.target_device)
241project.set_fenv_handler(args.fpe)
242project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)