10sys.path.insert(0, os.path.abspath(
".."))
16initial_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;
31boundary_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];
38refinement_criterion =
"""
39 auto result = ::exahype2::RefinementCommand::Keep;
43limiting_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]) {
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;
80parser = exahype2.ArgumentParser()
84 time_step_relaxation=0.45,
87args = parser.parse_args()
89if args.build_mode ==
"Debug":
93 "g": [9.81,
"double"],
94 "phi": [25.0,
"double"],
95 "invXi": [1.0 / 200.0,
"double"],
96 "slopeAngleTan": [math.tan(math.pi / 180.0 * 35.0),
"double"],
97 "initCenterX": [0.15,
"double"],
98 "initCenterY": [0.79,
"double"],
99 "squareSide": [0.1,
"double"],
100 "initHeight": [0.1,
"double"],
102problem_constants[
"hThreshold"] = [problem_constants[
"initHeight"][0] * 1e-3,
"double"]
103problem_constants[
"mu"] = [
104 math.tan(math.pi / 180.0 * problem_constants[
"phi"][0]),
109max_h = 1.1 * min(size) / (3.0**args.min_depth)
110min_h = max_h * 3.0 ** (-args.amr_levels)
111dg_order = args.degrees_of_freedom - 1
113regular_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
116 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
117 auxiliary_variables=0,
120 time_step_relaxation=0.5,
123regular_solver.set_implementation(
124 initial_conditions=initial_conditions,
125 boundary_conditions=boundary_conditions,
126 refinement_criterion=refinement_criterion,
128 ncp=nonconservative_product,
129 max_eigenvalue=eigenvalue
132 return std::fmax(sFlux, h[normal] * sSource);
134 diffusive_source_term=stiff_source_term_aderdg,
135 riemann_solver=rusanov_aderdg,
138regular_solver.set_plotter(args.plotter)
139regular_solver.add_kernel_optimisations(
141 polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
144limiting_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
146 patch_size=dg_order * 2 + 1,
147 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
148 auxiliary_variables={
"z": 1},
151 time_step_relaxation=0.5,
154limiting_solver.set_implementation(
155 initial_conditions=initial_conditions,
156 boundary_conditions=boundary_conditions,
157 refinement_criterion=refinement_criterion,
159 max_eigenvalue=eigenvalue
163 ncp=nonconservative_product + stiff_nonconservative_product,
164 riemann_solver=rusanov_fv,
165 diffusive_source_term=stiff_source_term_fv,
166 adjust_solution=adjust_solution,
169limiting_solver.set_plotter(args.plotter)
171limiter_solver = exahype2.solvers.limiting.PosterioriLimiting(
172 name=
"LimiterSolver",
173 regular_solver=regular_solver,
174 limiting_solver=limiting_solver,
175 number_of_dmp_observables=3,
176 dmp_relaxation_parameter=0.20,
177 dmp_differences_scaling=1e-3,
178 physical_admissibility_criterion=limiting_criterion,
181project = exahype2.Project(
182 namespace=[
"applications",
"exahype2",
"swe"],
183 project_name=
"DamBreakLandslide",
185 executable=
"ExaHyPE-ShallowWater",
188project.add_solver(regular_solver)
189project.add_solver(limiting_solver)
190project.add_solver(limiter_solver)
192if args.number_of_snapshots <= 0:
193 time_in_between_plots = 0.0
195 time_in_between_plots = args.end_time / args.number_of_snapshots
196 project.set_output_path(args.output)
198project.set_global_simulation_parameters(
202 min_end_time=args.end_time,
203 max_end_time=args.end_time,
204 first_plot_time_stamp=0.0,
205 time_in_between_plots=time_in_between_plots,
207 args.periodic_boundary_conditions_x,
208 args.periodic_boundary_conditions_y,
212project.set_load_balancer(
213 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
215project.set_Peano4_installation(
216 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
218project = project.generate_Peano4_project(verbose=
False)
219for const_name, const_info
in problem_constants.items():
220 const_val, const_type = const_info
221 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
222project.output.makefile.set_target_device(args.target_device)
223project.set_fenv_handler(args.fpe)
224project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)