Peano
Loading...
Searching...
No Matches
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
3import peano4
4import exahype2
5
6project = exahype2.Project(
7 ["tests", "exahype2", "aderdg"], ".", executable="ADERDG-Limiting"
8)
9
10parser = exahype2.ArgumentParser("ExaHyPE 2 - ADER-DG Limiting Testing Script")
11parser.set_defaults(
12 min_depth=3,
13 degrees_of_freedom=6,
14)
15args = parser.parse_args()
16
17dimensions = 2
18order = args.degrees_of_freedom - 1
19end_time = 1.0
20plot_interval = 0.0 # 0.1
21
22size = [2.0, 2.0, 2.0][0:dimensions]
23offset = [-1.0, -1.0, -1.0][0:dimensions]
24max_h = 1.1 * min(size) / (3.0**args.min_depth)
25min_h = max_h / (3.0**args.amr_levels)
26
27initial_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
34boundary_conditions = """
35 Qoutside[0] = Qinside[0];
36 Qoutside[1] = Qinside[1];
37 Qoutside[2] = Qinside[2];
38 Qoutside[3] = Qinside[3];
39"""
40
41flux = """
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
50ncp = """
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
67max_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
76limiting_criterion = """
77bool 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);
83return !isBoundaryCell;
84"""
85
86aderdg_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)
95aderdg_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)
102aderdg_solver.add_kernel_optimisations(
103 polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Lobatto
104)
105project.add_solver(aderdg_solver)
106
107fv_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)
117fv_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)
124project.add_solver(fv_solver)
125
126limiter = exahype2.solvers.limiting.StaticLimiting(
127 name="LimitingSolver",
128 regular_solver=aderdg_solver,
129 limiting_solver=fv_solver,
130 physical_admissibility_criterion=limiting_criterion,
131)
132project.add_solver(limiter)
133
134project.set_output_path("solutions")
135
136project.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
147project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
148project.set_Peano4_installation("../../../", mode=peano4.output.string_to_mode(args.build_mode))
149project = project.generate_Peano4_project(verbose=False)
150project.set_fenv_handler(False)
151project.build()