Saras
Finite Difference Solver for Fluid Dynamics Simulations
|
Scalar field class to store and operate on scalar fields. More...
#include "lib/sfield.h"
Public Member Functions | |
sfield (const grid &gridData, std::string fieldName) | |
Constructor of the sfield class. More... | |
void | computeDiff (plainsf &H) |
Function to compute the diffusion term. More... | |
void | computeNLin (const vfield &V, plainsf &H) |
Function to compute the convective derivative of the scalar field. More... | |
void | gradient (plainvf &gradF, const vfield &V) |
Operator to compute the gradient of the scalar field. More... | |
void | syncData () |
Function to synchronise data across all processors when performing parallel computations. More... | |
sfield & | operator+= (plainsf &a) |
Overloaded operator to add a given plain scalar field. More... | |
sfield & | operator-= (plainsf &a) |
Overloaded operator to subtract a given plain scalar field. More... | |
sfield & | operator+= (sfield &a) |
Overloaded operator to add a given scalar field. More... | |
sfield & | operator-= (sfield &a) |
Overloaded operator to subtract a given scalar field. More... | |
sfield & | operator*= (real a) |
Overloaded operator to multiply a scalar value to the scalar field. More... | |
void | operator= (plainsf &a) |
Overloaded operator to assign a plain scalar field to the scalar field. More... | |
void | operator= (sfield &a) |
Overloaded operator to assign a scalar field to the scalar field. More... | |
void | operator= (real a) |
Overloaded operator to assign a scalar value to the scalar field. More... | |
Public Attributes | |
field | F |
derivative | derS |
derS is an instance of the derivative class used to compute derivatives | |
std::string | fieldName |
This string is used to identify the vector field, and is useful in file-writing. | |
blitz::Array< real, 3 > | interTempF |
Scalar field class to store and operate on scalar fields.
The class stores scalar fields in the form of an instance of the field class defined in field.h. While the class field merely stores data in the form of a blitz array and offers functions to compute derivatives over a uniform grid, the sfield class adds another layer of functionality along with the grid (grid.h) class to apply necessary grid transformation metrics and compute derivatives over a non-uniform grid. The scalar field is also equipped with a gradient operator, which returns a vector field (vfield). However, this operation is presently restricted to cell-centered scalar fields, i.e., those which are staggered in all the directions. Moreover, the \( (\mathbf{u}.\nabla)f \) operator is also provided as the function computeNLin
sfield::sfield | ( | const grid & | gridData, |
std::string | fieldName | ||
) |
Constructor of the sfield class.
One instance of the field class to store the data of the scalar field is initialized. The field is initialized with the appropriate grid to place the scalar on the cell centres. The name for the scalar field as given by the user is also assigned. Temporary arrays to store data for calculation of derivatives or interpolation are also allocated.
gridData | is a const reference to the global data contained in the grid class |
fieldName | is a string value set by the user to name and identify the scalar field |
void sfield::computeDiff | ( | plainsf & | H | ) |
Function to compute the diffusion term.
It is assumed that the velocity is specified at face-centers, as required by the \ref sfield#computeNLin "computeNLin" function of sfield.
H | is a reference to the plain scalar field (plainsf) to which the output will be written |
Function to compute the convective derivative of the scalar field.
The function calculates \f$ (\mathbf{u}.\nabla)f \f$ at the grid nodes of the scalar field f. To do so, the function needs the vector field (vfield) of velocity. It is assumed that the velocity is always specified at face-centers, and is interpolated accordingly to the scalar field grid points.
V | is a const reference to a vector field (vfield) that specifies the convection velocity |
Operator to compute the gradient of the scalar field.
The function computes the gradient of the cell centered scalar field, and stores it into a face-centered plainvf: \f$ \nabla f = \frac{\partial f}{\partial x}i + \frac{\partial f}{\partial y}j + \frac{\partial f}{\partial z}k \f$.
gradF | is a reference to a plain vector field (plainvf) into which the computed gradient must be written. |
V | is a const reference to a vector field (vfield) whose core slices are used to compute gradient, since plainvf doesn't have them |
sfield & sfield::operator*= | ( | real | a | ) |
Overloaded operator to multiply a scalar value to the scalar field.
The unary operator *= multiplies a real value to the sfield and returns a pointer to itself.
a | is a real number to be multiplied to the scalar field |
Overloaded operator to add a given plain scalar field.
The unary operator += adds a given plain scalar field to the sfield and returns a pointer to itself.
a | is a reference to a plainsf to be added to the member field |
Overloaded operator to add a given scalar field.
The unary operator += adds a given scalar field to the sfield and returns a pointer to itself.
a | is a reference to another sfield to be added to the member field |
Overloaded operator to subtract a given plain scalar field.
The unary operator -= subtracts a given plain scalar field from the sfield and returns a pointer to itself.
a | is a reference to a plainsf to be subtracted from the member field |
Overloaded operator to subtract a given scalar field.
The unary operator -= subtracts a given scalar field from the sfield and returns a pointer to itself.
a | is a reference to another sfield to be subtracted from the member field |
void sfield::operator= | ( | plainsf & | a | ) |
Overloaded operator to assign a plain scalar field to the scalar field.
The operator = copies the contents of the input plain scalar field to itself.
a | is the plainsf to be assigned to the scalar field |
void sfield::operator= | ( | real | a | ) |
Overloaded operator to assign a scalar value to the scalar field.
The operator = assigns a real value to all the scalar field.
a | is a real number to be assigned to the scalar field |
void sfield::operator= | ( | sfield & | a | ) |
Overloaded operator to assign a scalar field to the scalar field.
The operator = copies the contents of the input scalar field to itself.
a | is the scalar field to be assigned to the scalar field |
void sfield::syncData | ( | ) |
Function to synchronise data across all processors when performing parallel computations.
This function calls the \ref mpidata#syncData "syncData" function of mpidata class to perform data-transfer and thus update the sub-domain boundary pads.