KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Classes | List of all members
Kratos::DataCommunicator Class Reference

Serial (do-nothing) version of a wrapper class for MPI communication. More...

#include <data_communicator.h>

Inheritance diagram for Kratos::DataCommunicator:
Collaboration diagram for Kratos::DataCommunicator:

Public Member Functions

Type Definitions
 KRATOS_CLASS_POINTER_DEFINITION (DataCommunicator)
 Pointer definition of DataCommunicator. More...
 
Life Cycle
 DataCommunicator ()
 Default constructor. More...
 
virtual ~DataCommunicator ()
 Destructor. More...
 
Inquiry
virtual int Rank () const
 Get the parallel rank for this DataCommunicator. More...
 
virtual int Size () const
 Get the parallel size of this DataCommunicator. More...
 
virtual bool IsDistributed () const
 Check whether this DataCommunicator is aware of parallelism. More...
 
virtual bool IsDefinedOnThisRank () const
 Check whether this DataCommunicator involves the current rank. More...
 
virtual bool IsNullOnThisRank () const
 Check whether this DataCommunicator is MPI_COMM_NULL for the current rank. More...
 
virtual const DataCommunicatorGetSubDataCommunicator (const std::vector< int > &rRanks, const std::string &rNewCommunicatorName) const
 Get a sub-data communicator. More...
 
Helper functions for error checking in MPI
virtual bool BroadcastErrorIfTrue (bool Condition, const int SourceRank) const
 This function throws an error on ranks != Sourcerank if Condition evaluates to true. More...
 
virtual bool BroadcastErrorIfFalse (bool Condition, const int SourceRank) const
 This function throws an error on ranks != Sourcerank if Condition evaluates to false. More...
 
virtual bool ErrorIfTrueOnAnyRank (bool Condition) const
 This function throws an error on ranks where Condition evaluates to false, if it evaluated to true on a different rank. More...
 
virtual bool ErrorIfFalseOnAnyRank (bool Condition) const
 This function throws an error on ranks where Condition evaluates to true, if it evaluated to false on a different rank. More...
 
Input and output
virtual std::string Info () const
 Turn back information as a string. More...
 
virtual void PrintInfo (std::ostream &rOStream) const
 Print information about this object. More...
 
virtual void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 

Static Public Member Functions

Access
static DataCommunicatorGetDefault ()
 Convenience function to retrieve the current default DataCommunicator. More...
 

Protected Member Functions

Protected operations
virtual void BroadcastImpl (std::string &rBuffer, const int SourceRank) const
 Synchronize a buffer to the value held by the broadcasting rank (string version). More...
 
template<class TObject >
void BroadcastImpl (TObject &rBroadcastObject, const int SourceRank) const
 Synchronize a buffer to the value held by the broadcasting rank (generic version). More...
 
virtual void SendRecvImpl (const std::string &rSendValues, const int SendDestination, const int SendTag, std::string &rRecvValues, const int RecvSource, const int RecvTag) const
 Exchange data with other ranks (string version). More...
 
virtual std::string SendRecvImpl (const std::string &rSendValues, const int SendDestination, const int SendTag, const int RecvSource, const int RecvTag) const
 Exchange data with other ranks (string version). More...
 
template<class TObject >
TObject SendRecvImpl (const TObject &rSendObject, const int SendDestination, const int SendTag, const int RecvSource, const int RecvTag) const
 Exchange data with other ranks (generic version). More...
 
virtual void SendImpl (const std::string &rSendValues, const int SendDestination, const int SendTag) const
 Send data to other ranks (string version). More...
 
template<class TObject >
void SendImpl (const TObject &rSendObject, const int SendDestination, const int SendTag) const
 Exchange data with other ranks (generic version). More...
 
virtual void RecvImpl (std::string &rRecvValues, const int RecvSource, const int RecvTag=0) const
 Receive data from other ranks (string version). More...
 
template<class TObject >
void RecvImpl (TObject &rRecvObject, const int RecvSource, const int RecvTag=0) const
 Exchange data with other ranks (generic version). More...
 

Operations

virtual void Barrier () const
 Pause program execution until all threads reach this call. More...
 
virtual bool AndReduce (const bool Value, const int Root) const
 
virtual Kratos::Flags AndReduce (const Kratos::Flags Values, const Kratos::Flags Mask, const int Root) const
 
virtual bool OrReduce (const bool Value, const int Root) const
 
virtual Kratos::Flags OrReduce (const Kratos::Flags Values, const Kratos::Flags Mask, const int Root) const
 
virtual bool AndReduceAll (const bool Value) const
 
virtual Kratos::Flags AndReduceAll (const Kratos::Flags Values, const Kratos::Flags Mask) const
 
virtual bool OrReduceAll (const bool Value) const
 
virtual Kratos::Flags OrReduceAll (const Kratos::Flags Values, const Kratos::Flags Mask) const
 
template<typename TObject >
void Broadcast (TObject &rBroadcastObject, const int SourceRank) const
 Synchronize a buffer to the value held by the broadcasting rank. More...
 
template<typename TObject >
TObject SendRecv (const TObject &rSendObject, const int SendDestination, const int SendTag, const int RecvSource, const int RecvTag) const
 Exchange data with other ranks. More...
 
template<class TObject >
TObject SendRecv (const TObject &rSendObject, const int SendDestination, const int RecvSource) const
 Exchange data with other ranks. More...
 
template<class TObject >
void SendRecv (const TObject &rSendObject, const int SendDestination, const int SendTag, TObject &rRecvObject, const int RecvSource, const int RecvTag) const
 Exchange data with other ranks. More...
 
template<class TObject >
void SendRecv (const TObject &rSendObject, const int SendDestination, TObject &rRecvObject, const int RecvSource) const
 Exchange data with other ranks. More...
 
template<typename TObject >
void Send (const TObject &rSendValues, const int SendDestination, const int SendTag=0) const
 Exchange data with other ranks. More...
 
template<typename TObject >
void Recv (TObject &rRecvObject, const int RecvSource, const int RecvTag=0) const
 Exchange data with other ranks. More...
 
static DataCommunicator::UniquePointer Create ()
 Create a new DataCommunicator as a copy of this one. More...
 

Detailed Description

Serial (do-nothing) version of a wrapper class for MPI communication.

See also
MPIDataCommunicator for a working distributed memory implementation.

Constructor & Destructor Documentation

◆ DataCommunicator()

Kratos::DataCommunicator::DataCommunicator ( )
inline

Default constructor.

◆ ~DataCommunicator()

virtual Kratos::DataCommunicator::~DataCommunicator ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ AndReduce() [1/2]

virtual bool Kratos::DataCommunicator::AndReduce ( const bool  Value,
const int  Root 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ AndReduce() [2/2]

virtual Kratos::Flags Kratos::DataCommunicator::AndReduce ( const Kratos::Flags  Values,
const Kratos::Flags  Mask,
const int  Root 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ AndReduceAll() [1/2]

virtual bool Kratos::DataCommunicator::AndReduceAll ( const bool  Value) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ AndReduceAll() [2/2]

virtual Kratos::Flags Kratos::DataCommunicator::AndReduceAll ( const Kratos::Flags  Values,
const Kratos::Flags  Mask 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ Barrier()

virtual void Kratos::DataCommunicator::Barrier ( ) const
inlinevirtual

Pause program execution until all threads reach this call.

Wrapper for MPI_Barrier.

Reimplemented in Kratos::MPIDataCommunicator.

◆ Broadcast()

template<typename TObject >
void Kratos::DataCommunicator::Broadcast ( TObject &  rBroadcastObject,
const int  SourceRank 
) const
inline

Synchronize a buffer to the value held by the broadcasting rank.

This is a wrapper for MPI_Bcast.

Parameters
[in/out]The broadcast value (input on SourceRank, output on all other ranks).
[in]SourceRankThe rank transmitting the value. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ BroadcastErrorIfFalse()

virtual bool Kratos::DataCommunicator::BroadcastErrorIfFalse ( bool  Condition,
const int  SourceRank 
) const
inlinevirtual

This function throws an error on ranks != Sourcerank if Condition evaluates to false.

This method is intended as a helper function to force ranks to stop after an error is detected on a given rank. A typical use case would be to completely stop the simulation if an error is detected on the root process. The intended usage is something like:

KRATOS_ERROR_IF_NOT( data_communicator_instance.BroadcastErrorIfFalse(Condition, Root) ) << "Detailed error message in Root rank";

If an error is detected, ranks other than Root will fail with a generic error message. Failing on the Root rank is left to the caller, so that a detailed error message can be produced.

Note
This method should be called from all ranks, it will deadlock if called within an if(rank == some_rank) statement.
See also
MPIDataCommunicator.
Parameters
ConditionThe condition to check.
SourceRankThe rank where the condition is meaningful.
Returns
The result of evaluating Condition.

Reimplemented in Kratos::MPIDataCommunicator.

◆ BroadcastErrorIfTrue()

virtual bool Kratos::DataCommunicator::BroadcastErrorIfTrue ( bool  Condition,
const int  SourceRank 
) const
inlinevirtual

This function throws an error on ranks != Sourcerank if Condition evaluates to true.

This method is intended as a helper function to force ranks to stop after an error is detected on a given rank. A typical use case would be to completely stop the simulation if an error is detected on the root process. The intended usage is something like:

KRATOS_ERROR_IF( data_communicator_instance.BroadcastErrorIfTrue(Condition, Root) ) << "Detailed error message in Root rank";

If an error is detected, ranks other than Root will fail with a generic error message. Failing on the Root rank is left to the caller, so that a detailed error message can be produced.

Note
This method should be called from all ranks, it will deadlock if called within an if(rank == some_rank) statement.
See also
MPIDataCommunicator.
Parameters
ConditionThe condition to check.
SourceRankThe rank where the condition is meaningful.
Returns
The result of evaluating Condition.

Reimplemented in Kratos::MPIDataCommunicator.

◆ BroadcastImpl() [1/2]

virtual void Kratos::DataCommunicator::BroadcastImpl ( std::string &  rBuffer,
const int  SourceRank 
) const
inlineprotectedvirtual

Synchronize a buffer to the value held by the broadcasting rank (string version).

This is a wrapper for MPI_Bcast.

Parameters
[in/out]The broadcast value (input on SourceRank, output on all other ranks).
[in]SourceRankThe rank transmitting the value.

Reimplemented in Kratos::MPIDataCommunicator.

◆ BroadcastImpl() [2/2]

template<class TObject >
void Kratos::DataCommunicator::BroadcastImpl ( TObject &  rBroadcastObject,
const int  SourceRank 
) const
inlineprotected

Synchronize a buffer to the value held by the broadcasting rank (generic version).

This is a wrapper for MPI_Bcast, using serialization to package complex objects.

Parameters
[in/out]The broadcast value (input on SourceRank, output on all other ranks).
[in]SourceRankThe rank transmitting the value.

◆ Create()

static DataCommunicator::UniquePointer Kratos::DataCommunicator::Create ( )
inlinestatic

Create a new DataCommunicator as a copy of this one.

This method is used in ParallelEnvironment to register DataCommunicators

See also
ParallelEnvironment.
Returns
a unique pointer to the new DataCommunicator.

◆ ErrorIfFalseOnAnyRank()

virtual bool Kratos::DataCommunicator::ErrorIfFalseOnAnyRank ( bool  Condition) const
inlinevirtual

This function throws an error on ranks where Condition evaluates to true, if it evaluated to false on a different rank.

This method is intended as a helper function to force ranks to stop after an error is detected on one or more ranks. The intended usage is something like:

KRATOS_ERROR_IF_NOT( data_communicator_instance.ErrorIfFalseOnAnyRank(Condition) ) << "Detailed error message in ranks where Condition == false.";

If an error is detected, ranks other than those where it was detected will fail with a generic error message. Failing on the ranks where the condition is false is left to the caller, so that a detailed error message can be produced.

Note
This method should be called from all ranks, it will deadlock if called within an if(rank == some_rank) statement.
See also
MPIDataCommunicator.
Parameters
ConditionThe condition to check.
Returns
The result of evaluating Condition.

Reimplemented in Kratos::MPIDataCommunicator.

◆ ErrorIfTrueOnAnyRank()

virtual bool Kratos::DataCommunicator::ErrorIfTrueOnAnyRank ( bool  Condition) const
inlinevirtual

This function throws an error on ranks where Condition evaluates to false, if it evaluated to true on a different rank.

This method is intended as a helper function to force ranks to stop after an error is detected on one or more ranks. The intended usage is something like:

KRATOS_ERROR_IF( data_communicator_instance.ErrorIfTrueOnAnyRank(Condition) ) << "Detailed error message in ranks where Condition == true.";

If an error is detected, ranks other than those where it was detected will fail with a generic error message. Failing on the ranks where the condition is true is left to the caller, so that a detailed error message can be produced.

Note
This method should be called from all ranks, it will deadlock if called within an if(rank == some_rank) statement.
See also
MPIDataCommunicator.
Parameters
ConditionThe condition to check.
Returns
The result of evaluating Condition.

Reimplemented in Kratos::MPIDataCommunicator.

◆ GetDefault()

DataCommunicator & Kratos::DataCommunicator::GetDefault ( )
static

Convenience function to retrieve the current default DataCommunicator.

Returns
A reference to the DataCommunicator instance registered as default in ParallelEnvironment.

◆ GetSubDataCommunicator()

virtual const DataCommunicator& Kratos::DataCommunicator::GetSubDataCommunicator ( const std::vector< int > &  rRanks,
const std::string &  rNewCommunicatorName 
) const
inlinevirtual

Get a sub-data communicator.

This function returns a sub-data communicator based on the provided ranks and a new communicator name.

Parameters
rRanksThe ranks to include in the sub-communicator.
rNewCommunicatorNameThe name of the new sub-communicator.
Returns
The sub-data communicator.

Reimplemented in Kratos::MPIDataCommunicator.

◆ Info()

virtual std::string Kratos::DataCommunicator::Info ( ) const
inlinevirtual

Turn back information as a string.

Reimplemented in Kratos::MPIDataCommunicator.

◆ IsDefinedOnThisRank()

virtual bool Kratos::DataCommunicator::IsDefinedOnThisRank ( ) const
inlinevirtual

Check whether this DataCommunicator involves the current rank.

In MPI, if the rank is not involved in communication, the communicator is MPI_COMM_NULL and is not a valid argument for most MPI calls.

Returns
True if the DataCommunicator is defined on the current rank, otherwise false.

Reimplemented in Kratos::MPIDataCommunicator.

◆ IsDistributed()

virtual bool Kratos::DataCommunicator::IsDistributed ( ) const
inlinevirtual

Check whether this DataCommunicator is aware of parallelism.

Returns
True if the DataCommunicator is distributed, otherwise false.

Reimplemented in Kratos::MPIDataCommunicator.

◆ IsNullOnThisRank()

virtual bool Kratos::DataCommunicator::IsNullOnThisRank ( ) const
inlinevirtual

Check whether this DataCommunicator is MPI_COMM_NULL for the current rank.

In MPI, if the rank is not involved in communication, the communicator is MPI_COMM_NULL and is not a valid argument for most MPI calls.

Returns
True if the DataCommunicator is MPI_COMM_NULL, otherwise false.

Reimplemented in Kratos::MPIDataCommunicator.

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::DataCommunicator::KRATOS_CLASS_POINTER_DEFINITION ( DataCommunicator  )

Pointer definition of DataCommunicator.

◆ OrReduce() [1/2]

virtual bool Kratos::DataCommunicator::OrReduce ( const bool  Value,
const int  Root 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ OrReduce() [2/2]

virtual Kratos::Flags Kratos::DataCommunicator::OrReduce ( const Kratos::Flags  Values,
const Kratos::Flags  Mask,
const int  Root 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ OrReduceAll() [1/2]

virtual bool Kratos::DataCommunicator::OrReduceAll ( const bool  Value) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ OrReduceAll() [2/2]

virtual Kratos::Flags Kratos::DataCommunicator::OrReduceAll ( const Kratos::Flags  Values,
const Kratos::Flags  Mask 
) const
inlinevirtual

Reimplemented in Kratos::MPIDataCommunicator.

◆ PrintData()

virtual void Kratos::DataCommunicator::PrintData ( std::ostream &  rOStream) const
inlinevirtual

Print object's data.

Reimplemented in Kratos::MPIDataCommunicator.

◆ PrintInfo()

virtual void Kratos::DataCommunicator::PrintInfo ( std::ostream &  rOStream) const
inlinevirtual

Print information about this object.

Reimplemented in Kratos::MPIDataCommunicator.

◆ Rank()

virtual int Kratos::DataCommunicator::Rank ( ) const
inlinevirtual

Get the parallel rank for this DataCommunicator.

This function serves as a wrapper for MPI_Comm_rank.

Returns
The parallel rank of the current process.

Reimplemented in Kratos::MPIDataCommunicator.

◆ Recv()

template<typename TObject >
void Kratos::DataCommunicator::Recv ( TObject &  rRecvObject,
const int  RecvSource,
const int  RecvTag = 0 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Recv.

Parameters
[out]rRecvObjectObjects to receive from rank RecvSource.
[in]RecvSourceRank the data will be received from.
[in]RecvTagMessage tag for received values. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ RecvImpl() [1/2]

virtual void Kratos::DataCommunicator::RecvImpl ( std::string &  rRecvValues,
const int  RecvSource,
const int  RecvTag = 0 
) const
inlineprotectedvirtual

Receive data from other ranks (string version).

This is a wrapper for MPI_Recv.

Parameters
[out]rRecvValuesReceived string from rank RecvSource.
[in]RecvSourceRank the string is expected from.
[in]RecvTagMessage tag for received values.

Reimplemented in Kratos::MPIDataCommunicator.

◆ RecvImpl() [2/2]

template<class TObject >
void Kratos::DataCommunicator::RecvImpl ( TObject &  rRecvObject,
const int  RecvSource,
const int  RecvTag = 0 
) const
inlineprotected

Exchange data with other ranks (generic version).

This is a wrapper for MPI_Recv that uses serialization to transfer arbitrary objects. The objects are expected to be serializable and come in an stl-like container supporting size() and resize()

Parameters
[out]rRecvObjectObjects to receive from rank RecvSource.
[in]RecvSourceRank the data will be received from.
[in]RecvTagMessage tag for received values.

◆ Send()

template<typename TObject >
void Kratos::DataCommunicator::Send ( const TObject &  rSendValues,
const int  SendDestination,
const int  SendTag = 0 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Send.

Parameters
[in]rSendValuesObjects to send to rank SendDestination.
[in]SendDestinationRank the data will be sent to.
[in]SendTagMessage tag for sent values. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ SendImpl() [1/2]

virtual void Kratos::DataCommunicator::SendImpl ( const std::string &  rSendValues,
const int  SendDestination,
const int  SendTag 
) const
inlineprotectedvirtual

Send data to other ranks (string version).

This is a wrapper for MPI_Send.

Parameters
[in]rSendValuesString to send to rank SendDestination.
[in]SendDestinationRank the string will be sent to.
[in]SendTagMessage tag for sent values.

Reimplemented in Kratos::MPIDataCommunicator.

◆ SendImpl() [2/2]

template<class TObject >
void Kratos::DataCommunicator::SendImpl ( const TObject &  rSendObject,
const int  SendDestination,
const int  SendTag 
) const
inlineprotected

Exchange data with other ranks (generic version).

This is a wrapper for MPI_Send that uses serialization to transfer arbitrary objects. The objects are expected to be serializable and come in an stl-like container supporting size() and resize()

Parameters
[in]rSendValuesObjects to send to rank SendDestination.
[in]SendDestinationRank the data will be sent to.
[in]SendTagMessage tag for sent values.

◆ SendRecv() [1/4]

template<class TObject >
TObject Kratos::DataCommunicator::SendRecv ( const TObject &  rSendObject,
const int  SendDestination,
const int  RecvSource 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesValues to send to rank SendDestination.
[in]RecvSourceRank values are expected from.
[in]SendDestinationRank the values will be sent to.
Returns
Received values from rank RecvSource. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ SendRecv() [2/4]

template<typename TObject >
TObject Kratos::DataCommunicator::SendRecv ( const TObject &  rSendObject,
const int  SendDestination,
const int  SendTag,
const int  RecvSource,
const int  RecvTag 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesValues to send to rank SendDestination.
[in]SendDestinationRank the values will be sent to.
[in]SendTagMessage tag for sent values.
[in]RecvSourceRank values are expected from.
[in]RecvTagMessage tag for received values.
Returns
Received values from rank RecvSource. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ SendRecv() [3/4]

template<class TObject >
void Kratos::DataCommunicator::SendRecv ( const TObject &  rSendObject,
const int  SendDestination,
const int  SendTag,
TObject &  rRecvObject,
const int  RecvSource,
const int  RecvTag 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesValues to send to rank SendDestination.
[in]SendDestinationRank the values will be sent to.
[in]SendTagMessage tag for sent values.
[out]rRecvValuesReceived values from rank RecvSource.
[in]RecvSourceRank values are expected from.
[in]RecvTagMessage tag for received values. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ SendRecv() [4/4]

template<class TObject >
void Kratos::DataCommunicator::SendRecv ( const TObject &  rSendObject,
const int  SendDestination,
TObject &  rRecvObject,
const int  RecvSource 
) const
inline

Exchange data with other ranks.

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesValues to send to rank SendDestination.
[in]SendDestinationRank the values will be sent to.
[out]rRecvValuesReceived values from rank RecvSource.
[in]RecvSourceRank values are expected from. This function will transfer basic types (or std::vectors of basic types) directly. For complex classes, serialization will be used to package the object(s) before communication.

◆ SendRecvImpl() [1/3]

virtual std::string Kratos::DataCommunicator::SendRecvImpl ( const std::string &  rSendValues,
const int  SendDestination,
const int  SendTag,
const int  RecvSource,
const int  RecvTag 
) const
inlineprotectedvirtual

Exchange data with other ranks (string version).

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesString to send to rank SendDestination.
[in]SendDestinationRank the string will be sent to.
[in]SendTagMessage tag for sent values.
[in]RecvSourceRank the string is expected from.
[in]RecvTagMessage tag for received values.
Returns
Received string from rank RecvSource.

Reimplemented in Kratos::MPIDataCommunicator.

◆ SendRecvImpl() [2/3]

virtual void Kratos::DataCommunicator::SendRecvImpl ( const std::string &  rSendValues,
const int  SendDestination,
const int  SendTag,
std::string &  rRecvValues,
const int  RecvSource,
const int  RecvTag 
) const
inlineprotectedvirtual

Exchange data with other ranks (string version).

This is a wrapper for MPI_Sendrecv.

Parameters
[in]rSendValuesString to send to rank SendDestination.
[in]SendDestinationRank the string will be sent to.
[in]SendTagMessage tag for sent values.
[out]rRecvValuesReceived string from rank RecvSource.
[in]RecvSourceRank the string is expected from.
[in]RecvTagMessage tag for received values.

Reimplemented in Kratos::MPIDataCommunicator.

◆ SendRecvImpl() [3/3]

template<class TObject >
TObject Kratos::DataCommunicator::SendRecvImpl ( const TObject &  rSendObject,
const int  SendDestination,
const int  SendTag,
const int  RecvSource,
const int  RecvTag 
) const
inlineprotected

Exchange data with other ranks (generic version).

This is a wrapper for MPI_Sendrecv that uses serialization to transfer arbitrary objects. The objects are expected to be serializable and come in an stl-like container supporting size() and resize()

Parameters
[in]rSendValuesObjects to send to rank SendDestination.
[in]SendDestinationRank the data will be sent to.
[in]SendTagMessage tag for sent values.
[in]RecvSourceRank the data is expected from.
[in]RecvTagMessage tag for received values.
Returns
Received data from rank RecvSource.

◆ Size()

virtual int Kratos::DataCommunicator::Size ( ) const
inlinevirtual

Get the parallel size of this DataCommunicator.

This function serves as a wrapper for MPI_Comm_size.

Returns
The parallel size of the communicator.

Reimplemented in Kratos::MPIDataCommunicator.


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