writeFile Class Reference

Base class for writing single files from the function objects. More...

Inheritance diagram for writeFile:
[legend]
Collaboration diagram for writeFile:
[legend]

Public Member Functions

 writeFile (const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true)
 Construct from objectRegistry, prefix, fileName. More...
 
 writeFile (const objectRegistry &obr, const fileName &prefix, const word &name, const dictionary &dict, const bool writeToFile=true)
 
 writeFile (const writeFile &wf)
 Construct copy. More...
 
virtual ~writeFile ()=default
 Destructor. More...
 
virtual bool read (const dictionary &dict)
 Read. More...
 
virtual OFstreamfile ()
 Return access to the file (if only 1) More...
 
virtual bool writeToFile () const
 Flag to allow writing to file. More...
 
virtual bool canWriteHeader () const
 Flag to allow writing the header. More...
 
virtual label charWidth () const
 Return width of character stream output. More...
 
virtual void writeCommented (Ostream &os, const string &str) const
 Write a commented string to stream. More...
 
virtual void writeTabbed (Ostream &os, const string &str) const
 Write a tabbed string to stream. More...
 
virtual void writeHeader (Ostream &os, const string &str) const
 Write a commented header to stream. More...
 
virtual void writeCurrentTime (Ostream &os) const
 Write the current time to stream. More...
 
virtual void writeBreak (Ostream &os) const
 Write a break marker to the stream. More...
 
template<class Type >
void writeHeaderValue (Ostream &os, const string &property, const Type &value) const
 Write a (commented) header property and value pair. More...
 

Static Public Attributes

static label addChars = 8
 Additional characters for writing. More...
 

Protected Member Functions

void initStream (Ostream &os) const
 Initialise the output stream for writing. More...
 
fileName baseFileDir () const
 Return the base directory for output. More...
 
fileName baseTimeDir () const
 Return the base directory for the current time value. More...
 
virtual autoPtr< OFstreamcreateFile (const word &name, scalar timeValue) const
 Return autoPtr to a new file for a given time. More...
 
virtual autoPtr< OFstreamcreateFile (const word &name) const
 Return autoPtr to a new file using the simulation start time. More...
 
virtual void resetFile (const word &name)
 Reset internal file pointer to new file with new name. More...
 
Omanip< int > valueWidth (const label offset=0) const
 Return the value width when writing to stream with optional offset. More...
 
void operator= (const writeFile &)=delete
 No copy assignment. More...
 

Protected Attributes

const objectRegistryfileObr_
 Reference to the region objectRegistry. More...
 
const fileName prefix_
 Prefix. More...
 
word fileName_
 Name of file. More...
 
autoPtr< OFstreamfilePtr_
 File pointer. More...
 
label writePrecision_
 Write precision. More...
 
bool writeToFile_
 Flag to enable/disable writing to file. More...
 
bool updateHeader_
 
bool writtenHeader_
 Flag to identify whether the header has been written. More...
 
bool useUserTime_
 
scalar startTime_
 Start time value. More...
 

Detailed Description

Base class for writing single files from the function objects.

Usage
<userDefinedSubDictName1>
{
    // Mandatory and other optional entries
    ...

    // Optional (inherited) entries (runtime modifiable)
    writePrecision    8;
    writeToFile       true;
    useUserTime       true;
}

where the entries mean:

Property Description Type Req'd Dflt
writePrecision Number of decimal points label no <system dflt>
writeToFile Flag to produce text file output bool no true
useUserTime Flag to use user time, e.g. degrees bool no true
See also
Source files

Definition at line 106 of file writeFile.H.

Constructor & Destructor Documentation

◆ writeFile() [1/3]

writeFile ( const objectRegistry obr,
const fileName prefix,
const word name = "undefined",
const bool  writeToFile = true 
)

Construct from objectRegistry, prefix, fileName.

Definition at line 172 of file writeFile.C.

◆ writeFile() [2/3]

writeFile ( const objectRegistry obr,
const fileName prefix,
const word name,
const dictionary dict,
const bool  writeToFile = true 
)

Construct from objectRegistry, prefix, fileName and read options from dictionary

Definition at line 193 of file writeFile.C.

References dict, and Foam::read().

Here is the call graph for this function:

◆ writeFile() [3/3]

writeFile ( const writeFile wf)

Construct copy.

Definition at line 156 of file writeFile.C.

◆ ~writeFile()

virtual ~writeFile ( )
virtualdefault

Destructor.

Member Function Documentation

◆ initStream()

void initStream ( Ostream os) const
protected

Initialise the output stream for writing.

Definition at line 42 of file writeFile.C.

References writeFile::charWidth(), Ostream::precision(), Foam::scientific(), IOstream::setf(), Ostream::width(), and writeFile::writePrecision_.

Referenced by logFiles::createFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ baseFileDir()

Foam::fileName baseFileDir ( ) const
protected

Return the base directory for output.

Definition at line 50 of file writeFile.C.

References fileName::clean(), polyMesh::defaultRegion, mesh, and functionObject::outputPrefix.

Here is the call graph for this function:

◆ baseTimeDir()

Foam::fileName baseTimeDir ( ) const
protected

Return the base directory for the current time value.

Definition at line 77 of file writeFile.C.

◆ createFile() [1/2]

Foam::autoPtr< Foam::OFstream > createFile ( const word name,
scalar  timeValue 
) const
protectedvirtual

Return autoPtr to a new file for a given time.

Definition at line 84 of file writeFile.C.

References Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, IOstream::good(), UPstream::master(), Foam::mkDir(), Foam::name(), autoPtr< T >::reset(), timeName, and Time::timeName().

Referenced by logFiles::createFiles(), and forceCoeffs::createFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFile() [2/2]

Foam::autoPtr< Foam::OFstream > createFile ( const word name) const
protectedvirtual

Return autoPtr to a new file using the simulation start time.

Definition at line 129 of file writeFile.C.

References Foam::name().

Here is the call graph for this function:

◆ resetFile()

void resetFile ( const word name)
protectedvirtual

Reset internal file pointer to new file with new name.

Definition at line 138 of file writeFile.C.

Referenced by logFiles::resetName().

Here is the caller graph for this function:

◆ valueWidth()

Foam::Omanip< int > valueWidth ( const label  offset = 0) const
protected

Return the value width when writing to stream with optional offset.

Definition at line 146 of file writeFile.C.

References Foam::setw().

Here is the call graph for this function:

◆ operator=()

void operator= ( const writeFile )
protecteddelete

No copy assignment.

◆ read()

bool read ( const dictionary dict)
virtual

Read.

Reimplemented in surfaceFieldValue, actuationDiskSource, volFieldValue, fluxSummary, sizeDistribution, fieldValue, radialActuationDiskSource, wallHeatFlux, timeInfo, cloudInfo, specieReactionRates< ChemistryModelType >, STDMD, stabilityBlendingFactor, regionSizeDistribution, forces, extractEulerianParticles, forceCoeffs, momentum, Curle, fieldMinMax, interfaceHeight, fieldValueDelta, fieldExtents, blendingFactor, particleDistribution, histogram, valueAverage, reactionsSensitivityAnalysis< chemistryType >, continuityError, wallShearStress, AMIWeights, DESModelRegions, solverInfo, yPlus, energySpectrum, and sixDoFRigidBodyState.

Definition at line 214 of file writeFile.C.

References IOstream::defaultPrecision(), dict, MinMax< T >::ge(), and UPstream::master().

Referenced by logFiles::logFiles(), cloudInfo::read(), timeInfo::read(), energySpectrum::read(), yPlus::read(), DESModelRegions::read(), AMIWeights::read(), wallHeatFlux::read(), fieldValue::read(), wallShearStress::read(), continuityError::read(), valueAverage::read(), histogram::read(), particleDistribution::read(), blendingFactor::read(), fieldExtents::read(), fieldMinMax::read(), sizeDistribution::read(), fluxSummary::read(), momentum::read(), extractEulerianParticles::read(), forces::read(), regionSizeDistribution::read(), and stabilityBlendingFactor::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file()

Foam::OFstream & file ( )
virtual

Return access to the file (if only 1)

Definition at line 237 of file writeFile.C.

References FatalErrorInFunction, and Foam::Snull.

Referenced by solverInfo::updateSolverInfo(), fieldValueDelta::write(), solverInfo::writeFileHeader(), and fieldMinMax::writeFileHeader().

Here is the caller graph for this function:

◆ writeToFile()

bool writeToFile ( ) const
virtual

Flag to allow writing to file.

Definition at line 254 of file writeFile.C.

Referenced by forceCoeffs::createFiles().

Here is the caller graph for this function:

◆ canWriteHeader()

bool canWriteHeader ( ) const
virtual

Flag to allow writing the header.

Definition at line 260 of file writeFile.C.

◆ charWidth()

Foam::label charWidth ( ) const
virtual

Return width of character stream output.

Definition at line 266 of file writeFile.C.

Referenced by writeFile::initStream().

Here is the caller graph for this function:

◆ writeCommented()

void writeCommented ( Ostream os,
const string str 
) const
virtual

Write a commented string to stream.

Definition at line 273 of file writeFile.C.

References Foam::setf(), and Foam::setw().

Referenced by cloudInfo::writeFileHeader(), timeInfo::writeFileHeader(), sixDoFRigidBodyState::writeFileHeader(), energySpectrum::writeFileHeader(), solverInfo::writeFileHeader(), DESModelRegions::writeFileHeader(), AMIWeights::writeFileHeader(), volRegion::writeFileHeader(), wallHeatFlux::writeFileHeader(), wallShearStress::writeFileHeader(), continuityError::writeFileHeader(), valueAverage::writeFileHeader(), fieldExtents::writeFileHeader(), blendingFactor::writeFileHeader(), and fieldMinMax::writeFileHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeTabbed()

void writeTabbed ( Ostream os,
const string str 
) const
virtual

Write a tabbed string to stream.

Definition at line 289 of file writeFile.C.

References Foam::setw(), and Foam::tab.

Referenced by cloudInfo::writeFileHeader(), timeInfo::writeFileHeader(), DESModelRegions::writeFileHeader(), AMIWeights::writeFileHeader(), wallHeatFlux::writeFileHeader(), wallShearStress::writeFileHeader(), valueAverage::writeFileHeader(), fieldExtents::writeFileHeader(), blendingFactor::writeFileHeader(), and fieldMinMax::writeFileHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeHeader()

void writeHeader ( Ostream os,
const string str 
) const
virtual

◆ writeCurrentTime()

void writeCurrentTime ( Ostream os) const
virtual

Write the current time to stream.

Definition at line 309 of file writeFile.C.

References Foam::setw(), and Time::timeName().

Referenced by fieldValueDelta::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeBreak()

void writeBreak ( Ostream os) const
virtual

Write a break marker to the stream.

Definition at line 322 of file writeFile.C.

References Foam::writeHeader().

Referenced by solverInfo::writeFileHeader(), fieldExtents::writeFileHeader(), and fieldMinMax::writeFileHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeHeaderValue()

void writeHeaderValue ( Ostream os,
const string property,
const Type &  value 
) const

Write a (commented) header property and value pair.

Definition at line 32 of file writeFileTemplates.C.

References Foam::nl, Foam::setf(), and Foam::setw().

Referenced by sixDoFRigidBodyState::writeFileHeader(), volRegion::writeFileHeader(), and fieldExtents::writeFileHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fileObr_

const objectRegistry& fileObr_
protected

Reference to the region objectRegistry.

Definition at line 113 of file writeFile.H.

Referenced by logFiles::createFiles().

◆ prefix_

const fileName prefix_
protected

Prefix.

Definition at line 116 of file writeFile.H.

◆ fileName_

word fileName_
protected

Name of file.

Definition at line 119 of file writeFile.H.

◆ filePtr_

autoPtr<OFstream> filePtr_
protected

File pointer.

Definition at line 122 of file writeFile.H.

◆ writePrecision_

label writePrecision_
protected

Write precision.

Definition at line 125 of file writeFile.H.

Referenced by writeFile::initStream().

◆ writeToFile_

bool writeToFile_
protected

Flag to enable/disable writing to file.

Definition at line 128 of file writeFile.H.

◆ updateHeader_

bool updateHeader_
protected

Flag to update the header, e.g. on mesh changes. Default is true.

Definition at line 132 of file writeFile.H.

◆ writtenHeader_

bool writtenHeader_
protected

Flag to identify whether the header has been written.

Definition at line 135 of file writeFile.H.

Referenced by solverInfo::writeFileHeader(), fieldExtents::writeFileHeader(), and fieldMinMax::writeFileHeader().

◆ useUserTime_

bool useUserTime_
protected

Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true

Definition at line 139 of file writeFile.H.

◆ startTime_

scalar startTime_
protected

Start time value.

Definition at line 142 of file writeFile.H.

◆ addChars

Foam::label addChars = 8
static

Additional characters for writing.

Definition at line 183 of file writeFile.H.


The documentation for this class was generated from the following files: