10initial_conditions =
"""
11 // Determine the position of the material region
12 bool insideTheSquare{true};
13 insideTheSquare &= (x[0] >= (initCenterX - squareSide * 0.5));
14 insideTheSquare &= (x[0] <= (initCenterX + squareSide * 0.5));
15 insideTheSquare &= (x[1] >= (initCenterY - squareSide * 0.5));
16 insideTheSquare &= (x[1] <= (initCenterY + squareSide * 0.5));
18 // Assign initial conditions based on the position of the material region
19 Q[Shortcuts::h] = (insideTheSquare ? initHeight : 0.0);
20 Q[Shortcuts::hu] = 0.0;
21 Q[Shortcuts::hv] = 0.0;
22 Q[Shortcuts::z] = (DomainSize[0] - x[0]) * slopeAngleTan;
25boundary_conditions =
"""
26 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
27 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
28 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
29 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
32refinement_criterion =
"""
33 auto result = ::exahype2::RefinementCommand::Keep;
37limiting_criterion =
"""
38 const double Qh{Q[0]};
39 if (!std::isfinite(Qh)) {
43 // Try not to limit untouched cells initialised with 0.0
44 if ((Qh < hThreshold) and (Qh > -hThreshold)) {
48 // Low values of h are resolved on FV layer
49 if (Qh <= -hThreshold) {
53 // Limit close to boundaries
55 if (std::abs(x[0] - DomainOffset[0]) < h[0] or std::abs(x[0] - DomainOffset[0] - DomainSize[0]) < h[0]) {
59 if (std::abs(x[1] - DomainOffset[1]) < h[1] or std::abs(x[1] - DomainOffset[1] - DomainSize[1]) < h[1]) {
67 if (Q[Shortcuts::h] < hThreshold) {
68 Q[Shortcuts::h] = std::fmax(0.0, Q[Shortcuts::h]);
69 Q[Shortcuts::hu] = 0.0;
70 Q[Shortcuts::hv] = 0.0;
74parser = exahype2.ArgumentParser()
80args = parser.parse_args()
82if args.build_mode ==
"Debug":
86 "g": [9.81,
"double"],
87 "phi": [25.0,
"double"],
88 "invXi": [1.0 / 200.0,
"double"],
89 "slopeAngleTan": [math.tan(math.pi / 180.0 * 35.0),
"double"],
90 "initCenterX": [0.15,
"double"],
91 "initCenterY": [0.79,
"double"],
92 "squareSide": [0.1,
"double"],
93 "initHeight": [0.1,
"double"],
95problem_constants[
"hThreshold"] = [problem_constants[
"initHeight"][0] * 1e-3,
"double"]
96problem_constants[
"mu"] = [
97 math.tan(math.pi / 180.0 * problem_constants[
"phi"][0]),
102max_h = 1.1 * min(size) / (3.0**args.min_depth)
103min_h = max_h * 3.0 ** (-args.amr_levels)
104dg_order = args.degrees_of_freedom - 1
106aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
109 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
110 auxiliary_variables=0,
113 time_step_relaxation=0.45,
116aderdg_solver.set_implementation(
117 initial_conditions=initial_conditions,
118 boundary_conditions=boundary_conditions,
119 refinement_criterion=refinement_criterion,
120 flux=f
"ShallowWater::flux<double, Shortcuts, {aderdg_solver.unknowns}>(Q, x, h, t, dt, normal, F);",
121 max_eigenvalue=
"return FrictionLaws::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
122 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
123 diffusive_source_term=f
"FrictionLaws::sourceTermADERDG<double, Shortcuts, {aderdg_solver.unknowns}, {aderdg_solver.auxiliary_variables}>(Q, deltaQ, x, h, t, dt, S);",
124 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);",
127aderdg_solver.add_kernel_optimisations(
128 is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
130aderdg_solver.add_user_solver_includes(
133#include "../FrictionLaws.h"
134#include "../RusanovRiemannSolver.h"
138fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
140 patch_size=dg_order * 2 + 1,
141 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
142 auxiliary_variables={
"z": 1},
145 time_step_relaxation=0.45,
148fv_solver.set_implementation(
149 initial_conditions=initial_conditions,
150 boundary_conditions=boundary_conditions,
151 refinement_criterion=refinement_criterion,
152 adjust_solution=adjust_solution,
153 diffusive_source_term=f
"FrictionLaws::sourceTermFV<double, Shortcuts, {fv_solver.unknowns}, {fv_solver.auxiliary_variables}>(Q, deltaQ, x, h, t, dt, S);",
154 riemann_solver=f
"return rusanovRiemannSolverFV<double, Shortcuts, {fv_solver.unknowns}, {fv_solver.auxiliary_variables}>(QL, QR, x, h, t, dt, normal, FL, FR);",
157fv_solver.add_user_solver_includes(
160#include "../FrictionLaws.h"
161#include "../RusanovRiemannSolver.h"
165limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
166 name=
"LimiterSolver",
167 regular_solver=aderdg_solver,
168 limiting_solver=fv_solver,
169 number_of_dmp_observables=3,
170 dmp_relaxation_parameter=0.2,
171 dmp_differences_scaling=1e-3,
172 physical_admissibility_criterion=limiting_criterion,
175project = exahype2.Project(
176 namespace=[
"applications",
"exahype2",
"ShallowWater"],
177 project_name=
"DamBreakLandslide",
179 executable=
"ExaHyPE",
182project.add_solver(aderdg_solver)
183project.add_solver(fv_solver)
184project.add_solver(limiter_solver)
186if args.number_of_snapshots <= 0:
187 time_in_between_plots = 0.0
189 time_in_between_plots = args.end_time / args.number_of_snapshots
190 project.set_output_path(args.output)
192project.set_global_simulation_parameters(
196 min_end_time=args.end_time,
197 max_end_time=args.end_time,
198 first_plot_time_stamp=0.0,
199 time_in_between_plots=time_in_between_plots,
201 args.periodic_boundary_conditions_x,
202 args.periodic_boundary_conditions_y,
206project.set_load_balancer(
207 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
209project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
210project = project.generate_Peano4_project(verbose=
False)
211for const_name, const_info
in problem_constants.items():
212 const_val, const_type = const_info
213 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
214project.output.makefile.set_target_device(args.target_device)
215project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)