Peano
Loading...
Searching...
No Matches
oscillating-lake.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
3import os
4import sys
5
6import peano4
7import exahype2
8
9sys.path.insert(0, os.path.abspath(".."))
10from HLLEM import hllem
11from PDE import eigenvalue
12
13initial_conditions = """
14 const double omega = std::sqrt(0.2 * g);
15
16 Q[Shortcuts::z] = 0.1 * (std::pow(x[0], 2) + std::pow(x[1], 2));
17 Q[Shortcuts::h] = std::fmax(0.0, 0.05 * (2 * x[0] * std::cos(omega * 0) + 2 * x[1] * std::sin(omega * 0)) + 0.075 - Q[Shortcuts::z]);
18 Q[Shortcuts::hu] = 0.5 * omega * std::sin(omega * 0) * Q[Shortcuts::h];
19 Q[Shortcuts::hv] = 0.5 * omega * std::cos(omega * 0) * Q[Shortcuts::h];
20
21 //Q[Shortcuts::h] = 0.025 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1))));
22 //Q[Shortcuts::z] = -0.2 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1)))) - 0.1;
23"""
24
25boundary_conditions = """
26 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
27 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
28 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
29 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
30"""
31
32refinement_criterion = """
33 return std::sqrt((x(0) * x(0)) + (x(1) * x(1))) <= 1.0
34 ? ::exahype2::RefinementCommand::Refine
35 : ::exahype2::RefinementCommand::Keep;
36"""
37
38parser = exahype2.ArgumentParser()
39parser.set_defaults(
40 min_depth=4,
41 end_time=1.0,
42)
43args = parser.parse_args()
44
45constants = {
46 "g": [9.81, "double"],
47 "hThreshold": [1e-5, "double"],
48}
49
50size = [4.0, 4.0]
51max_h = 1.1 * min(size) / (3.0**args.min_depth)
52min_h = max_h * 3.0 ** (-args.amr_levels)
53
54fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
55 name="FVSolver",
56 patch_size=args.degrees_of_freedom,
57 unknowns={"h": 1, "hu": 1, "hv": 1},
58 auxiliary_variables={"z": 1},
59 min_volume_h=min_h,
60 max_volume_h=max_h,
61 time_step_relaxation=0.5,
62)
63
64fv_solver.set_implementation(
65 initial_conditions=initial_conditions,
66 boundary_conditions=boundary_conditions,
67 refinement_criterion=refinement_criterion,
68 riemann_solver=hllem,
69)
70
71fv_solver.set_plotter(args.plotter)
72
73project = exahype2.Project(
74 namespace=["applications", "exahype2", "swe"],
75 project_name="OscillatingLake",
76 directory=".",
77 executable="ExaHyPE-ShallowWater",
78)
79project.add_solver(fv_solver)
80
81if args.number_of_snapshots <= 0:
82 time_in_between_plots = 0.0
83else:
84 time_in_between_plots = args.end_time / args.number_of_snapshots
85 project.set_output_path(args.output)
86
87project.set_global_simulation_parameters(
88 dimensions=2,
89 size=size,
90 offset=[-2.0, -2.0],
91 min_end_time=args.end_time,
92 max_end_time=args.end_time,
93 first_plot_time_stamp=0.0,
94 time_in_between_plots=time_in_between_plots,
95 periodic_BC=[
96 args.periodic_boundary_conditions_x,
97 args.periodic_boundary_conditions_y,
98 ],
99)
100
101project.set_load_balancer(
102 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
103)
104project.set_Peano4_installation(
105 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
106)
107project = project.generate_Peano4_project(verbose=False)
108for const_name, const_info in constants.items():
109 const_val, const_type = const_info
110 project.constants.export_constexpr_with_type(const_name, str(const_val), const_type)
111project.set_fenv_handler(args.fpe)
112project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)