ENH: Updated cloud function objects

This commit is contained in:
andy
2013-12-09 09:37:34 +00:00
parent 574b68c3ea
commit 1f524ef51b
18 changed files with 167 additions and 118 deletions

View File

@ -39,7 +39,8 @@ void Foam::CloudFunctionObject<CloudType>::write()
template<class CloudType>
Foam::CloudFunctionObject<CloudType>::CloudFunctionObject(CloudType& owner)
:
SubModelBase<CloudType>(owner)
CloudSubModelBase<CloudType>(owner),
outputDir_()
{}
@ -48,11 +49,28 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
(
const dictionary& dict,
CloudType& owner,
const word& type
const word& modelName,
const word& objectType
)
:
SubModelBase<CloudType>(owner, dict, typeName, type, "")
{}
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, objectType),
outputDir_(owner.mesh().time().path())
{
const fileName relPath =
"postProcessing"/cloud::prefix/owner.name()/this->modelName();
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir_ = outputDir_/".."/relPath;
}
else
{
outputDir_ = outputDir_/relPath;
}
}
template<class CloudType>
@ -61,7 +79,7 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
const CloudFunctionObject<CloudType>& ppm
)
:
SubModelBase<CloudType>(ppm)
CloudSubModelBase<CloudType>(ppm)
{}
@ -131,6 +149,13 @@ void Foam::CloudFunctionObject<CloudType>::postFace
}
template<class CloudType>
const Foam::fileName& Foam::CloudFunctionObject<CloudType>::outputDir() const
{
return outputDir_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CloudFunctionObjectNew.C"

View File

@ -39,7 +39,7 @@ SourceFiles
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "SubModelBase.H"
#include "CloudSubModelBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,9 +56,15 @@ class tetIndices;
template<class CloudType>
class CloudFunctionObject
:
public SubModelBase<CloudType>
public CloudSubModelBase<CloudType>
{
// Protected Member Functions
// Private data
//- Output path
fileName outputDir_;
// Private Member Functions
//- Write post-processing info
virtual void write();
@ -77,9 +83,10 @@ public:
dictionary,
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
),
(dict, owner)
(dict, owner, modelName)
);
@ -93,7 +100,8 @@ public:
(
const dictionary& dict,
CloudType& owner,
const word& modelType
const word& objectType,
const word& modelName
);
//- Construct copy
@ -118,7 +126,8 @@ public:
(
const dictionary& dict,
CloudType& owner,
const word& modelType
const word& objectType,
const word& modelName
);
@ -159,6 +168,12 @@ public:
const label faceI,
bool& keepParticle
);
// Input/output
//- Return the output path
const fileName& outputDir() const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,13 +33,15 @@ Foam::CloudFunctionObject<CloudType>::New
(
const dictionary& dict,
CloudType& owner,
const word& modelType
const word& objectType,
const word& modelName
)
{
Info<< " Selecting cloud function " << modelType << endl;
Info<< " Selecting cloud function " << modelName << " of type "
<< objectType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
dictionaryConstructorTablePtr_->find(objectType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
@ -48,16 +50,26 @@ Foam::CloudFunctionObject<CloudType>::New
"CloudFunctionObject<CloudType>::New"
"("
"const dictionary&, "
"CloudType&"
"CloudType&, "
"const word&, "
"const word&"
")"
) << "Unknown cloud function type "
<< modelType << nl << nl
<< objectType << nl << nl
<< "Valid cloud function types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<CloudFunctionObject<CloudType> >(cstrIter()(dict, owner));
return autoPtr<CloudFunctionObject<CloudType> >
(
cstrIter()
(
dict,
owner,
modelName
)
);
}

View File

@ -66,13 +66,19 @@ Foam::CloudFunctionObjectList<CloudType>::CloudFunctionObjectList
{
const word& modelName = modelNames[i];
const dictionary& modelDict(dict.subDict(modelName));
// read the type of the function object
const word objectType(modelDict.lookup("type"));
this->set
(
i,
CloudFunctionObject<CloudType>::New
(
dict,
modelDict,
owner,
objectType,
modelName
)
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,16 +50,17 @@ void Foam::FacePostProcessing<CloudType>::makeLogFile
if (Pstream::master())
{
const fileName logDir = outputDir_/this->owner().time().timeName();
// Create directory if does not exist
mkDir(logDir);
mkDir(this->outputDir());
// Open new file at start up
outputFilePtr_.set
(
zoneI,
new OFstream(logDir/(type() + '_' + zoneName + ".dat"))
new OFstream
(
this->outputDir()/(type() + '_' + zoneName + ".dat")
)
);
outputFilePtr_[zoneI]
@ -201,7 +202,7 @@ void Foam::FacePostProcessing<CloudType>::write()
writer->write
(
outputDir_/time.timeName(),
this->outputDir()/time.timeName(),
fZone.name(),
allPoints,
allFaces,
@ -212,7 +213,7 @@ void Foam::FacePostProcessing<CloudType>::write()
writer->write
(
outputDir_/time.timeName(),
this->outputDir()/time.timeName(),
fZone.name(),
allPoints,
allFaces,
@ -250,10 +251,11 @@ template<class CloudType>
Foam::FacePostProcessing<CloudType>::FacePostProcessing
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
faceZoneIDs_(),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
@ -263,7 +265,6 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(),
outputDir_(owner.mesh().time().path()),
timeOld_(owner.mesh().time().value())
{
wordList faceZoneNames(this->coeffDict().lookup("faceZones"));
@ -273,19 +274,6 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
outputFilePtr_.setSize(faceZoneNames.size());
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir_ =
outputDir_/".."/"postProcessing"/cloud::prefix/owner.name();
}
else
{
outputDir_ =
outputDir_/"postProcessing"/cloud::prefix/owner.name();
}
DynamicList<label> zoneIDs;
const faceZoneMesh& fzm = owner.mesh().faceZones();
const surfaceScalarField& magSf = owner.mesh().magSf();
@ -358,7 +346,6 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
massFlowRate_(pff.massFlowRate_),
log_(pff.log_),
outputFilePtr_(),
outputDir_(pff.outputDir_),
timeOld_(0.0)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -91,9 +91,6 @@ class FacePostProcessing
//- Output file pointer per zone
PtrList<OFstream> outputFilePtr_;
//- Output directory
fileName outputDir_;
//- Last calculation time
scalar timeOld_;
@ -127,7 +124,12 @@ public:
// Constructors
//- Construct from dictionary
FacePostProcessing(const dictionary& dict, CloudType& owner);
FacePostProcessing
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
FacePostProcessing(const FacePostProcessing<CloudType>& ppm);

View File

@ -51,15 +51,13 @@ void Foam::ParticleCollector<CloudType>::makeLogFile
if (Pstream::master())
{
const fileName logDir = outputDir_/this->owner().time().timeName();
// Create directory if does not exist
mkDir(logDir);
mkDir(this->outputDir());
// Open new file at start up
outputFilePtr_.reset
(
new OFstream(logDir/(type() + ".dat"))
new OFstream(this->outputDir()/(type() + ".dat"))
);
outputFilePtr_()
@ -463,7 +461,7 @@ void Foam::ParticleCollector<CloudType>::write()
writer->write
(
outputDir_/time.timeName(),
this->outputDir()/time.timeName(),
"collector",
points_,
faces_,
@ -474,7 +472,7 @@ void Foam::ParticleCollector<CloudType>::write()
writer->write
(
outputDir_/time.timeName(),
this->outputDir()/time.timeName(),
"collector",
points_,
faces_,
@ -516,10 +514,11 @@ template<class CloudType>
Foam::ParticleCollector<CloudType>::ParticleCollector
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
mode_(mtUnknown),
parcelType_(this->coeffDict().lookupOrDefault("parcelType", -1)),
removeCollected_(this->coeffDict().lookup("removeCollected")),
@ -542,22 +541,8 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(),
outputDir_(owner.mesh().time().path()),
timeOld_(owner.mesh().time().value())
{
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir_ =
outputDir_/".."/"postProcessing"/cloud::prefix/owner.name();
}
else
{
outputDir_ =
outputDir_/"postProcessing"/cloud::prefix/owner.name();
}
normal_ /= mag(normal_);
word mode(this->coeffDict().lookup("mode"));
@ -618,7 +603,6 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
massFlowRate_(pc.massFlowRate_),
log_(pc.log_),
outputFilePtr_(),
outputDir_(pc.outputDir_),
timeOld_(0.0)
{}

View File

@ -143,9 +143,6 @@ private:
//- Output file pointer
autoPtr<OFstream> outputFilePtr_;
//- Output directory
fileName outputDir_;
//- Last calculation time
scalar timeOld_;
@ -198,7 +195,12 @@ public:
// Constructors
//- Construct from dictionary
ParticleCollector(const dictionary& dict, CloudType& owner);
ParticleCollector
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
ParticleCollector(const ParticleCollector<CloudType>& pc);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,10 +66,11 @@ template<class CloudType>
Foam::ParticleErosion<CloudType>::ParticleErosion
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
QPtr_(NULL),
patchIDs_(),
p_(readScalar(this->coeffDict().lookup("p"))),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -96,7 +96,12 @@ public:
// Constructors
//- Construct from dictionary
ParticleErosion(const dictionary& dict, CloudType& owner);
ParticleErosion
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
ParticleErosion(const ParticleErosion<CloudType>& pe);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,10 +59,11 @@ template<class CloudType>
Foam::ParticleTracks<CloudType>::ParticleTracks
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
trackInterval_(readLabel(this->coeffDict().lookup("trackInterval"))),
maxSamples_(readLabel(this->coeffDict().lookup("maxSamples"))),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -95,7 +95,12 @@ public:
// Constructors
//- Construct from dictionary
ParticleTracks(const dictionary& dict, CloudType& owner);
ParticleTracks
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
ParticleTracks(const ParticleTracks<CloudType>& ppm);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,10 +32,11 @@ template<class CloudType>
Foam::ParticleTrap<CloudType>::ParticleTrap
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
alphaName_
(
this->coeffDict().template lookupOrDefault<word>("alphaName", "alpha")

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,8 +29,9 @@ Description
Model is activated using:
particleTrap
particleTrap1
{
type particleTrap;
alphaName alpha; // name volume fraction field
threshold 0.95; // alpha value below which model is active
}
@ -91,7 +92,12 @@ public:
// Constructors
//- Construct from dictionary
ParticleTrap(const dictionary& dict, CloudType& owner);
ParticleTrap
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
ParticleTrap(const ParticleTrap<CloudType>& pe);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -68,22 +68,7 @@ void Foam::PatchPostProcessing<CloudType>::write()
{
const fvMesh& mesh = this->owner().mesh();
fileName outputDir = mesh.time().path();
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir =
outputDir/".."/"postProcessing"/cloud::prefix/
this->owner().name()/mesh.time().timeName();
}
else
{
outputDir =
outputDir/"postProcessing"/cloud::prefix/
this->owner().name()/mesh.time().timeName();
}
fileName outputDir = this->outputDir()/mesh.time().timeName();
// Create directory if it doesn't exist
mkDir(outputDir);
@ -141,10 +126,11 @@ template<class CloudType>
Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
maxStoredParcels_(readScalar(this->coeffDict().lookup("maxStoredParcels"))),
patchIDs_(),
times_(),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -91,7 +91,12 @@ public:
// Constructors
//- Construct from dictionary
PatchPostProcessing(const dictionary& dict, CloudType& owner);
PatchPostProcessing
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
PatchPostProcessing(const PatchPostProcessing<CloudType>& ppm);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,10 +48,11 @@ template<class CloudType>
Foam::VoidFraction<CloudType>::VoidFraction
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(owner),
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
thetaPtr_(NULL)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -81,7 +81,12 @@ public:
// Constructors
//- Construct from dictionary
VoidFraction(const dictionary& dict, CloudType& owner);
VoidFraction
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
VoidFraction(const VoidFraction<CloudType>& vf);