6initial_conditions =
"""
7 static tarch::reader::NetCDFFieldParser fieldParser(
8 \"tohoku_gebco_ucsb3_2000m_hawaii_bath.nc\",
9 \"tohoku_gebco_ucsb3_2000m_hawaii_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 if (tarch::la::smallerEquals(Q[0], 1000.0)) {
40parser = exahype2.ArgumentParser()
46args = parser.parse_args()
49 "g": [9.81,
"double"],
50 "hThreshold": [1e-5,
"double"],
54max_h = 1.1 * min(size) / (3.0**args.min_depth)
55min_h = max_h * 3.0 ** (-args.amr_levels)
56dg_order = args.degrees_of_freedom - 1
58aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
61 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
62 auxiliary_variables=0,
65 time_step_relaxation=0.9,
68aderdg_solver.set_implementation(
69 initial_conditions=initial_conditions,
70 boundary_conditions=boundary_conditions,
72 double ih = 1.0 / Q[0];
74 F[1] = Q[1 + normal] * Q[1] * ih;
75 F[2] = Q[1 + normal] * Q[2] * ih;
78 max_eigenvalue=
"return ShallowWater::maxEigenvalue<double, Shortcuts>(Q, x, h, t, dt, normal);",
79 ncp=f
"ShallowWater::nonconservativeProduct<double, Shortcuts, {aderdg_solver.unknowns}>(Q, deltaQ, x, h, t, dt, normal, BTimesDeltaQ);",
81 // Compute max eigenvalue over face
83 for(int xy=0; xy<Order+1; xy++){
84 smax = std::max(smax, maxEigenvalue(&QL[xy*4], x, h, t, dt, direction));
85 smax = std::max(smax, maxEigenvalue(&QR[xy*4], x, h, t, dt, direction));
88 for(int xy=0; xy<Order+1; xy++){
89 // h gets added term from bathymetry, u and v are regular Rusanov, b does not change
90 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]) );
91 FL[xy*4+1] = 0.5*(FL[xy*4+1]+FR[xy*4+1] + smax*(QL[xy*4+1]-QR[xy*4+1]) );
92 FL[xy*4+2] = 0.5*(FL[xy*4+2]+FR[xy*4+2] + smax*(QL[xy*4+2]-QR[xy*4+2]) );
95 FR[xy*4+0] = FL[xy*4+0];
96 FR[xy*4+1] = FL[xy*4+1];
97 FR[xy*4+2] = FL[xy*4+2];
100 // Contribution from NCP
101 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]);
102 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]);
107aderdg_solver.add_user_solver_includes(
110#include "tarch/reader/NetCDFFieldParser.h"
114fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
116 patch_size=dg_order * 2 + 1,
117 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
118 auxiliary_variables={
"z": 1},
121 time_step_relaxation=0.9,
124fv_solver.set_implementation(
125 initial_conditions=initial_conditions,
126 boundary_conditions=boundary_conditions,
127 riemann_solver=
"return fWaveRiemannSolver<double, Shortcuts>(QL, QR, x, h, t, dt, normal, FL, FR);",
130fv_solver.add_user_solver_includes(
132#include "../FWaveRiemannSolver.h"
133#include "tarch/reader/NetCDFFieldParser.h"
137limiter_solver = exahype2.solvers.limiting.StaticLimiting(
138 name=
"LimiterSolver",
139 regular_solver=aderdg_solver,
140 limiting_solver=fv_solver,
141 physical_admissibility_criterion=is_physically_admissible,
144project = exahype2.Project(
145 namespace=[
"applications",
"exahype2",
"ShallowWater"],
146 project_name=
"TohokuTsunami",
148 executable=
"ExaHyPE",
151project.add_solver(aderdg_solver)
152project.add_solver(fv_solver)
153project.add_solver(limiter_solver)
155if args.number_of_snapshots <= 0:
156 time_in_between_plots = 0.0
158 time_in_between_plots = args.end_time / args.number_of_snapshots
159 project.set_output_path(args.output)
161project.set_global_simulation_parameters(
165 min_end_time=args.end_time,
166 max_end_time=args.end_time,
167 first_plot_time_stamp=0.0,
168 time_in_between_plots=time_in_between_plots,
170 args.periodic_boundary_conditions_x,
171 args.periodic_boundary_conditions_y,
175project.set_load_balancer(
176 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
178project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
179project = project.generate_Peano4_project(verbose=
False)
180for const_name, const_info
in constants.items():
181 const_val, const_type = const_info
182 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
183project.output.makefile.set_target_device(args.target_device)
184project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)