43 if (!dummyHandlerPtr_)
49 return dummyHandlerPtr_;
59 if (handlerType.empty())
61 handlerType = defaultFileHandler;
99 newHandler.
get() !=
nullptr
103 old.
swap(newHandler);
116 refPtr<fileOperation> old;
120 newHandler.
get() !=
nullptr
124 old.reset(newHandler.
release());
153 const word& handlerType,
157 if (handlerType.empty())
162 <<
"Default file-handler name is undefined" <<
nl
171 <<
"Constructing fileHandler: " << handlerType <<
endl;
173 auto* ctorPtr = wordConstructorTable(handlerType);
181 *wordConstructorTablePtr_
192 const word& handlerType,
193 const Tuple2<label, labelList>& commAndIORanks,
194 const bool distributedRoots,
198 if (handlerType.empty())
203 <<
"defaultFileHandler name is undefined" <<
nl
218 <<
"Constructing fileHandler: " << handlerType <<
endl;
220 auto* ctorPtr = commConstructorTable(handlerType);
228 *commConstructorTablePtr_
234 ctorPtr(commAndIORanks, distributedRoots, verbose)
247template<
class BoolListType>
263 if (!proci || useProc.test(proci))
281Foam::fileOperation::New_impl
283 const fileOperation& origHandler,
288 autoPtr<fileOperation> newHandler;
295 if (subProcs.contains(myProci))
302 const labelUList& origIOranks = origHandler.ioRanks();
303 DynamicList<label> subIORanks(origIOranks.size());
305 for (
const label proci : subProcs)
307 if (origIOranks.contains(proci))
309 subIORanks.push_back(proci);
326 const bool hasIOranks = (commAndIORanks.second().size() > 1);
331 && (hasIOranks || (subProcs.size() != numProcs))
346 if (siblingRange.size())
348 auto& dynSiblings = subIORanks;
351 for (
const label proci : subProcs)
353 if (siblingRange.contains(proci))
355 dynSiblings.push_back(proci);
359 siblings.transfer(dynSiblings);
385 origHandler.distributed(),
395 newHandler->nProcs(subProcs.size());
396 newHandler->storeComm();
407 const fileOperation& origHandler,
414 return New_impl(origHandler, subProcs, verbose);
428 return New_impl(origHandler, subProcs, verbose);
437 refPtr<fileOperation> oldHandler
442 autoPtr<fileOperation> old;
445 if (oldHandler.is_pointer())
447 old.reset(oldHandler.release());
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static label commWorld() noexcept
Communicator for all ranks (respecting any local worlds).
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
static label newCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Create new communicator with sub-ranks on the parent communicator.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
An encapsulation of filesystem-related operations.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
static refPtr< fileOperation > fileHandlerPtr_
The currently active file handler. Avoid accessing directly.
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
static word defaultFileHandler
Name of the default fileHandler.
static refPtr< fileOperation > null()
Reference to a dummy file handler.
static autoPtr< fileOperation > NewUncollated()
The commonly used uncollatedFileOperation.
fileOperation(const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false)
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
Dummy fileOperation, to be used as a placeholder for interfaces taking a reference to a fileOperation...
fileOperation that assumes file operations are local.
A range or interval of labels defined by a start and a size.
A class for managing references or pointers (no reference counting).
T * get() noexcept
Return pointer without nullptr checking.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
T * release() noexcept
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.
A class for handling words, derived from Foam::string.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInFunction
Report an information message using Foam::Info.
string getEnv(const std::string &envName)
Get environment value for given envName.
List< label > labelList
A List of labels.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
UList< bool > boolUList
A UList of bools.
static labelList getSelectedProcs(const BoolListType &useProc)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).