Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

FieldFV Class Reference

finite volume scalar field. More...

#include <FieldFV.h>

Inheritance diagram for FieldFV::

FieldWithPtValues Field HandleId List of all members.

Public Methods

 FieldFV ()
 FieldFV (const GridFV &grid, const char *fieldname)
 FieldFV (const GridFV &grid, Vec(NUMT) &coefficients, const char *fieldname)
 ~FieldFV ()
bool redim (const GridFV &grid, const char *fieldname)
bool redim (const GridFV &grid, const Vec(NUMT) &coefficients, const char *fieldname)
bool redim (const FieldFV &f, const char *fieldname)
GridFVgrid ()
const GridFVgrid () const
Vec(NUMT)& values ()
const Vec(NUMT)& values () const
void fieldFV2FieldFE (FieldFE &field_fe)
void exchangeValues (FieldFV &f)
bool empty () const
virtual bool ok () const
virtual void minmax (NUMT &min, NUMT &max, GridWithPts *grid=NULL) const
virtual NUMT& valueDof (int dofno)
virtual NUMT valueDof (int dofno) const
virtual NUMT& valuePoint (int point_no)
virtual NUMT valuePoint (int point_no) const
virtual NUMT valuePt (const Ptv(real) &x, real t=DUMMY)
virtual Ptv(NUMT) derivativePt (const Ptv(real) &x, real t=DUMMY)
void operator= (const FieldFV &field)
void operator= (const FieldFunc &func)
void fill (const FieldFunc &func, real time=DUMMY)
virtual void print (Os os) const
void scan (Is is)
virtual void fill (NUMT value)
virtual void add (NUMT value)
virtual void mult (NUMT value)
virtual void apply (Func(NUMT) f)
virtual void add (Field &field, int power, NUMT front_factor)
virtual Fieldscale ()
virtual Fieldunscale ()
virtual void unloadData (Os os) const
virtual void loadData (Is is)
virtual void attach (Grid &grid)
virtual GridgetGridBase ()
virtual int getNoPoints () const
virtual int getNoValues () const
virtual Ptv(real) getPt (int point_no) const
virtual GridWithPtsgetGridWithPts ()
virtual const GridWithPtsgetGridWithPts () const
virtual Vec(NUMT)& valuesVec ()
virtual const Vec(NUMT)& valuesVec () const
NUMT& valueNode (int i, real t=DUMMY)
virtual NUMT valueNode (int i, real t=DUMMY) const
NUMT getVol2ElmValue (int volno)
bool getBoVertexValue (int vertexno, NUMT &value)
CLASS_INFO VIRTUAL_CAST (FieldFV) COPY_CONSTRUCTOR(FieldFV)

Detailed Description

finite volume scalar field.

NAME: FieldFV - finite volume scalar field

DESCRIPTION:

The class implements a scalar field suited for finite difference methods. The field is defined in terms of a "GridFV" object and an array containing the point values at the grid points.

The number of space dimensions can be arbitrary (not limited to 1D, 2D or 3D). However, in high dimensions the amount of data is significant and subscripting is performed in terms of "Ptv(int)" objects, which is not very efficient (it is then wise to design a class with particular emphasis on efficient data handling).

This version of the "FieldFV" class can operate on staggered grids, with or without a ghost boundary.

If you use this "FieldFV" heavily in finite volume programming, we strongly recommend to study the code in the member functions, and the "ArrayGenSel" object and its base classes, to get a complete knowledge of the tool. This is important for creating efficient code.


Constructor & Destructor Documentation

FieldFV::FieldFV ( )
 

As for the other field objects, ""initialization"" here refers to allocation of internal data structures for the field values and setting a pointer to a valid grid object. Hence, initialization of field 'values' is not implied.

There are several types of "redim" functions and corresponding constructors (constructors and "redim" functions call "reallocate" in the same way).

(1) The constructor function without arguments performs no actions. "redim" must be called later to allocate data structures and bind the object to a grid.

(2) The "redim" function that takes a "GridFV" object allocates a corresponding field, according to the dimensions and lower and upper values of the various indices in the grid.

(3) The "redim" function that takes a "GridFV" object and an "ArrayGenSel(NUMT)" object binds the "mesh" pointer to the grid object and the "vec" pointer to the supplied array. Hence, there is no allocation of data and the field object relies on external data structures. This functionality is well suited for cases where several fields can share the same fundamental array of field values (transforming one field format to another is an example). Note that when this constructor is used, the field values are shared with the incoming array. That is, if that array is changed outside the "FieldFV" object, the changes also affect the "FieldFV" object. Moreover, the constructor performs initialization of field values in addition to the ""initialization" as defined above.

(4) As point (3) above, but the array is of "ArrayGen(NUMT)" type. In this case, the "vec" pointer cannot simply be bound to the supplied array. Instead, we allocate an "ArrayGenSel(NUMT)" array (without any ghost boundary of course) and copy the values from the supplied array. Notice that this seems to be a waste of memory, but there is no way to ""extend"" a base class object (here "ArrayGen") to a subclass object (here "ArrayGenSel").

(5) Another "redim" function takes a "GridFV" object and an integer representing the size of the fictitious (ghost) boundary. The "fict_boundary" does not affect the "GridFV" object, but the array allocated can in addition to holding the values at the grid points, also hold one or more extra points of points around grid. This is often convenient when programming finite difference methods. If the base value of the grid is "i0", and the field was allocated with "fict_boundary=1", one can access and place values in the fictitious point "i0-1".

(6) A "redim" function takes a "GridFV" object, an enumerator "comp_in_staggered_grid" and a "bool" "change_staggered_grid". The enumerator is defined in class "GridFV" and must have one of the values "GridFV p", "GridFV::u", "GridFV::v" or "GridFV w", where "p" is the scalar value in the computations, and "u", "v" and "w" hold the values of the different velocity components. The underlying grid will now not be "GridFV", but one of its subclasses "GridFVB" and "GridFVC". See the documentation in these classes for more information on using the staggered grid utilities. The optional last argument "change_staggered_grid" is true by default, but might be set to "false" if the staggered grid has been constructed in its right size 'before' the call to this "redim" or constructor. This functionality is normally only used in parallel programming, where a manager is in charge of dividing global grids into local ones and distributing these to subdomain solvers.

(7) A "redim" function takes a "GridFV" grid, an enumerator "comp_in_staggered_grid", an integer representing the size of the fictitious boundary, and a "bool" variable "change_staggered_grid". The constructor is just a combination of the constructors (5) and (6), see their documentation for more information.

FieldFV::FieldFV ( const GridFV & grid,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldFV::FieldFV ( const GridFV & grid,
Vec(NUMT) & coefficients,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldFV::~FieldFV ( )
 


Member Function Documentation

CLASS_INFO FieldFV::VIRTUAL_CAST ( FieldFV )
 

void FieldFV::add ( Field & field,
int power,
NUMT front_factor ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Field.

void FieldFV::add ( NUMT value ) [virtual]
 

adds a constant field to the field. An overloaded version takes a "Field" "f", an integer power "i" and a factor "c" as arguments. The formula "c*f^i" is added to the object field.

Reimplemented from Field.

void FieldFV::apply ( Func(NUMT) f ) [virtual]
 

applies a function, like "sin(x)", to the field.

Reimplemented from Field.

void FieldFV::attach ( Grid & grid ) [virtual]
 

attaches a grid to the field. Used by the "FieldReader" and "SimResFile" classes when reading fields from files. Specific versions of the function are implemented in the subclasses.

Reimplemented from Field.

Ptv(NUMT) FieldFV::derivativePt ( const Ptv(real) & x,
real t = DUMMY ) [virtual]
 

evaluates the derivative of the field at a point in space and time.

Reimplemented from Field.

bool FieldFV::empty ( ) const
 

returns true if the field has neither a grid or a value array allocated (or attached) and false if one of these are present in the field.

void FieldFV::exchangeValues ( FieldFV & f )
 

swap values between two fields ("this" and the supplied field). It is left up to the user of the function to ensure that the two fields are compatible.

void FieldFV::fieldFV2FieldFE ( FieldFE & field_fe )
 

void FieldFV::fill ( NUMT value ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Field.

void FieldFV::fill ( const FieldFunc & func,
real time = DUMMY )
 

fill the field with the given value or functor.

bool FieldFV::getBoVertexValue ( int vertexno,
NUMT & value )
 

Grid * FieldFV::getGridBase ( ) [virtual]
 

returns a "Grid" base class pointer to the grid associated with the field. Since many field types do not have an associated grid, the function is not meaningful for all fields. The "getGridBase" function is used by the "SimResFile" and "FileReader" classes.

Reimplemented from Field.

const GridWithPts & FieldFV::getGridWithPts ( ) const [inline, virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from FieldWithPtValues.

GridWithPts & FieldFV::getGridWithPts ( ) [inline, virtual]
 

gives access to the grid object associated with the "FieldWithPtValues" object. The corresponding base class for grid with discrete points is "GridWithPts".

Reimplemented from FieldWithPtValues.

int FieldFV::getNoPoints ( ) const [inline, virtual]
 

returns the number of points in the grid.

Reimplemented from FieldWithPtValues.

int FieldFV::getNoValues ( ) const [inline, virtual]
 

returns the number of field values (usually equal to the number of points).`\footnote{`In a "GridLattice" grid one can think of a finite difference field defined at the cell centers. Then the number of grid points does not coincide with the number of field values. However, the field is typically characterized as being defined at a finite number of spatial points.`}`

Reimplemented from FieldWithPtValues.

Ptv(real) FieldFV::getPt ( int point_no ) const [inline, virtual]
 

returns the coordinate of a point. The point is given by its point number in the grid.

Reimplemented from FieldWithPtValues.

NUMT FieldFV::getVol2ElmValue ( int volno )
 

const GridFV & FieldFV::grid ( ) const [inline]
 

See documentation of one of the overloaded functions.

GridFV & FieldFV::grid ( ) [inline]
 

gives access to the underlying grid.

void FieldFV::loadData ( Is is ) [virtual]
 

a special scan function used for reading the field from a SimRes file. (See classes "SimResFile" and "FieldReader").

Reimplemented from Field.

void FieldFV::minmax ( NUMT & min,
NUMT & max,
GridWithPts * grid = NULL ) const [virtual]
 

finds the minimum and maximum values of the field. Most of the subclass fields have an internal grid and will find the extreme values over this grid. The "minmax" function has an optional argument "grid" that can be supplied. This grid is not used if the field has an internal grid. However, some fields, like "FieldFunc", do not have internal grids and in that case the "grid" argument is required in order to compute the extreme values.

Reimplemented from Field.

void FieldFV::mult ( NUMT value ) [virtual]
 

multiplies the field values by a number.

Reimplemented from Field.

bool FieldFV::ok ( ) const [virtual]
 

returns true if the object is initialized, for the base class "Field" it just writes an error messages such that if a derived class fails to define an "ok" function, an error message will be written.

Reimplemented from Field.

void FieldFV::operator= ( const FieldFunc & func )
 

void FieldFV::operator= ( const FieldFV & field )
 

void FieldFV::print ( Os os ) const [virtual]
 

prints the field. Most subclass implementations involve printing the field values and the grid.

Reimplemented from Field.

bool FieldFV::redim ( const FieldFV & f,
const char * fieldname )
 

See documentation of one of the overloaded functions.

bool FieldFV::redim ( const GridFV & grid,
const Vec(NUMT) & coefficients,
const char * fieldname )
 

See documentation of one of the overloaded functions.

bool FieldFV::redim ( const GridFV & grid,
const char * fieldname )
 

documented under ""Construction and initialization"".

Field & FieldFV::scale ( ) [virtual]
 

scale the field values and the space(-time) domain. That is, the original values of the field are overwritten by the new, scaled values. To retrieve the original values, call "unscale". Both "scale" and "unscale" tests a variable first to determine if the field is already scaled or unscaled (calling e.g. "scale" twice then results in no action of the second call).

Reimplemented from Field.

void FieldFV::scan ( Is is )
 

void FieldFV::unloadData ( Os os ) const [virtual]
 

a special print function that is used for dumping the field to a SimRes file. (See classes "SimResFile" and "FieldWriter").

Reimplemented from Field.

Field & FieldFV::unscale ( ) [virtual]
 

the inverse action of "scale".

Reimplemented from Field.

NUMT FieldFV::valueDof ( int dofno ) const [virtual]
 

NUMT & FieldFV::valueDof ( int dofno ) [virtual]
 

NUMT FieldFV::valueNode ( int i,
real t = DUMMY ) const [virtual]
 

evaluates the field at a nodal point in space and time.

Reimplemented from Field.

NUMT & FieldFV::valueNode ( int i,
real t = DUMMY )
 

NUMT FieldFV::valuePoint ( int point_no ) const [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from FieldWithPtValues.

NUMT & FieldFV::valuePoint ( int point_no ) [virtual]
 

returns access to the field value at a spatial point. The point is given by its point number. (If the point is known by its coordinates and not the point number, one can use the "valuePt" function, see class "Field").

Reimplemented from FieldWithPtValues.

NUMT FieldFV::valuePt ( const Ptv(real) & x,
real t = DUMMY ) [virtual]
 

evaluates the field at a point in space and time. The time argument can be omitted, the default value is then "DUMMY". Generally, we suggest to use "DUMMY" to check if fields are stationary.

Reimplemented from Field.

const Vec(NUMT) & FieldFV::values ( ) const [inline]
 

See documentation of one of the overloaded functions.

Vec(NUMT) & FieldFV::values ( ) [inline]
 

gives access to the array of field values (at the grid points).

const Vec(NUMT) & FieldFV::valuesVec ( ) const [inline, virtual]
 

Reimplemented from FieldWithPtValues.

Vec(NUMT) & FieldFV::valuesVec ( ) [inline, virtual]
 

Reimplemented from FieldWithPtValues.


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.