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
6The Euler system of conservation laws for a compressible gas can be
7written
8
9\f[
10\partial_t\left(\begin{array}{c}
11\rho \\
12E \\
13w_x \\
14w_y \\
15\end{array}\right)
16+
17\nabla_x \cdot\left(\begin{array}{c}
18w_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}
25w_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
33with \f$\rho\f$ the gas density, \f$E\f$ the total energy, \f$\mathbf{w}\f$ the
34gas momentum and \f$p\f$ the pressure given by the equation of state
35
36\f[
37p = (\gamma - 1)(E - \rho\mathbf{u}^2/2)
38\f]
39
40with \f$\gamma\f$ the polytropic exponent. This system can be solved using
41the generic solver for systems of conservation laws. */
42
43#include "conservation.h"
44
45/**
46The 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
54double gammao = 1.4 ;
55
56/**
57The system is entirely defined by the `flux()` function called by the
58generic solver for conservation laws. The parameter passed to the
59function is the array `s` which contains the state variables for each
60conserved field, in the order of their definition above (i.e. scalars
61then vectors). */
62
63void 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}
vector un[]
Definition atmosphere.h:5
#define dimension
Definition bitree.h:3
int x
Definition common.h:76
static number sq(number x)
Definition common.h:11
scalar f[]
The primary fields are:
Definition two-phase.h:56
vector * vectors
double gammao
scalar E[]
vector w[]
scalar * scalars
scalar rho[]
The conserved scalars are the gas density and the total energy .
#define p
Definition tree.h:320
scalar s
Definition embed-tree.h:56
scalar int i
Definition embed.h:74
scalar flux[]
Definition vof.h:166
scalar c
Definition vof.h:57