Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
Public Member Functions | Public Attributes | List of all members
sfield Class Reference

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...
 
sfieldoperator+= (plainsf &a)
 Overloaded operator to add a given plain scalar field. More...
 
sfieldoperator-= (plainsf &a)
 Overloaded operator to subtract a given plain scalar field. More...
 
sfieldoperator+= (sfield &a)
 Overloaded operator to add a given scalar field. More...
 
sfieldoperator-= (sfield &a)
 Overloaded operator to subtract a given scalar field. More...
 
sfieldoperator*= (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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ sfield()

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.
Parameters
gridDatais a const reference to the global data contained in the grid class
fieldNameis a string value set by the user to name and identify the scalar field

Member Function Documentation

◆ computeDiff()

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.
Parameters
His a reference to the plain scalar field (plainsf) to which the output will be written

◆ computeNLin()

void sfield::computeNLin ( const vfield V,
plainsf H 
)

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.
Parameters
Vis a const reference to a vector field (vfield) that specifies the convection velocity

◆ gradient()

void sfield::gradient ( plainvf gradF,
const vfield V 
)

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$.
Parameters
gradFis a reference to a plain vector field (plainvf) into which the computed gradient must be written.
Vis a const reference to a vector field (vfield) whose core slices are used to compute gradient, since plainvf doesn't have them

◆ operator*=()

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.
Parameters
ais a real number to be multiplied to the scalar field
Returns
A pointer to itself is returned by the scalar field class to which the operator belongs

◆ operator+=() [1/2]

sfield & sfield::operator+= ( plainsf a)

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.
Parameters
ais a reference to a plainsf to be added to the member field
Returns
A pointer to itself is returned by the scalar field class to which the operator belongs

◆ operator+=() [2/2]

sfield & sfield::operator+= ( sfield a)

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.
Parameters
ais a reference to another sfield to be added to the member field
Returns
A pointer to itself is returned by the scalar field class to which the operator belongs

◆ operator-=() [1/2]

sfield & sfield::operator-= ( plainsf a)

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.
Parameters
ais a reference to a plainsf to be subtracted from the member field
Returns
A pointer to itself is returned by the scalar field class to which the operator belongs

◆ operator-=() [2/2]

sfield & sfield::operator-= ( sfield a)

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.
Parameters
ais a reference to another sfield to be subtracted from the member field
Returns
A pointer to itself is returned by the scalar field class to which the operator belongs

◆ operator=() [1/3]

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.
Parameters
ais the plainsf to be assigned to the scalar field

◆ operator=() [2/3]

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.
Parameters
ais a real number to be assigned to the scalar field

◆ operator=() [3/3]

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.
Parameters
ais the scalar field to be assigned to the scalar field

◆ syncData()

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.

The documentation for this class was generated from the following files: