Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
compressible.h
Go to the documentation of this file.
1
/** @file compressible.h
2
*/
3
/**
4
# Compressible gas dynamics
5
6
The Euler system of conservation laws for a compressible gas can be
7
written
8
9
\f[
10
\partial_t\left(\begin{array}{c}
11
\rho \\
12
E \\
13
w_x \\
14
w_y \\
15
\end{array}\right)
16
+
17
\nabla_x \cdot\left(\begin{array}{c}
18
w_x \\
19
\frac{w_x}{\rho} ( E + p ) \\
20
\frac{w_x^2}{\rho} + p \\
21
\frac{w_y w_x}{\rho} \\
22
\end{array}\right)
23
+
24
\nabla_y \cdot\left(\begin{array}{c}
25
w_y \\
26
\frac{w_y}{\rho} ( E + p ) \\
27
\frac{w_y w_x}{\rho} \\
28
\frac{w_y^2}{\rho} + p \\
29
\end{array}\right)
30
= 0
31
\f]
32
33
with \f$\rho\f$ the gas density, \f$E\f$ the total energy, \f$\mathbf{w}\f$ the
34
gas momentum and \f$p\f$ the pressure given by the equation of state
35
36
\f[
37
p = (\gamma - 1)(E - \rho\mathbf{u}^2/2)
38
\f]
39
40
with \f$\gamma\f$ the polytropic exponent. This system can be solved using
41
the generic solver for systems of conservation laws. */
42
43
#include "
conservation.h
"
44
45
/**
46
The conserved scalars are the gas density \f$\rho\f$ and the total energy
47
\f$E\f$. The only conserved vector is the momentum \f$\mathbf{w}\f$. The constant
48
\f$\gamma\f$ is represented by *gammao* here, with a default value of 1.4. */
49
50
scalar
rho
[],
E
[];
51
vector
w
[];
52
scalar
*
scalars
= {
rho
,
E
};
53
vector
*
vectors
= {
w
};
54
double
gammao
= 1.4 ;
55
56
/**
57
The system is entirely defined by the `flux()` function called by the
58
generic solver for conservation laws. The parameter passed to the
59
function is the array `s` which contains the state variables for each
60
conserved field, in the order of their definition above (i.e. scalars
61
then vectors). */
62
63
void
flux
(
const
double
*
s
,
double
*
f
,
double
*
e
)
64
{
65
66
/**
67
We first recover each value (\f$\rho\f$, \f$E\f$, \f$w_x\f$ and \f$w_y\f$) and then
68
compute the corresponding fluxes (`f[0]`, `f[1]`, `f[2]` and
69
`f[3]`). */
70
71
double
rho
=
s
[0],
E
=
s
[1],
wn
=
s
[2],
w2
= 0.;
72
for
(
int
i
= 2;
i
< 2 +
dimension
;
i
++)
73
w2
+=
sq
(
s
[
i
]);
74
double
un
=
wn
/
rho
,
p
= (
gammao
- 1.)*(
E
- 0.5*
w2
/
rho
);
75
76
f
[0] =
wn
;
77
f
[1] =
un
*(
E
+
p
);
78
f
[2] =
un
*
wn
+
p
;
79
for
(
int
i
= 3;
i
< 2 +
dimension
;
i
++)
80
f
[
i
] =
un
*
s
[
i
];
81
82
/**
83
The minimum and maximum eigenvalues for the Euler system are the
84
characteristic speeds \f$u \pm \sqrt(\gamma p / \rho)\f$. */
85
86
double
c
=
sqrt
(
gammao
*
p
/
rho
);
87
e
[0] =
un
-
c
;
// min
88
e
[1] =
un
+
c
;
// max
89
}
un
vector un[]
Definition
atmosphere.h:5
dimension
#define dimension
Definition
bitree.h:3
x
int x
Definition
common.h:76
sq
static number sq(number x)
Definition
common.h:11
f
scalar f[]
The primary fields are:
Definition
two-phase.h:56
vectors
vector * vectors
Definition
compressible.h:53
gammao
double gammao
Definition
compressible.h:54
E
scalar E[]
Definition
compressible.h:50
w
vector w[]
Definition
compressible.h:51
scalars
scalar * scalars
Definition
compressible.h:52
rho
scalar rho[]
The conserved scalars are the gas density and the total energy .
Definition
compressible.h:50
p
#define p
Definition
tree.h:320
s
scalar s
Definition
embed-tree.h:56
i
scalar int i
Definition
embed.h:74
conservation.h
scalar
Definition
common.h:44
vector
Definition
common.h:46
flux
scalar flux[]
Definition
vof.h:166
c
scalar c
Definition
vof.h:57
compressible.h
Generated by
1.9.8