Chombo + EB  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
BoxLayout Class Reference

A not-necessarily-disjoint collective of boxes. More...

#include <BoxLayout.H>

Inheritance diagram for BoxLayout:
Inheritance graph
[legend]

Public Member Functions

Vector< BoxboxArray () const
 
Vector< int > procIDs () const
 
unsigned int indexI (const LayoutIndex &) const
 
Constructors, destructors, assignments, defines
 BoxLayout ()
 
 BoxLayout (const Vector< Box > &a_boxes, const Vector< int > &a_procIDs)
 
void transform (BaseTransform &a_transform)
 
virtual ~BoxLayout ()
 
BoxLayoutoperator= (const BoxLayout &a_rhs)
 
virtual void define (const Vector< Box > &a_boxes, const Vector< int > &a_procIDs)
 
Accessors
Box operator[] (const LayoutIndex &it) const
 
Box operator[] (const LayoutIterator &it) const
 
Box operator[] (const DataIterator &it) const
 
Box get (const LayoutIndex &it) const
 
Box get (const DataIterator &it) const
 
Box get (const LayoutIterator &it) const
 
unsigned int procID (const LayoutIndex &a_index) const
 
bool sameBoxes (const BoxLayout &a_layout) const
 Checks whether this layout has the same boxes in the same order as a_layout. More...
 
int numBoxes (const int procID) const
 Returns the number of boxes assigned to a given procID. More...
 
long long numCells () const
 Return number of cells in all boxes of entire box layout. More...
 
unsigned int size () const
 Returns the total number of boxes in the BoxLayout. More...
 
unsigned int index (const LayoutIndex &index) const
 
unsigned int lindex (const DataIndex &index) const
 
Checks
bool operator== (const BoxLayout &rhs) const
 
bool operator< (const BoxLayout &rhs) const
 
int refCount () const
 
bool eq (const BoxLayout &rhs) const
 
bool isClosed () const
 
bool isSorted () const
 
bool check (const LayoutIndex &index) const
 
bool compatible (const BoxLayout &a_rhs) const
 
Iterators
DataIterator dataIterator () const
 Parallel iterator. More...
 
TimedDataIterator timedDataIterator () const
 
LayoutIterator layoutIterator () const
 Iterator that processes through ALL the boxes in a BoxLayout. More...
 
I/O functions
void print () const
 
void p () const
 

Protected Member Functions

void buildDataIndex ()
 
void checkDefine (const Vector< Box > &a_boxes, const Vector< int > &procIDs)
 

Protected Attributes

RefCountedPtr< Vector< Entry > > m_boxes
 
RefCountedPtr< int > m_layout
 
RefCountedPtr< bool > m_closed
 
RefCountedPtr< bool > m_sorted
 
RefCountedPtr< DataIteratorm_dataIterator
 
RefCountedPtr< Vector< LayoutIndex > > m_indicies
 

Friends

class LayoutIterator
 
class DataIterator
 

Modification functions

void coarsen (BoxLayout &output, const BoxLayout &input, int refinement)
 
void refine (BoxLayout &output, const BoxLayout &input, int refinement)
 
virtual void close ()
 
virtual void closeNoSort ()
 
virtual void deepCopy (const BoxLayout &a_source)
 
bool coarsenable (int refRatio) const
 
void growSide (int idir, int length, Side::LoHiSide a_sd)
 
void surroundingNodes ()
 
void convertOldToNew (const IntVect &a_permutation, const IntVect &a_sign, const IntVect &a_translation)
 
void convertNewToOld (const IntVect &a_permutation, const IntVect &a_sign, const IntVect &a_translation)
 
void enclosedCells ()
 
void coarsen (int a_ref)
 
void refine (int a_ref)
 
void grow (int a_growth)
 
void grow (IntVect a_growth)
 
void grow (int a_dir, int a_growth)
 
void adjCellSide (int a_dir, int a_len, Side::LoHiSide a_sd)
 
void operator &= (const Box &a_box)
 
void operator &= (const ProblemDomain &a_domain)
 
void setProcID (const LayoutIndex &a_index, unsigned int a_procID)
 
void sort ()
 

Detailed Description

A not-necessarily-disjoint collective of boxes.

A BoxLayout is a collection of Box objects that are assigned to process numbers. Each box is associated with only one process. Processes are numbered from 0 to n-1 (for a job with n processes).

A BoxLayout can be either open or closed.

Open BoxLayout:

Closed BoxLayout:

Ref-counting

BoxLayout is an explicitly ref-counted object.

Assignment and copy are compiler-generated. They increment the refcount on the contained data members. They perform shallow, ref-counted operations.

Refcounting is a process whereby multiple instantiations make use of a single implementation of that object and keep a tally of how many instantiations are sharing. Thus:

BoxLayout b1(boxes, procIDs);
      b1  ----> refcount = 1
          ---->  m_boxes
          ---->  m_processors
BoxLayout b2(b1)
      b1  ----> refcount = 2  <---- b2
          ---->  m_boxes      <----
          ---->  m_processors <----
BoxLayout b3;
b3 = b2;
      b1  ----> refcount = 3  <---- b2
          ---->  m_boxes      <----
          ---->  m_processors <----
                  ^^^
                  |||
                   b3

Constructor & Destructor Documentation

◆ BoxLayout() [1/2]

BoxLayout::BoxLayout ( )

Construct BoxLayout with no boxes.

◆ BoxLayout() [2/2]

BoxLayout::BoxLayout ( const Vector< Box > &  a_boxes,
const Vector< int > &  a_procIDs 
)

Construct from a Vector of Boxes and a Vector of processor assignments. On exit, the BoxLayout will be closed.

◆ ~BoxLayout()

virtual BoxLayout::~BoxLayout ( )
virtual

Ref-counted destruction. Once the last reference to the implementation of this class is destroyed, the data members are cleaned up

Member Function Documentation

◆ transform()

void BoxLayout::transform ( BaseTransform a_transform)

◆ operator=()

BoxLayout& BoxLayout::operator= ( const BoxLayout a_rhs)

Ref-counted assignment.

◆ define()

virtual void BoxLayout::define ( const Vector< Box > &  a_boxes,
const Vector< int > &  a_procIDs 
)
virtual

Define this BoxLayout from a Vector of Boxes and a Vector of processor assignments. Any pre-existing layout will be lost (ref-count dropped by one). The processor assignment Vector must be the same length as the Box Vector. On exit, the BoxLayout will be closed.

Reimplemented in DisjointBoxLayout.

Referenced by regionGather().

◆ operator[]() [1/3]

Box BoxLayout::operator[] ( const LayoutIndex it) const
inline

const accessor operator. See also get(const LayoutIndex&).

References CH_assert, and LayoutIndex::m_index.

◆ operator[]() [2/3]

Box BoxLayout::operator[] ( const LayoutIterator it) const

accessor operator. See also get(const LayoutIndex&).

◆ operator[]() [3/3]

Box BoxLayout::operator[] ( const DataIterator it) const

accessor operator. See also get(const LayoutIndex&).

◆ get() [1/3]

Box BoxLayout::get ( const LayoutIndex it) const
inline

Get box indexed by it.

As a consequence of the C++ compiler being free to choose which version of operator[] when the object is technically non-const, we very often get 'BoxLayout closed' errors. This is a non-overloaded get method.

References CH_assert, and LayoutIndex::m_index.

Referenced by LevelData< EBFluxFAB >::apply(), PetscSolver< LevelData< FArrayBox > >::create_mat_vec(), LevelData< EBFluxFAB >::define(), LevelDataOps< FArrayBox >::dotProduct(), LevelDataOps< FArrayBox >::mDotProduct(), and PetscSolver< LevelData< FArrayBox > >::solve_private().

◆ get() [2/3]

Box BoxLayout::get ( const DataIterator it) const

Get box indexed by it. equivalent to get(it()), just does the extra() for you.

◆ get() [3/3]

Box BoxLayout::get ( const LayoutIterator it) const

Get box indexed by it. equivalent to get(it()), just does the extra() for you.

◆ procID()

unsigned int BoxLayout::procID ( const LayoutIndex a_index) const
inline

Returns the processor to which this box has been assigned. Not a user function, at least, not a new user function. It can be used safely at anytime, closed or open. A person needing this level of knowledge of the processor assignment should have non-trivial needs, like writing your own load balancer or such. Most user-level parallel

References CH_assert, and LayoutIndex::m_index.

◆ sameBoxes()

bool BoxLayout::sameBoxes ( const BoxLayout a_layout) const

Checks whether this layout has the same boxes in the same order as a_layout.

Checks whether this layout has the same boxes in the same order as a_layout.

◆ numBoxes()

int BoxLayout::numBoxes ( const int  procID) const

Returns the number of boxes assigned to a given procID.

Returns the number of boxes assigned to a given procID.

◆ numCells()

long long BoxLayout::numCells ( ) const

Return number of cells in all boxes of entire box layout.

◆ size()

unsigned int BoxLayout::size ( ) const

Returns the total number of boxes in the BoxLayout.

Returns the total number of boxes in the BoxLayout.

Referenced by blockWriteBufferToFile(), getOffsets(), LayoutIterator::ok(), read(), and DataIterator::size().

◆ index()

unsigned int BoxLayout::index ( const LayoutIndex index) const
inline

Not a user function. Used in I/O routine.

References LayoutIndex::m_index.

Referenced by getOffsets(), read(), and write().

◆ lindex()

unsigned int BoxLayout::lindex ( const DataIndex index) const

◆ operator==()

bool BoxLayout::operator== ( const BoxLayout rhs) const
inline

Refcounted pointer check. Return true if these two objects share the same implementation.

References m_boxes.

◆ operator<()

bool BoxLayout::operator< ( const BoxLayout rhs) const
inline

RefCounted pointer compare. Need this to use DisjointBoxLayout as a Key in a std::map

References m_boxes.

◆ refCount()

int BoxLayout::refCount ( ) const
inline

current ref count for this object

◆ eq()

bool BoxLayout::eq ( const BoxLayout rhs) const
inline

Refcounted pointer check. Return true if these two objects share the same implementation.

◆ isClosed()

bool BoxLayout::isClosed ( ) const
inline

◆ isSorted()

bool BoxLayout::isSorted ( ) const
inline

Return true if sort() has been called.

◆ check()

bool BoxLayout::check ( const LayoutIndex index) const
inline

not a user function

References LayoutIndex::m_layoutIntPtr.

◆ compatible()

bool BoxLayout::compatible ( const BoxLayout a_rhs) const
inline

returns 'true' if you can use the same LayoutIterator and DataIterator on these two layouts and data holders built on top of these layouts

References coarsen(), enclosedCells(), grow(), m_layout, refine(), and surroundingNodes().

◆ close()

virtual void BoxLayout::close ( )
virtual

Mark this BoxLayout as complete and unchangeable.

Reimplemented in DisjointBoxLayout.

◆ closeNoSort()

virtual void BoxLayout::closeNoSort ( )
virtual

Reimplemented in DisjointBoxLayout.

◆ deepCopy()

virtual void BoxLayout::deepCopy ( const BoxLayout a_source)
virtual

Actual deep copy operation. New object created with copied data. This object disassociates itself with original implementation safely. This object now is considered 'open' and can be non-const modified. There is no assurance that the order in which this BoxLayout is indexed corresponds to the indexing of a_source.

       BoxLayout b1(boxes, procIDs);
 b1  ----> refcount = 1
     ---->  m_boxes
     ---->  m_processors
       BoxLayout b2(b1)
 b1  ----> refcount = 2  <---- b2
     ---->  m_boxes      <----
     ---->  m_processors <----
       BoxLayout b3;
       b3.deepCopy(b2);
            b1  -—> refcount = 2  <-— b2  b3 -—> refcount = 1
                -—>  m_boxes      <-—        -—>  m_boxes
                -—>  m_processors <-—        -—>  m_processors

Reimplemented in DisjointBoxLayout.

◆ coarsenable()

bool BoxLayout::coarsenable ( int  refRatio) const

returns true iff:

  • every Box in the BoxLayout can be coarsened by refRatio and return back to the original Box when refined by refRatio.
  • refRatio must be a positive non-zero integer.

◆ growSide()

void BoxLayout::growSide ( int  idir,
int  length,
Side::LoHiSide  a_sd 
)

if a_sd == side::lo, do growLo, else do grow hi with the other arguments.

◆ surroundingNodes()

void BoxLayout::surroundingNodes ( )

Do surroundingNodes on each box.

◆ convertOldToNew()

void BoxLayout::convertOldToNew ( const IntVect a_permutation,
const IntVect a_sign,
const IntVect a_translation 
)

multiblock stuff.

◆ convertNewToOld()

void BoxLayout::convertNewToOld ( const IntVect a_permutation,
const IntVect a_sign,
const IntVect a_translation 
)

multiblock stuff.

◆ enclosedCells()

void BoxLayout::enclosedCells ( )

Do enclosedCells on each box.

◆ coarsen()

void BoxLayout::coarsen ( int  a_ref)

coarsen each box by a_ref

◆ refine()

void BoxLayout::refine ( int  a_ref)

refine each box by a_ref

◆ grow() [1/3]

void BoxLayout::grow ( int  a_growth)

grow each box by a_growth

◆ grow() [2/3]

void BoxLayout::grow ( IntVect  a_growth)

grow each box by a_growth

◆ grow() [3/3]

void BoxLayout::grow ( int  a_dir,
int  a_growth 
)

grow each box in a_dir by a_growth

◆ adjCellSide()

void BoxLayout::adjCellSide ( int  a_dir,
int  a_len,
Side::LoHiSide  a_sd 
)

set each box to the appropriate adjCellSide call if a_sd == side::lo, do adjCellLo, else do adjCellhi with the other arguments.

◆ operator &=() [1/2]

void BoxLayout::operator&= ( const Box a_box)

intersect all boxes with incoming box

◆ operator &=() [2/2]

void BoxLayout::operator&= ( const ProblemDomain a_domain)

intersect all boxes with incoming box

◆ setProcID()

void BoxLayout::setProcID ( const LayoutIndex a_index,
unsigned int  a_procID 
)
inline

Assign a Box in the BoxLayout to a processor. Requires the BoxLayout to be open.

References CH_assert, LayoutIndex::m_index, and operator<<().

◆ sort()

void BoxLayout::sort ( )

Sort the boxes of an open BoxLayout. No change if the BoxLayout is closed.

◆ dataIterator()

DataIterator BoxLayout::dataIterator ( ) const

◆ timedDataIterator()

TimedDataIterator BoxLayout::timedDataIterator ( ) const

◆ layoutIterator()

LayoutIterator BoxLayout::layoutIterator ( ) const

Iterator that processes through ALL the boxes in a BoxLayout.

Iterator that processes through ALL the boxes in a BoxLayout.

If BoxLayout is closed, then LayoutIterator will return the Boxes in sorted order.

Referenced by MultilevelLinearOp< T >::dotProduct(), getOffsets(), and MergeSolver< T >::solve().

◆ print()

void BoxLayout::print ( ) const

Invokes cout<<*this; pretty-print dump of BoxLayout.

◆ p()

void BoxLayout::p ( ) const
inline

Invokes cout<<*this; pretty-print dump of BoxLayout.

◆ boxArray()

Vector<Box> BoxLayout::boxArray ( ) const

◆ procIDs()

Vector<int> BoxLayout::procIDs ( ) const

Return the processor id numbers corresponding to the boxes as returned by this->boxArray().

◆ indexI()

unsigned int BoxLayout::indexI ( const LayoutIndex ) const
inline

◆ buildDataIndex()

void BoxLayout::buildDataIndex ( )
protected

◆ checkDefine()

void BoxLayout::checkDefine ( const Vector< Box > &  a_boxes,
const Vector< int > &  procIDs 
)
protected

Friends And Related Function Documentation

◆ LayoutIterator

friend class LayoutIterator
friend

◆ DataIterator

friend class DataIterator
friend

◆ coarsen

void coarsen ( BoxLayout output,
const BoxLayout input,
int  refinement 
)
friend

Coarsen a BoxLayout:

  • output must be open
  • input must be closed
  • refinement must be a positive non-zero integer
  • output and input do not share an implementation.

output is first deepCopy'ed from input, then coarsen(refinement) is called on each box of output.

output returns from this function closed.

LayoutIterators and DataIterators from input and output can be used interchangeably.

◆ refine

void refine ( BoxLayout output,
const BoxLayout input,
int  refinement 
)
friend

Refine a BoxLayout:

  • output must be open
  • input must be closed
  • refinement must be a positive non-zero integer
  • output and input do not share an implementation.

output is first deepCopy'ed from input, then refine(refinement) is called on each box of output.

output returns from this function closed.

LayoutIterators and DataIterators from input and output can be used interchangeably.

Member Data Documentation

◆ m_boxes

RefCountedPtr<Vector<Entry> > BoxLayout::m_boxes
protected

Referenced by operator<(), and operator==().

◆ m_layout

RefCountedPtr<int> BoxLayout::m_layout
protected

Referenced by compatible().

◆ m_closed

RefCountedPtr<bool> BoxLayout::m_closed
protected

◆ m_sorted

RefCountedPtr<bool> BoxLayout::m_sorted
protected

◆ m_dataIterator

RefCountedPtr<DataIterator> BoxLayout::m_dataIterator
protected

◆ m_indicies

RefCountedPtr<Vector<LayoutIndex> > BoxLayout::m_indicies
protected

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