Peano
smooth-convergence.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 + 0.2 * std::cos(2.0 * tarch::la::PI * x[0]);
14  Q[Shortcuts::rhoU + 0] = 1.0;
15  Q[Shortcuts::rhoU + 1] = 0.0;
16 #if DIMENSIONS == 3
17  Q[Shortcuts::rhoU + 2] = 0.0;
18 #endif
19  Q[Shortcuts::rhoE] = PRESSURE / (GAMMA - 1) + 0.5 / Q[Shortcuts::rho] * (Q[Shortcuts::rhoU] * Q[Shortcuts::rhoU]);
20 """
21 
22 boundary_conditions = """
23  // Outflow boundary conditions
24  Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
25  Qoutside[Shortcuts::rhoU + 0] = Qinside[Shortcuts::rhoU + 0];
26  Qoutside[Shortcuts::rhoU + 1] = Qinside[Shortcuts::rhoU + 1];
27 #if DIMENSIONS == 3
28  Qoutside[Shortcuts::rhoU + 2] = Qinside[Shortcuts::rhoU + 2];
29 #endif
30  Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
31 """
32 
33 parser = exahype2.ArgumentParser(
34  "ExaHyPE 2 Euler Smooth Convergence Argument Parser"
35 )
36 parser.set_defaults(
37  min_depth=6,
38  end_time=0.01,
39  time_step_size=0.0001, # Suitable up to roughly min_depth = 6 based on speed of sound and max eigenvalue estimation
40  degrees_of_freedom=16,
41 )
42 args = parser.parse_args()
43 
44 size = [0.2, 0.2, 0.2]
45 max_h = 1.1 * min(size) / (3.0**args.min_depth)
46 min_h = max_h * 3.0 ** (-args.amr_levels)
47 
48 riemann_solver = exahype2.solvers.fv.musclhancock.GlobalFixedTimeStep(
49  name="MUSCLHancockSolver",
50  patch_size=args.degrees_of_freedom,
51  unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
52  auxiliary_variables=0,
53  min_volume_h=min_h,
54  max_volume_h=max_h,
55  normalised_time_step_size=args.time_step_size,
56 )
57 
58 riemann_solver.set_implementation(
59  initial_conditions=initial_conditions,
60  boundary_conditions=boundary_conditions,
61  flux=flux,
62  max_eigenvalue=max_eigenvalue,
63  limiter=exahype2.solvers.fv.musclhancock.Limiter.vanalbada,
64 )
65 
66 riemann_solver.set_plotter(args.plotter)
67 
68 project = exahype2.Project(
69  namespace=["applications", "exahype2", "euler"],
70  project_name="SmoothConvergence",
71  directory=".",
72  executable="Euler",
73 )
74 project.add_solver(riemann_solver)
75 
76 if args.number_of_snapshots <= 0:
77  time_in_between_plots = 0.0
78 else:
79  time_in_between_plots = args.end_time / args.number_of_snapshots
80  project.set_output_path(args.output)
81 
82 project.set_global_simulation_parameters(
83  dimensions=args.dimensions,
84  size=size[0 : args.dimensions],
85  offset=[-0.1, -0.1, -0.1][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=0.01,
90  periodic_BC=[
91  args.periodic_boundary_conditions_x,
92  args.periodic_boundary_conditions_y,
93  args.periodic_boundary_conditions_z,
94  ],
95 )
96 
97 project.set_load_balancer(
98  f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
99 )
100 project.set_Peano4_installation(
101  "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
102 )
103 project = project.generate_Peano4_project(verbose=False)
104 project.set_fenv_handler(args.fpe)
105 project.output.makefile.set_target_device(args.target_device)
106 project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
107 project.output.makefile.add_CXX_flag("-DPRESSURE=1.0")
108 project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)
static double min(double const x, double const y)