Diffpack Documentation


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

FieldLattice Class Reference

finite difference scalar field. More...

#include <FieldLattice.h>

Inheritance diagram for FieldLattice::

FieldWithPtValues Field HandleId List of all members.

Public Methods

 FieldLattice ()
 FieldLattice (const GridLattice &grid, const char *fieldname)
 FieldLattice (const GridLattice &grid, ArrayGen(NUMT) &coefficients, const char *fieldname)
 FieldLattice (const GridLattice &grid, ArrayGenSel(NUMT) &coefficients, const char *fieldname)
 FieldLattice (const GridLattice &grid, const int fict_boundary, const char *fieldname)
 FieldLattice (const GridLattice &grid, GridLattice::Component comp, const char *fieldname, const bool change_staggered_grid=true)
 FieldLattice (const GridLattice &grid, GridLattice::Component comp, const int fict_boundary, const char *fieldname, const bool change_staggered_grid=true)
 ~FieldLattice ()
bool redim (const GridLattice &grid, const char *fieldname)
bool redim (const GridLattice &grid, const ArrayGen(NUMT) &coefficients, const char *fieldname)
bool redim (const GridLattice &grid, const ArrayGenSel(NUMT) &coeff, const char *fieldname)
bool redim (const GridLattice &grid, const int fict_boundary, const char *fieldname)
bool redim (const GridLattice &grid, GridLattice::Component comp, const char *fieldname, const bool change_staggered_grid=true)
bool redim (const GridLattice &grid, GridLattice::Component comp, const int fict_boundary, const char *fieldname, const bool change_staggered_grid=true)
bool redim (const FieldLattice &f, const char *fieldname)
GridLatticegrid ()
const GridLatticegrid () const
ArrayGenSel(NUMT)& values ()
const ArrayGenSel(NUMT)& values () const
ArrayGen(NUMT)& values0 ()
const ArrayGen(NUMT)& values0 () const
bool ghostBoundary () const
void exchangeValues (FieldLattice &f)
bool empty () const
virtual bool ok () const
virtual void minmax (NUMT &min, NUMT &max, GridWithPts *grid=NULL) const
NUMT& valueIndex (int i)
NUMT& valueIndex (int i, int j)
NUMT& valueIndex (int i, int j, int k)
NUMT valueIndex (int i) const
NUMT valueIndex (int i, int j) const
NUMT valueIndex (int i, int j, int k) const
NUMT& valueIndex (double i)
NUMT& valueIndex (double i, double j)
NUMT& valueIndex (double i, double j, double k)
NUMT valueIndex (double i) const
NUMT valueIndex (double i, double j) const
NUMT valueIndex (double i, double j, double k) const
int fictBoundary () const
NUMT& valueIndex (const Ptv(int) &index)
NUMT valueIndex (const Ptv(int) &index) const
void value (const ArrayGenSel(NUMT) &values)
virtual NUMT valuePt (const Ptv(real) &x, real t=DUMMY)
virtual NUMT valueFEM (const FiniteElement &fe, real t=DUMMY)
virtual Ptv(NUMT) derivativePt (const Ptv(real) &x, real t=DUMMY)
virtual void derivativeFEM (Ptv(NUMT) &d, const FiniteElement &fe, real t=DUMMY)
void operator= (const FieldLattice &field)
void operator= (const FieldFunc &func)
void fill (const FieldFunc &func, real time=DUMMY)
void copyWithoutGhostBoundary (const FieldLattice &f)
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 NUMT& valuePoint (int point_no)
virtual NUMT valuePoint (int point_no) 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
CLASS_INFO VIRTUAL_CAST (FieldLattice) COPY_CONSTRUCTOR(FieldLattice)
void pack (CharPack &package)
void unpack (CharPack &package, int package_size)

Detailed Description

finite difference scalar field.

NAME: FieldLattice - finite difference scalar field

DESCRIPTION:

The class implements a scalar field suited for finite difference methods. The field is defined in terms of a "GridLattice" 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 "FieldLattice" class can operate on staggered grids, with or without a ghost boundary.

If you use this "FieldLattice" heavily in finite difference 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

FieldLattice::FieldLattice ( )
 

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 "GridLattice" 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 "GridLattice" 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 "FieldLattice" object, the changes also affect the "FieldLattice" 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 "GridLattice" object and an integer representing the size of the fictitious (ghost) boundary. The "fict_boundary" does not affect the "GridLattice" 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 "GridLattice" object, an enumerator "comp_in_staggered_grid" and a "bool" "change_staggered_grid". The enumerator is defined in class "GridLattice" and must have one of the values "GridLattice p", "GridLattice::u", "GridLattice::v" or "GridLattice 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 "GridLattice", but one of its subclasses "GridLatticeB" and "GridLatticeC". 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 "GridLattice" 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.

FieldLattice::FieldLattice ( const GridLattice & grid,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldLattice::FieldLattice ( const GridLattice & grid,
ArrayGen(NUMT) & coefficients,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldLattice::FieldLattice ( const GridLattice & grid,
ArrayGenSel(NUMT) & coefficients,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldLattice::FieldLattice ( const GridLattice & grid,
const int fict_boundary,
const char * fieldname )
 

See documentation of one of the overloaded constructor.

FieldLattice::FieldLattice ( const GridLattice & grid,
GridLattice::Component comp,
const char * fieldname,
const bool change_staggered_grid = true )
 

See documentation of one of the overloaded constructor.

FieldLattice::FieldLattice ( const GridLattice & grid,
GridLattice::Component comp,
const int fict_boundary,
const char * fieldname,
const bool change_staggered_grid = true )
 

See documentation of one of the overloaded constructor.

FieldLattice::~FieldLattice ( )
 


Member Function Documentation

CLASS_INFO FieldLattice::VIRTUAL_CAST ( FieldLattice )
 

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

See documentation of one of the overloaded functions.

Reimplemented from Field.

void FieldLattice::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 FieldLattice::apply ( Func(NUMT) f ) [virtual]
 

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

Reimplemented from Field.

void FieldLattice::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.

void FieldLattice::copyWithoutGhostBoundary ( const FieldLattice & f )
 

only for internal use. Gives a warning if the field has a ghost-boundary, otherwise, it makes a copy of the values.

void FieldLattice::derivativeFEM ( Ptv(NUMT) & d,
const FiniteElement & fe,
real t = DUMMY ) [virtual]
 

Reimplemented from Field.

Ptv(NUMT) FieldLattice::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 FieldLattice::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 FieldLattice::exchangeValues ( FieldLattice & 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.

int FieldLattice::fictBoundary ( ) const [inline]
 

returns the size of the fictitious boundary/ghost boundary.

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

See documentation of one of the overloaded functions.

Reimplemented from Field.

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

fill the field with the given value or functor.

Grid * FieldLattice::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 & FieldLattice::getGridWithPts ( ) const [inline, virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from FieldWithPtValues.

GridWithPts & FieldLattice::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 FieldLattice::getNoPoints ( ) const [inline, virtual]
 

returns the number of points in the grid.

Reimplemented from FieldWithPtValues.

int FieldLattice::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) FieldLattice::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.

bool FieldLattice::ghostBoundary ( ) const
 

returns true if the field was impleented to have a ghost boundary, and false if not.

const GridLattice & FieldLattice::grid ( ) const [inline]
 

See documentation of one of the overloaded functions.

GridLattice & FieldLattice::grid ( ) [inline]
 

gives access to the underlying grid.

void FieldLattice::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 FieldLattice::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 FieldLattice::mult ( NUMT value ) [virtual]
 

multiplies the field values by a number.

Reimplemented from Field.

bool FieldLattice::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 FieldLattice::operator= ( const FieldFunc & func )
 

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

void FieldLattice::pack ( CharPack & package )
 

pack all the values in the field into a "CharPack" object. (Used in communication between processes in parallel computations.)

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

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

Reimplemented from Field.

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

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
GridLattice::Component comp,
const int fict_boundary,
const char * fieldname,
const bool change_staggered_grid = true )
 

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
GridLattice::Component comp,
const char * fieldname,
const bool change_staggered_grid = true )
 

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
const int fict_boundary,
const char * fieldname )
 

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
const ArrayGenSel(NUMT) & coeff,
const char * fieldname )
 

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
const ArrayGen(NUMT) & coefficients,
const char * fieldname )
 

See documentation of one of the overloaded functions.

bool FieldLattice::redim ( const GridLattice & grid,
const char * fieldname )
 

documented under ""Construction and initialization"".

Field & FieldLattice::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 FieldLattice::scan ( Is is )
 

void FieldLattice::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.

void FieldLattice::unpack ( CharPack & package,
int package_size )
 

unpack all the values in the field from a "CharPack" object. (Used in communication between processes in parallel computations.)

Field & FieldLattice::unscale ( ) [virtual]
 

the inverse action of "scale".

Reimplemented from Field.

void FieldLattice::value ( const ArrayGenSel(NUMT) & values )
 

assigns numbers to all the field values based on the array given as argument to the function. The internal data structures in "*this" field must be allocated before the function can be called. A copy of the array given as argument is taken.

NUMT FieldLattice::valueFEM ( const FiniteElement & fe,
real t = DUMMY ) [virtual]
 

evaluates the field at a point in space and time, but the argument is a "FiniteElement" object which means that the evaluation process in a finite element context will be very efficient (since "FiniteElement" knows the element number and the local coordinates of the spatial point). The function is virtual and offers a unified interface to the evaluation of all types of fields in a finite element based simulator.

Reimplemented from Field.

NUMT FieldLattice::valueIndex ( const Ptv(int) & index ) const
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( const Ptv(int) & index )
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( double i,
double j,
double k ) const
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( double i,
double j ) const
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( double i ) const
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( double i,
double j,
double k )
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( double i,
double j )
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( double i )
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( int i,
int j,
int k ) const
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( int i,
int j ) const
 

See documentation of one of the overloaded functions.

NUMT FieldLattice::valueIndex ( int i ) const
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( int i,
int j,
int k )
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( int i,
int j )
 

See documentation of one of the overloaded functions.

NUMT & FieldLattice::valueIndex ( int i )
 

gives access to a single field value. For example, "valueIndex(j,k)" is identical to "values( (j,k)",) but the former construction is the ""most protected"" and hence the recommended one. If one creates a loop over the field values, the loop indices are given by the grid object, cf. the example below.

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

See documentation of one of the overloaded functions.

Reimplemented from FieldWithPtValues.

NUMT & FieldLattice::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 FieldLattice::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 ArrayGenSel(NUMT) & FieldLattice::values ( ) const [inline]
 

See documentation of one of the overloaded functions.

ArrayGenSel(NUMT) & FieldLattice::values ( ) [inline]
 

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

const ArrayGen(NUMT) & FieldLattice::values0 ( ) const
 

See documentation of one of the overloaded functions.

ArrayGen(NUMT) & FieldLattice::values0 ( )
 

gives access to the array of field values (at the grid points) as an "ArrayGen(NUMT)" array. This can have undesired side effects if the underlying "ArrayGenSel(NUMT)" object, used in this field, has a ghost boundary. You can use "ghostBoundary()" to check if there are fictitious pints outside the grid. Notice that the "values0" function is not inline. One should therefore never use it for subscripting line "...values0( (i,j)".) Use "values0" to initialize an "ArrayGen(NUMT)&" reference and perform subscripting based on this reference!

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

Reimplemented from FieldWithPtValues.

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

Reimplemented from FieldWithPtValues.


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