6physical_offset = [-1514683.37644735, -1108652.87362612]
7physical_size = [3029257.84023389, 2284903.696092]
8square_side = max(physical_size)
11 physical_offset[0] - 0.5 * (square_side - physical_size[0]),
12 physical_offset[1] - 0.5 * (square_side - physical_size[1]),
14size = [square_side, square_side]
16initial_conditions =
"""
17 static tarch::reader::NetCDFFieldParser fieldParser(
18 "bathymetry/gebco_projection.nc",
21 PhysicalDomainOffsetX,
22 PhysicalDomainOffsetY,
28 const double bathymetry = fieldParser.sampleTopology(x(0), x(1));
30 if (bathymetry < -15000) {
31 Q[Shortcuts::h] = 999;
32 Q[Shortcuts::hu] = 0.0;
33 Q[Shortcuts::hv] = 0.0;
34 Q[Shortcuts::z] = -999;
36 Q[Shortcuts::h] = -std::min(bathymetry, 0.0);
37 Q[Shortcuts::hu] = 0.0;
38 Q[Shortcuts::hv] = 0.0;
39 Q[Shortcuts::z] = bathymetry;
43boundary_conditions =
"""
44 Qoutside[0] = Qinside[0];
47 Qoutside[3] = Qinside[3];
50is_physically_admissible =
"""
51 // Low values of h are resolved on FV layer
52 if (tarch::la::smallerEquals(Q[0], 10.0 /*hThreshold*/)) {
56 // Limit close to boundaries
57 if (std::abs(x[0] - DomainOffset[0]) < h[0] or std::abs(x[0] - DomainOffset[0] - DomainSize[0]) < h[0]) {
60 if (std::abs(x[1] - DomainOffset[1]) < h[1] or std::abs(x[1] - DomainOffset[1] - DomainSize[1]) < h[1]) {
65 if (x(0) - PhysicalDomainOffsetX > 0.6 * PhysicalDomainSizeX) {
70 if (x(1) - PhysicalDomainOffsetY < 0.4 * PhysicalDomainSizeY) {
75 if (x(0) - PhysicalDomainOffsetX < 0.3 * PhysicalDomainSizeX) {
80 if (x(1) - PhysicalDomainOffsetY > 0.85 * PhysicalDomainSizeY) {
87parser = exahype2.ArgumentParser()
93args = parser.parse_args()
96 "g": [9.81,
"double"],
97 "hThreshold": [1e-5,
"double"],
98 "PhysicalDomainOffsetX": [physical_offset[0],
"double"],
99 "PhysicalDomainOffsetY": [physical_offset[1],
"double"],
100 "PhysicalDomainSizeX": [physical_size[0],
"double"],
101 "PhysicalDomainSizeY": [physical_size[1],
"double"],
110 "aeaStdParallel1": [18.3333333,
"double"],
111 "aeaStdParallel2": [31.6666667,
"double"],
112 "aeaLon0": [-84.0,
"double"],
113 "aeaLat0": [25.0,
"double"],
114 "aeaEarthRadius": [6371000.0,
"double"],
115 "pointLonA": [-85.107,
"double"],
116 "pointLatA": [30.747,
"double"],
117 "pointLonB": [-81.562,
"double"],
118 "pointLatB": [23.4480,
"double"],
119 "water_density": [1000,
"double"],
120 "coriolis_omega": [7.2921150e-5,
"double"],
121 "manning_param": [0.025,
"double"],
125max_h = 1.1 * min(physical_size) / (3.0**args.min_depth)
126min_h = max_h * 3.0 ** (-args.amr_levels)
127dg_order = args.degrees_of_freedom - 1
129aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
132 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
133 auxiliary_variables=0,
136 time_step_relaxation=0.9,
139aderdg_solver.set_implementation(
140 initial_conditions=initial_conditions,
141 boundary_conditions=boundary_conditions,
142 flux=f
"ShallowWater::flux<double, Shortcuts, {aderdg_solver.unknowns}>(Q, x, h, t, dt, normal, F);",
143 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
144 max_eigenvalue=
"return ShallowWater::maxEigenvalue<double, Shortcuts>(Q,x,h,t,dt,normal);",
146 // Compute max eigenvalue over face
148 for(int xy=0; xy<Order+1; xy++){
149 smax = std::max(smax, maxEigenvalue(&QL[xy*4], x, h, t, dt, direction));
150 smax = std::max(smax, maxEigenvalue(&QR[xy*4], x, h, t, dt, direction));
153 for(int xy=0; xy<Order+1; xy++){
154 if (QL[xy*4+0] <= hThreshold or QR[xy*4+0] <= hThreshold) {
155 FR[xy*4+0] = FL[xy*4+0] = 0.0;
156 FR[xy*4+1] = FL[xy*4+1] = 0.0;
157 FR[xy*4+2] = FL[xy*4+2] = 0.0;
158 FR[xy*4+3] = FL[xy*4+3] = 0.0;
162 // h gets added term from bathymetry, u and v are regular Rusanov, b does not change
163 FL[xy*4+0] = 0.5*(FL[xy*4+0]+FR[xy*4+0] + smax*(QL[xy*4+0]+QL[xy*4+3]-QR[xy*4+0]-QR[xy*4+3]) );
164 FL[xy*4+1] = 0.5*(FL[xy*4+1]+FR[xy*4+1] + smax*(QL[xy*4+1]-QR[xy*4+1]) );
165 FL[xy*4+2] = 0.5*(FL[xy*4+2]+FR[xy*4+2] + smax*(QL[xy*4+2]-QR[xy*4+2]) );
168 FR[xy*4+0] = FL[xy*4+0];
169 FR[xy*4+1] = FL[xy*4+1];
170 FR[xy*4+2] = FL[xy*4+2];
173 // Contribution from NCP
174 FL[xy*4+direction+1] += 0.5*g*0.5*(QL[xy*4+0]+QR[xy*4+0])*(QR[xy*4+3]+QR[xy*4+0]-QL[xy*4+3]-QL[xy*4+0]);
175 FR[xy*4+direction+1] -= 0.5*g*0.5*(QL[xy*4+0]+QR[xy*4+0])*(QR[xy*4+3]+QR[xy*4+0]-QL[xy*4+3]-QL[xy*4+0]);
178 source_term=f
"meteotsunami::sourceTerm<double, Shortcuts, {aderdg_solver.unknowns}, {aderdg_solver.auxiliary_variables}>(Q, x, h, t, dt, S);",
181aderdg_solver.add_user_solver_includes(
184#include "SourceTerm.h"
185#include "tarch/reader/NetCDFFieldParser.h"
189fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
191 patch_size=dg_order * 2 + 1,
192 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
193 auxiliary_variables={
"z": 1},
196 time_step_relaxation=0.9,
199fv_solver.set_implementation(
200 initial_conditions=initial_conditions,
201 boundary_conditions=boundary_conditions,
202 source_term=f
"meteotsunami::sourceTerm<double, Shortcuts, {fv_solver.unknowns}, {fv_solver.auxiliary_variables}>(Q, x, h, t, dt, S);",
203 riemann_solver=
"return fWaveRiemannSolver<double, Shortcuts>(QL, QR, x, h, t, dt, normal, FL, FR);",
206fv_solver.add_user_solver_includes(
208#include "../FWaveRiemannSolver.h"
209#include "SourceTerm.h"
210#include "tarch/reader/NetCDFFieldParser.h"
214limiter_solver = exahype2.solvers.limiting.StaticLimiting(
215 name=
"LimiterSolver",
216 regular_solver=aderdg_solver,
217 limiting_solver=fv_solver,
218 physical_admissibility_criterion=is_physically_admissible,
221project = exahype2.Project(
222 namespace=[
"applications",
"exahype2",
"ShallowWater"],
223 project_name=
"Meteotsunami",
225 executable=
"ExaHyPE",
228project.add_solver(aderdg_solver)
229project.add_solver(fv_solver)
230project.add_solver(limiter_solver)
232if args.number_of_snapshots <= 0:
233 time_in_between_plots = 0.0
235 time_in_between_plots = args.end_time / args.number_of_snapshots
236 project.set_output_path(args.output)
238project.set_global_simulation_parameters(
242 min_end_time=args.end_time,
243 max_end_time=args.end_time,
244 first_plot_time_stamp=0.0,
245 time_in_between_plots=time_in_between_plots,
247 args.periodic_boundary_conditions_x,
248 args.periodic_boundary_conditions_y,
252project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
253project = project.generate_Peano4_project(verbose=
False)
254for const_name, const_info
in constants.items():
255 const_val, const_type = const_info
256 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
257project.output.makefile.set_target_device(args.target_device)
258project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)