Peano
Loading...
Searching...
No Matches
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
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;
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
24boundary_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
35refinement_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
53parser = exahype2.ArgumentParser("ExaHyPE 2 Euler Point Explosion Argument Parser")
54parser.set_defaults(
55 min_depth=6,
56 degrees_of_freedom=16,
57)
58args = parser.parse_args()
59
60size = [1.0, 1.0, 1.0]
61max_h = 1.1 * min(size) / (3.0**args.min_depth)
62min_h = max_h * 3.0 ** (-args.amr_levels)
63
64riemann_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
65 name="FVSolver",
66 patch_size=args.degrees_of_freedom,
67 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
68 auxiliary_variables=0,
69 min_volume_h=min_h,
70 max_volume_h=max_h,
71 time_step_relaxation=0.5,
72 use_enclave_tasking=args.enclave_tasking,
73 number_of_enclave_tasks=args.ntasks,
74)
75
76riemann_solver.set_implementation(
77 initial_conditions=initial_conditions,
78 boundary_conditions=boundary_conditions,
79 refinement_criterion=refinement_criterion,
80 max_eigenvalue=max_eigenvalue,
81 flux=flux,
82)
83
84riemann_solver.set_plotter(args.plotter)
85
86project = exahype2.Project(
87 namespace=["applications", "exahype2", "euler"],
88 project_name="PointExplosion",
89 directory=".",
90 executable="Euler",
91)
92project.add_solver(riemann_solver)
93
94if args.number_of_snapshots <= 0:
95 time_in_between_plots = 0.0
96else:
97 time_in_between_plots = args.end_time / args.number_of_snapshots
98 project.set_output_path(args.output)
99
100project.set_global_simulation_parameters(
101 dimensions=args.dimensions,
102 size=size[0 : args.dimensions],
103 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
104 min_end_time=args.end_time,
105 max_end_time=args.end_time,
106 first_plot_time_stamp=0.0,
107 time_in_between_plots=time_in_between_plots,
108 periodic_BC=[
109 args.periodic_boundary_conditions_x,
110 args.periodic_boundary_conditions_y,
111 args.periodic_boundary_conditions_z,
112 ],
113)
114
115project.set_load_balancer(
116 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees}, {args.trees})"
117)
118project.set_Peano4_installation(
119 "../../../../", mode=peano4.output.string_to_mode(args.build_mode)
120)
121project = project.generate_Peano4_project(verbose=False)
122project.set_fenv_handler(args.fpe)
123project.output.makefile.set_target_device(args.target_device)
124project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
125project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)