9sys.path.insert(0, os.path.abspath(
".."))
10from HLLEM
import hllem
11from PDE
import eigenvalue
13initial_conditions =
"""
14 const double omega = std::sqrt(0.2 * g);
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];
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;
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];
32refinement_criterion =
"""
33 return std::sqrt((x(0) * x(0)) + (x(1) * x(1))) <= 1.0
34 ? ::exahype2::RefinementCommand::Refine
35 : ::exahype2::RefinementCommand::Keep;
38parser = exahype2.ArgumentParser()
43args = parser.parse_args()
46 "g": [9.81,
"double"],
47 "hThreshold": [1e-5,
"double"],
51max_h = 1.1 * min(size) / (3.0**args.min_depth)
52min_h = max_h * 3.0 ** (-args.amr_levels)
54fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
56 patch_size=args.degrees_of_freedom,
57 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
58 auxiliary_variables={
"z": 1},
61 time_step_relaxation=0.5,
64fv_solver.set_implementation(
65 initial_conditions=initial_conditions,
66 boundary_conditions=boundary_conditions,
67 refinement_criterion=refinement_criterion,
71fv_solver.set_plotter(args.plotter)
73project = exahype2.Project(
74 namespace=[
"applications",
"exahype2",
"swe"],
75 project_name=
"OscillatingLake",
77 executable=
"ExaHyPE-ShallowWater",
79project.add_solver(fv_solver)
81if args.number_of_snapshots <= 0:
82 time_in_between_plots = 0.0
84 time_in_between_plots = args.end_time / args.number_of_snapshots
85 project.set_output_path(args.output)
87project.set_global_simulation_parameters(
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,
96 args.periodic_boundary_conditions_x,
97 args.periodic_boundary_conditions_y,
101project.set_load_balancer(
102 f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
104project.set_Peano4_installation(
105 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
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)