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.api
4import exahype2
5
6project = exahype2.Project(
7 ["tests", "exahype2", "aderdg"], ".", executable="ADERDG-Limiting"
8)
9
10dimensions = 2
11min_level = 3
12max_depth = 0
13order = 5
14end_time = 1.0
15plot_interval = 0.0 # 0.1
16
17offset = [-1.0, -1.0, -1.0][0:dimensions]
18size = [2.0, 2.0, 2.0][0:dimensions]
19max_h = 1.1 * min(size) / (3.0**min_level)
20min_h = max_h / (3.0**max_depth)
21
22
24 return (
25 """
26 Q[0] = 4.0;
27 Q[1] = 0.0;
28 Q[2] = 0.0;
29 Q[3] = 2.0 - tarch::la::norm2("""
30 + x
31 + """);
32"""
33 )
34
35
36boundary_conditions = """
37 Qoutside[0] = Qinside[0];
38 Qoutside[1] = Qinside[1];
39 Qoutside[2] = Qinside[2];
40 Qoutside[3] = Qinside[3];
41"""
42
43flux = """
44 double ih = 1.0 / Q[0];
45
46 F[0] = Q[1 + normal];
47 F[1] = Q[1 + normal] * Q[1] * ih;
48 F[2] = Q[1 + normal] * Q[2] * ih;
49 F[3] = 0.0;
50"""
51
52ncp = """
53 constexpr double grav = 9.81;
54
55 BTimesDeltaQ[0] = 0.0;
56 switch (normal) {
57 case 0:
58 BTimesDeltaQ[1] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
59 BTimesDeltaQ[2] = 0.0;
60 break;
61 case 1:
62 BTimesDeltaQ[1] = 0.0;
63 BTimesDeltaQ[2] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
64 break;
65 }
66 BTimesDeltaQ[3] = 0.0;
67"""
68
69max_eval = """
70 constexpr double grav = 9.81;
71
72 double u = Q[1 + normal] / Q[0];
73 double c = std::sqrt(grav * Q[0]);
74
75 return std::max(std::abs(u + c), std::abs(u - c));
76"""
77
78limiting_criterion = """
79bool isBoundaryCell = (
80 x[0] + 1.00 < 0.5 * h[0] or
81 x[1] + 1.00 < 0.5 * h[1] or
82 x[0] - 1.00 > -0.5 * h[0] or
83 x[1] - 1.00 > -0.5 * h[1]
84);
85return !isBoundaryCell;
86"""
87
88aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
89 name="ADERDGSolver",
90 order=order,
91 unknowns=4,
92 auxiliary_variables=0,
93 min_cell_h=min_h,
94 max_cell_h=max_h,
95 time_step_relaxation=0.9,
96 flux=flux,
97 ncp=ncp,
98 eigenvalues=max_eval,
99 initial_conditions=initial_conditions("x"),
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.rusanov.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 flux=flux,
116 ncp=ncp,
117 eigenvalues=max_eval,
118 initial_conditions=initial_conditions("volumeCentre"),
119 boundary_conditions=boundary_conditions,
120)
121project.add_solver(fv_solver)
122
123limiter = exahype2.solvers.limiting.StaticLimiting(
124 name="LimitingSolver",
125 regular_solver=aderdg_solver,
126 limiting_solver=fv_solver,
127 limiting_criterion_implementation=limiting_criterion,
128)
129project.add_solver(limiter)
130
131project.set_output_path("solutions")
132
133build_mode = peano4.api.output.CompileMode.RELEASE
134
135project.set_global_simulation_parameters(
136 dimensions=dimensions,
137 offset=offset[0:dimensions],
138 size=size[0:dimensions],
139 min_end_time=end_time,
140 max_end_time=end_time,
141 first_plot_time_stamp=0.0,
142 time_in_between_plots=plot_interval,
143 periodic_BC=[False, False, False][0:dimensions],
144)
145
146project.set_load_balancing(
147 "toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates",
148 "new ::exahype2::LoadBalancingConfiguration(0.98)",
149)
150project.set_Peano4_installation("../../../", build_mode)
151project = project.generate_Peano4_project("False")
152#project.set_fenv_handler("FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
153
154project.build(make_clean_first=True)
155
156print(fv_solver)
157print(aderdg_solver)
158print(limiter)
159print(project)