Index

NAME

GridWithPts - base class for grids with discrete points


INCLUDE

include "GridWithPts.h"

SYNTAX

 class GridWithPts : public Grid
 {
 protected:
   GridWithPts ();
   bool is_scaled;                  // track if the grid is scaled or not
   Handle(SpaceTimeScale) grid_scale;  // info about grid scaling

 public:
   ~GridWithPts () {}

   virtual int  getNoSpaceDim () const =0;
   virtual int  getNoPoints () const =0;
   virtual void startIterator () =0;
   virtual bool nextPt (Ptv(real)& x) =0;

   void attachScale (const SpaceTimeScale& scale);
   const SpaceTimeScale* getSpaceScale () const { return grid_scale.getPtr(); }
   bool hasScaling ();
   bool isScaled ()  { return is_scaled; }
   virtual void scale ();
   virtual void unscale ();

   virtual int nearestPoint
     (const Ptv(real)& point, real& distance, bool& exact) =0;
   // this is virtual in FieldWithPtValues instead for easier call:
   // virtual Ptv(real) getPt (int point_no);


   // gneral function utilized by many subclasses:
   static int nearestPoint
     (
      const Ptv(real)&       point,
      const MatSimple(real)& coor,
            bool             test_for_exact_match_only,
            real&            distance,
            bool&         exact
     );

   virtual void getMinMaxCoord  // just to prevent a warning, see Grid
     (Ptv(real)& mincoord, Ptv(real)& maxcoord) const =0;

   static void getMinMaxCoord
     (
            Ptv(real)&       mincoord,
            Ptv(real)&       maxcoord,
      const MatSimple(real)& coor
     );


   CLASS_INFO

   // virtual cast functions:
   VIRTUAL_CAST(GridWithPts)
 };




KEYWORDS

grid, grid with points



DESCRIPTION

The  class serves as base class for all grids that have a collec­
tion of points. Such grids arise  frequently  when  solving  PDEs
(finite  element  grids,  finite  difference  lattices, scattered
point sets).  Example of a quantity that can be viewed as a grid,
but where there are no points, is the series expansion of a field
(e.g., in global Galerkin  or  collocation  methods).  The  basis
functions in the series expansion constitute a "grid".

There is a corresponding class FieldWithPtValues for representing
fields over a grid with points.

Grids can be scaled. The scaling information (which can be shared
among many objects) is contained in a SpaceTimeScale object.  The
virtual functions scale and unscale automatically scales the grid
point  coordinates  and  sets the internal indicator is_scaled to
its proper value such that one can test if the grid has been sub­
jected  to  a  scaling  or not. When implementing a subclass, the
programmer need only define the scale and unscale functions.


CONSTRUCTORS AND INITIALIZATION

The only constructor is protected and requires no arguments.   No
further initialization is necessary.



MEMBER FUNCTIONS

See class Grid for documentation of some member functions.

startIterator - initializes an iteration over the grid points.

nextPt  -  gives  the  coordinates of the next point in the grid.
The return value is false when there are no more  points  in  the
grid. Here is an example on iteration over the grid points:

   grid.startIterator();
   while (grid.nextPt(p))
     { .... }

nearestPoint  -  computes  the  grid  point that is nearest to an
arbitrarily given point. The  input  argument  is  the  specified
point,  while  the output arguments are the distance to the point
and a boolean variable indicating if the  given  point  coincides
with  one  of the grid points.  If the boolean value is true, the
distance to the point is zero.  The return  value  is  the  point
number  of  the  point  that  is  nearest to the specified point.
There are some overloaded versions  of  nearestPoint.  These  are
aimed  at various search algorithms required by valuePt in finite
element meshes.

attachScale - attach a scaling of the spatial coordinates.

hasScaling - returns true if the grid object has a scaling object
and  a  non-trivial  scaling  (i.e. not zero translation and unit
stretch of the coordinates) in this object.

getSpaceScale - returns a pointer to the scaling of  the  spatial
coordinates.  If  no  such  scaling is defined, NULL is returned.
Note that NULL as return value implies  that  hasScaling  returns
false,  while  the  converse  is  not  generally  true (a default
scaling, i.e., zero translation and unit stretch,  gives  a  non-
NULL return value while hasScaling is false).



SEE ALSO

class Grid, class GridLattice, class GridFE


DEVELOPED BY

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


AUTHOR

Hans Petter Langtangen, SINTEF/UiO