preCICE v3.1.2
Loading...
Searching...
No Matches
BoundM2N.cpp
Go to the documentation of this file.
1#include <memory>
2
6#include "m2n/BoundM2N.hpp"
7#include "m2n/M2N.hpp"
9#include "utils/IntraComm.hpp"
10#include "utils/assertion.hpp"
11
12namespace precice::m2n {
13
15{
16 if (isRequesting) {
17 return;
18 }
19
20 m2n->prepareEstablishment(localName, remoteName);
21}
22
24{
25 std::string fullLocalName = localName;
26
27 if (isRequesting) {
28 m2n->requestPrimaryRankConnection(remoteName, fullLocalName);
29 } else {
30 m2n->acceptPrimaryRankConnection(fullLocalName, remoteName);
31 }
32}
33
35{
36 if (m2n->usesTwoLevelInitialization()) {
37 PRECICE_DEBUG("Update secondary connections");
38 m2n->completeSecondaryRanksConnection();
39 } else {
40 if (isRequesting) {
41 PRECICE_DEBUG("Awaiting secondary connections from {}", remoteName);
42 m2n->requestSecondaryRanksConnection(remoteName, localName);
43 PRECICE_DEBUG("Established secondary connections from {}", remoteName);
44 } else {
45 PRECICE_DEBUG("Establishing secondary connections to {}", remoteName);
46 m2n->acceptSecondaryRanksConnection(localName, remoteName);
47 PRECICE_DEBUG("Established secondary connections to {}", remoteName);
48 }
49 }
50}
51
53{
54 if (not m2n->usesTwoLevelInitialization())
55 return;
56
57 PRECICE_WARN("Two-level initialization is still in beta testing. Several edge cases are known to fail. Please report problems nevertheless.");
58
59 if (isRequesting) {
60 PRECICE_DEBUG("Awaiting preliminary secondary connections from {}", remoteName);
61 m2n->requestSecondaryRanksPreConnection(remoteName, localName);
62 PRECICE_DEBUG("Established preliminary secondary connections from {}", remoteName);
63 } else {
64 PRECICE_DEBUG("Establishing preliminary secondary connections to {}", remoteName);
65 m2n->acceptSecondaryRanksPreConnection(localName, remoteName);
66 PRECICE_DEBUG("Established preliminary secondary connections to {}", remoteName);
67 }
68}
69
71{
72 if (isRequesting) {
73 return;
74 }
77 m2n->cleanupEstablishment(localName, remoteName);
78 }
79}
80
82{
85 int item = 0;
86 utils::IntraComm::getCommunication()->receive(item, rank);
87 PRECICE_ASSERT(item > 0);
88 }
89 }
91 int item = utils::IntraComm::getRank();
93 }
94}
95
96} // namespace precice::m2n
#define PRECICE_WARN(...)
Definition LogMacros.hpp:11
#define PRECICE_DEBUG(...)
Definition LogMacros.hpp:64
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
void preConnectSecondaryRanks()
pre-connect the Secondary ranks of the M2N
Definition BoundM2N.cpp:52
void connectPrimaryRanks()
Connect the Primary Ranks of the M2N.
Definition BoundM2N.cpp:23
std::string remoteName
Definition BoundM2N.hpp:30
void connectSecondaryRanks()
Connect the Secondary ranks of the M2N.
Definition BoundM2N.cpp:34
void cleanupEstablishment()
Cleanup after having established the connection.
Definition BoundM2N.cpp:70
void prepareEstablishment()
Prepare to establish the connection.
Definition BoundM2N.cpp:14
std::string localName
Definition BoundM2N.hpp:29
static Rank getRank()
Current rank.
Definition IntraComm.cpp:42
static bool isPrimary()
True if this process is running the primary rank.
Definition IntraComm.cpp:52
static auto allSecondaryRanks()
Returns an iterable range over salve ranks [1, _size)
Definition IntraComm.hpp:37
static bool isSecondary()
True if this process is running a secondary rank.
Definition IntraComm.cpp:57
static com::PtrCommunication & getCommunication()
Intra-participant communication.
Definition IntraComm.hpp:31
contains the logic of the parallel communication between participants.
Definition BoundM2N.cpp:12
int Rank
Definition Types.hpp:37