9 sys.path.insert(0, os.path.abspath(
".."))
12 initial_conditions =
"""
13 static tarch::reader::NetCDFFieldParser fieldParser(
14 \"artificial_bath_1000.nc\",
15 \"artificial_displ_1000.nc\",
22 const double bathymetryBeforeEarthquake = fieldParser.sampleTopology(x(0), x(1));
23 const double displacement = fieldParser.sampleDisplacement(x(0), x(1));
24 const double bathymetryAfterEarthquake = bathymetryBeforeEarthquake + displacement;
26 Q[Shortcuts::h] = -std::min(bathymetryBeforeEarthquake, 0.0);
27 Q[Shortcuts::hu] = 0.0;
28 Q[Shortcuts::hv] = 0.0;
29 Q[Shortcuts::z] = bathymetryAfterEarthquake;
32 boundary_conditions =
"""
33 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
34 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
35 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
36 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
39 refinement_criterion =
"""
40 auto result = ::exahype2::RefinementCommand::Keep;
41 if (x[0] >= 4500.0 && x[1] >= 4500.0 && x[0] <= 5500.0 && x[1] <= 5500.0) {
42 result = ::exahype2::RefinementCommand::Refine;
47 parser = exahype2.ArgumentParser()
52 args = parser.parse_args()
55 "g": [9.81,
"double"],
56 "hThreshold": [1e-5,
"double"],
59 size = [10000.0, 10000.0]
60 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
61 min_h = max_h * 3.0 ** (-args.amr_levels)
63 aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
65 order=args.degrees_of_freedom,
66 unknowns={
"h": 1,
"hu": 1,
"hv": 1,
"z": 1},
67 auxiliary_variables=0,
70 time_step_relaxation=args.time_step_relaxation,
73 aderdg_solver.set_implementation(
74 initial_conditions=initial_conditions,
75 boundary_conditions=boundary_conditions,
76 refinement_criterion=refinement_criterion,
78 ncp=nonconservative_product,
79 max_eigenvalue=eigenvalue +
"""
84 aderdg_solver.set_plotter(args.plotter)
85 aderdg_solver.add_kernel_optimisations(is_linear=
False, polynomials=exahype2.solvers.aderdg.Polynomials.Gauss_Legendre)
86 aderdg_solver.add_user_solver_includes(
88 #include "tarch/reader/NetCDFFieldParser.h"
92 project = exahype2.Project(
93 namespace=[
"applications",
"exahype2",
"swe"],
94 project_name=
"ArtificialTsunami",
96 executable=
"ExaHyPE-ShallowWater",
98 project.add_solver(aderdg_solver)
100 if args.number_of_snapshots <= 0:
101 time_in_between_plots = 0.0
103 time_in_between_plots = args.end_time / args.number_of_snapshots
104 project.set_output_path(args.output)
106 project.set_global_simulation_parameters(
110 min_end_time=args.end_time,
111 max_end_time=args.end_time,
112 first_plot_time_stamp=0.0,
113 time_in_between_plots=time_in_between_plots,
115 args.periodic_boundary_conditions_x,
116 args.periodic_boundary_conditions_y,
120 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
121 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
122 project = project.generate_Peano4_project(verbose=
False)
123 for const_name, const_info
in constants.items():
124 const_val, const_type = const_info
125 project.constants.export_constexpr_with_type(
126 const_name,
str(const_val), const_type
128 project.set_fenv_handler(args.fpe)
129 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)