37void Foam::masterOFstream::checkWrite
39 const fileName& fName,
44 if (!
str || !(len > 0))
62 <<
"Could not open file " << fName <<
nl
67 os.writeRaw(
str, len);
72 <<
"Failed writing to " << fName <<
nl
78void Foam::masterOFstream::commit()
86 checkWrite(pathName_, charData);
114 checkWrite(pathName_, charData);
130 const label dataSize =
149 recvProcs.reserve_exact(order.size());
154 const label proci = order[i];
157 if (recvSizes[proci] > 0)
159 recvProcs.push_back(proci);
177 charData.cdata_bytes(),
178 charData.size_bytes(),
189 for (
const int proci : recvProcs)
191 auto& slot = recvBuffers[proci];
192 slot.resize_nocopy(recvSizes[proci]);
209 checkWrite(pathName_, charData);
225 for (
const int i : indices)
227 const int proci = recvProcs[i];
228 auto& slot = recvBuffers[proci];
231 checkWrite(filePaths[proci], slot);
249 const int communicator,
250 const fileName& pathName,
251 IOstreamOption streamOpt,
253 const bool writeOnProc
256 OCharStream(streamOpt),
259 compression_(streamOpt.compression()),
261 writeOnProc_(writeOnProc),
262 comm_(communicator < 0 ? UPstream::worldComm : communicator)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
compressionType compression() const noexcept
Get the stream compression.
atomicType
Atomic operations (output).
appendType
File appending (NO_APPEND | APPEND_APP | APPEND_ATE).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
OCharStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output).
void append(std::streamsize count, char c)
Append repeated character content.
DynamicList< char > release()
Reset buffer and return contents.
auto str() const
For OStringStream compatibility, return the buffer as string copy.
void reserve(std::streamsize n)
Reserve output space for at least this amount.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive buffer contents (contiguous types) from given processor.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents (contiguous types only) to given processor.
Inter-processor communications stream.
static bool waitSomeRequests(label pos, label len=-1, DynamicList< int > *indices=nullptr)
Wait until some requests (from position onwards) have finished. Corresponds to MPI_Waitsome().
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 label nRequests() noexcept
Number of outstanding requests (on the internal list of requests).
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Gather individual values into list locations.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool is_subrank(const label communicator=worldComm)
True if process corresponds to a sub-rank in the given communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static void waitRequests()
Wait for all requests to finish.
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
A class for handling file names.
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
masterOFstream(IOstreamOption::atomicType atomic, const int communicator, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), IOstreamOption::appendType append=IOstreamOption::NO_APPEND, const bool writeOnProc=true)
Construct with specified atomic behaviour and communicator from pathname, stream option,...
~masterOFstream()
Destructor - commits buffered information to file.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
List< label > labelList
A List of labels.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAllReverse(list, i)
Reverse loop across all elements in list.