10 sys.path.insert(0, os.path.abspath(
".."))
16 initial_conditions =
"""
17 // Determine the position of the material region
18 bool insideTheSquare{true};
19 insideTheSquare &= (x[0] >= (initCenterX - squareSide * 0.5));
20 insideTheSquare &= (x[0] <= (initCenterX + squareSide * 0.5));
21 insideTheSquare &= (x[1] >= (initCenterY - squareSide * 0.5));
22 insideTheSquare &= (x[1] <= (initCenterY + squareSide * 0.5));
24 // Assign initial conditions based on the position of the material region
25 Q[Shortcuts::h] = (insideTheSquare ? initHeight : 0.0);
26 Q[Shortcuts::hu] = 0.0;
27 Q[Shortcuts::hu + 1] = 0.0;
28 Q[Shortcuts::z] = (DomainSize[0] - x[0]) * slopeAngleTan;
31 boundary_conditions =
"""
32 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
33 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
34 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
35 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
38 refinement_criterion =
"""
39 auto result = ::exahype2::RefinementCommand::Keep;
43 limiting_criterion =
"""
44 const double Qh{Q[0]};
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]) {
72 adjust_solution =
r"""
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;
80 parser = exahype2.ArgumentParser()
84 time_step_relaxation=0.45,
87 args = parser.parse_args()
90 "g" : [9.81,
"double"],
91 "phi" : [25.0,
"double"],
92 "invXi" : [1.0 / 200.0,
"double"],
93 "slopeAngleTan" : [math.tan(math.pi / 180.0 * 35.0),
"double"],
94 "initCenterX" : [0.15,
"double"],
95 "initCenterY" : [0.79,
"double"],
96 "squareSide" : [0.1,
"double"],
97 "initHeight" : [0.1,
"double"],
99 problem_constants[
"hThreshold"] = [problem_constants[
"initHeight"][0] * 1e-3,
"double"]
100 problem_constants[
"mu"] = [math.tan(math.pi / 180.0 * problem_constants[
"phi"][0]),
"double"]
103 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
104 min_h = max_h * 3.0 ** (-args.amr_levels)
105 dg_order = args.degrees_of_freedom - 1
107 regular_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
110 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
111 auxiliary_variables=0,
114 time_step_relaxation=args.time_step_relaxation,
117 regular_solver.set_implementation(
118 initial_conditions=initial_conditions,
119 boundary_conditions=boundary_conditions,
120 refinement_criterion=refinement_criterion,
122 ncp=nonconservative_product,
123 max_eigenvalue=eigenvalue + stiff_eigenvalue +
"""
124 return std::fmax(sFlux, h[normal] * sSource);
126 diffusive_source_term=stiff_source_term_aderdg,
127 riemann_solver=rusanov_aderdg,
130 regular_solver.set_plotter(args.plotter)
131 regular_solver.add_kernel_optimisations(
133 polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
136 limiting_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
138 patch_size=dg_order * 2 + 1,
139 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
140 auxiliary_variables={
"z": 1},
143 time_step_relaxation=args.time_step_relaxation,
146 limiting_solver.set_implementation(
147 initial_conditions=initial_conditions,
148 boundary_conditions=boundary_conditions,
149 refinement_criterion=refinement_criterion,
151 max_eigenvalue=eigenvalue +
"""
154 ncp=nonconservative_product + stiff_nonconservative_product,
155 riemann_solver=rusanov_fv,
156 diffusive_source_term=stiff_source_term_fv,
157 adjust_solution=adjust_solution,
160 limiting_solver.set_plotter(args.plotter)
162 limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
163 name=
"LimiterSolver",
164 regular_solver=regular_solver,
165 limiting_solver=limiting_solver,
166 number_of_dmp_observables=3,
167 dmp_relaxation_parameter=0.20,
168 dmp_differences_scaling=1e-3,
169 physical_admissibility_criterion=limiting_criterion,
172 project = exahype2.Project(
173 namespace=[
"applications",
"exahype2",
"swe"],
174 project_name=
"DamBreakLandslide",
176 executable=
"ExaHyPE-ShallowWater",
179 project.add_solver(regular_solver)
180 project.add_solver(limiting_solver)
181 project.add_solver(limiter_solver)
183 if args.number_of_snapshots <= 0:
184 time_in_between_plots = 0.0
186 time_in_between_plots = args.end_time / args.number_of_snapshots
187 project.set_output_path(args.output)
189 project.set_global_simulation_parameters(
193 min_end_time=args.end_time,
194 max_end_time=args.end_time,
195 first_plot_time_stamp=0.0,
196 time_in_between_plots=time_in_between_plots,
198 args.periodic_boundary_conditions_x,
199 args.periodic_boundary_conditions_y,
203 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
204 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
205 project = project.generate_Peano4_project(verbose=
False)
206 for const_name, const_info
in problem_constants.items():
207 const_val, const_type = const_info
208 project.constants.export_constexpr_with_type(
209 const_name,
str(const_val), const_type
211 project.output.makefile.set_target_device(args.target_device)
212 project.set_fenv_handler(args.fpe)
213 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)