Peano
Loading...
Searching...
No Matches
gaussian-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 peano4
4import exahype2
5
6from PDE import max_eigenvalue, flux
7
8initial_conditions = """
9 /**
10 * With plain DG, Rusanov, and without an additional limiter, we cannot solve
11 * discontinuous initial conditions. At the moment, most of the scenarios
12 * are physically meaningless. The only setup that should work
13 * out-of-the-box is the Gaussian, as it is infinitely smooth. Having said
14 * this, the Gaussian still can run into problems if it is too steep: If the
15 * polynomial order and mesh resolution are too low, the Gaussian continues
16 * to look like a discontinuous initial condition and thus introduces
17 * problems. Therefore, we scale its diameter with the maximum cell width. In
18 * a real setup, we should also take the polynomial order into account.
19 */
20
21 // Manual offset to make the wave originate slightly to the left of the center
22 // --- helps to detect if wave is moving to the left or right.
23#if DIMENSIONS == 2
24 const tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.3};
25#else
26 const tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.18, 0.3, 0.6};
27#endif
28
29 const double peakDeviation = MaxAdmissibleCellH;
30 const double distance = tarch::la::norm2(x - circleCentre);
31 const double exponent = -(distance * distance) / 2.0 / peakDeviation / peakDeviation;
32
33 Q[Shortcuts::rho] = 0.1;
34 Q[Shortcuts::rhoU + 0] = 0.0;
35 Q[Shortcuts::rhoU + 1] = 0.0;
36#if DIMENSIONS == 3
37 Q[Shortcuts::rhoU + 2] = 0.0;
38#endif
39 Q[Shortcuts::rhoE] = 1.0 + std::exp(exponent);
40"""
41
42boundary_conditions = """
43 // Reflective boundary conditions
44 Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
45 Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
46 Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
47#if DIMENSIONS == 3
48 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
49#endif
50 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
51"""
52
53refinement_criterion = """
54 auto result = ::exahype2::RefinementCommand::Keep;
55
56#if DIMENSIONS == 2
57 const tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.3};
58#else
59 const tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.18, 0.3, 0.6};
60#endif
61
62 if (tarch::la::equals(t, 0.0)) {
63 if (tarch::la::norm2(x - circleCentre) < 0.1) {
64 result = ::exahype2::RefinementCommand::Refine;
65 }
66 }
67
68 return result;
69"""
70
71parser = exahype2.ArgumentParser("ExaHyPE 2 - Finite Volumes Testing Script")
72parser.set_defaults(
73 min_depth=6,
74 degrees_of_freedom=16,
75)
76args = parser.parse_args()
77
78size = [1.0, 1.0, 1.0]
79max_h = 1.1 * min(size) / (3.0**args.min_depth)
80min_h = max_h * 3.0 ** (-args.amr_levels)
81
82fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
83 name="FVSolver",
84 patch_size=args.degrees_of_freedom,
85 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
86 auxiliary_variables=0,
87 min_volume_h=min_h,
88 max_volume_h=max_h,
89 time_step_relaxation=0.5,
90 use_enclave_tasking=args.enclave_tasking,
91 number_of_enclave_tasks=args.ntasks,
92)
93
94fv_solver.set_implementation(
95 initial_conditions=initial_conditions,
96 boundary_conditions=boundary_conditions,
97 refinement_criterion=refinement_criterion,
98 max_eigenvalue=max_eigenvalue,
99 flux=flux,
100)
101
102project = exahype2.Project(
103 namespace=["tests", "exahype2", "fv"],
104 project_name="GaussianExplosion",
105 directory=".",
106 executable="ExaHyPE",
107)
108project.add_solver(fv_solver)
109
110if args.number_of_snapshots <= 0:
111 time_in_between_plots = 0.0
112else:
113 time_in_between_plots = args.end_time / args.number_of_snapshots
114 project.set_output_path(args.output)
115
116project.set_global_simulation_parameters(
117 dimensions=args.dimensions,
118 size=size[0 : args.dimensions],
119 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
120 min_end_time=args.end_time,
121 max_end_time=args.end_time,
122 first_plot_time_stamp=0.0,
123 time_in_between_plots=time_in_between_plots,
124 periodic_BC=[
125 args.periodic_boundary_conditions_x,
126 args.periodic_boundary_conditions_y,
127 args.periodic_boundary_conditions_z,
128 ],
129)
130
131project.set_load_balancer(
132 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
133)
134project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
135project = project.generate_Peano4_project(verbose=False)
136project.output.makefile.set_target_device(args.target_device)
137project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
138project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)