57 fileObr_.time().globalPath()
62 const auto*
meshPtr = isA<polyMesh>(fileObr_);
65 baseDir /=
meshPtr->regionName();
75 return baseFileDir()/prefix_/fileObr_.time().timeName();
84 return baseFileDir()/prefix_/fName;
128 timeValue = fileObr_.time().timeToUserTime(timeValue);
133 fileName outputDir(baseFileDir()/prefix_/
timeName);
140 IFstream is(outputDir/(fName +
".dat"));
146 osPtr.
reset(
new OFstream(outputDir/(fName +
".dat")));
167 return newFileAtTime(
name, startTime_);
175 filePtr_ = newFileAtStartTime(fileName_);
184 return setw(writePrecision_ + addChars + offset);
192 fileObr_(wf.fileObr_),
194 fileName_(wf.fileName_),
196 writePrecision_(wf.writePrecision_),
197 writeToFile_(wf.writeToFile_),
198 updateHeader_(wf.updateHeader_),
199 writtenHeader_(wf.writtenHeader_),
200 useUserTime_(wf.useUserTime_),
201 startTime_(wf.startTime_)
210 const bool writeToFile
217 writePrecision_(
IOstream::defaultPrecision()),
218 writeToFile_(writeToFile),
220 writtenHeader_(false),
222 startTime_(obr.time().
startTime().value())
232 const bool writeToFile
251 dict.getCheckOrDefault
258 updateHeader_ =
dict.getOrDefault(
"updateHeader", updateHeader_);
265 useUserTime_ =
dict.getOrDefault(
"useUserTime",
true);
281 <<
"File pointer not allocated\n";
309 Pstream::master() && writeToFile_ && (updateHeader_ || !writtenHeader_);
315 return writePrecision_ + addChars;
330 <<
setf(ios_base::left) <<
setw(charWidth() - 2) << str.c_str();
341 os <<
tab <<
setw(charWidth()) << str.c_str();
351 writeCommented(
os, str);
358 const scalar timeValue =
361 ? fileObr_.time().timeOutputValue()
362 : fileObr_.time().value()
virtual OFstream & file()
Return access to the file (if only 1)
A class for handling file names.
virtual bool canWriteToFile() const
Flag to allow writing to the file.
static void writeHeader(Ostream &os, const word &fieldName)
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void writeBreak(Ostream &os) const
Write a break marker to the stream.
virtual void resetFile(const word &name)
Reset internal file pointer to new file with new name.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true)
Construct from objectRegistry, prefix, fileName.
Output to file stream, using an OSstream.
constexpr char nl
The newline '\n' character (0x0a)
OFstream Snull
Global predefined null output stream "/dev/null".
static unsigned int defaultPrecision() noexcept
Return the default precision.
static label addChars
Additional characters for writing.
constexpr char tab
The tab '\t' character(0x09)
virtual autoPtr< OFstream > newFile(const fileName &fName) const
Return autoPtr to a new file using file name.
const word & timeName() const noexcept
Return the current time name.
autoPtr< OFstream > filePtr_
File pointer.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
fileName filePath(const fileName &fName) const
Return the full path for the supplied file name.
virtual bool canResetFile() const
Flag to allow resetting the file.
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
bool good() const noexcept
True if the managed pointer is non-null.
virtual bool canWriteHeader() const
Flag to allow writing the header.
void initStream(Ostream &os) const
Initialise the output stream for writing.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
A class for handling words, derived from Foam::string.
static MinMax< T > ge(const T &minVal)
A semi-infinite range from minVal to the type max.
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
virtual bool writeToFile() const
Flag to allow writing to file.
fileName baseTimeDir() const
Return the base directory for the current time value.
virtual autoPtr< OFstream > newFileAtTime(const word &name, scalar timeValue) const
Return autoPtr to a new file for a given time.
virtual label charWidth() const
Return width of character stream output.
label writePrecision_
Write precision.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
virtual autoPtr< OFstream > newFileAtStartTime(const word &name) const
Return autoPtr to a new file using the simulation start time.
virtual bool read(const dictionary &dict)
Read.
virtual void writeCurrentTime(Ostream &os) const
Write the current time to stream.
bool writeToFile_
Flag to enable/disable writing to file.
fileName baseFileDir() const
Return the base directory for output.
An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Omanip< int > valueWidth(const label offset=0) const
Return the value width when writing to stream with optional offset.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static word outputPrefix
Directory prefix.
Omanip< int > setw(const int i)
Registry of regIOobjects.
Base class for writing single files from the function objects.
word fileName_
Name of file.
IOstream & scientific(IOstream &io)
An Ostream manipulator taking arguments.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.