37 void Foam::masterOFstream::checkWrite
39 const fileName& fName,
62 <<
"Could not open file " << fName <<
nl 69 os.writeRaw(
str, len);
74 <<
"Failed writing to " << fName <<
nl 80 void Foam::masterOFstream::checkWrite
82 const fileName& fName,
86 checkWrite(fName,
s.data(),
s.length());
90 void Foam::masterOFstream::commit()
110 checkWrite(pathName_, this->str());
125 string s(this->str());
133 pBufs.finishedGathers();
147 List<char> buf(pBufs.maxRecvCount());
151 const std::streamsize
count(pBufs.recvDataCount(proci));
155 UIPstream is(proci, pBufs);
157 is.read(buf.data(),
count);
158 checkWrite(filePaths[proci], buf.cdata(),
count);
165 checkWrite(pathName_, this->str());
183 const bool writeOnProc
189 compression_(streamOpt.compression()),
191 writeOnProc_(writeOnProc),
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual Ostream & write(const char c) override
Write character.
Foam::string str() const
Get the string - as Foam::string rather than std::string.
constexpr char nl
The newline '\n' character (0x0a)
static bool & parRun() noexcept
Test if this a parallel run.
static int & msgType() noexcept
Message tag of standard messages.
A simple container for options an IOstream can normally have.
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 void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
atomicType
Atomic operations (output)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
OBJstream os(runTime.globalPath()/outputName)
appendType
File appending (NON_APPEND | APPEND)
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
~masterOFstream()
Destructor - commits buffered information to file.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
versionNumber version() const noexcept
Get the stream version.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
masterOFstream(IOstreamOption::atomicType atomic, const label comm, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), IOstreamOption::appendType append=IOstreamOption::NON_APPEND, const bool writeOnProc=true)
Construct with specified atomic behaviour and communicator from pathname, stream option, optional append.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...