Peano
Loading...
Searching...
No Matches
smooth-convergence-test-with-injected-functions.py
Go to the documentation of this file.
1import os, sys
2import peano4.api
3import exahype2
4
5
7 namespace=["benchmarks", "exahype2", "euler", "smooth_convergence_test"],
8 project_name="smooth-convergence-test",
9 directory=".",
10 executable="smooth-convergence-test",
11)
12
13solver_name = "EulerFVSmooth"
14unknowns = 4
15auxiliary_variables = 0
16mesh_size = 0.2 / 9.0
17patch_size = 9
18dimensions = 2
19verbosity = peano4.api.LoggerVerbosity.TEXT
20# verbosity = peano4.api.LoggerVerbosity.VISUALISATION
21
23 solver_name,
24 unknowns,
25 auxiliary_variables,
26)
27
28thesolver.add_user_solver_includes("#include <cmath>\n" "#include <algorithm>\n")
29
30thesolver.add_pde_term(
32 implementation="""
33 const double irho = 1.0 / Q[0];
34 constexpr double gamma = 1.4;
35 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
36
37 switch (normal) {
38 case 0:
39 F[0] = Q[1];
40 F[1] = irho * Q[1] * Q[1] + p;
41 F[2] = irho * Q[1] * Q[2];
42 F[3] = irho * Q[1] * (Q[3] + p);
43 break;
44 case 1:
45 F[0] = Q[2];
46 F[1] = irho * Q[2] * Q[1];
47 F[2] = irho * Q[2] * Q[2] + p;
48 F[3] = irho * Q[2] * (Q[3] + p);
49 break;
50 }
51 """,
52 stateless=False,
53 )
54)
55thesolver.add_pde_term(
57 implementation="""
58 // Eigenvalues of the Euler flux Jacobian in direction "normal" are
59 // u_n +/- c, where u_n is the *velocity* component (momentum/density),
60 // not the raw momentum component - several earlier ExaHyPE
61 // applications/benchmarks used the raw momentum here by mistake, which
62 // silently gives a wrong (and usually too small) CFL time step bound.
63 const double irho = 1.0 / Q[0];
64 constexpr double gamma = 1.4;
65 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
66 const double c = std::sqrt(gamma * p * irho);
67
68 switch (normal) {
69 case 0:
70 lambdaMax[0] = std::max(std::abs(Q[1] * irho + c), std::abs(Q[1] * irho - c));
71 break;
72 case 1:
73 lambdaMax[0] = std::max(std::abs(Q[2] * irho + c), std::abs(Q[2] * irho - c));
74 break;
75 }
76 """,
77 stateless=True,
78 )
79)
80thesolver.add_pde_term(exahype2.api.InitPointWisely(stateless=False,))
81
82thesolver.numerical_scheme = exahype2.api.fv.RusanovWithExplicitEuler(thesolver, patch_size)
84 thesolver, volume_size=0.001
85)
87 thesolver, first_plot_time_stamp=0.0, time_in_between_plots=0.01
88)
89
90# patch_size,
91# mesh_size,
92# mesh_size,
93# normalised_time_step_size=0.0001,
94# flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
95# eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
96
97
98# oldsolver = exahype2.solvers.fv.musclhancock.GlobalFixedTimeStep(
99# solver_name,
100# patch_size,
101# unknowns, auxiliary_variables,
102# mesh_size,
103# mesh_size,
104# normalised_time_step_size=0.0001,
105# flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
106# eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
107# )
108
109project.add_solver(thesolver)
110
111# build_mode = peano4.api.output.CompileMode.RELEASE
112build_mode = peano4.api.output.CompileMode.DEBUG
113project.set_global_simulation_parameters(
114 dimensions=dimensions,
115 offset=[-0.1, -0.1],
116 size=[0.2, 0.2],
117 min_end_time=0.01,
118 max_end_time=0.01,
119 periodic_BC=[False, False, False],
120)
121
122# project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveBipartition", "new ::exahype2::LoadBalancingConfiguration()")
123project.set_Peano4_installation("../../../../", build_mode)
124peano4_project = project.generate_Peano4_project(verbosity=verbosity)
125peano4_project.generate()
126peano4_project.build(make_clean_first=True)
The conservative flux F(Q) of a hyperbolic PDE.
Definition Flux.py:8
Point-wise initial condition: given the physical position of a single degree of freedom,...
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
ExaHyPE 2 project.
Definition Project.py:15
Abstract base class for all ExaHyPE 2 solvers.
Definition Solver.py:17
Plotting counterpart to RusanovWithExplicitEuler: maps the patch data of a Finite Volume scheme with ...
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...