6initial_conditions =
"""
7 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
11 constexpr double h0 = 0.32;
12 constexpr double A = 0.064;
13 constexpr double xc = 12.5;
14 constexpr double yc = 15.0;
15 constexpr double rc = 3.6;
16 const double gamma = std::sqrt((3.0 * A) / (4.0 * h0));
18 auto r = [](double x, double y) {
19 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
22 Q[Shortcuts::h] = h0 + (A / h0 * std::pow(1.0 / (std::cosh(gamma * (x(0) - 2.5))), 2));
23 Q[Shortcuts::z] = r(x(0), x(1)) <= rc ? 0.93 * (1.0 - r(x(0), x(1)) / rc) : 0.0;
26boundary_conditions =
"""
27 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
28 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
29 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
30 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
33refinement_criterion =
"""
34 static constexpr double xc = 12.5;
35 static constexpr double yc = 15.0;
36 static constexpr double rc = 3.6;
38 auto r = [](double x, double y) {
39 return std::sqrt(std::pow(x - xc, 2) + std::pow(y - yc, 2));
42 return r(x(0), x(1)) <= rc
43 ? ::exahype2::RefinementCommand::Refine
44 : ::exahype2::RefinementCommand::Keep;
47parser = exahype2.ArgumentParser()
52args = parser.parse_args()
55 "g": [9.81,
"double"],
56 "hThreshold": [1e-5,
"double"],
60max_h = 1.1 * min(size) / (3.0**args.min_depth)
61min_h = max_h * 3.0 ** (-args.amr_levels)
63aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
65 order=args.degrees_of_freedom,
66 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
67 auxiliary_variables=0,
70 time_step_relaxation=0.5,
73aderdg_solver.set_implementation(
74 initial_conditions=initial_conditions,
75 boundary_conditions=boundary_conditions,
76 refinement_criterion=refinement_criterion,
77 flux=f
"ShallowWater::flux<double, Shortcuts, {aderdg_solver.unknowns}>(Q, x, h, t, dt, normal, F);",
78 max_eigenvalue=
"return ShallowWater::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
79 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
82aderdg_solver.add_kernel_optimisations(
83 is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
85aderdg_solver.add_user_solver_includes(
91project = exahype2.Project(
92 namespace=[
"applications",
"exahype2",
"ShallowWater"],
93 project_name=
"CircularIsland",
97project.add_solver(aderdg_solver)
99if args.number_of_snapshots <= 0:
100 time_in_between_plots = 0.0
102 time_in_between_plots = args.end_time / args.number_of_snapshots
103 project.set_output_path(args.output)
105project.set_global_simulation_parameters(
109 min_end_time=args.end_time,
110 max_end_time=args.end_time,
111 first_plot_time_stamp=0.0,
112 time_in_between_plots=time_in_between_plots,
114 args.periodic_boundary_conditions_x,
115 args.periodic_boundary_conditions_y,
119project.set_load_balancer(
120 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
122project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
123project = project.generate_Peano4_project(verbose=
False)
124for const_name, const_info
in constants.items():
125 const_val, const_type = const_info
126 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
127project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)