28 #include <unordered_map>
29 #include <unordered_set>
66 template<
class TIndexType=std::
size_t >
91 mNonLocalGraphs.resize(mpComm->
Size(),
false);
92 mNonLocalLocks = decltype(mNonLocalLocks)(mpComm->
Size());
94 mpRowNumbering = Kratos::make_unique<DistributedNumbering<IndexType>>(*mpComm,
LocalSize);
113 return *mpRowNumbering;
118 return mpRowNumbering->
Size();
136 for(
IndexType local_i = 0; local_i<mLocalGraph.
Size(); ++local_i)
138 for(
auto J : mLocalGraph[local_i] )
159 return mLocalGraph[LocalPosition];
165 mNonLocalGraphs.clear();
177 const std::lock_guard<LockObject> scope_lock(mNonLocalLocks[owner]);
178 mNonLocalGraphs[owner].AddEntry(
GetRowNumbering().RemoteLocalId(RowIndex,owner), ColIndex);
182 template<
class TContainerType>
192 mNonLocalLocks[owner].lock();
193 mNonLocalGraphs[owner].AddEntries(
GetRowNumbering().RemoteLocalId(RowIndex,owner), rColIndices);
194 mNonLocalLocks[owner].unlock();
198 template<
class TIteratorType>
200 const TIteratorType& rColBegin,
201 const TIteratorType& rColEnd
211 mNonLocalLocks[owner].lock();
212 mNonLocalGraphs[owner].AddEntries(
GetRowNumbering().RemoteLocalId(RowIndex,owner), rColBegin, rColEnd);
213 mNonLocalLocks[owner].unlock();
217 template<
class TContainerType>
220 for(
auto I : rIndices)
229 mNonLocalLocks[owner].lock();
230 mNonLocalGraphs[owner].AddEntries(
GetRowNumbering().RemoteLocalId(I,owner), rIndices);;
231 mNonLocalLocks[owner].unlock();
236 template<
class TContainerType>
237 void AddEntries(
const TContainerType& rRowIndices,
const TContainerType& rColIndices)
239 for(
auto I : rRowIndices)
252 std::vector<MpiIndexType> send_list;
254 for(
unsigned int id = 0;
id<mNonLocalGraphs.size(); ++id)
255 if( !mNonLocalGraphs[
id].
IsEmpty())
256 send_list.push_back(
id);
276 auto send_single_vector_repr = mNonLocalGraphs[
color].ExportSingleVectorRepresentation();
277 const auto recv_single_vector_repr = mpComm->
SendRecv(send_single_vector_repr,
color,
color);
292 return mNonLocalGraphs[Rank];
297 return mNonLocalGraphs;
323 std::stringstream buffer;
324 buffer <<
"DistributedSparseGraph" ;
331 rOStream <<
"DistributedSparseGraph";
394 std::vector<LockObject> mNonLocalLocks;
451 template<
class TIndexType>
459 template<
class TIndexType>
464 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
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
TObject SendRecv(const TObject &rSendObject, const int SendDestination, const int SendTag, const int RecvSource, const int RecvTag) const
Exchange data with other ranks.
Definition: data_communicator.h:492
IndexType OwnerRank(const IndexType RowIndex) const
Definition: distributed_numbering.h:200
IndexType LocalSize() const
Definition: distributed_numbering.h:161
IndexType Size() const
Definition: distributed_numbering.h:167
Short class definition.
Definition: distributed_sparse_graph.h:68
const DataCommunicator & GetComm() const
Definition: distributed_sparse_graph.h:101
const DenseVector< NonLocalGraphType > & GetNonLocalGraphs() const
Definition: distributed_sparse_graph.h:295
void Clear()
Definition: distributed_sparse_graph.h:162
void Finalize()
Definition: distributed_sparse_graph.h:250
void AddEntries(const IndexType RowIndex, const TIteratorType &rColBegin, const TIteratorType &rColEnd)
Definition: distributed_sparse_graph.h:199
SparseContiguousRowGraph< IndexType > LocalGraphType
Definition: distributed_sparse_graph.h:74
TIndexType IndexType
Definition: distributed_sparse_graph.h:72
std::string Info() const
Turn back information as a string.
Definition: distributed_sparse_graph.h:321
KRATOS_CLASS_POINTER_DEFINITION(DistributedSparseGraph)
Pointer definition of DistributedSparseGraph.
DistributedSparseGraph(const IndexType LocalSize, DataCommunicator &rComm)
constructor.
Definition: distributed_sparse_graph.h:85
int MpiIndexType
Definition: distributed_sparse_graph.h:73
IndexType Size() const
Definition: distributed_sparse_graph.h:116
SparseGraph< IndexType > NonLocalGraphType
Definition: distributed_sparse_graph.h:75
bool Has(const IndexType GlobalI, const IndexType GlobalJ) const
Definition: distributed_sparse_graph.h:126
~DistributedSparseGraph()
Destructor.
Definition: distributed_sparse_graph.h:99
const NonLocalGraphType & GetNonLocalGraph(IndexType Rank) const
Definition: distributed_sparse_graph.h:290
void AddEntry(const IndexType RowIndex, const IndexType ColIndex)
Definition: distributed_sparse_graph.h:168
const DataCommunicator * pGetComm() const
Definition: distributed_sparse_graph.h:106
IndexType ComputeMaxGlobalColumnIndex() const
Definition: distributed_sparse_graph.h:146
const DistributedNumbering< IndexType > & GetRowNumbering() const
Definition: distributed_sparse_graph.h:111
void AddEntries(const TContainerType &rRowIndices, const TContainerType &rColIndices)
Definition: distributed_sparse_graph.h:237
IndexType LocalSize() const
Definition: distributed_sparse_graph.h:121
void AddEntries(const IndexType RowIndex, const TContainerType &rColIndices)
Definition: distributed_sparse_graph.h:183
void ComputeLocalMinMaxColumnIndex(IndexType &rMinJ, IndexType &rMaxJ) const
Definition: distributed_sparse_graph.h:132
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: distributed_sparse_graph.h:329
const LocalGraphType::GraphType::value_type & operator[](const IndexType &LocalPosition) const
Definition: distributed_sparse_graph.h:157
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: distributed_sparse_graph.h:335
void AddEntries(const TContainerType &rIndices)
Definition: distributed_sparse_graph.h:218
const LocalGraphType & GetLocalGraph() const
Definition: distributed_sparse_graph.h:285
Definition: amatrix_interface.h:41
TDataType value_type
Definition: amatrix_interface.h:56
static std::vector< int > ComputeCommunicationScheduling(const std::vector< int > &rLocalDestinationIds, const DataCommunicator &rComm)
Definition: communication_coloring_utilities.cpp:56
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void Clear()
Definition: sparse_contiguous_row_graph.h:135
bool Has(const IndexType I, const IndexType J) const
Definition: sparse_contiguous_row_graph.h:145
void AddEntry(const IndexType RowIndex, const IndexType ColIndex)
Definition: sparse_contiguous_row_graph.h:164
void AddEntries(const IndexType RowIndex, const TContainerType &rColIndices)
Definition: sparse_contiguous_row_graph.h:172
IndexType Size() const
Definition: sparse_contiguous_row_graph.h:141
void AddFromSingleVectorRepresentation(const std::vector< IndexType > &rSingleVectorRepresentation)
Definition: sparse_contiguous_row_graph.h:349
Short class definition.
Definition: sparse_graph.h:66
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
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
color
Definition: all_t_win_vs_m_fixed_error.py:230
def load(f)
Definition: ode_solve.py:307
J
Definition: sensitivityMatrix.py:58
def IsEmpty(_A)
Definition: custom_math.py:33