52 a(iter.key()) |= iter.val();
60 os <<
nl <<
"// Multiworld communication graph:" <<
nl;
68 os << worldi <<
" [xlabel=" << worldi
69 <<
",label=\"" << worldName <<
"\"]" <<
nl;
79 os << connect.first() <<
" -- " << connect.second();
82 if (connections.
lookup(connect, 0u) != 3u)
84 os <<
" [style=dashed] // mismatched?";
91 os <<
"// end graph" <<
nl;
99Foam::edge Foam::multiWorldConnections::worldPair(
const label otherWorld)
103 Perr<<
"ignore: no world or non-parallel" <<
endl;
108 Perr<<
"ignore: invalid world: " << otherWorld <<
endl;
115 return edge(thisWorldID, otherWorld,
true);
119Foam::edge Foam::multiWorldConnections::worldPair(
const word& otherWorld)
123 Perr<<
"ignore: no world or non-parallel" <<
endl;
130 if (otherWorldID < 0)
133 <<
"Cannot find world " << otherWorld
139 return edge(thisWorldID, otherWorldID,
true);
143Foam::label Foam::multiWorldConnections::createCommunicator(
const edge& worlds)
155 DynamicList<label> subRanks(worldIDs.size());
158 if (worlds.found(worldIDs[proci]))
160 subRanks.append(proci);
169 Pout<<
"multiWorld::communicator :"
172 <<
" sub-ranks: " << subRanks
173 <<
" comm:" << comm <<
endl;
193 return MeshObjectType::New(
runTime);
207 return table_.empty();
213 return table_.size();
226 const edge& connect = iter.key();
231 (connect.
first() == thisWorldID ? 1u : 2u)
253 label brokenConnections = 0;
258 if (iter.val() != 3u)
264 if (brokenConnections)
270 <<
"Has " << brokenConnections
271 <<
" broken world-world connections";
287 auto iter = table_.find(connect);
288 if (iter.found() && iter.val() == -1)
290 iter.val() = createCommunicator(connect);
308 edge worlds(worldPair(otherWorld));
315 const bool added = table_.insert(worlds, -1);
317 Pout<< (added ?
"Add" :
"Existing") <<
" connection from "
327 edge worlds(worldPair(otherWorld));
334 const bool added = table_.insert(worlds, -1);
336 Pout<< (added ?
"Add" :
"Existing") <<
" connection from "
345 const label otherWorldID
352 edge worlds(worldPair(otherWorldID));
359 const auto iter = table_.cfind(worlds);
364 <<
"No connection registered for worlds " << worlds
386 const word& otherWorld
393 edge worlds(worldPair(otherWorld));
400 const auto iter = table_.cfind(worlds);
405 <<
"No connection registered for worlds " << worlds
438 if (iter.val() == -1)
451 list[i] = iter.val();
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
T & first() noexcept
The first element of the list, position [0].
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void resize(const label len)
Adjust allocated size of list.
virtual void indent()
Add indentation characters.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endBlock()
Write end block group.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
static void combineGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag, const label comm)
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static const labelList & worldIDs() noexcept
worldID (index in allWorlds) of all processes
static label worldComm
Default communicator (all processors)
static label myWorldID()
My worldID.
static const wordList & allWorlds() noexcept
All worlds.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static bool & parRun() noexcept
Test if this a parallel run.
static const word & myWorld()
My world.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool valid() const
Return true if the vertices are unique and non-negative.
Centralized handling of multi-world MPI connections.
label getCommByName(const word &otherWorld) const
Get communicator for myWorld to other world connection by NAME.
bool empty() const noexcept
True if no world-to-world connections are defined.
bool addConnectionByName(const word &otherWorld)
Define a connection from myWorld to other world by NAME.
label getCommById(const label otherWorld) const
Get communicator for myWorld to other world connection by ID.
label size() const noexcept
Number of world-to-world connections defined.
~multiWorldConnections()
Destructor.
labelList comms() const
Get communicators used for myWorld to other worlds in sorted order.
bool addConnectionById(const label otherWorld)
Define a connection from myWorld to other world by ID.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
List< label > labelList
A List of labels.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static void printDOT(Ostream &os, const EdgeMap< unsigned > &connections)
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
void sort(UList< T > &list)
Sort the list.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
void operator()(EdgeMap< unsigned > &a, const EdgeMap< unsigned > &b) const