Peano
point-explosion.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;
15  Q[Shortcuts::rhoU + 1] = 0.0;
16 #if DIMENSIONS == 2
17  Q[Shortcuts::rhoE] = ((std::sqrt(std::pow(0.5 - x(0), 2) + std::pow(0.5 - x(1), 2)) < 0.2) ? (1.0) : (1.01));
18 #else
19  Q[Shortcuts::rhoU + 2] = 0.0;
20  Q[Shortcuts::rhoE] = ((std::sqrt(std::pow(0.5 - x(0), 2) + std::pow(0.5 - x(1), 2) + std::pow(0.5 - x(2), 2)) < 0.2) ? (1.0) : (1.01));
21 #endif
22 """
23 
24 boundary_conditions = """
25  // Reflective boundary conditions
26  Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
27  Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
28  Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
29 #if DIMENSIONS == 3
30  Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
31 #endif
32  Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
33 """
34 
35 refinement_criterion = """
36  auto result = ::exahype2::RefinementCommand::Keep;
37 
38 #if DIMENSIONS == 3
39  tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5, 0.5};
40 #else
41  tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5};
42 #endif
43 
44  if (tarch::la::equals(t, 0.0)) {
45  if (tarch::la::norm2(x - circleCentre) < 0.1) {
46  result = ::exahype2::RefinementCommand::Refine;
47  }
48  }
49 
50  return result;
51 """
52 
53 parser = exahype2.ArgumentParser(
54  "ExaHyPE 2 Euler Point Explosion Argument Parser"
55 )
56 parser.set_defaults(
57  min_depth=6,
58  degrees_of_freedom=16,
59 )
60 args = parser.parse_args()
61 
62 size = [1.0, 1.0, 1.0]
63 max_h = 1.1 * min(size) / (3.0**args.min_depth)
64 min_h = max_h * 3.0 ** (-args.amr_levels)
65 
66 riemann_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
67  name="FVSolver",
68  patch_size=args.degrees_of_freedom,
69  unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
70  auxiliary_variables=0,
71  min_volume_h=min_h,
72  max_volume_h=max_h,
73  time_step_relaxation=args.time_step_relaxation,
74  use_enclave_tasking=args.enclave_tasking,
75  number_of_enclave_tasks=args.ntasks,
76 )
77 
78 riemann_solver.set_implementation(
79  initial_conditions=initial_conditions,
80  boundary_conditions=boundary_conditions,
81  refinement_criterion=refinement_criterion,
82  max_eigenvalue=max_eigenvalue,
83  flux=flux,
84 )
85 
86 riemann_solver.set_plotter(args.plotter)
87 
88 project = exahype2.Project(
89  namespace=["applications", "exahype2", "euler"],
90  project_name="PointExplosion",
91  directory=".",
92  executable="Euler",
93 )
94 project.add_solver(riemann_solver)
95 
96 if args.number_of_snapshots <= 0:
97  time_in_between_plots = 0.0
98 else:
99  time_in_between_plots = args.end_time / args.number_of_snapshots
100  project.set_output_path(args.output)
101 
102 project.set_global_simulation_parameters(
103  dimensions=args.dimensions,
104  size=size[0 : args.dimensions],
105  offset=[0.0, 0.0, 0.0][0 : args.dimensions],
106  min_end_time=args.end_time,
107  max_end_time=args.end_time,
108  first_plot_time_stamp=0.0,
109  time_in_between_plots=time_in_between_plots,
110  periodic_BC=[
111  args.periodic_boundary_conditions_x,
112  args.periodic_boundary_conditions_y,
113  args.periodic_boundary_conditions_z,
114  ],
115 )
116 
117 project.set_load_balancer(
118  f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
119 )
120 project.set_Peano4_installation(
121  "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
122 )
123 project = project.generate_Peano4_project(verbose=False)
124 project.set_fenv_handler(args.fpe)
125 project.output.makefile.set_target_device(args.target_device)
126 project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
127 project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)
static double min(double const x, double const y)