12 #if !defined(KRATOS_DISTRIBUTED_NUMBERING_H_INCLUDED )
13 #define KRATOS_DISTRIBUTED_NUMBERING_H_INCLUDED
54 template<
class TIndexType=std::
size_t>
84 mCpuBounds.resize(pComm->
Size()+1);
86 std::vector<IndexType> send_vect{
LocalSize};
87 std::vector<IndexType> local_sizes = pComm->AllGather(send_vect);
89 for(
unsigned int i=1;
i<mCpuBounds.size(); ++
i)
90 mCpuBounds[
i] = mCpuBounds[
i-1] + local_sizes[
i-1];
110 KRATOS_ERROR_IF(pComm->
Size() != Nranks) <<
"We expect Nranks to be the same as pComm->size()" << std::endl;
112 mCpuBounds.resize(pComm->
Size()+1);
116 mCpuBounds[Nranks] = TotalSize;
117 for (
int i=1;
i<Nranks;
i++) {
124 const std::vector<IndexType>& CpuBounds)
126 mpComm(pComm), mCpuBounds(CpuBounds)
132 const std::vector<IndexType>& CpuBounds)
134 mpComm(&rComm), mCpuBounds(CpuBounds)
141 mpComm(rOther.mpComm), mCpuBounds(rOther.
GetCpuBounds())
164 return mCpuBounds[
k+1]-mCpuBounds[
k];
169 return mCpuBounds[mCpuBounds.size()-1];
175 return (I>=mCpuBounds[
k] && I<mCpuBounds[
k+1]);
181 return rGlobalId-mCpuBounds[
k];
187 return rLocalId+mCpuBounds[
k];
192 return rGlobalId-mCpuBounds[rOwnerRank];
197 return rRemoteLocalId+mCpuBounds[rOwnerRank];
203 auto it = std::upper_bound(mCpuBounds.begin(), mCpuBounds.end(), RowIndex);
206 "row RowIndex " << RowIndex <<
207 " is not owned by any processor " << std::endl;
209 IndexType owner_rank = (it-mCpuBounds.begin()-1);
223 std::stringstream buffer;
224 buffer <<
"DistributedNumbering: CpuBounds = " << mCpuBounds << std::endl;
231 rOStream <<
"DistributedNumbering";
236 rOStream <<
"DistributedNumbering: CpuBounds = " << mCpuBounds << std::endl;
244 std::vector<IndexType> mCpuBounds;
249 mpComm = rOther.mpComm;
269 template<
class TDataType,
class TIndexType>
277 template<
class TDataType,
class TIndexType>
282 rOStream << std::endl;
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
virtual int Size() const
Get the parallel size of this DataCommunicator.
Definition: data_communicator.h:597
virtual int Rank() const
Get the parallel rank for this DataCommunicator.
Definition: data_communicator.h:587
This function provides essential capabilities for mapping between local and global ids in a distribut...
Definition: distributed_numbering.h:56
DistributedNumbering(const DataCommunicator *pComm, const std::vector< IndexType > &CpuBounds)
Definition: distributed_numbering.h:122
KRATOS_CLASS_POINTER_DEFINITION(DistributedNumbering)
Pointer definition of DistributedNumbering.
TIndexType IndexType
Definition: distributed_numbering.h:60
DistributedNumbering(const DataCommunicator *pComm, const IndexType TotalSize, const MpiIndexType Nranks)
Definition: distributed_numbering.h:102
DistributedNumbering(const DataCommunicator *pComm, const IndexType LocalSize)
Definition: distributed_numbering.h:78
IndexType OwnerRank(const IndexType RowIndex) const
Definition: distributed_numbering.h:200
IndexType LocalSize() const
Definition: distributed_numbering.h:161
DistributedNumbering(const DataCommunicator &rComm, const IndexType TotalSize, const MpiIndexType Nranks)
Definition: distributed_numbering.h:94
IndexType RemoteGlobalId(const IndexType rRemoteLocalId, const IndexType rOwnerRank) const
Definition: distributed_numbering.h:195
IndexType RemoteLocalId(const IndexType rGlobalId, const IndexType rOwnerRank) const
Definition: distributed_numbering.h:190
int MpiIndexType
Definition: distributed_numbering.h:61
DistributedNumbering(const DataCommunicator &rComm, const IndexType LocalSize)
Definition: distributed_numbering.h:71
IndexType LocalId(const IndexType rGlobalId) const
Definition: distributed_numbering.h:178
DistributedNumbering(const DistributedNumbering &rOther)
Copy constructor.
Definition: distributed_numbering.h:139
DistributedNumbering(const DataCommunicator &rComm, const std::vector< IndexType > &CpuBounds)
Definition: distributed_numbering.h:130
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: distributed_numbering.h:235
std::string Info() const
Turn back information as a string.
Definition: distributed_numbering.h:221
const std::vector< IndexType > & GetCpuBounds() const
Definition: distributed_numbering.h:215
~DistributedNumbering()
Destructor.
Definition: distributed_numbering.h:146
bool IsLocal(const IndexType I) const
Definition: distributed_numbering.h:172
IndexType GlobalId(const IndexType rLocalId) const
Definition: distributed_numbering.h:184
IndexType Size() const
Definition: distributed_numbering.h:167
const DataCommunicator & GetComm() const
Definition: distributed_numbering.h:151
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: distributed_numbering.h:229
const DataCommunicator * pGetComm() const
Definition: distributed_numbering.h:156
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int local_size
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:17
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17