6 project = exahype2.Project(
7 [
"tests",
"exahype2",
"aderdg"],
".", executable=
"ADERDG-Limiting"
10 parser = exahype2.ArgumentParser(
"ExaHyPE 2 - ADER-DG Limiting Testing Script")
15 args = parser.parse_args()
18 order = args.degrees_of_freedom - 1
24 max_h = 1.1 *
min(size) / (3.0**args.min_depth)
25 min_h = max_h / (3.0**args.amr_levels)
28 // Parameters which define a symmetric NACA airfoil
29 constexpr double c = 100.;
30 constexpr double t = 0.12;
37 double yl = x[1] - h[1]/2;
38 double yu = x[1] + h[1]/2;
39 double volumePercentage = 1.0;
41 constexpr int nI = 50; // NumberOfIntegrationMeasurementPoints
42 const double hI = h[0] / nI;
44 for(int i=0; i<nI; i++){
45 double xI = x[0] + i * hI;
46 double yI = 5.0 * t * c * (
47 0.2969 * sqrt ( xI / c )
49 - 0.1015 ) * ( xI / c )
50 + 0.2843 ) * ( xI / c )
51 - 0.3516 ) * ( xI / c )
52 - 0.1260 ) * ( xI / c ) ); // Specific function for a symmetric NACA airfoil
54 if( -yI<yl && yI>yu ){ // fully within the airfoil
55 volumePercentage -= hI ;
57 else if ( yI>yl && yI<yu && -yI<yl ){ // y in cell, -y below
58 volumePercentage -= hI*(yI - yl) / (yu - yl);
60 else if ( -yI<yu && -yI>yl && yI>yu){ // -y in cell, y above
61 volumePercentage -= hI*(yu + yI) / (yu - yl);
63 else if ( yI>yl && yI<yu && -yI<yu && -yI>yl ){ // -y and y both in cell
64 volumePercentage -= hI*( 2*yI ) / (yu - yl);
68 Q[4] = std::max(0.0, std::min(1.0, volumePercentage));
71 boundaryCondition =
"""
72 if (normal == 0 && x[0] == DomainOffset[0]) {
79 Qoutside[0] = Qinside[0];
80 Qoutside[1] = Qinside[1];
81 Qoutside[2] = Qinside[2];
82 Qoutside[3] = Qinside[3];
88 const double irho = 1.0 / Q[0];
89 constexpr double Gamma = 1.4;
90 const double p = (Gamma - 1) * (Q[3] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]));
93 F[1] = Q[normal+1] * Q[1] * irho;
94 F[2] = Q[normal+1] * Q[2] * irho;
95 F[3] = Q[normal+1] * irho * (Q[3] + p);
101 const double irho = 1.0 / Q[0];
102 constexpr double Gamma = 1.4;
103 const double p = (Gamma - 1) * (Q[3] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]));
105 const double c = std::sqrt(Gamma * p * irho);
106 const double u = Q[normal + 1] * irho;
109 aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
114 time_step_relaxation=0.5,
116 auxiliary_variables=1,
118 aderdg_solver.set_implementation(
119 initial_conditions=init,
120 boundary_conditions=boundaryCondition,
122 max_eigenvalue=eigenvalues
124 return std::max(std::abs(u-c), std::abs(u+c));""",
126 aderdg_solver.add_kernel_optimisations(
127 polynomials=exahype2.solvers.aderdg.ADERDG.Polynomials.Gauss_Lobatto
129 project.add_solver(aderdg_solver)
131 fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
133 patch_size=2 * order + 1,
136 time_step_relaxation=0.5,
138 auxiliary_variables=1
140 fv_solver.set_implementation(
142 boundary_conditions=boundaryCondition,
143 initial_conditions=init,
144 eigenvalues=eigenvalues
153 eigenvalues(QL, x, h, t, dt, normal, LL);
154 eigenvalues(QR, x, h, t, dt, normal, LR);
155 const double sMax = std::max(*std::max_element(LL, LL+4), *std::max_element(LR, LR+4));
159 flux(QL, x, h, t, dt, normal, fluxLeft);
160 flux(QR, x, h, t, dt, normal, fluxRight);
162 const double vL = QL[4];
163 const double vR = QR[4];
166 Assuming anything that can't get into the other is reflected back to me.
167 own + what's reflected from what I send + what was sent to me and not reflected
168 Rl = vl*Fl + vl*Fl*(1-vr) + vr*Fr*vl
169 Rr = vr*Fr + vr*Fr*(1-vl) + vl*Fl*vr
171 for(int i=0; i<4; i++){
172 const double FLe = 0.5*vL*(fluxLeft[i]+sMax*QL[i]);
173 const double FRe = 0.5*vR*(fluxRight[i]-sMax*QR[i]);
176 FL[i] = FLe*(2-vR) + vL*FRe;
178 FR[i] = FRe*(2-vL) + vR*FLe;
183 project.add_solver(fv_solver)
185 limiter = exahype2.solvers.limiting.StaticLimiting(
186 name=
"LimitingSolver",
187 regular_solver=aderdg_solver,
188 limiting_solver=fv_solver,
189 limiting_criterion_implementation=
"""return (Q[4] == 1.0);""",
191 project.add_solver(limiter)
193 project.set_output_path(
"solutions")
195 project.set_global_simulation_parameters(
196 dimensions=dimensions,
197 offset=offset[0:dimensions],
198 size=size[0:dimensions],
199 min_end_time=end_time,
200 max_end_time=end_time,
201 first_plot_time_stamp=0.0,
202 time_in_between_plots=plot_interval,
203 periodic_BC=[
False,
False],
206 project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
207 project.set_Peano4_installation(
"../../../", mode=peano4.output.string_to_mode(args.build_mode))
208 project = project.generate_Peano4_project(verbose=
False)
209 project.set_fenv_handler(
False)
static double min(double const x, double const y)