Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::BoxIteratorND< dim > Class Template Reference

Iterator over all IntVects in a Box. More...

#include <AMReX_BoxIterator.H>

Public Member Functions

 BoxIteratorND () noexcept=default
 Default constructor. Constructs an invalid iterator; call define() before use.
 
 BoxIteratorND (const BoxND< dim > &a_bx) noexcept
 Construct a BoxIteratorND associated with Box a_bx.
 
void setBox (const BoxND< dim > &a_bx) noexcept
 Associate this iterator with Box a_bx (equivalent to define()).
 
void define (const BoxND< dim > &a_bx) noexcept
 Associate this iterator with Box a_bx.
 
BoxIteratorND begin () noexcept
 Reset to the first IntVect (smallEnd) and return *this for range-based for.
 
BoxIteratorND end () const noexcept
 Return a past-the-end sentinel for use by range-based for loops.
 
void reset () noexcept
 Reset to the first IntVect (smallEnd) of the Box.
 
BoxIteratorNDoperator++ () noexcept
 Advance to the next IntVect in the Box (pre-increment).
 
void next () noexcept
 Advance to the next IntVect in the Box.
 
const IntVectND< dim > & operator() () const noexcept
 Return the current IntVect.
 
IntVectND< dim > operator* () const noexcept
 Dereference: return the current IntVect by value.
 
bool ok () const noexcept
 Return true if the iterator is within the Box.
 

Friends

bool operator!= (const BoxIteratorND &b1, const BoxIteratorND &b2) noexcept
 Inequality test used by range-based for loops (checks only the last dimension).
 

Detailed Description

template<int dim>
class amrex::BoxIteratorND< dim >

Iterator over all IntVects in a Box.

Iterates through the IntVects of a Box in the same order as a series of nested for loops, with the innermost loop over the first dimension.

Typical usage with a range-based for loop:

Box b;
...
for (IntVect iv : b.iterator()) {
// do operations involving iv
}

Using a traditional for loop:

Box b;
...
BoxIterator bit (b);
for (bit.begin(); bit.ok(); ++bit)
{
IntVect iv = bit();
// do operations involving iv
}

Note that while regular iteration of the range-based version is reasonably performant, neither version is compatible with omp parallel for or simd autovectorization.

Template Parameters
dimSpatial dimension.

Constructor & Destructor Documentation

◆ BoxIteratorND() [1/2]

template<int dim>
amrex::BoxIteratorND< dim >::BoxIteratorND ( )
defaultnoexcept

Default constructor. Constructs an invalid iterator; call define() before use.

◆ BoxIteratorND() [2/2]

template<int dim>
amrex::BoxIteratorND< dim >::BoxIteratorND ( const BoxND< dim > &  a_bx)
inlineexplicitnoexcept

Construct a BoxIteratorND associated with Box a_bx.

Parameters
a_bxBox to iterate over.

Member Function Documentation

◆ begin()

template<int dim>
BoxIteratorND amrex::BoxIteratorND< dim >::begin ( )
inlinenoexcept

Reset to the first IntVect (smallEnd) and return *this for range-based for.

◆ define()

template<int dim>
void amrex::BoxIteratorND< dim >::define ( const BoxND< dim > &  a_bx)
inlinenoexcept

Associate this iterator with Box a_bx.

Parameters
a_bxBox to iterate over.

◆ end()

template<int dim>
BoxIteratorND amrex::BoxIteratorND< dim >::end ( ) const
inlinenoexcept

Return a past-the-end sentinel for use by range-based for loops.

◆ next()

template<int dim>
void amrex::BoxIteratorND< dim >::next ( )
inlinenoexcept

Advance to the next IntVect in the Box.

◆ ok()

template<int dim>
bool amrex::BoxIteratorND< dim >::ok ( ) const
inlinenoexcept

Return true if the iterator is within the Box.

◆ operator()()

template<int dim>
const IntVectND< dim > & amrex::BoxIteratorND< dim >::operator() ( ) const
inlinenoexcept

Return the current IntVect.

◆ operator*()

template<int dim>
IntVectND< dim > amrex::BoxIteratorND< dim >::operator* ( ) const
inlinenoexcept

Dereference: return the current IntVect by value.

◆ operator++()

template<int dim>
BoxIteratorND & amrex::BoxIteratorND< dim >::operator++ ( )
inlinenoexcept

Advance to the next IntVect in the Box (pre-increment).

◆ reset()

template<int dim>
void amrex::BoxIteratorND< dim >::reset ( )
inlinenoexcept

Reset to the first IntVect (smallEnd) of the Box.

◆ setBox()

template<int dim>
void amrex::BoxIteratorND< dim >::setBox ( const BoxND< dim > &  a_bx)
inlinenoexcept

Associate this iterator with Box a_bx (equivalent to define()).

Friends And Related Symbol Documentation

◆ operator!=

template<int dim>
bool operator!= ( const BoxIteratorND< dim > &  b1,
const BoxIteratorND< dim > &  b2 
)
friend

Inequality test used by range-based for loops (checks only the last dimension).


The documentation for this class was generated from the following files: