Peano
Loading...
Searching...
No Matches
channel-flow.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 peano4
4import exahype2
5
6from PDE import max_eigenvalue, flux
7
8initial_conditions = """
9 Q[Shortcuts::rho] = 1.0;
10 Q[Shortcuts::rhoU + 0] = 0.0; // Flow in x-direction
11 Q[Shortcuts::rhoU + 1] = 0.0; // No vertical velocity
12#if DIMENSIONS == 3
13 Q[Shortcuts::rhoU + 2] = 0.0;
14#endif
15 Q[Shortcuts::rhoE] = 1.0 / (GAMMA - 1.0) + 0.5 * (Q[Shortcuts::rhoU + 0] * Q[Shortcuts::rhoU + 0] + Q[Shortcuts::rhoU + 1] * Q[Shortcuts::rhoU + 1]) / Q[Shortcuts::rho];
16"""
17
18boundary_conditions = """
19 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
20 Qoutside[i] = Qinside[i];
21 }
22
23 // Inlet boundary condition (x[0] = 0.0)
24 if (tarch::la::smallerEquals(x[0], MaxAdmissibleCellH)) {
25 Qoutside[Shortcuts::rhoU + 0] = 1.0;
26 }
27
28 // Outlet boundary condition
29 if (tarch::la::greaterEquals(x[0], DomainSize[0] - MaxAdmissibleCellH)) {
30 Qoutside[Shortcuts::rhoU + 0] = Qinside[Shortcuts::rhoU + 0];
31 }
32"""
33
34refinement_criterion = """
35 auto result = ::exahype2::RefinementCommand::Keep;
36 return result;
37"""
38
39parser = exahype2.ArgumentParser("ExaHyPE 2 - Finite Volumes Testing Script")
40parser.set_defaults(min_depth=6, degrees_of_freedom=16, end_time=2.0)
41args = parser.parse_args()
42
43size = [1.0, 1.0, 1.0]
44max_h = 1.1 * min(size) / (3.0**args.min_depth)
45min_h = max_h * 3.0 ** (-args.amr_levels)
46
47fv_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
48 name="FVSolver",
49 patch_size=args.degrees_of_freedom,
50 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
51 auxiliary_variables=0,
52 min_volume_h=min_h,
53 max_volume_h=max_h,
54 time_step_relaxation=0.5,
55 use_enclave_tasking=args.enclave_tasking,
56 number_of_enclave_tasks=args.ntasks,
57)
58
59fv_solver.set_implementation(
60 initial_conditions=initial_conditions,
61 boundary_conditions=boundary_conditions,
62 refinement_criterion=refinement_criterion,
63 max_eigenvalue=max_eigenvalue,
64 flux=flux,
65 limiter=exahype2.solvers.fv.musclhancock.Limiter.minmod,
66)
67
68project = exahype2.Project(
69 namespace=["tests", "exahype2", "fv"],
70 project_name="ChannelFlow",
71 directory=".",
72 executable="ExaHyPE",
73)
74project.add_solver(fv_solver)
75
76if args.number_of_snapshots <= 0:
77 time_in_between_plots = 0.0
78else:
79 time_in_between_plots = args.end_time / args.number_of_snapshots
80 project.set_output_path(args.output)
81
82project.set_global_simulation_parameters(
83 dimensions=args.dimensions,
84 size=size[0 : args.dimensions],
85 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
86 min_end_time=args.end_time,
87 max_end_time=args.end_time,
88 first_plot_time_stamp=0.0,
89 time_in_between_plots=time_in_between_plots,
90 periodic_BC=[
91 args.periodic_boundary_conditions_x,
92 args.periodic_boundary_conditions_y,
93 args.periodic_boundary_conditions_z,
94 ],
95)
96
97project.set_load_balancer(
98 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
99)
100project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
101project = project.generate_Peano4_project(verbose=False)
102project.output.makefile.set_target_device(args.target_device)
103project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
104project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)