10sys.path.insert(0, os.path.abspath(
".."))
11from sweargs
import SWEArgumentParser
15initial_conditions =
"""
16 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
20 using s = VariableShortcuts;
21 const tarch::la::Vector<Dimensions, double>& granularMaterialCenter = { 0.15, 0.35 };
22 const bool nearCentre = tarch::la::norm2(x - granularMaterialCenter) < 0.10;
23 Q[s::h] = (nearCentre ? 0.008 : 0.000); // Granular material height (h)
26boundary_conditions =
"""
27 using s = VariableShortcuts;
28 Qoutside[s::h] = Qinside[s::h];
29 Qoutside[s::hu] = -Qinside[s::hu];
30 Qoutside[s::hv] = -Qinside[s::hv];
31 Qoutside[s::b] = Qinside[s::b];
34refinement_criterion =
"""
35 auto result = ::exahype2::RefinementCommand::Keep;
37 const tarch::la::Vector<Dimensions, double>& granularMaterialCenter = { 0.15, 0.35 };
38 const bool nearCentre = tarch::la::norm2(x - granularMaterialCenter) < 0.10;
39 if (tarch::la::equals(t, 0.0) and nearCentre) {
40 result = ::exahype2::RefinementCommand::Refine;
51args = parser.parse_args()
53max_h = (1.1 * min(args.width) / (3.0**args.min_depth))
54min_h = max_h * 3.0 ** (-args.amr_levels)
55args.patch_size = args.dg_order * 2 + 1
57unknowns={
"h": 1,
"hu": 1,
"hv": 1}
76riemann_solver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep(
77 name=
"Rusanov" + str(args.patch_size),
78 patch_size=args.patch_size,
80 auxiliary_variables=auxiliary_variables,
83 time_step_relaxation=args.time_step_relaxation,
84 pde_terms_without_state=args.stateless,
85 initial_conditions=re.sub(
r'\bx\b',
'volumeCentre', initial_conditions),
86 boundary_conditions=boundary_conditions,
87 refinement_criterion=re.sub(
r'\bx\b',
'volumeCentre', refinement_criterion),
88 flux=
"applications::exahype2::swe::frictionlaws::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
89 ncp=
"applications::exahype2::swe::frictionlaws::nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BTimesDeltaQ);",
90 eigenvalues=
"applications::exahype2::swe::frictionlaws::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, maxEigenvalue);",
91 source_term=
"applications::exahype2::swe::frictionlaws::materialDependentBasalFriction(Q, volumeCentre, volumeH, t, dt, S);",
93riemann_solver.plot_description =
", ".join(unknowns.keys()) +
", "
94riemann_solver.plot_description +=
", ".join(auxiliary_variables.keys())
95riemann_solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
96riemann_solver.add_user_solver_includes(
99#include "../FrictionLaws.h"
100#include "../ComputeFirstDerivatives.h"
103riemann_solver._preprocess_reconstructed_patch =
"""
104 extrapolateHalo<{NumberOfDofs}, {NumberOfUnknowns}, {NumberOfAuxiliaryVariables}>(oldQWithHalo);
105 computeFirstDerivatives<{NumberOfDofs}, {NumberOfUnknowns}, {NumberOfAuxiliaryVariables}>(oldQWithHalo);
107 NumberOfDofs=args.patch_size,
108 NumberOfUnknowns=sum(unknowns.values()),
109 NumberOfAuxiliaryVariables=sum(auxiliary_variables.values()),
112project = exahype2.Project(
113 namespace=[
"applications",
"exahype2",
"swe"],
114 project_name=
"DamBreakLandslide",
116 executable=f
"DamBreakLandslide.{args.build_mode}",
118project.add_solver(riemann_solver)
120if args.number_of_snapshots <= 0:
121 time_in_between_plots = 0.0
123 time_in_between_plots = args.end_time / args.number_of_snapshots
124 project.set_output_path(args.output)
126project.set_global_simulation_parameters(
130 min_end_time=args.end_time,
131 max_end_time=args.end_time,
132 first_plot_time_stamp=0.0,
133 time_in_between_plots=time_in_between_plots,
135 args.periodic_boundary_conditions_x,
136 args.periodic_boundary_conditions_y,
140if args.load_balancing_strategy !=
"None":
141 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
142 assume_periodic_boundary_conditions = any([
143 args.periodic_boundary_conditions_x,
144 args.periodic_boundary_conditions_y,
147 f
"new ::exahype2::LoadBalancingConfiguration("
148 f
"{args.load_balancing_quality},"
150 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
154 project.set_load_balancing(strategy, configuration)
156project.set_number_of_threads(args.threads)
157project.set_timeout(3600)
158project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
159project = project.generate_Peano4_project(verbose=
True)
161 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
163project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
164project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)