Saras
Finite Difference Solver for Fluid Dynamics Simulations
|
Vector field class to store and operate on vector fields. More...
#include "lib/vfield.h"
Public Member Functions | |
vfield (const grid &gridData, std::string fieldName) | |
Constructor of the vfield class. More... | |
void | computeDiff (plainvf &H) |
Function to compute the diffusion term. More... | |
void | computeTStp (real &dt_out) |
Operator is used to calculate time step #dt_out using CFL Condition. More... | |
void | computeNLin (const vfield &V, plainvf &H) |
Function to compute the convective derivative of the vector field. More... | |
void | divergence (plainsf &divV, const sfield &P) |
Operator to compute the divergence of the vector field. More... | |
void | syncData () |
Function to synchronise data across all processors when performing parallel computations. More... | |
vfield & | operator+= (plainvf &a) |
Overloaded operator to add a given plain vector field. More... | |
vfield & | operator-= (plainvf &a) |
Overloaded operator to subtract a given plain vector field. More... | |
vfield & | operator+= (vfield &a) |
Overloaded operator to add a given vector field. More... | |
vfield & | operator-= (vfield &a) |
Overloaded operator to subtract a given vector field. More... | |
vfield & | operator*= (real a) |
Overloaded operator to multiply a scalar value to the vector field. More... | |
void | operator= (plainvf &a) |
Overloaded operator to assign a plain vector field to the vector field. More... | |
void | operator= (vfield &a) |
Overloaded operator to assign another vector field to the vector field. More... | |
void | operator= (real a) |
Overloaded operator to assign a scalar value to the vector field. More... | |
Public Attributes | |
field | Vx |
field | Vy |
field | Vz |
derivative | derVx |
derVx, derVy and derVz are three instances of the derivative class used to compute derivatives. More... | |
derivative | derVy |
derivative | derVz |
std::string | fieldName |
This string is used to identify the vector field, and is useful in file-writing. | |
blitz::Array< real, 3 > | interTempX |
blitz::Array< real, 3 > | interTempY |
blitz::Array< real, 3 > | interTempZ |
Vector field class to store and operate on vector fields.
The class stores vector fields in the form of three instances of the field class defined in field.h. The vector field is stored in such a way that the components are face-centered, with:
The vector field is also equipped with a divergence operator, which returns a scalar field (sfield). However, this operation returns only cell-centered scalar field as output as most scalar fields are stored at cell centers. Moreover, the \( (\mathbf{u}.\nabla)\mathbf{v} \) operator is also provided as the function computeNLin
vfield::vfield | ( | const grid & | gridData, |
std::string | fieldName | ||
) |
Constructor of the vfield class.
Three instances of field class are initialized. Each instance corresponds to a component of the vector field. The fields are initialized with appropriate grid to place the components on the cell faces. The name of the vector field as given by the user is also assigned.
gridData | is a const reference to the global data in the grid class |
fieldName | is a string value used to name and identify the vector field |
void vfield::computeDiff | ( | plainvf & | H | ) |
Function to compute the diffusion term.
The diffusion term (grad-squared) is caulculated here. The second derivatives of each component field are calculated along x, y and z. These terms are added to the corresponding components of the given plain vector field (plainvf), which is usually the RHS of the PDE being solved.
H | is a reference to the plainvf into which the output is written |
Function to compute the convective derivative of the vector field.
The function calculates \f$ (\mathbf{u}.\nabla)\mathbf{v} \f$ on the vector field, \f$\mathbf{v}\f$. To do so, the function needs the vector field (vfield) of velocity, \f$\mathbf{u}\f$. This value is used in three separate calls to the \ref sfield#computeNLin "computeNLin" function of sfield to compute the derivatives for the three components of the vector field. It is assumed that the velocity is specified at face-centers, as required by the \ref sfield#computeNLin "computeNLin" function of sfield.
V | is a const reference to the vector field (vfield) that specifies the convection velocity |
H | is a reference to the plainvf into which the output is written |
void vfield::computeTStp | ( | real & | dt_out | ) |
Operator is used to calculate time step #dt_out using CFL Condition.
When the parameters specify that time-step must be adaptively calculated using the Courant Number given in the parameters file, this function will provide the \f$ dt \f$ using the maximum values of the components of the vfield.
dt_out | is a reference to the real value into which the calculated value of time-step is written |
Operator to compute the divergence of the vector field.
The operator computes the divergence of a face-centered staggered vector field, and stores it into a cell centered scalar field as defined by the tensor operation: \f$ \nabla . \mathbf{v} = \frac{\partial \mathbf{v}}{\partial x} + \frac{\partial \mathbf{v}}{\partial y} + \frac{\partial \mathbf{v}}{\partial z} \f$.
divV | is a reference to the scalar field (sfield) into which the computed divergence is written. |
vfield & vfield::operator*= | ( | real | a | ) |
Overloaded operator to multiply a scalar value to the vector field.
The unary operator *= multiplies a real value to all the fields (Vx, Vy and Vz) stored in vfield and returns a pointer to itself.
a | is a real number to be multiplied to the vector field |
Overloaded operator to add a given plain vector field.
The unary operator += adds a given plain vector field to the vfield and returns a pointer to itself.
a | is a reference to the plainvf to be added to the member fields |
Overloaded operator to add a given vector field.
The unary operator += adds a given vector field to the vfield and returns a pointer to itself.
a | is a reference to the vfield to be added to the member fields |
Overloaded operator to subtract a given plain vector field.
The unary operator -= subtracts a given plain vector field from the vfield and returns a pointer to itself.
a | is a reference to the plainvf to be subtracted from the member fields |
Overloaded operator to subtract a given vector field.
The unary operator -= subtracts a given vector field from the vfield and returns a pointer to itself.
a | is a reference to the vfield to be subtracted from the member fields |
void vfield::operator= | ( | plainvf & | a | ) |
Overloaded operator to assign a plain vector field to the vector field.
The operator = assigns all the three blitz arrays of a plain vector field (plainvf) to the corresponding arrays in the three fields of the vfield.
a | is a plainvf to be assigned to the vector field |
void vfield::operator= | ( | real | a | ) |
Overloaded operator to assign a scalar value to the vector field.
The operator = assigns a real value to all the fields (Vx, Vy and Vz) stored in vfield.
a | is a real number to be assigned to the vector field |
void vfield::operator= | ( | vfield & | a | ) |
Overloaded operator to assign another vector field to the vector field.
The operator = assigns all the three fields of a given vector field (vfield) to the corresponding fields of the vfield.
a | is a vfield to be assigned to the vector field |
void vfield::syncData | ( | ) |
Function to synchronise data across all processors when performing parallel computations.
Each of the individual field components have their own subroutine, \ref sfield#syncData "syncData" to send and receive data across its MPI decomposed sub-domains. This function calls the \ref sfield#syncData "syncData" function of its components to update the sub-domain boundary pads.
derivative vfield::derVx |
derVx, derVy and derVz are three instances of the derivative class used to compute derivatives.
They correspond to finite-differencing operations along X, Y and Z directions respectively.