TransFlow
0.1.0
A transient pipeline flow simulation library
|
Discretizer is an abstract class, the base class the implementation of the discretization of the two different sets of governing equations; internal energy and enthalpy. More...
#include <discretizer.hpp>
Public Member Functions | |
virtual | ~Discretizer () |
Discretizer (const arma::uword nGridPoints, const arma::uword nEquationsAndVariables) | |
Construct from number of grid points and number of equations and variables. More... | |
virtual void | discretize (const arma::uword dt, const Pipeline ¤tState, const Pipeline &newState)=0 |
Pure virtual function, stencil for subclasses. This method calculates in the coefficients of \(y_i\) and \(y_{i+1}\) and stores them in Discretizer::m_term_i and Discretizer::m_term_ipp. More... | |
const arma::cube & | term_i () const |
Get coefficients of \(y_i\). | |
const arma::cube & | term_ipp () const |
Get coefficients of \(y_{i+1}\). | |
const arma::mat & | boundaryTerms () const |
Get constant terms. | |
Protected Attributes | |
arma::cube | m_term_i |
The coefficients of \(y_i\) in the discretized governing equations. More... | |
arma::cube | m_term_ipp |
The coefficients of \(y_i\) in the discretized governing equations. More... | |
arma::mat | m_boundaryTerm |
The constant/known terms in the discretized governing equations. More... | |
double | m_gravity = 9.81 |
Gravity. | |
Discretizer is an abstract class, the base class the implementation of the discretization of the two different sets of governing equations; internal energy and enthalpy.
The governing equations are discretized using a implicit backward difference method, as detailed in
This finite difference scheme discretizes the governing properties flow, pressure and temperature onto a grid. The derivatives and values for each grid section \(I\) are approximated by different combination of the flow, pressure and temperatures at the grid points, \(y_i\) and \(y_{i+1}\), as follows
\[ \frac{\partial y(I, t_{n+1})}{\partial t} = \frac{y_{i+1}^{n+1} + y_{i}^{n+1} - y_{i+1}^{n} - y_{i}^{n}}{2\Delta t} \]
\[ \frac{\partial y(I, t_{n+1})}{\partial x} = \frac{y_{i+1}^{n+1} - y_{i}^{n+1}}{\Delta x} \]
\[ y(I, t_{n+1}) = \frac{y_{i+1}^{n+1} + y_{i}^{n+1}}{2} \]
This sets up a matrix equation \(Ax = b\), where the matrix \(A\) contains the coeffcients of each term \(y_i\), the vector \(x\) contain the unknowns \(\dot m_i\) (flow), \(p_i\) (pressure) and \(T_i\) (temperature), and the vector \(b\) contain the constant/known terms (from boundary conditions and other knowns).
|
virtual |
Have to declare virtual destructor to avoid compiler warnings. Only declared here, to avoid the inline compiler-generated default destructor.
Discretizer::Discretizer | ( | const arma::uword | nGridPoints, |
const arma::uword | nEquationsAndVariables | ||
) |
Construct from number of grid points and number of equations and variables.
Allocates the matrices Discretizer::m_term_i, Discretizer::m_term_ipp, and the vector Discretizer::m_boundaryTerm.
nGridPoints | Number of grid points |
nEquationsAndVariables | Number of equations and variables |
|
pure virtual |
Pure virtual function, stencil for subclasses. This method calculates in the coefficients of \(y_i\) and \(y_{i+1}\) and stores them in Discretizer::m_term_i and Discretizer::m_term_ipp.
dt | Time step |
currentState | Current pipeline state |
newState | New/guess pipeline state |
Implemented in EnthalpyDiscretizer, and InternalEnergyDiscretizer.
|
protected |
The constant/known terms in the discretized governing equations.
This is a matrix, organized as m_boundaryTerm(grid point, equation number)
.
|
protected |
The coefficients of \(y_i\) in the discretized governing equations.
This is an arma::cube
, which is organized as follows. m_term_i(grid point, equation number, variable number)
, where grid points are the usual grid points, equations are the continuity (0), momentum (1) and energy equations (2), and the variables are in order flow (0), pressure (1) and temperature(1). So for example if you want the coefficient at grid point number 5, in the energy equation, for flow, you want m_term_i(4, 2, 0)
(zero-indexed).
|
protected |
The coefficients of \(y_i\) in the discretized governing equations.
See Discretizer::m_term_i for a description of the organization of this.