Chombo + EB + MF  3.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
ListBox< T > Class Template Reference

#include <ListBox.H>

Public Member Functions

 ListBox ()
 Null constructor. More...
 
 ListBox (const Box &a_box, const RealVect &a_meshSpacing, const RealVect &a_origin)
 
virtual ~ListBox ()
 Destructor. More...
 
virtual void define (const Box &a_box, const RealVect &a_meshSpacing, const RealVect &a_origin)
 Same as the constructor. More...
 
virtual void undefine ()
 Free the memory associated with this ListBox. More...
 
List< T > & listItems ()
 Returns the list of items contained in this ListBox. More...
 
const List< T > & listItems () const
 Returns the list of items contained in this ListBox, const version. More...
 
virtual void getItems (List< T > &a_list, const Box &a_valid) const
 
virtual void getItemsDestructive (List< T > &a_list, const Box &a_valid)
 
virtual void getInvalid (List< T > &a_list, const Box &a_valid) const
 
virtual void getInvalidDestructive (List< T > &a_list, const Box &a_valid)
 
virtual void addItem (const T &a_item)
 Add a_item to this ListBox if it is contained within m_box. More...
 
virtual void addItems (const List< T > &a_list)
 
virtual void addItemsDestructive (List< T > &a_list)
 
virtual void addItemsDestructive (List< T > &a_list, const Box &a_valid)
 
virtual void transfer (ListBox< T > &a_src, const Box &a_srcBox, const Box &a_destBox, const int a_srcComp=0, const int a_destComp=0, const int a_numComp=1)
 
virtual void copy (const Box &a_RegionFrom, const Interval &a_Cdest, const Box &a_RegionTo, const ListBox< T > &a_src, const Interval &a_Csrc)
 
virtual size_t numItems () const
 Return the number of items in this ListBox. More...
 
virtual size_t numItems (const Box &a_box, const bool a_in=true) const
 
virtual int size (const Box &a_box, const Interval &a_comps=Interval()) const
 The number of bytes used by linearIn()/linearOut(). More...
 
virtual void linearOut (void *a_buf, const Box &a_box, const Interval &a_comps=Interval()) const
 Write a serialized (packed) representation into a_buf. More...
 
virtual void linearOutDestructive (void *buf, const Box &a_box, const Interval &a_comps=Interval())
 
virtual void linearIn (void *a_buf, const Box &a_box, const Interval &a_comps=Interval())
 Extract a serialized (packed) representation from a_buf. More...
 
virtual const RealVectmeshSpacing () const
 Retrieve the mesh size. More...
 
const Boxbox () const
 Retrieve the box. More...
 
virtual void clear ()
 Delete all items in this ListBox and reset it to the null Box. More...
 
IntVect size () const
 as in BaseFab; needed for loop-unroll macro More...
 

Static Public Member Functions

static int preAllocatable ()
 Lists are not pre-allocatable. This function is needed so that ListBox. More...
 

Protected Member Functions

virtual bool isEnclosed (const T &a_item, const Box &a_box) const
 Determines whether a_item is enclosed in a_box. More...
 

Static Protected Member Functions

static std::string name ()
 

Protected Attributes

Box m_box
 The Box that defines the valid region of this ListBox. More...
 
List< T > * m_dptr
 Pointer to the List that stores our items. More...
 
RealVect m_mesh_spacing
 The cell size in physical space. More...
 
RealVect m_origin
 The center of our coordinate system. Used for binning our items. More...
 

Static Protected Attributes

static Arenas_Arena = NULL
 

Private Member Functions

ListBox< T > & operator= (const ListBox< T > &)
 
 ListBox (const ListBox< T > &)
 

Detailed Description

template<class T>
class ListBox< T >

A class for storing and sorting particle items. Particles are held in a List and belong to this ListBox if their position is within the domain represented by the object Box.. Class <T> must have a RealVect <T>::position() const function which is used to assign the item to the ListBox. See class BinItem for a base class for particles.

Constructor & Destructor Documentation

◆ ListBox() [1/3]

template<class T >
ListBox< T >::ListBox ( )

Null constructor.

◆ ListBox() [2/3]

template<class T >
ListBox< T >::ListBox ( const Box a_box,
const RealVect a_meshSpacing,
const RealVect a_origin 
)

Constructs an empty ListBox on a_box. a_meshSpacing is the cell size in each direction, and a_origin is the location in physical coordinates of the lower left corner of the problem domain.

References ListBox< T >::define().

◆ ~ListBox()

template<class T >
ListBox< T >::~ListBox ( )
virtual

Destructor.

References ListBox< T >::undefine().

◆ ListBox() [3/3]

template<class T>
ListBox< T >::ListBox ( const ListBox< T > &  )
private

Member Function Documentation

◆ define()

template<class T >
void ListBox< T >::define ( const Box a_box,
const RealVect a_meshSpacing,
const RealVect a_origin 
)
virtual

◆ undefine()

template<class T >
void ListBox< T >::undefine ( )
virtual

Free the memory associated with this ListBox.

References CH_assert, Arena::free(), ListBox< T >::m_dptr, and ListBox< T >::s_Arena.

Referenced by ListBox< T >::clear(), and ListBox< T >::~ListBox().

◆ listItems() [1/2]

template<class T >
List< T > & ListBox< T >::listItems ( )
inline

◆ listItems() [2/2]

template<class T >
const List< T > & ListBox< T >::listItems ( ) const
inline

Returns the list of items contained in this ListBox, const version.

References CH_assert, and ListBox< T >::m_dptr.

◆ getItems()

template<class T >
void ListBox< T >::getItems ( List< T > &  a_list,
const Box a_valid 
) const
virtual

Copy items from this ListBox into a_list only if they are contained in a_valid. This operation does not remove the items from this ListBox.

References List< T >::add(), CH_assert, ListBox< T >::isEnclosed(), List< T >::join(), ListBox< T >::listItems(), ListBox< T >::m_box, and ListBox< T >::m_dptr.

Referenced by ListBox< T >::copy(), and ListBox< T >::linearOut().

◆ getItemsDestructive()

template<class T >
void ListBox< T >::getItemsDestructive ( List< T > &  a_list,
const Box a_valid 
)
virtual

Transfer items from this ListBox into a_list only if they are contained in a_valid. This operation removes the items from this ListBox.

References List< T >::catenate(), CH_assert, ListBox< T >::isEnclosed(), ListBox< T >::listItems(), ListBox< T >::m_box, ListBox< T >::m_dptr, and List< T >::transfer().

Referenced by ListBox< T >::copy(), ListBox< T >::linearOutDestructive(), and ListBox< T >::transfer().

◆ getInvalid()

template<class T >
void ListBox< T >::getInvalid ( List< T > &  a_list,
const Box a_valid 
) const
virtual

Copy items from this ListBox into a_list if they are NOT contained in a_valid. Does not remove the items from this ListBox.

References List< T >::add(), CH_assert, ListBox< T >::isEnclosed(), ListBox< T >::listItems(), and ListBox< T >::m_dptr.

Referenced by ParticleData< P >::fillGhosts().

◆ getInvalidDestructive()

template<class T >
void ListBox< T >::getInvalidDestructive ( List< T > &  a_list,
const Box a_valid 
)
virtual

Transfer items from this ListBox into a_list if they are NOT contained in a_valid. This removes the items from this ListBox.

References CH_assert, ListBox< T >::isEnclosed(), ListBox< T >::listItems(), ListBox< T >::m_dptr, and List< T >::transfer().

◆ addItem()

template<class T >
void ListBox< T >::addItem ( const T &  a_item)
virtual

Add a_item to this ListBox if it is contained within m_box.

References ListBox< T >::isEnclosed(), ListBox< T >::listItems(), and ListBox< T >::m_box.

◆ addItems()

template<class T >
void ListBox< T >::addItems ( const List< T > &  a_list)
virtual

Add each item in a_list into this ListBox if they are contained within m_box. Does not remove the items from a_list.

References List< T >::add(), ListBox< T >::isEnclosed(), List< T >::isNotEmpty(), ListBox< T >::listItems(), ListBox< T >::m_box, and ListIterator< T >::ok().

◆ addItemsDestructive() [1/2]

template<class T >
void ListBox< T >::addItemsDestructive ( List< T > &  a_list)
virtual

Transfer each item in a_list into this ListBox if it is contained within m_box. This removes the items from a_list.

References ListBox< T >::m_box.

Referenced by ListBox< T >::copy().

◆ addItemsDestructive() [2/2]

template<class T >
void ListBox< T >::addItemsDestructive ( List< T > &  a_list,
const Box a_valid 
)
virtual

Transfer each item in a_list into this ListBox if it is contained within a_valid. This removes the items from a_list.

References ListBox< T >::isEnclosed(), List< T >::isNotEmpty(), ListBox< T >::listItems(), and List< T >::transfer().

◆ transfer()

template<class T >
void ListBox< T >::transfer ( ListBox< T > &  a_src,
const Box a_srcBox,
const Box a_destBox,
const int  a_srcComp = 0,
const int  a_destComp = 0,
const int  a_numComp = 1 
)
virtual

Performs transfer of the items from src to dest. Notice that as a result both *this and a_src are modified.

References CH_assert, Box::contains(), ListBox< T >::getItemsDestructive(), ListBox< T >::listItems(), ListBox< T >::m_box, ListBox< T >::m_dptr, and Box::sameSize().

◆ copy()

template<class T >
void ListBox< T >::copy ( const Box a_RegionFrom,
const Interval a_Cdest,
const Box a_RegionTo,
const ListBox< T > &  a_src,
const Interval a_Csrc 
)
virtual

Remove all the items from this ListBox that are within a_RegionTo, and add all the particles from the ListBox a_src that are within a_RegionFrom.

References ListBox< T >::addItemsDestructive(), ListBox< T >::getItems(), ListBox< T >::getItemsDestructive(), and ListBox< T >::listItems().

◆ numItems() [1/2]

template<class T >
size_t ListBox< T >::numItems ( ) const
virtual

Return the number of items in this ListBox.

References ListBox< T >::listItems().

Referenced by ListBox< T >::linearIn(), ListBox< T >::numItems(), and ListBox< T >::size().

◆ numItems() [2/2]

template<class T >
size_t ListBox< T >::numItems ( const Box a_box,
const bool  a_in = true 
) const
virtual

◆ size() [1/2]

template<class T >
int ListBox< T >::size ( const Box a_box,
const Interval a_comps = Interval() 
) const
virtual

The number of bytes used by linearIn()/linearOut().

Returns the size, in number of bytes, of a flat linear representation of the items in the specified Box.

References ListBox< T >::numItems().

◆ linearOut()

template<class T >
void ListBox< T >::linearOut ( void *  a_buf,
const Box a_box,
const Interval a_comps = Interval() 
) const
virtual

Write a serialized (packed) representation into a_buf.

Write a linear representation of the items in the specified Box. Assumes that sufficient memory for the buffer has already been allocated by the caller.

References ListBox< T >::getItems(), and List< T >::length().

◆ linearOutDestructive()

template<class T >
void ListBox< T >::linearOutDestructive ( void *  buf,
const Box a_box,
const Interval a_comps = Interval() 
)
virtual

◆ linearIn()

template<class T >
void ListBox< T >::linearIn ( void *  a_buf,
const Box a_box,
const Interval a_comps = Interval() 
)
virtual

Extract a serialized (packed) representation from a_buf.

Given a linear representation of the class data previously made using linearIn() in a_buf, set the data for this class on the specified Box.

References List< T >::append(), ListBox< T >::listItems(), and ListBox< T >::numItems().

◆ meshSpacing()

template<class T >
const RealVect & ListBox< T >::meshSpacing ( ) const
virtual

Retrieve the mesh size.

References ListBox< T >::m_mesh_spacing.

◆ box()

template<class T >
const Box & ListBox< T >::box ( ) const

Retrieve the box.

References ListBox< T >::m_box.

◆ clear()

template<class T >
void ListBox< T >::clear ( )
virtual

Delete all items in this ListBox and reset it to the null Box.

References ListBox< T >::m_box, ListBox< T >::m_mesh_spacing, ListBox< T >::m_origin, ListBox< T >::undefine(), and RealVect::Zero.

◆ preAllocatable()

template<class T>
static int ListBox< T >::preAllocatable ( )
inlinestatic

Lists are not pre-allocatable. This function is needed so that ListBox.

can be stored inside LevelData<T> containers

◆ size() [2/2]

template<class T>
IntVect ListBox< T >::size ( ) const
inline

as in BaseFab; needed for loop-unroll macro

References ListBox< T >::m_box, and Box::size().

◆ name()

template<class T >
std::string ListBox< T >::name ( )
inlinestaticprotected

Referenced by ListBox< T >::define().

◆ isEnclosed()

template<class T >
bool ListBox< T >::isEnclosed ( const T &  a_item,
const Box a_box 
) const
inlineprotectedvirtual

◆ operator=()

template<class T>
ListBox<T>& ListBox< T >::operator= ( const ListBox< T > &  )
private

These functions are made private to prevent use of the default functions provided by the C++ compiler.

Member Data Documentation

◆ s_Arena

template<class T>
Arena * ListBox< T >::s_Arena = NULL
staticprotected

◆ m_box

template<class T>
Box ListBox< T >::m_box
protected

◆ m_dptr

template<class T>
List<T>* ListBox< T >::m_dptr
protected

◆ m_mesh_spacing

template<class T>
RealVect ListBox< T >::m_mesh_spacing
protected

◆ m_origin

template<class T>
RealVect ListBox< T >::m_origin
protected

The center of our coordinate system. Used for binning our items.

Referenced by ListBox< T >::clear(), ListBox< T >::define(), and ListBox< T >::isEnclosed().


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