Peano
static-limiting-swe.py
Go to the documentation of this file.
1 # This file is part of the ExaHyPE2 project. For conditions of distribution and
2 # use, please see the copyright notice at www.peano-framework.org
3 import peano4
4 import exahype2
5 
6 project = exahype2.Project(
7  ["tests", "exahype2", "aderdg"], ".", executable="ADERDG-Limiting"
8 )
9 
10 parser = exahype2.ArgumentParser("ExaHyPE 2 - ADER-DG Limiting Testing Script")
11 parser.set_defaults(
12  min_depth=3,
13  degrees_of_freedom=6,
14 )
15 args = parser.parse_args()
16 
17 dimensions = 2
18 order = args.degrees_of_freedom - 1
19 end_time = 1.0
20 plot_interval = 0.0 # 0.1
21 
22 size = [2.0, 2.0, 2.0][0:dimensions]
23 offset = [-1.0, -1.0, -1.0][0:dimensions]
24 max_h = 1.1 * min(size) / (3.0**args.min_depth)
25 min_h = max_h / (3.0**args.amr_levels)
26 
27 initial_conditions = """
28  Q[0] = 4.0;
29  Q[1] = 0.0;
30  Q[2] = 0.0;
31  Q[3] = 2.0 - tarch::la::norm2(x);
32 """
33 
34 boundary_conditions = """
35  Qoutside[0] = Qinside[0];
36  Qoutside[1] = Qinside[1];
37  Qoutside[2] = Qinside[2];
38  Qoutside[3] = Qinside[3];
39 """
40 
41 flux = """
42  double ih = 1.0 / Q[0];
43 
44  F[0] = Q[1 + normal];
45  F[1] = Q[1 + normal] * Q[1] * ih;
46  F[2] = Q[1 + normal] * Q[2] * ih;
47  F[3] = 0.0;
48 """
49 
50 ncp = """
51  constexpr double grav = 9.81;
52 
53  BTimesDeltaQ[0] = 0.0;
54  switch (normal) {
55  case 0:
56  BTimesDeltaQ[1] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
57  BTimesDeltaQ[2] = 0.0;
58  break;
59  case 1:
60  BTimesDeltaQ[1] = 0.0;
61  BTimesDeltaQ[2] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
62  break;
63  }
64  BTimesDeltaQ[3] = 0.0;
65 """
66 
67 max_eval = """
68  constexpr double grav = 9.81;
69 
70  double u = Q[1 + normal] / Q[0];
71  double c = std::sqrt(grav * Q[0]);
72 
73  return std::max(std::abs(u + c), std::abs(u - c));
74 """
75 
76 limiting_criterion = """
77 bool isBoundaryCell = (
78  x[0] + 1.00 < 0.5 * h[0] or
79  x[1] + 1.00 < 0.5 * h[1] or
80  x[0] - 1.00 > -0.5 * h[0] or
81  x[1] - 1.00 > -0.5 * h[1]
82 );
83 return !isBoundaryCell;
84 """
85 
86 aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
87  name="ADERDGSolver",
88  order=order,
89  unknowns=4,
90  auxiliary_variables=0,
91  min_cell_h=min_h,
92  max_cell_h=max_h,
93  time_step_relaxation=0.9,
94 )
95 aderdg_solver.set_implementation(
96  flux=flux,
97  ncp=ncp,
98  max_eigenvalue=max_eval,
99  initial_conditions=initial_conditions,
100  boundary_conditions=boundary_conditions,
101 )
102 aderdg_solver.add_kernel_optimisations(
103  polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Lobatto
104 )
105 project.add_solver(aderdg_solver)
106 
107 fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
108  name="FVSolver",
109  patch_size=2 * order + 1,
110  unknowns=4,
111  auxiliary_variables=0,
112  min_volume_h=min_h,
113  max_volume_h=max_h,
114  time_step_relaxation=0.9,
115 
116 )
117 fv_solver.set_implementation(
118  flux=flux,
119  ncp=ncp,
120  max_eigenvalue=max_eval,
121  initial_conditions=initial_conditions,
122  boundary_conditions=boundary_conditions,
123 )
124 project.add_solver(fv_solver)
125 
126 limiter = exahype2.solvers.limiting.StaticLimiting(
127  name="LimitingSolver",
128  regular_solver=aderdg_solver,
129  limiting_solver=fv_solver,
130  limiting_criterion_implementation=limiting_criterion,
131 )
132 project.add_solver(limiter)
133 
134 project.set_output_path("solutions")
135 
136 project.set_global_simulation_parameters(
137  dimensions=dimensions,
138  offset=offset[0:dimensions],
139  size=size[0:dimensions],
140  min_end_time=end_time,
141  max_end_time=end_time,
142  first_plot_time_stamp=0.0,
143  time_in_between_plots=plot_interval,
144  periodic_BC=[False, False, False][0:dimensions],
145 )
146 
147 project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
148 project.set_Peano4_installation("../../../", mode=peano4.output.string_to_mode(args.build_mode))
149 project = project.generate_Peano4_project(verbose=False)
150 project.set_fenv_handler(False)
151 project.build()
static double min(double const x, double const y)