Chaste  Release::3.4
BoxCollection< DIM > Class Template Reference

#include <BoxCollection.hpp>

+ Collaboration diagram for BoxCollection< DIM >:

Public Member Functions

 BoxCollection (double boxWidth, c_vector< double, 2 *DIM > domainSize, bool isPeriodicInX=false, bool isPeriodicInY=false, bool isPeriodicInZ=false)
 
void EmptyBoxes ()
 
unsigned CalculateContainingBox (Node< DIM > *pNode)
 
unsigned CalculateContainingBox (c_vector< double, DIM > &rLocation)
 
Box< DIM > & rGetBox (unsigned boxIndex)
 
unsigned GetNumBoxes ()
 
void SetupLocalBoxesHalfOnly ()
 
void SetupAllLocalBoxes ()
 
std::set< unsignedGetLocalBoxes (unsigned boxIndex)
 
const c_vector< double, 2 *DIM > & rGetDomainSize () const
 
void CalculateNodePairs (std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, std::map< unsigned, std::set< unsigned > > &rNodeNeighbours)
 

Private Member Functions

unsigned GetLinearIndex (c_vector< int, DIM > gridIndices)
 
c_vector< int, DIM > GetGridIndices (unsigned linearIndex)
 
bool IsBoxInDomain (c_vector< int, DIM > gridIndices)
 
c_vector< bool, DIM > IsIndexPenultimate (c_vector< int, DIM > gridIndices)
 
void SetupLocalBoxes (std::vector< c_vector< int, DIM > > neighbours)
 

Private Attributes

std::vector< Box< DIM > > mBoxes
 
c_vector< double, 2 *DIM > mDomainSize
 
double mBoxWidth
 
c_vector< unsigned, DIM > mNumBoxesEachDirection
 
std::vector< std::set< unsigned > > mLocalBoxes
 
c_vector< bool, DIM > mIsDomainPeriodic
 

Static Private Attributes

static const double msFudge = 5e-14
 

Friends

class TestBoxCollection
 

Detailed Description

template<unsigned DIM>
class BoxCollection< DIM >

A collection of 'boxes' partitioning the domain with information on which nodes are located in which box Not archived - in cell_based constructed in NodeBasedCellPopulation constructor.

Definition at line 48 of file BoxCollection.hpp.

Constructor & Destructor Documentation

template<unsigned DIM>
BoxCollection< DIM >::BoxCollection ( double  boxWidth,
c_vector< double, 2 *DIM >  domainSize,
bool  isPeriodicInX = false,
bool  isPeriodicInY = false,
bool  isPeriodicInZ = false 
)

Constructor.

Parameters
boxWidththe width of each box (cut-off length in NodeBasedCellPopulation simulations)
domainSizethe size of the domain, in the form (xmin, xmax, ymin, ymax) (etc)
isPeriodicInXwhether the domain is periodic in the x direction
isPeriodicInYwhether the domain is periodic in the y direction
isPeriodicInZwhether the domain is periodic in the z direction
Todo:
#2725 example: domain width of 1.0 and box width of 0.25, the following line will create 5 boxes not 4

Definition at line 49 of file BoxCollection.cpp.

References BoxCollection< DIM >::mBoxes, BoxCollection< DIM >::mIsDomainPeriodic, BoxCollection< DIM >::mNumBoxesEachDirection, BoxCollection< DIM >::msFudge, and NEVER_REACHED.

Member Function Documentation

template<unsigned DIM>
unsigned BoxCollection< DIM >::CalculateContainingBox ( Node< DIM > *  pNode)
Returns
the index of the box this node is contained in.
Parameters
pNodeaddress of the node

Definition at line 162 of file BoxCollection.cpp.

References Node< SPACE_DIM >::rGetLocation().

Referenced by FineCoarseMeshPair< DIM >::SetUpBoxes().

template<unsigned DIM>
unsigned BoxCollection< DIM >::CalculateContainingBox ( c_vector< double, DIM > &  rLocation)
Returns
the index of the box a point is contained in
Parameters
rLocationThe point

Definition at line 170 of file BoxCollection.cpp.

References EXCEPTION.

template<unsigned DIM>
void BoxCollection< DIM >::CalculateNodePairs ( std::vector< Node< DIM > * > &  rNodes,
std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &  rNodePairs,
std::map< unsigned, std::set< unsigned > > &  rNodeNeighbours 
)

Compute all the pairs of (potentially) connected nodes for cell_based simulations, ie nodes which are in a local box to the box containing the first node. **Note: the user still has to check that the node pairs are less than the cut-off distance apart.** The pairs are checked so that index1 < index2, so each connected pair of nodes is only in the set once.

Parameters
rNodesall the nodes to be considered
rNodePairsthe return value, a set of pairs of nodes
rNodeNeighboursthe other return value, the neighbours of each node.

Definition at line 681 of file BoxCollection.cpp.

References Node< SPACE_DIM >::GetIndex().

template<unsigned DIM>
void BoxCollection< DIM >::EmptyBoxes ( )

Remove the list of nodes stored in each box.

Definition at line 153 of file BoxCollection.cpp.

template<unsigned DIM>
c_vector< int, DIM > BoxCollection< DIM >::GetGridIndices ( unsigned  linearIndex)
private
Parameters
linearIndexthe linear index in row-major form
Returns
the grid indices (i), (i,j), or (i,j,k) depending on DIM

Definition at line 261 of file BoxCollection.cpp.

References NEVER_REACHED.

template<unsigned DIM>
unsigned BoxCollection< DIM >::GetLinearIndex ( c_vector< int, DIM >  gridIndices)
private
Parameters
gridIndicesthe grid indices (i), (i,j), or (i,j,k) depending on DIM
Returns
the linear index in row-major form

Definition at line 201 of file BoxCollection.cpp.

References NEVER_REACHED.

template<unsigned DIM>
std::set< unsigned > BoxCollection< DIM >::GetLocalBoxes ( unsigned  boxIndex)
Returns
the set of all the local boxes, i.e. itself and its nearest-neighbours.
Parameters
boxIndexthe index of the box

Definition at line 668 of file BoxCollection.cpp.

Referenced by FineCoarseMeshPair< DIM >::CollectElementsInLocalBoxes().

template<unsigned DIM>
unsigned BoxCollection< DIM >::GetNumBoxes ( )
Returns
the number of boxes.

Definition at line 195 of file BoxCollection.cpp.

template<unsigned DIM>
bool BoxCollection< DIM >::IsBoxInDomain ( c_vector< int, DIM >  gridIndices)
private
Parameters
gridIndicesthe coordinates (i), (i,j), or (i,j,k) depending on DIM
Returns
whether the box is in the domain

Definition at line 298 of file BoxCollection.cpp.

template<unsigned DIM>
c_vector< bool, DIM > BoxCollection< DIM >::IsIndexPenultimate ( c_vector< int, DIM >  gridIndices)
private

This method is used for periodicity. It is necessary to consider additional boxes as being local to a candidate box if and only if the candidate box is in the penultimate location of any dimension.

Parameters
gridIndicesthe coordinates (i), (i,j), or (i,j,k) depending on DIM
Returns
whether the box is in the penultimate location in each dimension

Definition at line 326 of file BoxCollection.cpp.

template<unsigned DIM>
Box< DIM > & BoxCollection< DIM >::rGetBox ( unsigned  boxIndex)
Returns
a box.
Parameters
boxIndexthe index of the box to return

Definition at line 188 of file BoxCollection.cpp.

Referenced by FineCoarseMeshPair< DIM >::CollectElementsInContainingBox(), FineCoarseMeshPair< DIM >::CollectElementsInLocalBoxes(), and FineCoarseMeshPair< DIM >::SetUpBoxes().

template<unsigned DIM>
const c_vector< double, 2 *DIM > & BoxCollection< DIM >::rGetDomainSize ( ) const

Return the size of the domain partitioned by this collection

Returns
the vector of the domain edges (xmin, xmax etc).

Definition at line 675 of file BoxCollection.cpp.

template<unsigned DIM>
void BoxCollection< DIM >::SetupAllLocalBoxes ( )

Generates a list of vectors representing all the possible neighbour locations in DIM-dimensions, and calls SetupLocalBoxes().

Definition at line 434 of file BoxCollection.cpp.

References NEVER_REACHED.

Referenced by FineCoarseMeshPair< DIM >::SetUpBoxes().

template<unsigned DIM>
void BoxCollection< DIM >::SetupLocalBoxes ( std::vector< c_vector< int, DIM > >  neighbours)
private

Helper function for SetupLocalBoxesHalfOnly() and SetupAllLocalBoxes().

Accepts a vector of neighbours that should be considered for each box and populates mLocalBoxes based on these neighbours. The set of neighbours is either half or all of the neighbours, depending on the function calling this method.

Parameters
neighboursa vector of neighbours

Definition at line 509 of file BoxCollection.cpp.

References NEVER_REACHED.

template<unsigned DIM>
void BoxCollection< DIM >::SetupLocalBoxesHalfOnly ( )

Generates a list of vectors representing half the possible neighbour locations in DIM-dimensions ({0} and {1} in 1D, rather than {-1}, {0}, {1}), and similar in higher dimensions, and calls SetupLocalBoxes().

Definition at line 339 of file BoxCollection.cpp.

References NEVER_REACHED.

Member Data Documentation

template<unsigned DIM>
std::vector< Box<DIM> > BoxCollection< DIM >::mBoxes
private

A vector of boxes to store rough node/element positions.

Definition at line 54 of file BoxCollection.hpp.

Referenced by BoxCollection< DIM >::BoxCollection().

template<unsigned DIM>
double BoxCollection< DIM >::mBoxWidth
private

The width of each box.

Definition at line 60 of file BoxCollection.hpp.

template<unsigned DIM>
c_vector<double, 2*DIM> BoxCollection< DIM >::mDomainSize
private

The domain being partitioned.

Definition at line 57 of file BoxCollection.hpp.

template<unsigned DIM>
c_vector<bool, DIM> BoxCollection< DIM >::mIsDomainPeriodic
private

Whether the domain is periodic

Definition at line 69 of file BoxCollection.hpp.

Referenced by BoxCollection< DIM >::BoxCollection().

template<unsigned DIM>
std::vector< std::set<unsigned> > BoxCollection< DIM >::mLocalBoxes
private

The boxes local (itself and nearest neighbour) to a given box.

Definition at line 66 of file BoxCollection.hpp.

template<unsigned DIM>
c_vector<unsigned, DIM> BoxCollection< DIM >::mNumBoxesEachDirection
private

Number of boxes in each direction.

Definition at line 63 of file BoxCollection.hpp.

Referenced by BoxCollection< DIM >::BoxCollection().

template<unsigned DIM>
const double BoxCollection< DIM >::msFudge = 5e-14
staticprivate

A fudge (box swelling) factor to deal with 32-bit floating point issues.

Definition at line 72 of file BoxCollection.hpp.

Referenced by BoxCollection< DIM >::BoxCollection().


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