Diffpack Documentation


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

Field Class Reference

base class for scalar fields. More...

#include <Field.h>

Inheritance diagram for Field::

HandleId FieldConst FieldFunc FieldSelector FieldWithPtValues BellFunc DomainFunctor FieldBob FieldFE FieldFV FieldLattice FieldPiWisConst FieldScatPt List of all members.

Public Methods

virtual ~Field ()
void setFieldname (const char *name)
String getFieldname () const
bool hasFieldname () const
virtual bool ok () const
virtual void minmax (NUMT &min, NUMT &max, GridWithPts *grid=NULL) const
virtual NUMT valuePt (const Ptv(real) &x, real t=DUMMY)
virtual NUMT valueFEM (const FiniteElement &fe, real t=DUMMY)
virtual NUMT valueNode (int node, real t=DUMMY) const
virtual NUMT divergencePt (const Ptv(real) &x, real t=DUMMY)
virtual NUMT divergenceFEM (const FiniteElement &fe, real t=DUMMY)
virtual NUMT divergenceNode (int node, 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)
virtual void derivativeNode (Ptv(NUMT) &d, int node, real t=DUMMY)
virtual void hessianPt (Ptv(NUMT) &, const Ptv(real) &x, real=DUMMY)
virtual void hessianFEM (Ptv(NUMT) &, const FiniteElement &fe, real=DUMMY)
virtual void hessianNode (Ptv(NUMT) &, int node, real=DUMMY)
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)
void attachScale (const SpaceTimeScale &xt_scale)
ScalarScalegetFieldScale ()
const SpaceTimeScalegetSpaceTimeScale ()
bool hasScaling ()
bool isScaled ()
virtual Field& scale ()
virtual Field& unscale ()
virtual void print (Os os) const
virtual void attach (Grid &grid)
virtual GridgetGridBase ()
virtual void loadData (Is is)
virtual void unloadData (Os os) const

Static Public Methods

void checkAndSetFieldname (String &fieldname, const char *name)

Protected Methods

 Field (const char *fieldname=NULL)

Protected Attributes

String fieldname
Handle(SpaceTimeScalext_scale
ScalarScale field_scale

Detailed Description

base class for scalar fields.

NAME: Field - base class for scalar fields

DESCRIPTION:

The class represents the base class for scalar fields. Various subclasses implement finite difference fields, finite element fields, constant fields, function fields and so on. The main functions define methods for evaluating the field. With a "Handle(Field)" it is easy to program with a field (for example a variable coeffient in a PDE) without knowing the particular format, that is, whether the field is just a constant, or defined in terms of an explicit function, or represented by finite element basis functions over a complicated grid etc. Together with class "FieldFormat", that reads the field format from a menu system, the "Field" abstraction results in simplified programming.

A "Field" can be assigned a scaling. Both the field values and the spatial and temporal domain can be given different scalings. The scaling information is contained in a "SpaceTimeScale" object (which is common for perhaps all fields in a problem) and a "ScalarScale" object which is used to scale the field values. The "ScalarScale" object has a pointer that can point to the data structure data stores the field value(s). Calling "ScalarScale scale" will then automatically scale the field values. An ""inverse"" function "unscale" also exists. For a pure user of a field class, the virtual "scale" and "unscale" functions in the "Field" hierarchy can be used directly. An example of using the scaling features in Diffpack is given in the man page of class "ScalarScale".

For the programmer of a field subclass it is important to note that one must explicitly attach the internal field value data structure to the "field_scale" object before scaling/unscaling can take place. For the programmer of a subclass, "scale" must call the "field_scale.scale" function and perhaps a scale function for the grid. Note that two calls to a scale function should have no effect, the second call should automatically be ignored. Look at "scale" and "unscale" functions in, e.g., class "FieldConst" and "FieldFE" for examples.

Note that at present "FieldFunc" is not well supported for scaling.


Constructor & Destructor Documentation

Field::Field ( const char * fieldname = NULL ) [protected]
 

The constructor takes the fieldname as argument. Although it can be omitted, must subclasses require the fieldname to be given. The fieldname is used when dumping data to file (for later visualization) and in error messages.

Field::~Field ( ) [virtual]
 


Member Function Documentation

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

See documentation of one of the overloaded functions.

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

void Field::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 in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

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

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

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

void Field::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 in FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

void Field::attachScale ( const SpaceTimeScale & xt_scale )
 

attaches a space-time scaling that applies to the domain of the field.

static void Field::checkAndSetFieldname ( String & fieldname,
const char * name ) [static]
 

checks if a string "name" is a valid fieldname (which means that it must be a valid filename). If so, "name" is assigned to "fieldname". Otherwise, "fieldname" is set equal to a dummy name "Field_without_name" (this is also the case if "name" is NULL).

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

Reimplemented in FieldConst, FieldFE, FieldFunc, FieldLattice, FieldPiWisConst, and FieldSelector.

void Field::derivativeNode ( Ptv(NUMT) & d,
int node,
real t = DUMMY ) [virtual]
 

Reimplemented in FieldConst, FieldFE, and FieldSelector.

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

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

Reimplemented in FieldConst, FieldFE, FieldFunc, FieldFV, FieldLattice, FieldPiWisConst, and FieldSelector.

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

Reimplemented in FieldConst, and FieldFunc.

NUMT Field::divergenceNode ( int node,
real t = DUMMY ) [virtual]
 

Reimplemented in FieldConst.

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

evaluates the divergence of the field "f" at a point in space and time, i.e. "df/dx + df/dy + df/dz"

Reimplemented in FieldConst.

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

fills the field with a numerical value (that is, the field becomes constant).

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

ScalarScale & Field::getFieldScale ( )
 

returns access to the scaling of the scalar field. To load an external scaling (represented by a "ScalarScale" object) to a particular field, simply use the "ScalarScale operator=" function by calling

      field.getFieldScale() = myscale; // myscale is of class ScalarScale
Only the scaling parameters will be copied (not the name or pointers to data structures, see the man page of class "ScalarScale").

String Field::getFieldname ( ) const [inline]
 

returns the fieldname as a "String".

Grid * Field::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 in FieldFE, FieldFV, FieldLattice, FieldPiWisConst, FieldScatPt, and FieldSelector.

const SpaceTimeScale & Field::getSpaceTimeScale ( )
 

returns access to the scaling of the domain that applies to the field (if such a scaling has been attached by the "attach" function).

bool Field::hasFieldname ( ) const
 

bool Field::hasScaling ( )
 

returns a true value if the field has a scaling (either the field values or the space/time-domain is scaled).

void Field::hessianFEM ( Ptv(NUMT) &,
const FiniteElement & fe,
real = DUMMY ) [virtual]
 

Reimplemented in FieldConst, FieldFE, FieldFunc, and FieldPiWisConst.

void Field::hessianNode ( Ptv(NUMT) &,
int node,
real = DUMMY ) [virtual]
 

Reimplemented in FieldConst.

void Field::hessianPt ( Ptv(NUMT) &,
const Ptv(real) & x,
real = DUMMY ) [virtual]
 

evaluates the hessian (2nd derivatives) of the field at a point in space and time, i.e. f,xx for nsd=1, {f,xx f,yy f,xy} for nsd=2 and {f,xx f,yy f,zz f,xy f,xz f,yz} for nsd=3.

Reimplemented in FieldConst, FieldFE, FieldFunc, and FieldPiWisConst.

bool Field::isScaled ( ) [inline]
 

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

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

Reimplemented in FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

void Field::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 in FieldBob, FieldConst, FieldFE, FieldFunc, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

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

multiplies the field values by a number.

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

bool Field::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 in FieldBob, FieldConst, FieldFE, FieldFunc, FieldFV, FieldLattice, FieldPiWisConst, FieldScatPt, and FieldSelector.

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

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

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

Field & Field::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 in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

void Field::setFieldname ( const char * name )
 

sets the fieldname manually.

void Field::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 in FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

Field & Field::unscale ( ) [virtual]
 

the inverse action of "scale".

Reimplemented in FieldConst, FieldFE, FieldFV, FieldLattice, FieldPiWisConst, and FieldScatPt.

NUMT Field::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 in FieldConst, FieldFE, FieldFunc, FieldLattice, FieldPiWisConst, and FieldSelector.

NUMT Field::valueNode ( int node,
real t = DUMMY ) const [virtual]
 

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

Reimplemented in FieldConst, FieldFE, FieldFV, FieldScatPt, and FieldSelector.

NUMT Field::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 in FieldBob, FieldConst, FieldFE, FieldFunc, BellFunc, FieldFV, FieldLattice, FieldPiWisConst, FieldScatPt, and FieldSelector.


Member Data Documentation

ScalarScale Field::field_scale [protected]
 

String Field::fieldname [protected]
 

Handle(SpaceTimeScale) Field::xt_scale [protected]
 


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