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

Base class for particle data on a Box. More...

#include <BinFab.H>

Inheritance diagram for BinFab< T >:
Inheritance graph
[legend]

Public Member Functions

 BinFab ()
 Null constructor, copy constructor and operator= can be compiler defined. More...
 
 BinFab (const Box &a_domain, const RealVect &a_mesh_spacing, const RealVect &a_origin)
 Constructs an empty BinFab on a_domain. More...
 
 BinFab (const BinFab &a_binfab)
 Copy constructor. More...
 
virtual ~BinFab ()
 Destructor. More...
 
virtual void define (const Box &a_domain, const RealVect &a_mesh_spacing, const RealVect &a_origin)
 Same as the constructor. More...
 
virtual void reBin ()
 Sort all the items into the appropriate bins, losing items not in the FAB's domain. More...
 
virtual void reBin (List< T > &a_lost, const Box &a_valid=Box(), bool a_in=true)
 Sort all the items into the appropriate bins and return items in (or not in) the Box. More...
 
virtual void addItem (const T &a_item)
 Copy one item into the appropriate bin. More...
 
virtual void addItem (const T &a_item, const IntVect &a_bin)
 Copy one item into the specified bin. More...
 
virtual void addItems (const List< T > &a_list)
 Copy items into the appropriate bins. More...
 
virtual void addItemsDestructive (List< T > &a_list)
 Copy items into the appropriate bins and remove them from the List. More...
 
virtual void addItemsDestructive (List< T > &a_list, const Box &a_valid, bool a_in=true)
 Copy items into the appropriate bins. Remove items that are in (or not in) the Box from the List. More...
 
virtual void transfer (BinFab< T > &a_src, const Box &a_srcBox, const Box &a_destBox)
 Move particles from a BinFab to the overlapping cells in this one. More...
 
virtual void clear ()
 Delete all the items in this BinFab and reset it to the null Box. More...
 
virtual int numItems (const Box &a_box=Box()) const
 Count the number of items in this BinFab in the specified Box. More...
 
virtual RealVect meshSpacing () const
 Retrieve the mesh cell size, in physical coordinates. More...
 
virtual void meshSpacing (const RealVect &a_mesh_spacing)
 Set the mesh cell size, in physical coordinates. More...
 
RealVect origin () const
 Retrieve the physical coordinates of the lower corner of cell zero. More...
 
void origin (const RealVect &a_origin)
 Set the physical coordinates of the lower corner of cell zero. More...
 
virtual size_t size (const Box &a_box, const Interval &a_comps=Interval(0, 0)) const
 The number of bytes used by linearIn()/linearOut(). More...
 
virtual void linearOut (void *a_buf, const Box &a_box, const Interval &a_comps) const
 Write a serialized (packed) representation into a_buf. More...
 
virtual void linearOutDestructive (void *buf, const Box &a_box, const Interval &a_comps=Interval(0, 0))
 Write a serialized (packed) representation into a_buf and remove from *this. More...
 
virtual void linearIn (void *a_buf, const Box &a_box, const Interval &a_comps=Interval(0, 0))
 Extract a serialized (packed) representation from a_buf. More...
 
IntVect size () const
 Should be inherited from BaseFab but it isn't, sigh; code is the same. More...
 
- Public Member Functions inherited from BaseFab< List< T > >
virtual long offset (const IntVect &a_iv, const int &a_ivar) const
 { constructors, destructor and defines} More...
 
 BaseFab ()
 
 BaseFab (const Box &a_bx, int a_n, List< T > *a_alias=NULL)
 
 BaseFab (const Interval &a_comps, BaseFab< List< T > > &a_original)
 
 BaseFab (BaseFab< List< T > > &&a_in) noexcept
 move constructor More...
 
virtual ~BaseFab ()
 
void resize (const Box &a_b, int a_n=1, List< T > *a_alias=NULL)
 
virtual void define (const Box &a_box, int a_comps, List< T > *a_alias=NULL)
 
virtual void define (const Interval &a_comps, BaseFab< List< T > > &a_original)
 
void clear ()
 
int nComp () const
 { accessors} More...
 
const Boxbox () const
 
IntVect size () const
 
const IntVectsmallEnd () const
 
const IntVectbigEnd () const
 
Interval interval () const
 
BaseFab< List< T > > & operator= (BaseFab< List< T > > &&) noexcept
 move assignment More...
 
List< T > & operator() (const IntVect &a_p, int a_N)
 
List< T > & operator() (const IntVect &a_p)
 
const List< T > & operator() (const IntVect &p, int N) const
 
const List< T > & operator() (const IntVect &p) const
 
void getVal (List< T > *a_data, const IntVect &a_pos, int a_N, int a_numcomp) const
 
void getVal (List< T > *a_data, const IntVect &a_pos) const
 
const int * loVect () const
 { Fortran interface functions} More...
 
const int * hiVect () const
 
const int * nCompPtr () const
 
List< T > * dataPtr (int a_n=0)
 
const List< T > * dataPtr (int a_n=0) const
 
bool contains (const BaseFab< List< T > > &a_fab) const
 { comparison functions} More...
 
bool contains (const Box &a_bx) const
 
void setVal (List< T > a_x, const Box &a_bx, int a_nstart, int a_numcomp)
 { data modification functions} More...
 
void setVal (List< T > a_x, const Box &a_bx, int a_n)
 
void setVal (List< T > a_x, int a_n)
 
void setVal (List< T > a_x)
 
BaseFab< List< T > > & copy (const BaseFab< List< T > > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
 
BaseFab< List< T > > & copy (const BaseFab< List< T > > &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
 
BaseFab< List< T > > & copy (const BaseFab< List< T > > &a_src, const Box &a_destbox)
 
BaseFab< List< T > > & copy (const BaseFab< List< T > > &a_src)
 
void copy (const Box &a_RegionFrom, const Interval &a_Cdest, const Box &a_RegionTo, const BaseFab< List< T > > &a_src, const Interval &a_Csrc)
 
BaseFab< List< T > > & shift (const IntVect &a_v)
 { domain modification functions} More...
 
BaseFab< List< T > > & shift (int a_idir, int a_ncells)
 
BaseFab< List< T > > & shiftHalf (int a_dir, int a_numHalfs)
 
BaseFab< List< T > > & shiftHalf (const IntVect &a_v)
 
void linearOut (void *a_buf) const
 These functions are required for broadcast & gather. More...
 
virtual void * linearOut2 (void *a_buf, const Box &a_R, const Interval &a_comps) const
 Same as linearOut, but returns the current location in the buffer. More...
 
void linearIn (const void *const a_buf)
 
virtual void * linearIn2 (void *a_buf, const Box &a_R, const Interval &a_comps)
 same as linearIn, but returns the current location in the buffer More...
 
int linearSize (void) const
 
void degenerate (BaseFab< List< T > > &a_slice, const SliceSpec &a_sliceSpec) const
 
bool isAliased () const
 
bool isUsable () const
 

Static Public Member Functions

static int preAllocatable ()
 
- Static Public Member Functions inherited from BaseFab< List< T > >
static int preAllocatable ()
 
static int test ()
 regression test More...
 
static int testBoxAndComp ()
 regression test More...
 

Protected Member Functions

virtual IntVect locateBin (const T &a_item) const
 compute the cell index containing the physical position of the item More...
 
- Protected Member Functions inherited from BaseFab< List< T > >
void define ()
 
void undefine ()
 
virtual void performCopy (const BaseFab< List< T > > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
 
void performSetVal (List< T > a_x, const Box &a_bx, int a_nstart, int a_numcomp)
 

Protected Attributes

RealVect m_origin
 location in physical space of the 0 index More...
 
RealVect m_mesh_spacing
 cell size in physical space More...
 
- Protected Attributes inherited from BaseFab< List< T > >
Box m_domain
 
int m_nvar
 
long m_numpts
 
long m_truesize
 
List< T > *__restrict m_dptr
 
bool m_aliased
 

Additional Inherited Members

- Static Protected Member Functions inherited from BaseFab< List< T > >
static std::string name ()
 
- Static Protected Attributes inherited from BaseFab< List< T > >
static Arenas_Arena
 

Detailed Description

template<class T>
class BinFab< T >

Base class for particle data on a Box.

This is a class for holding and sorting particle items. Class <T> must have a RealVect <T>::position() const function which is used to place the item in an appropriate bin. See class BinItem for a base class for particles. All BinFabs are assumed to have 1 component.

Constructor & Destructor Documentation

◆ BinFab() [1/3]

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

Null constructor, copy constructor and operator= can be compiler defined.

Referenced by BinFab< T >::BinFab().

◆ BinFab() [2/3]

template<class T >
BinFab< T >::BinFab ( const Box a_domain,
const RealVect a_mesh_spacing,
const RealVect a_origin 
)

Constructs an empty BinFab on a_domain.

References MayDay::Abort(), BinFab< T >::BinFab(), and BaseFab< List< T > >::define().

◆ BinFab() [3/3]

template<class T>
BinFab< T >::BinFab ( const BinFab< T > &  a_binfab)

Copy constructor.

◆ ~BinFab()

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

Destructor.

References BaseFab< List< T > >::undefine().

Member Function Documentation

◆ define()

template<class T >
void BinFab< T >::define ( const Box a_domain,
const RealVect a_mesh_spacing,
const RealVect a_origin 
)
virtual

◆ reBin() [1/2]

template<class T >
void BinFab< T >::reBin ( )
virtual

Sort all the items into the appropriate bins, losing items not in the FAB's domain.

This is used after "pushing" particles (i.e. updating physical positions).

References Box::contains(), List< T >::isNotEmpty(), BinFab< T >::locateBin(), BaseFab< List< T > >::m_domain, BoxIterator::ok(), BaseFab< List< T > >::operator()(), and List< T >::remove().

◆ reBin() [2/2]

template<class T >
void BinFab< T >::reBin ( List< T > &  a_lost,
const Box a_valid = Box(),
bool  a_in = true 
)
virtual

Sort all the items into the appropriate bins and return items in (or not in) the Box.

This is used after "pushing" particles, to find which have left the domain of the BinFab.

References Box::contains(), Box::isEmpty(), List< T >::isNotEmpty(), BinFab< T >::locateBin(), BaseFab< List< T > >::m_domain, BoxIterator::ok(), BaseFab< List< T > >::operator()(), List< T >::remove(), and List< T >::transfer().

◆ addItem() [1/2]

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

Copy one item into the appropriate bin.

Insert a single item into this BinFab in the appropriate cell.

References Box::contains(), BinFab< T >::locateBin(), BaseFab< List< T > >::m_domain, and BaseFab< List< T > >::operator()().

◆ addItem() [2/2]

template<class T >
void BinFab< T >::addItem ( const T &  a_item,
const IntVect a_bin 
)
virtual

Copy one item into the specified bin.

Insert a single item into this BinFab in the specified cell.

References Box::contains(), BaseFab< List< T > >::m_domain, and BaseFab< List< T > >::operator()().

◆ addItems()

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

◆ addItemsDestructive() [1/2]

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

Copy items into the appropriate bins and remove them from the List.

Insert multiple items into BinFab and remove from source list.

References Box::contains(), List< T >::isNotEmpty(), BinFab< T >::locateBin(), BaseFab< List< T > >::m_domain, BaseFab< List< T > >::operator()(), and ListIterator< T >::rewind().

◆ addItemsDestructive() [2/2]

template<class T >
void BinFab< T >::addItemsDestructive ( List< T > &  a_list,
const Box a_valid,
bool  a_in = true 
)
virtual

Copy items into the appropriate bins. Remove items that are in (or not in) the Box from the List.

Move or copy items from arg list to *this, depending on in or not-in the given Box.

References Box::cellCentered(), CH_assert, Box::contains(), List< T >::isNotEmpty(), BinFab< T >::locateBin(), BaseFab< List< T > >::m_domain, BaseFab< List< T > >::operator()(), and ListIterator< T >::rewind().

◆ transfer()

template<class T >
void BinFab< T >::transfer ( BinFab< T > &  a_src,
const Box a_srcBox,
const Box a_destBox 
)
virtual

Move particles from a BinFab to the overlapping cells in this one.

Performs a point-wise transfer of the whole List<T> in src cells to the corresponding cells in *this. Notice that as a result both this and a_src are modified.

References BaseFab< List< T > >::box(), List< T >::catenate(), CH_assert, Box::contains(), BaseFab< List< T > >::nComp(), and Box::sameSize().

◆ clear()

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

◆ numItems()

template<class T >
int BinFab< T >::numItems ( const Box a_box = Box()) const
virtual

Count the number of items in this BinFab in the specified Box.

The default is to do the whole FAB. This is slow, so use it sparingly.

References BaseFab< List< T > >::box(), Box::isEmpty(), BoxIterator::ok(), and BaseFab< List< T > >::operator()().

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

◆ meshSpacing() [1/2]

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

Retrieve the mesh cell size, in physical coordinates.

References BinFab< T >::m_mesh_spacing.

◆ meshSpacing() [2/2]

template<class T >
void BinFab< T >::meshSpacing ( const RealVect a_mesh_spacing)
virtual

Set the mesh cell size, in physical coordinates.

References BinFab< T >::m_mesh_spacing.

◆ origin() [1/2]

template<class T >
RealVect BinFab< T >::origin ( ) const

Retrieve the physical coordinates of the lower corner of cell zero.

References BinFab< T >::m_origin.

◆ origin() [2/2]

template<class T >
void BinFab< T >::origin ( const RealVect a_origin)

Set the physical coordinates of the lower corner of cell zero.

References BinFab< T >::m_origin.

◆ size() [1/2]

template<class T >
size_t BinFab< T >::size ( const Box a_box,
const Interval a_comps = Interval(0,0) 
) 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.

Reimplemented from BaseFab< List< T > >.

References BinFab< T >::numItems(), and Box::numPts().

◆ linearOut()

template<class T >
void BinFab< T >::linearOut ( void *  a_buf,
const Box a_box,
const Interval a_comps 
) 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.

Reimplemented from BaseFab< List< T > >.

References List< T >::length(), ListIterator< T >::ok(), BoxIterator::ok(), and BaseFab< List< T > >::operator()().

◆ linearOutDestructive()

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

Write a serialized (packed) representation into a_buf and remove from *this.

Write a linear representation of the items in the specified Box and removes them from this BinFab. Assumes that sufficient memory for the buffer has already been allocated by the caller.

References List< T >::clear(), List< T >::length(), ListIterator< T >::ok(), BoxIterator::ok(), and BaseFab< List< T > >::operator()().

◆ linearIn()

template<class T >
void BinFab< T >::linearIn ( void *  a_buf,
const Box a_box,
const Interval a_comps = Interval(0,0) 
)
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.

Reimplemented from BaseFab< List< T > >.

References List< T >::append(), List< T >::clear(), BinFab< T >::numItems(), BoxIterator::ok(), and BaseFab< List< T > >::operator()().

◆ preAllocatable()

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

◆ size() [2/2]

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

Should be inherited from BaseFab but it isn't, sigh; code is the same.

needed for loop-unroll macro

References BaseFab< List< T > >::m_domain, and Box::size().

◆ locateBin()

template<class T >
IntVect BinFab< T >::locateBin ( const T &  a_item) const
inlineprotectedvirtual

compute the cell index containing the physical position of the item

References BinFab< T >::m_mesh_spacing, BinFab< T >::m_origin, and SpaceDim.

Referenced by BinFab< T >::addItem(), BinFab< T >::addItems(), BinFab< T >::addItemsDestructive(), and BinFab< T >::reBin().

Member Data Documentation

◆ m_origin

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

location in physical space of the 0 index

Referenced by BinFab< T >::clear(), BinFab< T >::define(), BinFab< T >::locateBin(), and BinFab< T >::origin().

◆ m_mesh_spacing

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

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