2 import peano4, exahype2
4 project = exahype2.Project([
"exahype",
"limiting",
"swe"],
".", executable=
"SWE")
11 scenario =
"oscillating_lake"
13 if scenario==
"simple_beach":
18 constexpr double Hd = 0.0185;
19 constexpr double d = 0.3;
21 constexpr double H = Hd * d;
22 constexpr double beta = std::atan(1/19.85);
24 constexpr double gamma = std::sqrt((3*H)/(4*d));
25 constexpr double x0 = d * cos(beta)/sin(beta);
26 constexpr double L = d * std::log(std::sqrt(20) + std::sqrt(20 - 1)) / gamma;
27 const double eta = H * (1/(std::cosh(gamma*(x[0]-(x0 + L))/d))) * (1/(std::cosh(gamma*(x[0]-(x0 + L))/d)));
31 Q[3] = -x[0] * std::sin(beta)/std::cos(beta) + d;
34 Q[0] = x[0] * std::sin(beta)/std::cos(beta);
38 Q[0] = H * (1/(std::cosh(gamma*(x[0]-(x0 + L))/d))) * (1/(std::cosh(gamma*(x[0]-(x0 + L))/d))) + d;
41 Q[1] = -eta * std::sqrt(9.81/d) * Q[0];
45 elif scenario==
"oscillating_lake":
52 Q[3] = 0.1 * (x[0]*x[0] + x[1]*x[1]);
53 Q[0] = std::max(0.0, 0.1 * (x[0] * cos(omega * 0) + x[1] * sin(omega * 0)) + 0.075 - Q[3]);
54 Q[1] = 0.5 * omega * sin(omega * 0) * Q[0];
55 Q[2] = 0.5 * omega * cos(omega * 0) * Q[0];
59 // doi: 10.1017/S0022112081001882
61 //More legible, translated into the form we are using:
62 // doi: 10.4208/cicp.070114.271114a
64 constexpr double a = 1.0;
65 constexpr double h0 = 0.1;
66 constexpr double sigma = 0.5;
67 const double omega = std::sqrt(2*9.81*h0)/a;
69 Q[3] = (h0 / (a*a)) * (x[0]*x[0] + x[1]*x[1]) ;
70 Q[0] = std::max(0.0, (sigma*h0/(a*a)) * (2 * x[0] * cos(omega * 0) + 2 * x[1] * sin(omega * 0) - sigma) + h0 - Q[3]);
71 Q[1] = -sigma * omega * sin(omega * 0) * Q[0];
72 Q[2] = sigma * omega * cos(omega * 0) * Q[0];
76 max_h = 1.1 *
min(size) / (3.0**min_level)
77 min_h = max_h / (3.0**max_depth)
80 boundary_conditions =
"""
81 std::copy_n(Qinside, 4, Qoutside);
82 Qoutside[normal+1] = -Qinside[normal+1];
85 aderSolver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
86 name =
"aderSWE", order = 3,
87 min_cell_h = min_h, max_cell_h = max_h,
88 time_step_relaxation = 0.9,
90 auxiliary_variables = 0,
93 aderSolver.set_implementation(
94 initial_conditions = init,
95 boundary_conditions = boundary_conditions,
96 max_eigenvalue = exahype2.solvers.PDETerms.User_Defined_Implementation,
97 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
98 ncp = exahype2.solvers.PDETerms.User_Defined_Implementation,
100 riemann_solver=exahype2.solvers.PDETerms.User_Defined_Implementation,
103 aderSolver.add_kernel_optimisations(
104 polynomials=exahype2.solvers.aderdg.ADERDG.Polynomials.Gauss_Lobatto,
107 project.add_solver(aderSolver)
109 fvSolver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
111 patch_size = 2*order+1,
112 min_volume_h = min_h,
113 max_volume_h = max_h,
114 time_step_relaxation = 0.9,
116 auxiliary_variables = 1,
118 fvSolver.set_implementation(
119 initial_conditions =
"",
120 boundary_conditions = boundary_conditions,
121 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
122 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
123 riemann_solver = exahype2.solvers.PDETerms.User_Defined_Implementation
125 project.add_solver(fvSolver)
128 limiter = exahype2.solvers.limiting.PosterioriLimiting(
129 name =
"limitingSolver",
130 regular_solver = aderSolver,
131 limiting_solver = fvSolver,
132 number_of_dmp_observables = 0,
133 dmp_relaxation_parameter = 0.001,
134 dmp_differences_scaling = 0.02,
135 physical_admissibility_criterion =
"""
138 if(Q[0] <= 20 * 1e-3)
142 project.add_solver(limiter)
144 project.set_output_path(
145 "posterioriSolutions_o_" +
str(order)
146 +
"_l_" +
str(min_level)
147 +
"_d_" +
str(max_depth)
151 build_mode = peano4.output.CompileMode.Release
153 project.set_global_simulation_parameters(
154 dimensions = dimensions,
155 offset = offset[0:dimensions],
156 size = size[0:dimensions],
159 first_plot_time_stamp = 0.0,
160 time_in_between_plots = 0.1,
161 periodic_BC=[
False,
False,
False][0:dimensions]
164 project._project.output.makefile.set_Fortran_compiler(
"gfortran")
166 project._project.output.makefile.add_cpp_file(
"fvSWE.cpp")
167 project._project.output.makefile.add_cpp_file(
"aderSWE.cpp")
169 project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
170 project.set_Peano4_installation(
"../../../", build_mode)
171 peano4_project = project.generate_Peano4_project(verbose=
False)
172 peano4_project.build(make_clean_first=
True)
static double min(double const x, double const y)