NAME
FieldsLattice - collection of finite difference scalar fields
(ie. vector field)
INCLUDE
include "FieldLattice.h"
SYNTAX
class FieldsLattice : public FieldsWithPtValues
{
protected:
VecSimplest(Handle(FieldLattice)) fdsfvec;
public:
FieldsLattice () : FieldsWithPtValues(NULL) {} // redim and attach required
FieldsLattice (GridLattice& grid, const char* fieldname);
FieldsLattice (GridLattice& grid, int n, const char* fieldname_);
void redim (int nsf, const char* fieldname);
bool redim (GridLattice& grid, // allocates nsd FieldLattice components
const char* fieldname); // with size given from grid
bool redim (GridLattice& grid, int n, // allocates n FieldLattice components
const char* fieldname_); // with size given from grid
~FieldsLattice () {}
FieldLattice& operator () (int i);
const FieldLattice& operator () (int i) const;
virtual FieldWithPtValues& component (int i);
virtual const FieldWithPtValues& component (int i) const;
virtual Field* getFieldBase (int i = 1) const
{
if (fdsfvec(i).ok()) return (Field*) fdsfvec(i).getPtr();
else return NULL;
}
virtual void attach (Field& field, int i = 1);
void fill (const FieldsFunc& func, real time = DUMMY);
virtual bool ok () const
{ return fdsfvec.ok(); }
virtual int getNoFields () const
{ return fdsfvec.size(); }
virtual int getNoValues () const;
virtual void valuePt (Ptv(NUMT)& vec, const Ptv(real)& x, real t = DUMMY);
void valueIndex (Ptv(NUMT)& vec, const Ptv(int) idx) const;
void magnitude (FieldLattice& m);
CLASS_INFO
VIRTUAL_CAST(FieldsLattice)
};
KEYWORDS
finite differences, vector field
DESCRIPTION
The class implements a vector field suited for finite difference
methods. The vector field is simply a collection of scalar
finite difference fields, or more precisely, an array of handles
(pointers) to FieldLattice objects. We refer to the classes
Fields and FieldsWithPtValues for documentation.
CONSTRUCTORS AND INITIALIZATION
There are three constructors. One is without arguments and must
be followed by a call to redim(int,...) and attach before the
FieldsLattice object is initialized. one constructor takes a
GridLattice object and allocates nsd vector components of length
equal to the number of grid points (here nsd is, as usual in
Diffpack, the number of space dimensions, in this case given by
GridLattice::getNoSpaceDim). No further initialization is then
necessary (by initialization we here mean that all internal data
structures are allocated, this is the condition that ok will
test). The third constructor takes a GridLattice object and an
integer n and allocates n vector domponents of length equal to
the number og points on the grid.
MEMBER FUNCTIONS
Most of the member functions are virtual and explained in the
base classes.
magnitude - computes the magnitude of the vector field as a
FieldLattice object. The magnitude is simply the Eucledian norm
of the vector (at each node). The argument (result) field m will
be automatically initialized in magnitude (by a relevant redim
call) if the field is empty at input.
valuePt - evaluates the field at a given index in space.
SEE ALSO
class FieldLattice, class GridLattice
DEVELOPED BY
SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway
AUTHOR
Hans Petter Langtangen, SINTEF/UiO