Index

NAME

FieldScatPt - field over a grid of arbitrary scattered points


INCLUDE

include "FieldScatPt.h"

SYNTAX

 class FieldScatPt : public FieldWithPtValues
 {
   friend class FieldsScatPt;

   Handle(GridScatPt) mesh;
   Handle(Vec(NUMT))  point_values;

   bool reallocate (GridScatPt& grid, const char* fieldname);

 public:
   FieldScatPt (const char* fieldname_ = NULL)
     : FieldWithPtValues(fieldname_){} // use scan for further init
   FieldScatPt (GridScatPt& grid, const char* fieldname);
  ~FieldScatPt () {}

   bool redim (GridScatPt& grid, const char* fieldname);

         GridScatPt& grid ()          { return mesh.getRef(); }
   const GridScatPt& grid () const    { return mesh.getRef(); }
         Vec(NUMT)& values ()         { return point_values.getRef(); }
   const Vec(NUMT)& values () const   { return point_values.getRef(); }

   virtual bool ok () const;

   virtual void minmax (NUMT& min, NUMT& max, GridWithPts* grid =NULL) const;

   virtual NUMT  valueNode (int node, real /*t*/ = DUMMY) const
                                      { return point_values()(node); }
           NUMT& valueNode (int node) { return point_values()(node); }

   int   getNoNodes () const           { return mesh->getNoPoints(); }

   virtual NUMT valuePt (const Ptv(real)& x, real t = DUMMY); // not impl!!!

   void operator = (const FieldFunc& func);

   void fill (const Vector(NUMT)& new_values);

   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 Field&   scale ();
   virtual Field& unscale ();

   virtual void  unloadData (Os os) const;
   virtual void  loadData (Is is);
   virtual void  attach (Grid& grid);
   virtual Grid* getGridBase();

   // virtual functions from FieldWithPtValues:

   virtual int   getNoPoints () const  // cannot be made inline
     { return mesh->getNoPoints(); }

   virtual int   getNoValues () const  // cannot be made inline
     { return point_values->size(); }

   virtual Vec(NUMT)& valuesVec()
     { return *point_values; }

   virtual const Vec(NUMT)& valuesVec() const
     { return *point_values; }

   virtual NUMT& valuePoint (int point_no)
     { return point_values()(point_no); }  // less efficient than valueNode

   virtual NUMT  valuePoint (int point_no) const
     { return point_values()(point_no); }  // less efficient than valueNode

   virtual Ptv(real) getPt (int point_no) const
     { return mesh->getPt(point_no); }


   virtual GridWithPts& getGridWithPts ()
     { return mesh.getRef(); }

   virtual const GridWithPts& getGridWithPts () const
     { return mesh.getRef(); }


   CLASS_INFO

   VIRTUAL_CAST(FieldScatPt)
 };



KEYWORDS

point collection field, field, scattered points, scattered data



DESCRIPTION

The  class  represents  a  field  over a scattered point set. The
field is only defined at the discrete points. Hence there  is  no
interpolation  functionality.  The  class consists basically of a
GridScatPt grid and an array containing the field values  at  the
grid points.



CONSTRUCTORS AND INITIALIZATION

One constructor requires the fieldname as argument. This argument
can be omitted, which may be desired when FieldScatPt is a member
of  a  class  (although a handle of the field is more common). To
initialize the field, one must also attach  a  grid  and  give  a
fieldname,  this  is accomplished by the redim function. Alterna­
tively, one can create and initialize the object by  calling  the
constructor  that  takes the grid and the fieldname as arguments.
A call to ok ensures, as usual, that the object  is  sufficiently
initialized.  As  is  common with the Diffpack field classes, the
object is considered initialized when the  internal  data  struc­
tures are allocated and the grid is sensible. In other words, the
field values can be uninitialized.




MEMBER FUNCTIONS

Note: There are both local and virtual versions of several member
functions.   F.ex.,   valueNode  and  valuePoint  give  identical
results, but valueNode is the most efficient one, since it  gives
direct  access  to  the  array  element  by inlining all function
calls. The valuePoint function is virtual, and  hence  cannot  be
made  inline,  but  enables  a uniform treatment of several field
types (particularly in statistical random field functions).  Sim­
ilar comments yield the grid and getGridWithPts functions.

Most  virtual  functions are documented in the base classes Field
and FieldWithPtValues.

grid - returns access to the grid part of the field.

values - gives access to the array containing the field values at
the grid points.

valueNode  - gives access to the field value at a particular grid
point.  For example, values()(i) is  identical  to  valueNode(i).
The latter is in some sense more "protected" and is the generally
recommended function for reading and setting field values.

getNoNodes - returns the number of field  values.  To  initialize
the  field  values one can create a loop from 1 to getNoNodes and
for each pass in the loop call valueNode.

operator= - sets the field values equal to the  values  generated
by an explicit function.

fill  -  fill the field values with the values given by a vector.
The length of the vector must coincide with the  number  of  grid
points.



SEE ALSO

class Field, class FieldWithPtValues


DEVELOPED BY

SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway


AUTHOR

Hans Petter Langtangen, SINTEF/UiO