9 sys.path.insert(0, os.path.abspath(
".."))
12 initial_conditions =
"""
13 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
17 static constexpr double h0 = 0.32;
18 static constexpr double A = 0.064;
19 static constexpr double xc = 12.5;
20 static constexpr double yc = 15.0;
21 static constexpr double rc = 3.6;
22 const double gamma = std::sqrt((3.0 * A) / (4.0 * h0));
24 auto r = [](double x, double y) {
25 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
28 Q[Shortcuts::h] = h0 + (A / h0 * std::pow(1.0 / (std::cosh(gamma * (x(0) - 2.5))), 2));
29 Q[Shortcuts::z] = r(x(0), x(1)) <= rc ? 0.93 * (1.0 - r(x(0), x(1)) / rc) : 0.0;
32 boundary_conditions =
"""
33 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
34 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
35 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
36 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
39 refinement_criterion =
"""
40 static constexpr double xc = 12.5;
41 static constexpr double yc = 15.0;
42 static constexpr double rc = 3.6;
44 auto r = [](double x, double y) {
45 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
48 return r(x(0), x(1)) <= rc
49 ? ::exahype2::RefinementCommand::Refine
50 : ::exahype2::RefinementCommand::Keep;
53 parser = exahype2.ArgumentParser()
58 args = parser.parse_args()
61 "g": [9.81,
"double"],
62 "hThreshold": [1e-5,
"double"],
66 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
67 min_h = max_h * 3.0 ** (-args.amr_levels)
69 aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
71 order=args.degrees_of_freedom,
72 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
73 auxiliary_variables=0,
76 time_step_relaxation=args.time_step_relaxation,
79 aderdg_solver.set_implementation(
80 initial_conditions=initial_conditions,
81 boundary_conditions=boundary_conditions,
82 refinement_criterion=refinement_criterion,
84 ncp=nonconservative_product,
85 max_eigenvalue=eigenvalue +
"""
90 aderdg_solver.set_plotter(args.plotter)
91 aderdg_solver.add_kernel_optimisations(is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre)
93 project = exahype2.Project(
94 namespace=[
"applications",
"exahype2",
"swe"],
95 project_name=
"CircularIsland",
97 executable=
"ExaHyPE-ShallowWater",
99 project.add_solver(aderdg_solver)
101 if args.number_of_snapshots <= 0:
102 time_in_between_plots = 0.0
104 time_in_between_plots = args.end_time / args.number_of_snapshots
105 project.set_output_path(args.output)
107 project.set_global_simulation_parameters(
111 min_end_time=args.end_time,
112 max_end_time=args.end_time,
113 first_plot_time_stamp=0.0,
114 time_in_between_plots=time_in_between_plots,
116 args.periodic_boundary_conditions_x,
117 args.periodic_boundary_conditions_y,
121 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
122 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
123 project = project.generate_Peano4_project(verbose=
False)
124 for const_name, const_info
in constants.items():
125 const_val, const_type = const_info
126 project.constants.export_constexpr_with_type(
127 const_name,
str(const_val), const_type
129 project.set_fenv_handler(args.fpe)
130 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)