Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
writeFile Class Reference

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

Inheritance diagram for writeFile:
Inheritance graph
[legend]
Collaboration diagram for writeFile:
Collaboration graph
[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)
 Construct from objectRegistry, prefix, fileName and read options from dictionary. More...
 
 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 canWriteToFile () const
 Flag to allow writing to the file. More...
 
virtual bool canResetFile () const
 Flag to allow resetting the 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...
 
template<class Type >
void writeValue (Ostream &os, const Type &val) const
 Write a given value to stream with the space delimiter. 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...
 
fileName filePath (const fileName &fName) const
 Return the full path for the supplied file name. More...
 
virtual autoPtr< OFstreamnewFile (const fileName &fName) const
 Return autoPtr to a new file using file name. More...
 
virtual autoPtr< OFstreamnewFileAtTime (const word &name, scalar timeValue) const
 Return autoPtr to a new file for a given time. More...
 
virtual autoPtr< OFstreamnewFileAtStartTime (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...
 
virtual autoPtr< OFstreamcreateFile (const word &name, scalar timeValue) const
 Deprecated(2022-09) Return autoPtr to a new file for a given time. More...
 
virtual autoPtr< OFstreamcreateFile (const word &name) const
 Deprecated(2022-09) Return autoPtr to a new file using the simulation start time. 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_
 Flag to update the header, e.g. on mesh changes. Default is true. More...
 
bool writtenHeader_
 Flag to identify whether the header has been written. More...
 
bool useUserTime_
 Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true. More...
 
scalar startTime_
 Start time value. More...
 

Detailed Description

Base class for writing single files from the function objects.

Usage
<dictName>
{
    // Inherited entries
    ...

    // Optional entries
    writePrecision    <int>;
    writeToFile       <bool>;
    useUserTime       <bool>;
    updateHeader      <bool>;
}

where the entries mean:

Property Description Type Reqd Deflt
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.
Source files

Definition at line 112 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 199 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 220 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 183 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 35 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 43 of file writeFile.C.

References meshPtr, and functionObject::outputPrefix.

Referenced by surfaceNoise::calculate().

Here is the caller graph for this function:

◆ baseTimeDir()

Foam::fileName baseTimeDir ( ) const
protected

Return the base directory for the current time value.

Definition at line 66 of file writeFile.C.

◆ filePath()

Foam::fileName filePath ( const fileName fName) const
protected

Return the full path for the supplied file name.

Definition at line 73 of file writeFile.C.

Referenced by surfaceNoise::calculate().

Here is the caller graph for this function:

◆ newFile()

Foam::autoPtr< Foam::OFstream > newFile ( const fileName fName) const
protectedvirtual

Return autoPtr to a new file using file name.

Note: no check for if the file already exists

Definition at line 82 of file writeFile.C.

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

Referenced by surfaceNoise::calculate().

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

◆ newFileAtTime()

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

Return autoPtr to a new file for a given time.

Definition at line 110 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 writeFile::createFile().

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

◆ newFileAtStartTime()

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

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

Definition at line 156 of file writeFile.C.

References Foam::name().

Referenced by writeFile::createFile(), logFiles::createFiles(), and binModel::read().

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

◆ resetFile()

void resetFile ( const word name)
protectedvirtual

Reset internal file pointer to new file with new name.

Definition at line 165 of file writeFile.C.

Referenced by logFiles::resetName(), and turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs().

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 173 of file writeFile.C.

References Foam::setw().

Here is the call graph for this function:

◆ operator=()

void operator= ( const writeFile )
protecteddelete

No copy assignment.

◆ createFile() [1/2]

virtual autoPtr<OFstream> createFile ( const word name,
scalar  timeValue 
) const
inlineprotectedvirtual

Deprecated(2022-09) Return autoPtr to a new file for a given time.

Deprecated:
(2022-09) - use newFileAtTime function

Definition at line 244 of file writeFile.H.

References Foam::name(), and writeFile::newFileAtTime().

Here is the call graph for this function:

◆ createFile() [2/2]

virtual autoPtr<OFstream> createFile ( const word name) const
inlineprotectedvirtual

Deprecated(2022-09) Return autoPtr to a new file using the simulation start time.

Deprecated:
(2022-09) - use newFileAtStartTime function

Definition at line 261 of file writeFile.H.

References Foam::name(), and writeFile::newFileAtStartTime().

Here is the call graph for this function:

◆ read()

bool read ( const dictionary dict)
virtual

Read.

Reimplemented in surfaceFieldValue, forceCoeffs, stabilityBlendingFactor, STDMD, forces, actuationDiskSource, propellerInfo, noiseModel, regionSizeDistribution, volFieldValue, extractEulerianParticles, effectivenessTable, fluxSummary, momentum, sizeDistribution, Curle, multiFieldValue, surfaceNoise, interfaceHeight, fieldMinMax, fieldExtents, reactionsSensitivityAnalysis< chemistryType >, particleDistribution, solverInfo, uniformBin, blendingFactor, fieldValue, referenceTemperature, continuityError, velocityDampingConstraint, wallShearStress, radialActuationDiskSource, singleDirectionUniformBin, AMIWeights, wallHeatFlux, binModel, yPlus, cloudInfo, DESModelRegions, valueAverage, heatExchangerModel, limitTemperature, valueAverageBase, DMDModel, energySpectrum, histogramModel, limitVelocity, timeInfo, sixDoFRigidBodyState, equalBinWidth, unequalBinWidth, pointNoise, and specieReactionRates< ChemistryModelType >.

Definition at line 241 of file writeFile.C.

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

Referenced by logFiles::logFiles(), timeInfo::read(), histogramModel::read(), energySpectrum::read(), valueAverageBase::read(), DESModelRegions::read(), yPlus::read(), cloudInfo::read(), binModel::read(), wallHeatFlux::read(), AMIWeights::read(), wallShearStress::read(), continuityError::read(), fieldValue::read(), blendingFactor::read(), particleDistribution::read(), fieldExtents::read(), fieldMinMax::read(), sizeDistribution::read(), momentum::read(), fluxSummary::read(), extractEulerianParticles::read(), noiseModel::read(), forces::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

◆ writeToFile()

bool writeToFile ( ) const
virtual

Flag to allow writing to file.

Definition at line 281 of file writeFile.C.

Referenced by uniformBin::processField().

Here is the caller graph for this function:

◆ canWriteToFile()

bool canWriteToFile ( ) const
virtual

Flag to allow writing to the file.

Definition at line 287 of file writeFile.C.

References UPstream::master().

Referenced by velocityDampingConstraint::addDamping(), and turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs().

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

◆ canResetFile()

bool canResetFile ( ) const
virtual

Flag to allow resetting the file.

Definition at line 293 of file writeFile.C.

References UPstream::master().

Referenced by turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs().

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

◆ canWriteHeader()

bool canWriteHeader ( ) const
virtual

Flag to allow writing the header.

Definition at line 299 of file writeFile.C.

References UPstream::master().

Referenced by turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs().

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

◆ charWidth()

Foam::label charWidth ( ) const
virtual

Return width of character stream output.

Definition at line 306 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

◆ writeTabbed()

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

◆ 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 349 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 362 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 26 of file writeFileTemplates.C.

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

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

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

◆ writeValue()

void writeValue ( Ostream os,
const Type &  val 
) const

Write a given value to stream with the space delimiter.

Definition at line 40 of file writeFileTemplates.C.

References Foam::component(), and os().

Here is the call graph for this function:

Member Data Documentation

◆ fileObr_

const objectRegistry& fileObr_
protected

Reference to the region objectRegistry.

Definition at line 121 of file writeFile.H.

Referenced by logFiles::createFiles(), and surfaceNoise::initialise().

◆ prefix_

const fileName prefix_
protected

Prefix.

Definition at line 126 of file writeFile.H.

◆ fileName_

word fileName_
protected

Name of file.

Definition at line 131 of file writeFile.H.

◆ filePtr_

autoPtr<OFstream> filePtr_
protected

File pointer.

Definition at line 136 of file writeFile.H.

◆ writePrecision_

label writePrecision_
protected

Write precision.

Definition at line 141 of file writeFile.H.

Referenced by writeFile::initStream().

◆ writeToFile_

bool writeToFile_
protected

Flag to enable/disable writing to file.

Definition at line 146 of file writeFile.H.

◆ updateHeader_

bool updateHeader_
protected

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

Definition at line 152 of file writeFile.H.

◆ writtenHeader_

bool writtenHeader_
protected

◆ useUserTime_

bool useUserTime_
protected

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

Definition at line 163 of file writeFile.H.

◆ startTime_

scalar startTime_
protected

Start time value.

Definition at line 168 of file writeFile.H.

◆ addChars

Foam::label addChars = 8
static

Additional characters for writing.

Definition at line 274 of file writeFile.H.


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