mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Refactored function objects to make use of new base class
This commit is contained in:
@ -34,53 +34,9 @@ defineTypeNameAndDebug(Foam::cloudInfo, 0);
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::cloudInfo::makeFiles()
|
||||
void Foam::cloudInfo::writeFileHeader(const label i)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating cloudInfo output files." << endl;
|
||||
}
|
||||
|
||||
outputFilePtr_.clear();
|
||||
outputFilePtr_.setSize(cloudSet_.size());
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
label i = 0;
|
||||
forAllConstIter(wordHashSet, cloudSet_, iter)
|
||||
{
|
||||
const word& cloudName = iter.key();
|
||||
fileName cloudInfoDir(obr_.time().path());
|
||||
word timeName = Foam::name(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
cloudInfoDir = cloudInfoDir/".."/name_/timeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
cloudInfoDir = cloudInfoDir/name_/timeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(cloudInfoDir);
|
||||
|
||||
// Open new files at start up
|
||||
outputFilePtr_.set
|
||||
(
|
||||
i,
|
||||
new OFstream(cloudInfoDir/(cloudName + ".dat"))
|
||||
);
|
||||
|
||||
// Add headers
|
||||
outputFilePtr_[i]
|
||||
<< "# Time" << tab << "nParcels" << tab << "mass" << endl;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
file(i) << "# Time" << tab << "nParcels" << tab << "mass" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -94,11 +50,10 @@ Foam::cloudInfo::cloudInfo
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
cloudSet_(),
|
||||
outputFilePtr_()
|
||||
active_(true)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -116,19 +71,17 @@ void Foam::cloudInfo::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
cloudSet_.insert(wordList(dict.lookup("clouds")));
|
||||
functionObjectFile::resetNames(dict.lookup("clouds"));
|
||||
|
||||
Info<< type() << ": ";
|
||||
if (cloudSet_.size())
|
||||
if (names_.size())
|
||||
{
|
||||
Info<< "applying to clouds:" << nl;
|
||||
forAllConstIter(wordHashSet, cloudSet_, iter)
|
||||
forAllConstIter(wordHashSet, names_, iter)
|
||||
{
|
||||
Info<< " " << iter.key() << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
makeFiles();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -154,8 +107,10 @@ void Foam::cloudInfo::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(wordHashSet, cloudSet_, iter)
|
||||
forAllConstIter(wordHashSet, names_, iter)
|
||||
{
|
||||
const word& cloudName = iter.key();
|
||||
|
||||
@ -168,7 +123,7 @@ void Foam::cloudInfo::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_[i]
|
||||
file(i)
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< nParcels << token::TAB
|
||||
<< massInSystem << endl;
|
||||
|
||||
@ -72,7 +72,7 @@ SourceFiles
|
||||
#ifndef cloudInfo_H
|
||||
#define cloudInfo_H
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "functionObjectFile.H"
|
||||
#include "PtrList.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "volFields.H"
|
||||
@ -93,6 +93,8 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cloudInfo
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -101,22 +103,17 @@ protected:
|
||||
//- Name of this set of cloudInfo object
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Clouds to process
|
||||
wordHashSet cloudSet_;
|
||||
|
||||
//- Output file pointers
|
||||
PtrList<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- If the output file has not been created create it
|
||||
void makeFiles();
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
cloudInfo(const cloudInfo&);
|
||||
|
||||
@ -62,14 +62,13 @@ Foam::fieldMinMax::fieldMinMax
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
write_(true),
|
||||
log_(false),
|
||||
mode_(mdMag),
|
||||
fieldSet_(),
|
||||
fieldMinMaxFilePtr_(NULL)
|
||||
fieldSet_()
|
||||
{
|
||||
// Check if the available mesh is an fvMesh otherise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -99,7 +98,6 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
write_ = dict.lookupOrDefault<Switch>("write", true);
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
@ -108,72 +106,25 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::makeFile()
|
||||
void Foam::fieldMinMax::writeFileHeader(const label i)
|
||||
{
|
||||
// Create the fieldMinMax file if not already created
|
||||
if (fieldMinMaxFilePtr_.empty())
|
||||
file()
|
||||
<< "# Time" << token::TAB << "field" << token::TAB
|
||||
<< "min" << token::TAB << "position(min)";
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating fieldMinMax file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName fieldMinMaxDir;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
fieldMinMaxDir =
|
||||
obr_.time().path()/".."/name_/obr_.time().timeName();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldMinMaxDir =
|
||||
obr_.time().path()/name_/obr_.time().timeName();
|
||||
}
|
||||
|
||||
// Create directory if does not exist.
|
||||
mkDir(fieldMinMaxDir);
|
||||
|
||||
// Open new file at start up
|
||||
fieldMinMaxFilePtr_.reset
|
||||
(
|
||||
new OFstream(fieldMinMaxDir/(type() + ".dat"))
|
||||
);
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
file() << token::TAB << "proc";
|
||||
}
|
||||
}
|
||||
|
||||
file() << token::TAB << "max" << token::TAB << "position(max)";
|
||||
|
||||
void Foam::fieldMinMax::writeFileHeader()
|
||||
{
|
||||
if (fieldMinMaxFilePtr_.valid())
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_()
|
||||
<< "# Time" << token::TAB << "field" << token::TAB
|
||||
<< "min" << token::TAB << "position(min)";
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << "proc";
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_()
|
||||
<< token::TAB << "max" << token::TAB << "position(max)";
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << "proc";
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_() << endl;
|
||||
file() << token::TAB << "proc";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -193,11 +144,7 @@ void Foam::fieldMinMax::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
// Create the fieldMinMax file if not already created
|
||||
if (write_)
|
||||
{
|
||||
makeFile();
|
||||
}
|
||||
functionObjectFile::write();
|
||||
|
||||
if (log_)
|
||||
{
|
||||
|
||||
@ -76,6 +76,7 @@ SourceFiles
|
||||
#ifndef fieldMinMax_H
|
||||
#define fieldMinMax_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
@ -99,6 +100,8 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldMinMax
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
public:
|
||||
|
||||
@ -115,8 +118,8 @@ protected:
|
||||
//- Mode type names
|
||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||
|
||||
//- Name of this set of field min/max.
|
||||
// Also used as the name of the output directory.
|
||||
//- Name of this set of field min/max
|
||||
// Also used as the name of the output directory
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
@ -124,9 +127,6 @@ protected:
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to enable/disable writing to file
|
||||
Switch write_;
|
||||
|
||||
//- Switch to send output to Info as well
|
||||
Switch log_;
|
||||
|
||||
@ -136,15 +136,9 @@ protected:
|
||||
//- Fields to assess min/max
|
||||
wordList fieldSet_;
|
||||
|
||||
//- Min/max file ptr
|
||||
autoPtr<OFstream> fieldMinMaxFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- If the output file has not been created create it
|
||||
void makeFile();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&);
|
||||
|
||||
@ -152,7 +146,7 @@ protected:
|
||||
void operator=(const fieldMinMax&);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader();
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -83,29 +83,25 @@ void Foam::fieldMinMax::calcMinMaxFields
|
||||
scalar maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
if (write_)
|
||||
file()
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< fieldName << token::TAB
|
||||
<< minValue << token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_()
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< fieldName << token::TAB
|
||||
<< minValue << token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << minI;
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_()
|
||||
<< token::TAB << maxValue << token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << maxI;
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_() << endl;
|
||||
file() << token::TAB << minI;
|
||||
}
|
||||
|
||||
file() << token::TAB << maxValue << token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file() << token::TAB << maxI;
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " min(mag(" << fieldName << ")) = "
|
||||
@ -163,29 +159,25 @@ void Foam::fieldMinMax::calcMinMaxFields
|
||||
Type maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
if (write_)
|
||||
file()
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< fieldName << token::TAB
|
||||
<< minValue << token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_()
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< fieldName << token::TAB
|
||||
<< minValue << token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << minI;
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_()
|
||||
<< token::TAB << maxValue << token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
fieldMinMaxFilePtr_() << token::TAB << maxI;
|
||||
}
|
||||
|
||||
fieldMinMaxFilePtr_() << endl;
|
||||
file() << token::TAB << minI;
|
||||
}
|
||||
|
||||
file() << token::TAB << maxValue << token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file() << token::TAB << maxI;
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " min(" << fieldName << ") = "
|
||||
|
||||
@ -153,24 +153,21 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::cellSource::writeFileHeader()
|
||||
void Foam::fieldValues::cellSource::writeFileHeader(const label i)
|
||||
{
|
||||
if (outputFilePtr_.valid())
|
||||
file()
|
||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
||||
<< sourceName_ << nl << "# Cells : " << nCells_ << nl
|
||||
<< "# Time" << tab << "sum(V)";
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
outputFilePtr_()
|
||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
||||
<< sourceName_ << nl << "# Cells : " << nCells_ << nl
|
||||
<< "# Time" << tab << "sum(V)";
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
outputFilePtr_()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
outputFilePtr_() << endl;
|
||||
file()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +181,7 @@ Foam::fieldValues::cellSource::cellSource
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, loadFromFiles),
|
||||
fieldValue(name, obr, dict, typeName, loadFromFiles),
|
||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
nCells_(0),
|
||||
@ -223,7 +220,7 @@ void Foam::fieldValues::cellSource::write()
|
||||
scalar totalVolume = gSum(filterField(mesh().V()));
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << tab << totalVolume;
|
||||
file() << obr_.time().value() << tab << totalVolume;
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
@ -237,7 +234,7 @@ void Foam::fieldValues::cellSource::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_()<< endl;
|
||||
file()<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
|
||||
@ -214,7 +214,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader();
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -195,7 +195,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
}
|
||||
|
||||
|
||||
outputFilePtr_()<< tab << result;
|
||||
file()<< tab << result;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
|
||||
@ -472,24 +472,21 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::writeFileHeader()
|
||||
void Foam::fieldValues::faceSource::writeFileHeader(const label i)
|
||||
{
|
||||
if (outputFilePtr_.valid())
|
||||
file()
|
||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
||||
<< sourceName_ << nl << "# Faces : " << nFaces_ << nl
|
||||
<< "# Time" << tab << "sum(magSf)";
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
outputFilePtr_()
|
||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
||||
<< sourceName_ << nl << "# Faces : " << nFaces_ << nl
|
||||
<< "# Time" << tab << "sum(magSf)";
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
outputFilePtr_()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
outputFilePtr_() << endl;
|
||||
file()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -532,7 +529,7 @@ Foam::fieldValues::faceSource::faceSource
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, loadFromFiles),
|
||||
fieldValue(name, obr, dict, typeName, loadFromFiles),
|
||||
surfaceWriterPtr_(NULL),
|
||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
@ -586,7 +583,7 @@ void Foam::fieldValues::faceSource::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << tab << totalArea;
|
||||
file() << obr_.time().value() << tab << totalArea;
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
@ -600,7 +597,7 @@ void Foam::fieldValues::faceSource::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_()<< endl;
|
||||
file()<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
|
||||
@ -296,7 +296,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader();
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -269,19 +269,8 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
|
||||
combineMeshGeometry(faces, points);
|
||||
}
|
||||
|
||||
fileName outputDir;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir = obr_.time().path()/".."/name_;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_;
|
||||
}
|
||||
|
||||
outputDir = outputDir/"surface"/obr_.time().timeName();
|
||||
fileName outputDir =
|
||||
baseFileDir()/name_/"surface"/obr_.time().timeName();
|
||||
|
||||
surfaceWriterPtr_->write
|
||||
(
|
||||
@ -302,7 +291,7 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
|
||||
{
|
||||
Type result = processValues(values, Sf, weightField);
|
||||
|
||||
outputFilePtr_()<< tab << result;
|
||||
file()<< tab << result;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
|
||||
@ -49,48 +49,6 @@ void Foam::fieldValue::movePoints(const Field<point>&)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::makeFile()
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
@ -106,12 +64,12 @@ void Foam::fieldValue::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,17 +81,18 @@ Foam::fieldValue::fieldValue
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const word& valueType,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, valueType),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
||||
fields_(dict.lookup("fields")),
|
||||
valueOutput_(dict.lookup("valueOutput")),
|
||||
outputFilePtr_(NULL)
|
||||
valueOutput_(dict.lookup("valueOutput"))
|
||||
{
|
||||
// Only active if obr is an fvMesh
|
||||
if (isA<fvMesh>(obr_))
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#ifndef fieldValue_H
|
||||
#define fieldValue_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "Switch.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "OFstream.H"
|
||||
@ -58,6 +59,8 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldValue
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
|
||||
protected:
|
||||
@ -85,18 +88,9 @@ protected:
|
||||
//- Output field values flag
|
||||
Switch valueOutput_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Functions to be over-ridden from IOoutputFilter class
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
|
||||
//- Write the output file header
|
||||
virtual void writeFileHeader() = 0;
|
||||
|
||||
//- Update mesh
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
@ -116,6 +110,7 @@ public:
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const word& valueType,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
@ -69,26 +69,19 @@ void Foam::regionSizeDistribution::writeGraph
|
||||
|
||||
const wordList valNames(1, valueName);
|
||||
|
||||
fileName outputPath;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
outputPath = mesh.time().path()/".."/name_;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPath = mesh.time().path()/name_;
|
||||
}
|
||||
fileName outputPath = baseFileDir()/name_;
|
||||
|
||||
if (mesh.name() != fvMesh::defaultRegion)
|
||||
{
|
||||
outputPath = outputPath/mesh.name();
|
||||
}
|
||||
|
||||
mkDir(outputPath/mesh.time().timeName());
|
||||
outputPath = outputPath/mesh.time().timeName();
|
||||
|
||||
mkDir(outputPath);
|
||||
OFstream str
|
||||
(
|
||||
outputPath
|
||||
/ mesh.time().timeName()
|
||||
/ formatterPtr_().getFileName(coords, valNames)
|
||||
);
|
||||
Info<< "Writing distribution of " << valueName << " to " << str.name()
|
||||
@ -341,6 +334,7 @@ Foam::regionSizeDistribution::regionSizeDistribution
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
|
||||
@ -98,6 +98,7 @@ SourceFiles
|
||||
#ifndef regionSizeDistribution_H
|
||||
#define regionSizeDistribution_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "writer.H"
|
||||
#include "Map.H"
|
||||
@ -121,6 +122,8 @@ class polyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionSizeDistribution
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
|
||||
|
||||
@ -85,14 +85,11 @@ void Foam::forceCoeffs::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeFileHeader()
|
||||
void Foam::forceCoeffs::writeFileHeader(const label i)
|
||||
{
|
||||
if (forcesFilePtr_.valid())
|
||||
{
|
||||
forcesFilePtr_()
|
||||
<< "# Time" << tab << "Cm" << tab << "Cd" << tab << "Cl" << tab
|
||||
<< "Cl(f)" << "Cl(r)" << endl;
|
||||
}
|
||||
file()
|
||||
<< "# Time" << tab << "Cm" << tab << "Cd" << tab << "Cl" << tab
|
||||
<< "Cl(f)" << "Cl(r)" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -112,12 +109,12 @@ void Foam::forceCoeffs::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
// Create the forces file if not already created
|
||||
makeFile();
|
||||
forces::calcForcesMoment();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
||||
|
||||
Field<vector> totForce(force_[0] + force_[1]);
|
||||
@ -140,7 +137,7 @@ void Foam::forceCoeffs::write()
|
||||
scalar Clf = Cl/2.0 - Cm;
|
||||
scalar Clr = Cl/2.0 + Cm;
|
||||
|
||||
forcesFilePtr_()
|
||||
file()
|
||||
<< obr_.time().value() << tab
|
||||
<< Cm << tab << Cd << tab << Cl << tab << Clf << tab << Clr
|
||||
<< endl;
|
||||
|
||||
@ -146,7 +146,7 @@ class forceCoeffs
|
||||
protected:
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader();
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -45,74 +45,21 @@ defineTypeNameAndDebug(Foam::forces, 0);
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::forces::baseFileDir() const
|
||||
void Foam::forces::writeFileHeader(const label i)
|
||||
{
|
||||
fileName baseDir;
|
||||
file()
|
||||
<< "# Time" << tab
|
||||
<< "forces(pressure, viscous) moment(pressure, viscous)";
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (localSystem_)
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
baseDir = obr_.time().path()/".."/name_;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseDir = obr_.time().path()/name_;
|
||||
file()
|
||||
<< tab
|
||||
<< "local forces(pressure, viscous) "
|
||||
<< "local moment(pressure, viscous)";
|
||||
}
|
||||
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
|
||||
void Foam::forces::makeFile()
|
||||
{
|
||||
// Create the forces file if not already created
|
||||
if (forcesFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating forces file" << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
fileName forcesDir = baseFileDir()/startTimeName;
|
||||
|
||||
// Create directory if does not exist.
|
||||
mkDir(forcesDir);
|
||||
|
||||
// Open new file at start up
|
||||
forcesFilePtr_.reset(new OFstream(forcesDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forces::writeFileHeader()
|
||||
{
|
||||
if (forcesFilePtr_.valid())
|
||||
{
|
||||
forcesFilePtr_()
|
||||
<< "# Time" << tab
|
||||
<< "forces(pressure, viscous) moment(pressure, viscous)";
|
||||
|
||||
if (localSystem_)
|
||||
{
|
||||
forcesFilePtr_()
|
||||
<< tab
|
||||
<< "local forces(pressure, viscous) "
|
||||
<< "local moment(pressure, viscous)";
|
||||
}
|
||||
|
||||
forcesFilePtr_()<< endl;
|
||||
}
|
||||
file()<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -281,13 +228,12 @@ void Foam::forces::writeBins() const
|
||||
autoPtr<writer<vector> > binWriterPtr(writer<vector>::New(binFormat_));
|
||||
coordSet axis("forces", "distance", binPoints_, mag(binPoints_));
|
||||
|
||||
fileName forcesDir = baseFileDir()/"bins"/obr_.time().timeName();
|
||||
fileName forcesDir = baseFileDir()/name_/"bins"/obr_.time().timeName();
|
||||
mkDir(forcesDir);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Writing bins to " << forcesDir << endl;
|
||||
|
||||
}
|
||||
|
||||
wordList fieldNames(IStringStream("(pressure viscous)")());
|
||||
@ -327,6 +273,7 @@ Foam::forces::forces
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
@ -348,8 +295,7 @@ Foam::forces::forces
|
||||
binDx_(0.0),
|
||||
binMin_(GREAT),
|
||||
binPoints_(),
|
||||
binFormat_("undefined"),
|
||||
forcesFilePtr_(NULL)
|
||||
binFormat_("undefined")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh otherise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -385,6 +331,7 @@ Foam::forces::forces
|
||||
const coordinateSystem& coordSys
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
@ -406,8 +353,7 @@ Foam::forces::forces
|
||||
binDx_(0.0),
|
||||
binMin_(GREAT),
|
||||
binPoints_(),
|
||||
binFormat_("undefined"),
|
||||
forcesFilePtr_(NULL)
|
||||
binFormat_("undefined")
|
||||
{}
|
||||
|
||||
|
||||
@ -592,13 +538,12 @@ void Foam::forces::write()
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the forces file if not already created
|
||||
makeFile();
|
||||
|
||||
calcForcesMoment();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " output:" << nl
|
||||
@ -609,7 +554,7 @@ void Foam::forces::write()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
forcesFilePtr_() << obr_.time().value() << tab
|
||||
file() << obr_.time().value() << tab
|
||||
<< "(" << sum(force_[0]) << "," << sum(force_[1]) << ") "
|
||||
<< "(" << sum(moment_[0]) << "," << sum(moment_[1]) << ")"
|
||||
<< endl;
|
||||
@ -621,7 +566,7 @@ void Foam::forces::write()
|
||||
vectorField localMomentP(coordSys_.localVector(moment_[0]));
|
||||
vectorField localMomentV(coordSys_.localVector(moment_[1]));
|
||||
|
||||
forcesFilePtr_() << obr_.time().value() << tab
|
||||
file() << obr_.time().value() << tab
|
||||
<< "(" << sum(localForceP) << "," << sum(localForceV) << ") "
|
||||
<< "(" << sum(localMomentP) << "," << sum(localMomentV) << ")"
|
||||
<< endl;
|
||||
@ -633,8 +578,6 @@ void Foam::forces::write()
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
forcesFilePtr_() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +103,7 @@ SourceFiles
|
||||
#ifndef forces_H
|
||||
#define forces_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "coordinateSystems.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
@ -129,6 +130,8 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class forces
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -207,20 +210,10 @@ protected:
|
||||
word binFormat_;
|
||||
|
||||
|
||||
//- Forces/moment file ptr
|
||||
autoPtr<OFstream> forcesFilePtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the base file directory for output
|
||||
fileName baseFileDir() const;
|
||||
|
||||
//- If the forces file has not been created create it
|
||||
void makeFile();
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader();
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Return the effective viscous stress (laminar + turbulent).
|
||||
tmp<volSymmTensorField> devRhoReff() const;
|
||||
|
||||
@ -35,49 +35,13 @@ License
|
||||
defineTypeNameAndDebug(Foam::DESModelRegions, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::DESModelRegions::makeFile()
|
||||
void Foam::DESModelRegions::writeFileHeader(const label i)
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# DES model region coverage (% volume)" << nl
|
||||
<< "# time " << token::TAB << "LES" << token::TAB << "RAS"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
file() << "# DES model region coverage (% volume)" << nl
|
||||
<< "# time " << token::TAB << "LES" << token::TAB << "RAS"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -91,11 +55,11 @@ Foam::DESModelRegions::DESModelRegions
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
outputFilePtr_(NULL)
|
||||
log_(false)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -114,8 +78,6 @@ Foam::DESModelRegions::DESModelRegions
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -159,6 +121,8 @@ void Foam::DESModelRegions::write()
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
if (log_)
|
||||
@ -203,7 +167,7 @@ void Foam::DESModelRegions::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().timeName() << token::TAB
|
||||
file() << obr_.time().timeName() << token::TAB
|
||||
<< prc << token::TAB << 100.0 - prc << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ SourceFiles
|
||||
#ifndef DESModelRegions_H
|
||||
#define DESModelRegions_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Switch.H"
|
||||
@ -64,8 +65,12 @@ class fvMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class DESModelRegions
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of DESModelRegions object
|
||||
word name_;
|
||||
@ -78,14 +83,11 @@ class DESModelRegions
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
DESModelRegions(const DESModelRegions&);
|
||||
|
||||
@ -35,49 +35,14 @@ License
|
||||
defineTypeNameAndDebug(Foam::wallShearStress, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::wallShearStress::makeFile()
|
||||
void Foam::wallShearStress::writeFileHeader(const label i)
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# Wall shear stress" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << endl;
|
||||
}
|
||||
}
|
||||
// Add headers to output data
|
||||
file() << "# Wall shear stress" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +69,7 @@ void Foam::wallShearStress::calcShearStress
|
||||
vector minSsp = min(ssp);
|
||||
vector maxSsp = max(ssp);
|
||||
|
||||
outputFilePtr_() << mesh.time().timeName() << token::TAB
|
||||
file() << mesh.time().timeName() << token::TAB
|
||||
<< pp.name() << token::TAB << minSsp
|
||||
<< token::TAB << maxSsp << endl;
|
||||
|
||||
@ -128,12 +93,12 @@ Foam::wallShearStress::wallShearStress
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
phiName_("phi"),
|
||||
outputFilePtr_(NULL)
|
||||
phiName_("phi")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -152,8 +117,6 @@ Foam::wallShearStress::wallShearStress
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -195,6 +158,8 @@ void Foam::wallShearStress::write()
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField wallShearStress
|
||||
|
||||
@ -54,6 +54,7 @@ SourceFiles
|
||||
#ifndef wallShearStress_H
|
||||
#define wallShearStress_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Switch.H"
|
||||
@ -75,8 +76,12 @@ class fvMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallShearStress
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of wallShearStress object
|
||||
word name_;
|
||||
@ -92,14 +97,11 @@ class wallShearStress
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate the shear stress
|
||||
void calcShearStress
|
||||
|
||||
@ -39,48 +39,12 @@ defineTypeNameAndDebug(Foam::yPlusLES, 0);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusLES::makeFile()
|
||||
void Foam::yPlusLES::writeFileHeader(const label i)
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# y+ (LES)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
file() << "# y+ (LES)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +97,7 @@ void Foam::yPlusLES::calcIncompressibleYPlus
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
file() << obr_.time().value() << token::TAB
|
||||
<< currPatch.name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
@ -199,7 +163,7 @@ void Foam::yPlusLES::calcCompressibleYPlus
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
file() << obr_.time().value() << token::TAB
|
||||
<< currPatch.name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
@ -224,13 +188,13 @@ Foam::yPlusLES::yPlusLES
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
phiName_("phi"),
|
||||
UName_("U"),
|
||||
outputFilePtr_(NULL)
|
||||
UName_("U")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -248,8 +212,6 @@ Foam::yPlusLES::yPlusLES
|
||||
) << "No fvMesh available, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
|
||||
|
||||
@ -287,6 +249,8 @@ void Foam::yPlusLES::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ SourceFiles
|
||||
#ifndef yPlusLES_H
|
||||
#define yPlusLES_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Switch.H"
|
||||
@ -61,6 +62,8 @@ class fvMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusLES
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -81,14 +84,11 @@ class yPlusLES
|
||||
//- Name of velocity field
|
||||
word UName_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus
|
||||
|
||||
@ -41,48 +41,12 @@ defineTypeNameAndDebug(Foam::yPlusRAS, 0);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusRAS::makeFile()
|
||||
void Foam::yPlusRAS::writeFileHeader(const label i)
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# y+ (RAS)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
file() << "# y+ (RAS)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +92,7 @@ void Foam::yPlusRAS::calcIncompressibleYPlus
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
file() << obr_.time().value() << token::TAB
|
||||
<< nutPw.patch().name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
@ -186,7 +150,7 @@ void Foam::yPlusRAS::calcCompressibleYPlus
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
file() << obr_.time().value() << token::TAB
|
||||
<< mutPw.patch().name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
@ -212,12 +176,12 @@ Foam::yPlusRAS::yPlusRAS
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
phiName_("phi"),
|
||||
outputFilePtr_(NULL)
|
||||
phiName_("phi")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -235,8 +199,6 @@ Foam::yPlusRAS::yPlusRAS
|
||||
) << "No fvMesh available, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
|
||||
|
||||
@ -274,6 +236,8 @@ void Foam::yPlusRAS::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ SourceFiles
|
||||
#ifndef yPlusRAS_H
|
||||
#define yPlusRAS_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Switch.H"
|
||||
@ -61,6 +62,8 @@ class fvMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusRAS
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -78,14 +81,11 @@ class yPlusRAS
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus);
|
||||
|
||||
Reference in New Issue
Block a user