6initial_conditions =
"""
7 static tarch::reader::NetCDFFieldParser fieldParser(
8 \"chile_gebco_usgs_2000m_bath.nc\",
9 \"chile_gebco_usgs_2000m_displ.nc\",
16 const double bathymetryBeforeEarthquake = fieldParser.sampleTopology(x(0), x(1));
17 const double displacement = fieldParser.sampleDisplacement(x(0), x(1));
18 const double bathymetryAfterEarthquake = bathymetryBeforeEarthquake + displacement;
20 Q[Shortcuts::h] = -std::min(bathymetryBeforeEarthquake, 0.0);
21 Q[Shortcuts::hu] = 0.0;
22 Q[Shortcuts::hv] = 0.0;
23 Q[Shortcuts::z] = bathymetryAfterEarthquake;
26boundary_conditions =
"""
27 Qoutside[0] = Qinside[0];
30 Qoutside[3] = Qinside[3];
33is_physically_admissible =
"""
34 bool isAdmissible = Q[0] > 100.0;
36 tarch::la::Vector<DIMENSIONS, double> bblPos = {3050000., 400000.};
37 isAdmissible &= tarch::la::norm2(x-bblPos) > 5000.;
39 tarch::la::Vector<DIMENSIONS, double> blPos = {3050000., 940000.};
40 isAdmissible &= tarch::la::norm2(x-blPos) > 5000.;
42 tarch::la::Vector<DIMENSIONS, double> mPos = {5350000., 2320000.};
43 isAdmissible &= tarch::la::norm2(x-mPos) > 25000.;
45 tarch::la::Vector<DIMENSIONS, double> tlPos = {3790000., 3360000.};
46 isAdmissible &= tarch::la::norm2(x-tlPos) > 5000.;
48 tarch::la::Vector<DIMENSIONS, double> ttlPos = {3665000., 3410000.};
49 isAdmissible &= tarch::la::norm2(x-ttlPos) > 50000.;
51 // Juan Fernández Islands
52 tarch::la::Vector<DIMENSIONS, double> jfiPos = {5960000., 1040000.};
53 isAdmissible &= tarch::la::norm2(x-jfiPos) > 10000.;
58parser = exahype2.ArgumentParser()
64args = parser.parse_args()
67 "g": [9.81,
"double"],
68 "hThreshold": [1e-5,
"double"],
73max_h = 1.1 * min(size) / (3.0**args.min_depth)
74min_h = max_h * 3.0 ** (-args.amr_levels)
75dg_order = args.degrees_of_freedom - 1
77aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
80 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
81 auxiliary_variables=0,
84 time_step_relaxation=0.9,
87aderdg_solver.set_implementation(
88 initial_conditions=initial_conditions,
89 boundary_conditions=boundary_conditions,
91 double ih = 1.0 / Q[0];
93 F[1] = Q[1 + normal] * Q[1] * ih;
94 F[2] = Q[1 + normal] * Q[2] * ih;
97 max_eigenvalue=
"return ShallowWater::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
98 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
100 // Compute max eigenvalue over face
102 for(int xy=0; xy<Order+1; xy++){
103 smax = std::max(smax, maxEigenvalue(&QL[xy*4], x, h, t, dt, direction));
104 smax = std::max(smax, maxEigenvalue(&QR[xy*4], x, h, t, dt, direction));
107 for(int xy=0; xy<Order+1; xy++){
108 // h gets added term from bathymetry, u and v are regular Rusanov, b does not change
109 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]) );
110 FL[xy*4+1] = 0.5*(FL[xy*4+1]+FR[xy*4+1] + smax*(QL[xy*4+1]-QR[xy*4+1]) );
111 FL[xy*4+2] = 0.5*(FL[xy*4+2]+FR[xy*4+2] + smax*(QL[xy*4+2]-QR[xy*4+2]) );
114 FR[xy*4+0] = FL[xy*4+0];
115 FR[xy*4+1] = FL[xy*4+1];
116 FR[xy*4+2] = FL[xy*4+2];
119 // Contribution from NCP
120 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]);
121 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]);
126aderdg_solver.add_user_solver_includes(
129#include "tarch/reader/NetCDFFieldParser.h"
133fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
135 patch_size=dg_order * 2 + 1,
136 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
137 auxiliary_variables={
"z": 1},
140 time_step_relaxation=0.9,
143fv_solver.set_implementation(
144 initial_conditions=initial_conditions,
145 boundary_conditions=boundary_conditions,
146 riemann_solver=
"return fWaveRiemannSolver<double, Shortcuts>(QL, QR, x, h, t, dt, normal, FL, FR);",
149fv_solver.add_user_solver_includes(
151#include "../FWaveRiemannSolver.h"
152#include "tarch/reader/NetCDFFieldParser.h"
156limiter_solver = exahype2.solvers.limiting.StaticLimiting(
157 name=
"LimiterSolver",
158 regular_solver=aderdg_solver,
159 limiting_solver=fv_solver,
160 physical_admissibility_criterion=is_physically_admissible,
163project = exahype2.Project(
164 namespace=[
"applications",
"exahype2",
"ShallowWater"],
165 project_name=
"ChileTsunami",
167 executable=
"ExaHyPE",
170project.add_solver(aderdg_solver)
171project.add_solver(fv_solver)
172project.add_solver(limiter_solver)
174if args.number_of_snapshots <= 0:
175 time_in_between_plots = 0.0
177 time_in_between_plots = args.end_time / args.number_of_snapshots
178 project.set_output_path(args.output)
180project.set_global_simulation_parameters(
184 min_end_time=args.end_time,
185 max_end_time=args.end_time,
186 first_plot_time_stamp=0.0,
187 time_in_between_plots=time_in_between_plots,
189 args.periodic_boundary_conditions_x,
190 args.periodic_boundary_conditions_y,
194project.set_load_balancer(
195 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
197project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
198project = project.generate_Peano4_project(verbose=
False)
199for const_name, const_info
in constants.items():
200 const_val, const_type = const_info
201 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
202project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)