9 sys.path.insert(0, os.path.abspath(
".."))
10 from HLLEM
import hllem
12 initial_conditions =
"""
13 const double omega = std::sqrt(0.2 * g);
15 Q[Shortcuts::z] = 0.1 * (std::pow(x[0], 2) + std::pow(x[1], 2));
16 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]);
17 Q[Shortcuts::hu] = 0.5 * omega * std::sin(omega * 0) * Q[Shortcuts::h];
18 Q[Shortcuts::hv] = 0.5 * omega * std::cos(omega * 0) * Q[Shortcuts::h];
20 //Q[Shortcuts::h] = 0.025 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1))));
21 //Q[Shortcuts::z] = -0.2 * (1.0 - std::sqrt((x(0) * x(0)) + (x(1) * x(1)))) - 0.1;
24 boundary_conditions =
"""
25 Qoutside[Shortcuts::h] = Qinside[Shortcuts::h];
26 Qoutside[Shortcuts::hu] = -Qinside[Shortcuts::hu];
27 Qoutside[Shortcuts::hv] = -Qinside[Shortcuts::hv];
28 Qoutside[Shortcuts::z] = Qinside[Shortcuts::z];
31 refinement_criterion =
"""
32 return std::sqrt((x(0) * x(0)) + (x(1) * x(1))) <= 1.0
33 ? ::exahype2::RefinementCommand::Refine
34 : ::exahype2::RefinementCommand::Keep;
37 parser = exahype2.ArgumentParser()
42 args = parser.parse_args()
45 "g": [9.81,
"double"],
46 "hThreshold": [1e-5,
"double"],
50 max_h = (1.1 *
min(size) / (3.0**args.min_depth))
51 min_h = max_h * 3.0 ** (-args.amr_levels)
53 fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
55 patch_size=args.degrees_of_freedom,
56 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
57 auxiliary_variables={
"z": 1},
60 time_step_relaxation=args.time_step_relaxation,
63 fv_solver.set_implementation(
64 initial_conditions=initial_conditions,
65 boundary_conditions=boundary_conditions,
66 refinement_criterion=refinement_criterion,
70 fv_solver.set_plotter(args.plotter)
72 project = exahype2.Project(
73 namespace=[
"applications",
"exahype2",
"swe"],
74 project_name=
"OscillatingLake",
76 executable=
"ExaHyPE-ShallowWater",
78 project.add_solver(fv_solver)
80 if args.number_of_snapshots <= 0:
81 time_in_between_plots = 0.0
83 time_in_between_plots = args.end_time / args.number_of_snapshots
84 project.set_output_path(args.output)
86 project.set_global_simulation_parameters(
90 min_end_time=args.end_time,
91 max_end_time=args.end_time,
92 first_plot_time_stamp=0.0,
93 time_in_between_plots=time_in_between_plots,
95 args.periodic_boundary_conditions_x,
96 args.periodic_boundary_conditions_y,
100 project.set_load_balancer(f
"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})")
101 project.set_Peano4_installation(
"../../../../", mode=peano4.output.string_to_mode(args.build_mode))
102 project = project.generate_Peano4_project(verbose=
False)
103 for const_name, const_info
in constants.items():
104 const_val, const_type = const_info
105 project.constants.export_constexpr_with_type(
106 const_name,
str(const_val), const_type
108 project.set_fenv_handler(args.fpe)
109 project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
static double min(double const x, double const y)