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