ENH: Refactored function objects to make use of new base class

This commit is contained in:
andy
2012-10-15 17:59:38 +01:00
parent d8321469e9
commit 72d49281ce
27 changed files with 225 additions and 612 deletions

View File

@ -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_);

View File

@ -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);