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;
128 friend class boost::serialization::access;
136 template<
class Archive>
137 void serialize(Archive & archive,
const unsigned int version)
155 DistributedBoxCollection(
double boxWidth, c_vector<double, 2*DIM> domainSize,
bool isPeriodicInX =
false,
int localRows = PETSC_DECIDE);
285 int LoadBalance(std::vector<int> localDistribution);
317 bool IsOwned(c_vector<double, DIM>& location);
395 namespace serialization
400 template<
class Archive,
unsigned DIM>
401 inline void save_construct_data(
408 MPI_Gather(&num_local_rows, 1, MPI_INT, &num_rows[0], 1, MPI_INT, 0, PETSC_COMM_WORLD);
416 for (
unsigned i=0; i<2*DIM; i++)
418 ar << domain_size[i];
427 std::vector<int>
const const_num_rows = num_rows;
428 ar << const_num_rows;
434 template<
class Archive,
unsigned DIM>
435 inline void load_construct_data(
442 c_vector<double,2*DIM> domain_size;
443 for (
unsigned i=0; i<2*DIM; i++)
447 domain_size[i] = coordinate;
451 for (
unsigned i=0; i<DIM; i++)
453 domain_size[2*i+1] -= 1e-14;
458 unsigned num_original_procs;
459 ar >> num_original_procs;
461 int num_rows = PETSC_DECIDE;
462 std::vector<int> original_rows;
std::vector< Box< DIM > > mBoxes
bool IsBoxOwned(unsigned globalIndex)
std::vector< unsigned > & rGetHaloNodesRight()
std::vector< unsigned > mHalosRight
unsigned CalculateContainingBox(Node< DIM > *pNode)
unsigned GetNumLocalBoxes()
void serialize(Archive &archive, const unsigned int version)
void CalculateInteriorNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)
~DistributedBoxCollection()
bool IsInteriorBox(unsigned globalIndex)
c_vector< double, 2 *DIM > rGetDomainSize() const
c_vector< double, 2 *DIM > mDomainSize
std::vector< std::set< unsigned > > mLocalBoxes
std::vector< unsigned > mHalosLeft
void SetCalculateNodeNeighbours(bool calculateNodeNeighbours)
unsigned CalculateGlobalIndex(c_vector< unsigned, DIM > gridIndices)
void CalculateBoundaryNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)
std::vector< Box< DIM > > mHaloBoxes
std::vector< int > CalculateNumberOfNodesInEachStrip()
unsigned GetProcessOwningNode(Node< DIM > *pNode)
bool GetIsPeriodicInX() const
unsigned GetNumLocalRows() const
std::set< unsigned > & rGetLocalBoxes(unsigned boxIndex)
void SetupLocalBoxesHalfOnly()
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
void CalculateNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)
std::map< unsigned, unsigned > mHaloBoxesMapping
int LoadBalance(std::vector< int > localDistribution)
bool mCalculateNodeNeighbours
c_vector< unsigned, DIM > CalculateGridIndices(unsigned globalIndex)
bool IsHaloBox(unsigned globalIndex)
Box< DIM > & rGetHaloBox(unsigned boxIndex)
unsigned mNumBoxesInAFace
Box< DIM > & rGetBox(unsigned boxIndex)
bool GetAreLocalBoxesSet() const
std::vector< unsigned > mHaloNodesLeft
gcov doesn't like this file...
DistributedVectorFactory * mpDistributedBoxStackFactory
void SetupAllLocalBoxes()
void AddPairsFromBox(unsigned boxIndex, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)