Peano
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
3 import os
4 import sys
5 
6 import peano4
7 import exahype2
8 
9 sys.path.insert(0, os.path.abspath(".."))
10 from PDE import max_eigenvalue, flux
11 
12 initial_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 
22 boundary_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 
38 refinement_criterion = """
39  auto result = ::exahype2::RefinementCommand::Keep;
40  return result;
41 """
42 
43 parser = exahype2.ArgumentParser("ExaHyPE 2 Euler Channel Flow Argument Parser")
44 parser.set_defaults(
45  min_depth=6,
46  degrees_of_freedom=16,
47  end_time=2.0
48 )
49 args = parser.parse_args()
50 
51 size = [1.0, 1.0, 1.0]
52 max_h = 1.1 * min(size) / (3.0**args.min_depth)
53 min_h = max_h * 3.0 ** (-args.amr_levels)
54 
55 riemann_solver = exahype2.solvers.fv.musclhancock.GlobalAdaptiveTimeStep(
56  name="FVSolver",
57  patch_size=args.degrees_of_freedom,
58  unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
59  auxiliary_variables=0,
60  min_volume_h=min_h,
61  max_volume_h=max_h,
62  time_step_relaxation=args.time_step_relaxation,
63  use_enclave_tasking=args.enclave_tasking,
64  number_of_enclave_tasks=args.ntasks,
65 )
66 
67 riemann_solver.set_implementation(
68  initial_conditions=initial_conditions,
69  boundary_conditions=boundary_conditions,
70  refinement_criterion=refinement_criterion,
71  max_eigenvalue=max_eigenvalue,
72  flux=flux,
73  limiter=exahype2.solvers.fv.musclhancock.Limiter.minmod
74 )
75 
76 riemann_solver.set_plotter(args.plotter)
77 
78 project = exahype2.Project(
79  namespace=["applications", "exahype2", "euler"],
80  project_name="ChannelFlow",
81  directory=".",
82  executable="Euler",
83 )
84 project.add_solver(riemann_solver)
85 
86 if args.number_of_snapshots <= 0:
87  time_in_between_plots = 0.0
88 else:
89  time_in_between_plots = args.end_time / args.number_of_snapshots
90  project.set_output_path(args.output)
91 
92 project.set_global_simulation_parameters(
93  dimensions=args.dimensions,
94  size=size[0 : args.dimensions],
95  offset=[0.0, 0.0, 0.0][0 : args.dimensions],
96  min_end_time=args.end_time,
97  max_end_time=args.end_time,
98  first_plot_time_stamp=0.0,
99  time_in_between_plots=time_in_between_plots,
100  periodic_BC=[
101  args.periodic_boundary_conditions_x,
102  args.periodic_boundary_conditions_y,
103  args.periodic_boundary_conditions_z,
104  ],
105 )
106 
107 project.set_load_balancer(
108  f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
109 )
110 project.set_Peano4_installation(
111  "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
112 )
113 project = project.generate_Peano4_project(verbose=False)
114 project.set_fenv_handler(args.fpe)
115 project.output.makefile.set_target_device(args.target_device)
116 project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
117 project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)
static double min(double const x, double const y)