35 #ifndef DISTRIBUTEDBOXCOLLECTION_HPP_
36 #define DISTRIBUTEDBOXCOLLECTION_HPP_
39 #include <boost/serialization/vector.hpp>
42 #include "Element.hpp"
45 #include "DistributedVectorFactory.hpp"
53 template<
unsigned DIM>
57 friend class TestDistributedBoxCollection;
123 friend class boost::serialization::access;
131 template<
class Archive>
132 void serialize(Archive & archive,
const unsigned int version)
150 DistributedBoxCollection(
double boxWidth, c_vector<double, 2*DIM> domainSize,
bool isPeriodicInX =
false,
int localRows = PETSC_DECIDE);
280 int LoadBalance(std::vector<int> localDistribution);
312 bool IsOwned(c_vector<double, DIM>& location);
394 namespace serialization
399 template<
class Archive,
unsigned DIM>
400 inline void save_construct_data(
407 MPI_Gather(&num_local_rows, 1, MPI_INT, &num_rows[0], 1, MPI_INT, 0, PETSC_COMM_WORLD);
415 for (
unsigned i=0; i<2*DIM; i++)
417 ar << domain_size[i];
426 std::vector<int>
const const_num_rows = num_rows;
427 ar << const_num_rows;
433 template<
class Archive,
unsigned DIM>
434 inline void load_construct_data(
441 c_vector<double,2*DIM> domain_size;
442 for (
unsigned i=0; i<2*DIM; i++)
446 domain_size[i] = coordinate;
450 for (
unsigned i=0; i<DIM; i++)
452 domain_size[2*i+1] -= 1e-14;
457 unsigned num_original_procs;
458 ar >> num_original_procs;
460 int num_rows = PETSC_DECIDE;
461 std::vector<int> original_rows;
std::vector< Box< DIM > > mBoxes
std::vector< unsigned > & rGetHaloNodesRight()
std::set< unsigned > GetLocalBoxes(unsigned boxIndex)
std::vector< unsigned > mHalosRight
unsigned CalculateContainingBox(Node< DIM > *pNode)
unsigned GetNumLocalBoxes()
void serialize(Archive &archive, const unsigned int version)
~DistributedBoxCollection()
void CalculateInteriorNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, std::map< unsigned, std::set< unsigned > > &rNodeNeighbours)
bool IsInteriorBox(unsigned globalIndex)
c_vector< double, 2 *DIM > rGetDomainSize() const
c_vector< double, 2 *DIM > mDomainSize
void AddPairsFromBox(unsigned boxIndex, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, std::map< unsigned, std::set< unsigned > > &rNodeNeighbours)
std::vector< std::set< unsigned > > mLocalBoxes
std::vector< unsigned > mHalosLeft
void SetCalculateNodeNeighbours(bool calculateNodeNeighbours)
std::map< unsigned, unsigned > mBoxesMapping
std::vector< Box< DIM > > mHaloBoxes
std::vector< int > CalculateNumberOfNodesInEachStrip()
unsigned CalculateGlobalIndex(c_vector< unsigned, DIM > coordinateIndices)
unsigned GetProcessOwningNode(Node< DIM > *pNode)
unsigned GetNumLocalRows() const
void SetupLocalBoxesHalfOnly()
c_vector< unsigned, DIM > CalculateCoordinateIndices(unsigned globalIndex)
static const double msFudge
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
double GetBoxWidth() const
c_vector< unsigned, DIM > mNumBoxesEachDirection
std::vector< unsigned > & rGetHaloNodesLeft()
bool IsOwned(Node< DIM > *pNode)
unsigned GetNumRowsOfBoxes() const
DistributedBoxCollection(double boxWidth, c_vector< double, 2 *DIM > domainSize, bool isPeriodicInX=false, int localRows=PETSC_DECIDE)
std::vector< unsigned > mHaloNodesRight
bool GetHaloBoxOwnership(unsigned globalIndex)
bool GetBoxOwnership(unsigned globalIndex)
std::map< unsigned, unsigned > mHaloBoxesMapping
void CalculateNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, std::map< unsigned, std::set< unsigned > > &rNodeNeighbours)
int LoadBalance(std::vector< int > localDistribution)
bool mCalculateNodeNeighbours
Box< DIM > & rGetHaloBox(unsigned boxIndex)
unsigned mNumBoxesInAFace
Box< DIM > & rGetBox(unsigned boxIndex)
bool GetAreLocalBoxesSet() const
std::vector< unsigned > mHaloNodesLeft
DistributedVectorFactory * mpDistributedBoxStackFactory
void SetupAllLocalBoxes()
void CalculateBoundaryNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, std::map< unsigned, std::set< unsigned > > &rNodeNeighbours)