Peano
artificial-meteo-tsunami.py
Go to the documentation of this file.
1 # This file is part of the ExaHyPE2 project. For conditions of distribution and
2 # use, please see the copyright notice at www.peano-framework.org
3 import peano4
4 import exahype2
5 
6 parser = exahype2.ArgumentParser()
7 parser.set_defaults(
8  end_time=50000.0,
9  min_depth=5,
10 )
11 args = parser.parse_args()
12 
13 xLeft, xRight = -1514683.37644735, 1514574.46378654
14 yLeft, yRight = -1108652.87362612, 1176250.82246588
15 
16 size = [abs(xLeft) + abs(xRight), abs(yLeft) + abs(yRight)]
17 max_h = 1.1 * min(size) / (3.0**args.min_depth)
18 min_h = max_h * 3.0 ** (-args.amr_levels)
19 
20 fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
21  name="FVSolver",
22  patch_size=args.degrees_of_freedom,
23  unknowns={"h": 1, "hu": 1, "hv": 1},
24  auxiliary_variables={"b": 1},
25  min_volume_h=min_h,
26  max_volume_h=max_h,
27  time_step_relaxation=args.time_step_relaxation,
28  number_of_enclave_tasks=args.ntasks,
29 )
30 
31 fv_solver.set_implementation(
32  initial_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
33  boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
34  refinement_criterion=exahype2.solvers.PDETerms.User_Defined_Implementation,
35  flux=exahype2.solvers.PDETerms.User_Defined_Implementation,
36  ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
37  max_eigenvalue=exahype2.solvers.PDETerms.User_Defined_Implementation,
38  source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
39 )
40 
41 fv_solver.set_plotter(args.plotter)
42 
43 project = exahype2.Project(
44  namespace=["applications", "exahype2", "swe"],
45  project_name="ArtificalMeteoTsunami",
46  directory=".",
47  executable="ExaHyPE-ShallowWater",
48 )
49 project.add_solver(fv_solver)
50 
51 if args.number_of_snapshots <= 0:
52  time_in_between_plots = 0.0
53 else:
54  time_in_between_plots = args.end_time / args.number_of_snapshots
55  project.set_output_path(args.output)
56 
57 project.set_global_simulation_parameters(
58  dimensions=2,
59  size=size,
60  offset=[xLeft, yLeft],
61  min_end_time=args.end_time,
62  max_end_time=args.end_time,
63  first_plot_time_stamp=0.0,
64  time_in_between_plots=time_in_between_plots,
65  periodic_BC=[
66  args.periodic_boundary_conditions_x,
67  args.periodic_boundary_conditions_y,
68  ],
69 )
70 
71 constants = {
72  "GRAV": [9.81, "double"],
73  "hThreshold": [1e-5, "double"],
74  "aeaEllipsoidA": [
75  6378137.0,
76  "double",
77  ], # Semi-major axis of the WGS84 ellipsoid (in meters)
78  "aeaEllipsoidE": [
79  0.08181919084262157,
80  "double",
81  ], # First numerical eccentricity of the WGS84 ellipsoid
82  "aeaStdParallel1": [18.3333333, "double"], # Standard Parallel 1 (degrees)
83  "aeaStdParallel2": [31.6666667, "double"], # Standard Parallel 2 (degrees)
84  "aeaLon0": [-84.0, "double"], # Central Meridian (degrees)
85  "aeaLat0": [25.0, "double"], # Latitude of Origin (degrees)
86  "aeaEarthRadius": [6371000.0, "double"], # Projection Earth Radius
87  "pointLonA": [-85.107, "double"],
88  "pointLatA": [30.747, "double"],
89  "pointLonB": [-81.562, "double"],
90  "pointLatB": [23.4480, "double"],
91  "waterDensity": [1000 + 25, "double"], # Mean value of 24.50 and 25.50
92 }
93 
94 project.set_load_balancer(
95  f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
96 )
97 project.set_Peano4_installation(
98  "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
99 )
100 
101 project = project.generate_Peano4_project(verbose=False)
102 project.output.makefile.add_cpp_file("FVSolver.cpp")
103 for const_name, const_info in constants.items():
104  const_val, const_type = const_info
105  project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
106 project.set_fenv_handler(args.fpe)
107 project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)
static double min(double const x, double const y)
str
Definition: ccz4.py:55