Peano
Loading...
Searching...
No Matches
posteriori-limiting-euler-shock.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.api
4import exahype2
5
6project = exahype2.Project(
7 ["tests", "exahype2", "aderdg"], ".", executable="ADERDG-Limiting"
8)
9
10dimensions = 2
11min_level = 3
12max_depth = 0
13order = 5
14end_time = 1.0
15plot_interval = 0.0 # 0.05
16
17offset = [-1.0, -1.0, -1.0][0:dimensions]
18size = [2.0, 2.0, 2.0][0:dimensions]
19max_h = 1.1 * min(size) / (3.0**min_level)
20min_h = max_h / (3.0**max_depth)
21
22initial_conditions = """
23 constexpr double OriginalShockPosition = 0.111;
24 constexpr double Gamma = 1.4;
25 const double p = (x[0] < -OriginalShockPosition && x[1] < -OriginalShockPosition) ? 0.1 : 1.0;
26
27 Q[0] = (x[0] < -OriginalShockPosition && x[1] < -OriginalShockPosition) ? 0.125 : 1.0;
28 Q[1] = 0.0;
29 Q[2] = 0.0;
30 Q[3] = p / (Gamma - 1.0);
31"""
32
33boundary_conditions = """
34 constexpr double OriginalShockPosition = 0.111;
35 constexpr double Gamma = 1.4;
36 const double p = (x[0] < -OriginalShockPosition && x[1] < -OriginalShockPosition) ? 0.1 : 1.0;
37
38 Qoutside[0] = (x[0] < -OriginalShockPosition && x[1] < -OriginalShockPosition) ? 0.125 : 1.0;
39 Qoutside[1] = 0.0;
40 Qoutside[2] = 0.0;
41 Qoutside[3] = p / (Gamma - 1.0);
42"""
43
44flux = """
45 const double irho = 1.0 / Q[0];
46 constexpr double Gamma = 1.4;
47 const double p = (Gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]));
48
49 F[0] = Q[normal+1];
50 F[1] = Q[normal+1] * Q[1] * irho;
51 F[2] = Q[normal+1] * Q[2] * irho;
52 F[3] = Q[normal+1] * irho * (Q[3] + p);
53
54 F[normal+1] += p;
55"""
56
57max_eval = """
58 const double irho = 1.0 / Q[0];
59 constexpr double Gamma = 1.4;
60 const double p = (Gamma - 1.0) * (Q[3] - 0.5 * irho*(Q[1]*Q[1]+Q[2]*Q[2]));
61
62 const double c = std::sqrt(Gamma * p * irho);
63 const double u = Q[normal + 1] * irho;
64
65 return std::max(std::abs(u-c), std::abs(u+c));
66"""
67
68aderdg_solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
69 name="ADERDGSolver",
70 order=order,
71 unknowns=4,
72 auxiliary_variables=0,
73 min_cell_h=min_h,
74 max_cell_h=max_h,
75 time_step_relaxation=0.9,
76 flux=flux,
77 eigenvalues=max_eval,
78 initial_conditions=initial_conditions,
79 boundary_conditions=boundary_conditions,
80)
81project.add_solver(aderdg_solver)
82
83fv_solver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep(
84 name="FVSolver",
85 patch_size=2 * order + 1,
86 unknowns=4,
87 auxiliary_variables=0,
88 min_volume_h=min_h,
89 max_volume_h=max_h,
90 time_step_relaxation=0.9,
91 flux=flux,
92 eigenvalues=max_eval,
93 initial_conditions="const tarch::la::Vector<Dimensions, double>& x = volumeCentre;\n" + initial_conditions,
94 boundary_conditions="const tarch::la::Vector<Dimensions, double>& x = faceCentre;\n" + boundary_conditions,
95)
96project.add_solver(fv_solver)
97
98limiter = exahype2.solvers.limiting.PosterioriLimiting(
99 name="LimitingSolver",
100 regular_solver=aderdg_solver,
101 limiting_solver=fv_solver,
102 number_of_dmp_observables=4,
103 dmp_relaxation_parameter=0.01, # 0.02 works for depth 2, 0.01 works for depth 3
104 dmp_differences_scaling=0.03, # 0.04 works for depth 2, 0.02 works for depth 3
105 physical_admissibility_criterion="return (Q[0] > 0.0 && Q[3] > 0.0); // Density and energy must be positive",
106)
107project.add_solver(limiter)
108
109project.set_output_path("solutions")
110
111build_mode = peano4.api.output.CompileMode.RELEASE
112
113project.set_global_simulation_parameters(
114 dimensions=dimensions,
115 offset=offset[0:dimensions],
116 size=size[0:dimensions],
117 min_end_time=end_time,
118 max_end_time=end_time,
119 first_plot_time_stamp=0.0,
120 time_in_between_plots=plot_interval,
121 periodic_BC=[False, False, False][0:dimensions],
122)
123
124project.set_load_balancing(
125 "toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates",
126 "new ::exahype2::LoadBalancingConfiguration(0.98)",
127)
128project.set_Peano4_installation("../../../", build_mode)
129project = project.generate_Peano4_project("False")
130#project.set_fenv_handler("FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")
131
132project.build(make_clean_first=True)
133
134print(fv_solver)
135print(aderdg_solver)
136print(limiter)
137print(project)