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 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,
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_
232 return autoPtr<fileOperation>
234 ctorPtr(commAndIORanks, distributedRoots, verbose)
247 template<
class BoolListType>
263 if (!proci || useProc.test(proci))
281 Foam::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);
314 Tuple2<label, labelList> commAndIORanks
326 const bool hasIOranks = (commAndIORanks.
second().
size() > 1);
331 && (hasIOranks || (subProcs.size() != numProcs))
336 labelRange siblingRange(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();
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());
static refPtr< fileOperation > fileHandlerPtr_
The currently active file handler. Avoid accessing directly.
void size(const label n)
Older name for setAddressableSize.
static labelList getSelectedProcs(const BoolListType &useProc)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static refPtr< fileOperation > null()
Reference to a dummy file handler.
string getEnv(const std::string &envName)
Get environment value for given envName.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
An encapsulation of filesystem-related operations.
UList< label > labelUList
A UList of labels.
fileOperation that assumes file operations are local.
Dummy fileOperation, to be used as a placeholder for interfaces taking a reference to a fileOperation...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
#define DebugInFunction
Report an information message using Foam::Info.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T * get() noexcept
Return pointer without nullptr checking.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
void push_back(const T &val)
Copy append an element to the end of this list.
static label commWorld() noexcept
Communicator for all ranks (respecting any local worlds)
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
T * release() noexcept
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
static word defaultFileHandler
Name of the default fileHandler.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
const T2 & second() const noexcept
Access the second element.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
List< label > labelList
A List of labels.
const T1 & first() const noexcept
Access the first element.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
static label allocateCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Allocate new communicator with contiguous sub-ranks on the parent communicator.
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.
static autoPtr< fileOperation > NewUncollated()
The commonly used uncollatedFileOperation.