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