10sys.path.insert(0, os.path.abspath(
".."))
11from sweargs
import SWEArgumentParser
13initial_conditions =
"""
14 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
18 static tarch::reader::NetCDFFieldParser fieldParser(
19 \"Tafjord_5m_EPSG25832.nc\",
20 \"ini_3.0Mm3_5m_EPSG25832.nc\",
33 using s = VariableShortcuts;
34 Q[s::h] = fieldParser.sampleDisplacement(x(0), x(1));
35 Q[s::b] = fieldParser.sampleTopology(x(0), x(1));
38boundary_conditions =
"""
39 using s = VariableShortcuts;
40 Qoutside[s::h] = Qinside[s::h];
41 Qoutside[s::hu] = -Qinside[s::hu];
42 Qoutside[s::hv] = -Qinside[s::hv];
43 Qoutside[s::b] = Qinside[s::b];
46refinement_criterion =
"""
47 auto result = ::exahype2::RefinementCommand::Keep;
55 offset=[414895.5, 6904495.5],
57args = parser.parse_args()
59max_h = (1.1 * min(args.width) / (3.0**args.min_depth))
60min_h = max_h * 3.0 ** (-args.amr_levels)
61args.patch_size = args.dg_order * 2 + 1
63unknowns={
"h": 1,
"hu": 1,
"hv": 1}
82riemann_solver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep(
83 name=
"Rusanov" + str(args.patch_size),
84 patch_size=args.patch_size,
86 auxiliary_variables=auxiliary_variables,
89 time_step_relaxation=args.time_step_relaxation,
90 pde_terms_without_state=args.stateless,
91 initial_conditions=re.sub(
r'\bx\b',
'volumeCentre', initial_conditions),
92 boundary_conditions=boundary_conditions,
93 refinement_criterion=re.sub(
r'\bx\b',
'volumeCentre', refinement_criterion),
94 flux=
"applications::exahype2::swe::frictionlaws::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
96 using s = VariableShortcuts;
97 BTimesDeltaQ[s::h] = 0.0;
98 BTimesDeltaQ[s::hu] = 0.0;
99 BTimesDeltaQ[s::hv] = 0.0;
100 BTimesDeltaQ[s::hu + normal] += GRAV * Q[s::h] * deltaQ[s::b];
102 eigenvalues=
"return applications::exahype2::swe::frictionlaws::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal);",
103 source_term=
"applications::exahype2::swe::frictionlaws::coulombFriction(Q, volumeCentre, volumeH, t, dt, S);",
105riemann_solver.plot_description =
", ".join(unknowns.keys()) +
", "
106riemann_solver.plot_description +=
", ".join(auxiliary_variables.keys())
107riemann_solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
108riemann_solver.add_user_solver_includes(
111#include "../FrictionLaws.h"
112#include "../ComputeFirstDerivatives.h"
113#include "tarch/reader/NetCDFFieldParser.h"
125project = exahype2.Project(
126 namespace=[
"applications",
"exahype2",
"swe"],
127 project_name=
"TafjordLandslide",
129 executable=f
"TafjordLandslide.{args.build_mode}",
131project.add_solver(riemann_solver)
133if args.number_of_snapshots <= 0:
134 time_in_between_plots = 0.0
136 time_in_between_plots = args.end_time / args.number_of_snapshots
137 project.set_output_path(args.output)
139project.set_global_simulation_parameters(
143 min_end_time=args.end_time,
144 max_end_time=args.end_time,
145 first_plot_time_stamp=0.0,
146 time_in_between_plots=time_in_between_plots,
148 args.periodic_boundary_conditions_x,
149 args.periodic_boundary_conditions_y,
153if args.load_balancing_strategy !=
"None":
154 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
155 assume_periodic_boundary_conditions = any([
156 args.periodic_boundary_conditions_x,
157 args.periodic_boundary_conditions_y,
160 f
"new ::exahype2::LoadBalancingConfiguration("
161 f
"{args.load_balancing_quality},"
163 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
167 project.set_load_balancing(strategy, configuration)
169project.set_number_of_threads(args.threads)
170project.set_timeout(3600)
171project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
172project = project.generate_Peano4_project(verbose=
True)
174 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
176project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
177project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)