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 Reqd Dflt
writePrecision Number of decimal points int no <system dflt>
writeToFile Produce text file output? bool no true
useUserTime Use user time (e.g. degrees)? bool no true
updateHeader Update header on mesh changes? bool no true
Note
The file header is normally updated whenver the mesh points or topology changes. In some cases, the function object is actually unaffected by these changes. Use the updateHeader flag to override the default behaviour.
See also
Source files

Definition at line 119 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 171 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 192 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 155 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(), os(), Foam::scientific(), 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 polyMesh::defaultRegion, mesh, and functionObject::outputPrefix.

◆ baseTimeDir()

Foam::fileName baseTimeDir ( ) const
protected

Return the base directory for the current time value.

Definition at line 76 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 83 of file writeFile.C.

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

Referenced by logFiles::createFiles(), forces::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 128 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 137 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 145 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 DMDModel, surfaceFieldValue, STDMD, actuationDiskSource, volFieldValue, fluxSummary, sizeDistribution, multiFieldValue, radialActuationDiskSource, fieldValue, wallHeatFlux, timeInfo, cloudInfo, specieReactionRates< ChemistryModelType >, stabilityBlendingFactor, propellerInfo, regionSizeDistribution, forces, extractEulerianParticles, forceCoeffs, momentum, Curle, fieldMinMax, interfaceHeight, fieldExtents, blendingFactor, particleDistribution, histogram, valueAverage, solverInfo, reactionsSensitivityAnalysis< chemistryType >, continuityError, wallShearStress, AMIWeights, yPlus, DESModelRegions, energySpectrum, and sixDoFRigidBodyState.

Definition at line 213 of file writeFile.C.

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

Referenced by logFiles::logFiles(), cloudInfo::read(), timeInfo::read(), energySpectrum::read(), DESModelRegions::read(), yPlus::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(), momentum::read(), fluxSummary::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 236 of file writeFile.C.

References FatalErrorInFunction, and Foam::Snull.

Referenced by solverInfo::updateSolverInfo(), multiFieldValue::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 253 of file writeFile.C.

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

Here is the caller graph for this function:

◆ canWriteHeader()

bool canWriteHeader ( ) const
virtual

Flag to allow writing the header.

Definition at line 259 of file writeFile.C.

◆ charWidth()

Foam::label charWidth ( ) const
virtual

Return width of character stream output.

Definition at line 265 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 272 of file writeFile.C.

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

Referenced by cloudInfo::writeFileHeader(), timeInfo::writeFileHeader(), sixDoFRigidBodyState::writeFileHeader(), energySpectrum::writeFileHeader(), DESModelRegions::writeFileHeader(), AMIWeights::writeFileHeader(), volRegion::writeFileHeader(), wallHeatFlux::writeFileHeader(), wallShearStress::writeFileHeader(), solverInfo::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 288 of file writeFile.C.

References os(), 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

Write a commented header to stream.

Definition at line 298 of file writeFile.C.

References Foam::nl, and os().

Referenced by cloudInfo::writeFileHeader(), sixDoFRigidBodyState::writeFileHeader(), energySpectrum::writeFileHeader(), DESModelRegions::writeFileHeader(), AMIWeights::writeFileHeader(), wallHeatFlux::writeFileHeader(), wallShearStress::writeFileHeader(), solverInfo::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:

◆ writeCurrentTime()

void writeCurrentTime ( Ostream os) const
virtual

Write the current time to stream.

Definition at line 308 of file writeFile.C.

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

Referenced by multiFieldValue::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 321 of file writeFile.C.

References os(), and 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, os(), 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 126 of file writeFile.H.

Referenced by logFiles::createFiles().

◆ prefix_

const fileName prefix_
protected

Prefix.

Definition at line 129 of file writeFile.H.

◆ fileName_

word fileName_
protected

Name of file.

Definition at line 132 of file writeFile.H.

◆ filePtr_

autoPtr<OFstream> filePtr_
protected

File pointer.

Definition at line 135 of file writeFile.H.

◆ writePrecision_

label writePrecision_
protected

Write precision.

Definition at line 138 of file writeFile.H.

Referenced by writeFile::initStream().

◆ writeToFile_

bool writeToFile_
protected

Flag to enable/disable writing to file.

Definition at line 141 of file writeFile.H.

◆ updateHeader_

bool updateHeader_
protected

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

Definition at line 145 of file writeFile.H.

◆ writtenHeader_

bool writtenHeader_
protected

Flag to identify whether the header has been written.

Definition at line 148 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 152 of file writeFile.H.

◆ startTime_

scalar startTime_
protected

Start time value.

Definition at line 155 of file writeFile.H.

◆ addChars

Foam::label addChars = 8
static

Additional characters for writing.

Definition at line 196 of file writeFile.H.


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