Go to the documentation of this file.
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;
99 Foam::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);
119 Foam::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);
143 Foam::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;
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();
int debug
Static debugging option.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
List< label > labelList
A List of labels.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
void resize(const label len)
Adjust allocated size of list.
bool addConnectionById(const label otherWorld)
Define a connection from myWorld to other world by ID.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool insert(const edge &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
label getCommById(const label otherWorld) const
Get communicator for myWorld to other world connection by ID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define forAll(list, i)
Loop across all elements in list.
static const wordList & allWorlds() noexcept
All worlds.
~multiWorldConnections()
Destructor.
static const multiWorldConnections & New(const Time &runTime)
Access mesh object.
labelList comms() const
Get communicators used for myWorld to other worlds in sorted order.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static label myWorldID()
My worldID.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
messageStream Info
Information stream (stdout output on master, null elsewhere)
label size() const noexcept
Number of world-to-world connections defined.
label getCommByName(const word &otherWorld) const
Get communicator for myWorld to other world connection by NAME.
static const labelList & worldIDs() noexcept
worldID (index in allWorlds) of all processes
static const word & myWorld()
My world.
virtual Ostream & endBlock()
Write end block group.
OBJstream os(runTime.globalPath()/outputName)
const T & lookup(const edge &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
static void combineGather(const List< commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
List< edge > sortedToc() const
The table of contents (the keys) in sorted order.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool empty() const noexcept
True if no world-to-world connections are defined.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
virtual void indent()
Add indentation characters.
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
void operator()(EdgeMap< unsigned > &a, const EdgeMap< unsigned > &b) const
Centralized handling of multi-world MPI connections.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
forAllConstIters(mixture.phases(), phase)
static label worldComm
Default communicator (all processors)
static bool & parRun() noexcept
Test if this a parallel run.
multiWorldConnections(const Time &runTime)
Construct.
static void printDOT(Ostream &os, const EdgeMap< unsigned > &connections)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool valid() const
Return true if the vertices are unique and non-negative.
defineTypeNameAndDebug(combustionModel, 0)
bool addConnectionByName(const word &otherWorld)
Define a connection from myWorld to other world by NAME.