11#include "precice/impl/versions.hpp"
59 auto sep = remoteInfo.
find(
";");
60 PRECICE_CHECK(sep != std::string::npos,
"The received information string from participant {} is damaged. \"{}\"");
62 auto remoteVersion = remoteInfo.
substr(0, sep);
64 "This participant {} uses preCICE version {} but the requester participant {} uses preCICE version {}. Mixing preCICE versions can lead to undefined behavior and is, thus, forbidden.",
65 localParticipant, PRECICE_VERSION, remoteParticipant, remoteVersion);
67 auto remoteConfigHash = remoteInfo.
substr(sep + 1);
69 "This participant {} uses a different configuration file than the remote participant {}. Hashes differ {} != {}.",
70 localParticipant, remoteParticipant, localConfigHash, remoteConfigHash);
114 _interComm->requestConnection(acceptorName, requesterName,
"PRIMARYCOM", 0, 1);
143 pair.second->acceptConnection(acceptorName, requesterName);
160 pair.second->requestConnection(acceptorName, requesterName);
170 _interComm->prepareEstablishment(acceptorName, requesterName);
177 _interComm->cleanupEstablishment(acceptorName, requesterName);
188 pair.second->acceptPreConnection(acceptorName, requesterName);
202 pair.second->requestPreConnection(acceptorName, requesterName);
212 pair.second->completeSecondaryRanksConnection();
244 pair.second->closeConnection();
274 Event es(
"mn2.sendData.interSync");
283 _distComs[meshID]->send(itemsToSend, valueDimension);
326 "This method can only be used for parallel participants");
337 "This method can only be used for parallel participants");
340 _distComs[meshID]->scatterAllCommunicationMap(localCommunicationMap);
346 "This method can only be used for parallel participants");
349 _distComs[meshID]->broadcastSend(itemToSend);
362 Event es(
"m2n.receiveData.interSync");
371 _distComs[meshID]->receive(itemsToReceive, valueDimension);
427 "This method can only be used for parallel participants");
430 _distComs[meshID]->broadcastReceiveAll(itemToReceive);
436 "This method can only be used for parallel participants");
441 _distComs[meshID]->broadcastReceiveAllMesh();
447 "This method can only be used for parallel participants");
450 _distComs[meshID]->gatherAllCommunicationMap(localCommunicationMap);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
std::shared_ptr< DistributedComFactory > SharedPointer
void scatterAllCommunicationMap(std::map< int, std::vector< int > > &localCommunicationMap, mesh::Mesh &mesh)
Scatters a communication map over connected ranks on remote participant (concerning the given mesh)
void broadcastReceiveAll(std::vector< int > &itemToReceive, mesh::Mesh &mesh)
Receives an int per connected rank on remote participant (concerning the given mesh) @para[out] itemT...
bool _isPrimaryRankConnected
void closeDistributedConnections()
Disconnects all connections of the DistributedCommunication.
void createDistributedCommunication(const mesh::PtrMesh &mesh)
Creates a new distributes communication for that mesh, stores the pointer in _distComs.
void closePrimaryRankConnection()
Disconnects the primary connection.
std::map< int, DistributedCommunication::SharedPointer > _distComs
mesh::getID() -> Pointer to distributed communication
com::PtrCommunication _interComm
connection between the primary ranks of the connected participants
void acceptPrimaryRankConnection(const std::string &acceptorName, const std::string &requesterName, std::string_view configHash)
Connects to another participant, which has to call requestConnection().
void cleanupEstablishment(const std::string &acceptorName, const std::string &requesterName)
cleans-up to establish the connections
void gatherAllCommunicationMap(std::map< int, std::vector< int > > &localCommunicationMap, mesh::Mesh &mesh)
Gathers a communication maps from connected ranks on remote participant (concerning the given mesh)
void broadcastSendMesh(mesh::Mesh &mesh)
Broadcasts a mesh to connected ranks on remote participant (concerning the given mesh)
void closeConnection()
Disconnects from communication space, i.e. participant.
com::PtrCommunication getPrimaryRankCommunication()
Get the basic communication between the 2 primary ranks.
void checkRemoteInfo(std::string_view localParticipant, std::string_view remoteParticipant, std::string_view localConfigHash, std::string_view remoteInfo)
checks the info of the remote participant against the version and config hash of the local participan...
void acceptSecondaryRanksPreConnection(const std::string &acceptorName, const std::string &requesterName)
bool _useOnlyPrimaryCom
between two serial participants, only use the primary com and no secondary com
void acceptSecondaryRanksConnection(const std::string &acceptorName, const std::string &requesterName)
Connects to another participant, which has to call requestConnection().
void requestSecondaryRanksConnection(const std::string &acceptorName, const std::string &requesterName)
Connects to another participant, which has to call acceptConnection().
bool _areSecondaryRanksConnected
void broadcastReceiveAllMesh(mesh::Mesh &mesh)
Receive mesh partitions per connected rank on remote participant (concerning the given mesh)
void requestSecondaryRanksPreConnection(const std::string &acceptorName, const std::string &requesterName)
DistributedComFactory::SharedPointer _distrFactory
M2N(com::PtrCommunication intraComm, DistributedComFactory::SharedPointer distrFactory, bool useOnlyPrimaryCom=false, bool useTwoLevelInit=false)
bool isConnected()
Returns true, if a connection to a remote participant has been setup.
void requestPrimaryRankConnection(const std::string &acceptorName, const std::string &requesterName, std::string_view configHash)
Connects to another participant, which has to call acceptConnection().
void broadcastSend(int itemToSend, mesh::Mesh &mesh)
Broadcasts an int to connected ranks on remote participant (concerning the given mesh)
void completeSecondaryRanksConnection()
bool _useTwoLevelInit
use the two-level initialization concept
void prepareEstablishment(const std::string &acceptorName, const std::string &requesterName)
prepares to establish the connections
void send(precice::span< double const > itemsToSend, int meshID, int valueDimension)
Sends an array of double values from all ranks (different for each rank).
void receive(precice::span< double > itemsToReceive, int meshID, int valueDimension)
Container and creator for meshes.
A C++ 11 implementation of the non-owning C++20 std::span type.
constexpr size_type size() const noexcept
static Rank getRank()
Current rank.
static void broadcast(bool &value)
static bool isParallel()
True if this process is running in parallel.
static bool isSecondary()
True if this process is running a secondary rank.
std::shared_ptr< Communication > PtrCommunication
contains the logic of the parallel communication between participants.
provides Mesh, Data and primitives.
std::shared_ptr< Mesh > PtrMesh
static constexpr FundamentalTag Fundamental
Convenience instance of the FundamentalTag.
static constexpr SynchronizeTag Synchronize
Convenience instance of the SynchronizeTag.
Main namespace of the precice library.
constexpr auto get(span< E, S > s) -> decltype(s[N])
bool syncMode
Enabled further inter- and intra-solver synchronisation.