9sys.path.insert(0, os.path.abspath(
".."))
10from FWave
import fWave
11from PDE
import nonconservative_product, eigenvalue
13initial_conditions =
"""
14 static tarch::reader::NetCDFFieldParser fieldParser(
15 \"chile_gebco_usgs_2000m_bath.nc\",
16 \"chile_gebco_usgs_2000m_displ.nc\",
23 const double bathymetryBeforeEarthquake = fieldParser.sampleTopology(x(0), x(1));
24 const double displacement = fieldParser.sampleDisplacement(x(0), x(1));
25 const double bathymetryAfterEarthquake = bathymetryBeforeEarthquake + displacement;
27 Q[Shortcuts::h] = -std::min(bathymetryBeforeEarthquake, 0.0);
28 Q[Shortcuts::hu] = 0.0;
29 Q[Shortcuts::hv] = 0.0;
30 Q[Shortcuts::z] = bathymetryAfterEarthquake;
33boundary_conditions =
"""
34 Qoutside[0] = Qinside[0];
37 Qoutside[3] = Qinside[3];
40is_physically_admissible =
"""
41 bool isAdmissible = Q[0] > 100.0;
43 tarch::la::Vector<DIMENSIONS, double> bblPos = {3050000., 400000.};
44 isAdmissible &= tarch::la::norm2(x-bblPos) > 5000.;
46 tarch::la::Vector<DIMENSIONS, double> blPos = {3050000., 940000.};
47 isAdmissible &= tarch::la::norm2(x-blPos) > 5000.;
49 tarch::la::Vector<DIMENSIONS, double> mPos = {5350000., 2320000.};
50 isAdmissible &= tarch::la::norm2(x-mPos) > 25000.;
52 tarch::la::Vector<DIMENSIONS, double> tlPos = {3790000., 3360000.};
53 isAdmissible &= tarch::la::norm2(x-tlPos) > 5000.;
55 tarch::la::Vector<DIMENSIONS, double> ttlPos = {3665000., 3410000.};
56 isAdmissible &= tarch::la::norm2(x-ttlPos) > 50000.;
58 // Juan Fernández Islands
59 tarch::la::Vector<DIMENSIONS, double> jfiPos = {5960000., 1040000.};
60 isAdmissible &= tarch::la::norm2(x-jfiPos) > 10000.;
65parser = exahype2.ArgumentParser()
71args = parser.parse_args()
74 "g": [9.81,
"double"],
75 "hThreshold": [1e-5,
"double"],
80max_h = 1.1 * min(size) / (3.0**args.min_depth)
81min_h = max_h * 3.0 ** (-args.amr_levels)
82dg_order = args.degrees_of_freedom - 1
84aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
87 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
88 auxiliary_variables=0,
91 time_step_relaxation=0.9,
94aderdg_solver.set_implementation(
95 initial_conditions=initial_conditions,
96 boundary_conditions=boundary_conditions,
98 double ih = 1.0 / Q[0];
100 F[1] = Q[1 + normal] * Q[1] * ih;
101 F[2] = Q[1 + normal] * Q[2] * ih;
104 ncp=nonconservative_product,
105 max_eigenvalue=eigenvalue+
"""
109 // Compute max eigenvalue over face
111 for(int xy=0; xy<Order+1; xy++){
112 smax = std::max(smax, maxEigenvalue(&QL[xy*4], x, h, t, dt, direction));
113 smax = std::max(smax, maxEigenvalue(&QR[xy*4], x, h, t, dt, direction));
116 for(int xy=0; xy<Order+1; xy++){
117 // h gets added term from bathymetry, u and v are regular Rusanov, b does not change
118 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]) );
119 FL[xy*4+1] = 0.5*(FL[xy*4+1]+FR[xy*4+1] + smax*(QL[xy*4+1]-QR[xy*4+1]) );
120 FL[xy*4+2] = 0.5*(FL[xy*4+2]+FR[xy*4+2] + smax*(QL[xy*4+2]-QR[xy*4+2]) );
123 FR[xy*4+0] = FL[xy*4+0];
124 FR[xy*4+1] = FL[xy*4+1];
125 FR[xy*4+2] = FL[xy*4+2];
128 // Contribution from NCP
129 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]);
130 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]);
135aderdg_solver.set_plotter(args.plotter)
136aderdg_solver.add_user_solver_includes(
138#include "tarch/reader/NetCDFFieldParser.h"
142fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
144 patch_size=dg_order * 2 + 1,
145 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
146 auxiliary_variables={
"z": 1},
149 time_step_relaxation=0.9,
152fv_solver.set_implementation(
153 initial_conditions=initial_conditions,
154 boundary_conditions=boundary_conditions,
155 riemann_solver=fWave,
158fv_solver.set_plotter(args.plotter)
159fv_solver.add_user_solver_includes(
161#include "tarch/reader/NetCDFFieldParser.h"
165limiter_solver = exahype2.solvers.limiting.StaticLimiting(
166 name=
"LimiterSolver",
167 regular_solver=aderdg_solver,
168 limiting_solver=fv_solver,
169 physical_admissibility_criterion=is_physically_admissible,
172project = exahype2.Project(
173 namespace=[
"applications",
"exahype2",
"swe"],
174 project_name=
"ChileTsunami",
176 executable=
"ExaHyPE-ShallowWater",
179project.add_solver(aderdg_solver)
180project.add_solver(fv_solver)
181project.add_solver(limiter_solver)
183if args.number_of_snapshots <= 0:
184 time_in_between_plots = 0.0
186 time_in_between_plots = args.end_time / args.number_of_snapshots
187 project.set_output_path(args.output)
189project.set_global_simulation_parameters(
193 min_end_time=args.end_time,
194 max_end_time=args.end_time,
195 first_plot_time_stamp=0.0,
196 time_in_between_plots=time_in_between_plots,
198 args.periodic_boundary_conditions_x,
199 args.periodic_boundary_conditions_y,
203project.set_load_balancer(
204 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
206project.set_Peano4_installation(
207 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
209project = project.generate_Peano4_project(verbose=
False)
210for const_name, const_info
in constants.items():
211 const_val, const_type = const_info
212 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
213project.set_fenv_handler(args.fpe)
214project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)