Saras
Finite Difference Solver for Fluid Dynamics Simulations
|
Field class to store data and perform finite difference operations on the data. More...
#include "lib/field.h"
Public Member Functions | |
field (const grid &gridData, std::string fieldName, const bool xStag, const bool yStag, const bool zStag) | |
Constructor of the field class. More... | |
void | syncData () |
Function to synchronise data across all processors when performing parallel computations. More... | |
real | fieldMax () |
Function to extract the maximum value from the field. More... | |
blitz::RectDomain< 3 > | shift (int dim, const blitz::RectDomain< 3 > core, int steps) |
Function to shift a blitz RectDomain object by a given number of steps along a specified dimension. More... | |
field & | operator+= (field &a) |
Overloaded operator to add a given field. More... | |
field & | operator-= (field &a) |
Overloaded operator to subtract a given field. More... | |
field & | operator+= (real a) |
Overloaded operator to add a given scalar value. More... | |
field & | operator-= (real a) |
Overloaded operator to subtract a given scalar value. More... | |
void | operator= (field &a) |
Overloaded operator to assign a field to the field. More... | |
void | operator= (real a) |
Overloaded operator to assign a scalar value to the field. More... | |
Public Attributes | |
blitz::Array< real, 3 > | F |
The field data is stored in this Blitz array. | |
std::string | fieldName |
This string is used to identify the field, and is useful in file-writing. | |
const bool | xStag |
xStag, yStag and zStag are the boolean flags which specify whether the field variable is at cell-center, face-center, edge-center and so on. More... | |
const bool | yStag |
const bool | zStag |
blitz::RectDomain< 3 > | fCore |
The core slice is a view of the field data excluding the ghost points surrounding it. | |
blitz::RectDomain< 3 > | fBulk |
The bulk slice is a view of the field data excluding the walls surrounding it. More... | |
blitz::RectDomain< 3 > | fCLft |
fCLft, fCRgt, fCFrt, fCBak, fCBot, fCTop are views of the field data generated by shifting the core slice in all the three independent directions. More... | |
blitz::RectDomain< 3 > | fCRgt |
blitz::RectDomain< 3 > | fCFrt |
blitz::RectDomain< 3 > | fCBak |
blitz::RectDomain< 3 > | fCBot |
blitz::RectDomain< 3 > | fCTop |
blitz::Array< blitz::RectDomain< 3 >, 1 > | fWalls |
The wall slices are views of the field data showing only the wall points. More... | |
blitz::Array< blitz::RectDomain< 3 >, 1 > | PcIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | QvIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | VxIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | VyIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | VzIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | WxIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | WyIntSlices |
blitz::Array< blitz::RectDomain< 3 >, 1 > | WzIntSlices |
blitz::TinyVector< int, 3 > | fSize |
blitz::TinyVector< int, 3 > | flBound |
blitz::TinyVector< int, 3 > | cuBound |
mpidata * | mpiHandle |
Field class to store data and perform finite difference operations on the data.
The class stores the base data of both scalar and vector fields as blitz arrays. The data is stored with a uniform grid spacing as in the transformed plane. The limits and views of the full, core and bulk domains are also stored in a set of TinyVector and RectDomain objects respectively.
field::field | ( | const grid & | gridData, |
std::string | fieldName, | ||
const bool | xStag, | ||
const bool | yStag, | ||
const bool | zStag | ||
) |
Constructor of the field class.
The field class decides the limits necessary for a 3D array to store the data as per the specified grid indexing (half or full index). It initializes and stores necessary RectDomain objects for getting the core slice and bulk slice. Moreover, various offset slices of both core and bulk, used for performing finite difference operations, are also defined in this class. The upper and lower bounds of the array are calculated based on the directions along which the variable is staggered (or half-indexed). Finally, a blitz array to store the data of the field is resized according to the limits and initialized to 0.
gridData | is a const reference to the global data in the grid class |
xStag | is a const boolean value that is true when F is staggered (half-indexed) along x-direction |
yStag | is a const boolean value that is true when F is staggered (half-indexed) along y-direction |
zStag | is a const boolean value that is true when F is staggered (half-indexed) along z-direction |
real field::fieldMax | ( | ) |
Function to extract the maximum value from the field.
The function uses the in-built blitz function to obtain the maximum value in an array. Note that this function *takes the maximum of the absolute value* of the field. While performing parallel computation, the function performs an <B>MPI_Allreduce()</B> to get the global maximum from the entire computational domain.
Overloaded operator to add a given field.
The unary operator += adds a given field to the field stored by the class and returns a pointer to itself.
a | is a reference to another to be added to the member field |
field & field::operator+= | ( | real | a | ) |
Overloaded operator to add a given scalar value.
The unary operator += adds a given constant scalar value to the field stored by the class and returns a pointer to itself.
a | is a real number to be added to the field |
Overloaded operator to subtract a given field.
The unary operator -= subtracts a given field from the field stored by the class and returns a pointer to itself.
a | is a reference to another field to be deducted from the member field |
field & field::operator-= | ( | real | a | ) |
Overloaded operator to subtract a given scalar value.
The unary operator -= subtracts a given constant scalar value from the field stored by the class and returns a pointer to itself.
a | is a real number to be subtracted from the field |
void field::operator= | ( | field & | a | ) |
Overloaded operator to assign a field to the field.
The operator = copies the contents of the input field to itself.
a | is the field to be assigned to the field |
void field::operator= | ( | real | a | ) |
Overloaded operator to assign a scalar value to the field.
The operator = assigns a real value to the entire field.
a | is a real number to be assigned to the field |
blitz::RectDomain< 3 > field::shift | ( | int | dim, |
const blitz::RectDomain< 3 > | core, | ||
int | steps | ||
) |
Function to shift a blitz RectDomain object by a given number of steps along a specified dimension.
The RectDomain objects offer a view of the blitz arrays on which the shift function operates. These objects are shifted along the dimension specified in the argument, by <B>dim</B>, through a number of steps, to offer offset views.
dim | is the integer input to specify the dimension (direction) of the shift. (x -> 0, y -> 1, z -> 2) |
core | is the input RectDomain object which is to be shifted to get the new view |
steps | is the integer value by which the input view must be offset along the dimension specified by dim |
void field::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.
blitz::RectDomain<3> field::fBulk |
The bulk slice is a view of the field data excluding the walls surrounding it.
This view is therefore a subset of the core slice.
blitz::RectDomain<3> field::fCLft |
fCLft, fCRgt, fCFrt, fCBak, fCBot, fCTop are views of the field data generated by shifting the core slice in all the three independent directions.
These views are useful in calculating derivatives, like in divergence calculations.
blitz::Array<blitz::RectDomain<3>, 1> field::fWalls |
The wall slices are views of the field data showing only the wall points.
Thus, the core slice is a union of both bulk and wall slices.
const bool field::xStag |
xStag, yStag and zStag are the boolean flags which specify whether the field variable is at cell-center, face-center, edge-center and so on.
When the flag is true, the variable is shifted by half the grid-spacing. This means that when all the flags are true, the variable is at the cell-center. And when all the flags are false, the variable is placed at the vertex centers (collocated arrangement).