G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGridIterator< T, mode, d, false > Class Template Reference

Detailed Description

template<class T, int mode, short_t d>
class gismo::gsGridIterator< T, mode, d, false >

Iterator over a Cartesian product of uniformly distributed numeric points inside a (hyper-)cube.

The iteration is done in the natural lexicographic order.

  • mode = 0 : iteration over uniform samples in [a, b] gsGridIterator<T,CUBE> grid(a,b);
  • mode = 1 : iteration over uniform samples on the boundary points [a, b] gsGridIterator<T,BDR> grid(a,b);
  • mode = 2 : iteration over the vertices [a, b] gsGridIterator<T,VERTEX> grid(a,b);

A third argument, eg. gsGridIterator<T,CUBE,d> grid(a,b); specifies fixed size dimension d.

Template Parameters
Ttype of the numeric coordinates of the index vector
dstatically known dimension, or dynamic dimension if d = -1 (default value)
mode0: all sample points in [a,b], 1: all points in [a,b), 2: vertices of cube [a,b]
+ Collaboration diagram for gsGridIterator< T, mode, d, false >:

Public Member Functions

 gsGridIterator (point const &a, point const &b, point_index const &np)
 Constructor using lower and upper limits. More...
 
 gsGridIterator (gsMatrix< T, d, 2 > const &ab, point_index const &np)
 Constructor using lower and upper limits. More...
 
 gsGridIterator (gsMatrix< T, d, 2 > const &ab, unsigned numPoints)
 Constructor using lower and upper limits. More...
 
index_t index (const index_t i) const
 Returns the i-th index of the current point.
 
const integer_iterator & index_iterator () const
 Returns a reference to the underlying integer lattice iterator.
 
bool isBoundary () const
 Returns true if the current point lies on a boundary.
 
bool isCeil (int i) const
 Returns true if the i-th coordinate has maximal value.
 
bool isFloor (int i) const
 Returns true if the i-th coordinate has minimal value.
 
const pointlower () const
 Returns the first point in the iteration.
 
index_t numPoints () const
 Returns the total number of points that are iterated.
 
point_index numPointsCwise () const
 Returns the total number of points per coordinate which are iterated.
 
const gsMatrix< T > operator[] (const point_index &ti) const
 Returns the point corresponding to tensor index ti. More...
 
void reset ()
 Resets the iterator, so that a new iteration over the points may start.
 
void reset (point const &a, point const &b)
 Resets the iterator using new lower and upper limits. More...
 
const pointstep () const
 Returns the coordinate-wise stepping between the samples.
 
const point_index & tensorIndex () const
 Returns the tensor index of the current point.
 
const pointupper () const
 Returns the last point in the iteration.
 

Private Attributes

gsMatrix< T > m_cur
 Current point pointed at by the iterator.
 
integer_iterator m_iter
 Underlying integer lattice iterator.
 
point m_step
 Iteration lower and upper limits and stepsize.
 

Constructor & Destructor Documentation

gsGridIterator ( point const &  a,
point const &  b,
point_index const &  np 
)
inline

Constructor using lower and upper limits.

Uniformly sampled points will be generated

Parameters
alower limit (vertex of a cube)
bupper limit (vertex of a cube)
npnumber of sample points per coordinate
gsGridIterator ( gsMatrix< T, d, 2 > const &  ab,
point_index const &  np 
)
inline

Constructor using lower and upper limits.

Uniformly sampled points will be generated

Parameters
abMatrix with two columns, corresponding to lower and upper limits
npnumber of sample points per coordinate
gsGridIterator ( gsMatrix< T, d, 2 > const &  ab,
unsigned  numPoints 
)
inline

Constructor using lower and upper limits.

Uniformly sampled points will be generated. The number of the points is approximately numPoints

Parameters
abMatrix with two columns, corresponding to lower and upper limits
numPointsthe number sample points to be used (in total, approximately)

Member Function Documentation

const gsMatrix<T> operator[] ( const point_index &  ti) const
inline

Returns the point corresponding to tensor index ti.

Note
Unlikely to std iterators, the position is not counted from the current position of this, but from the starting point of the iteration
Parameters
tia valid tensor index of a point in the iteration sequence
void reset ( point const &  a,
point const &  b 
)
inline

Resets the iterator using new lower and upper limits.

Parameters
alower limit (vertex of a cube)
bupper limit (vertex of a cube)