ENH: Enabled writing of mass stick/escape for particle localInteraction model

This commit is contained in:
andy
2012-07-31 15:03:26 +01:00
parent a9238db4a3
commit 114c9851ca
2 changed files with 119 additions and 8 deletions

View File

@ -39,8 +39,26 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
nEscape_(patchData_.size(), 0),
massEscape_(patchData_.size(), 0.0),
nStick_(patchData_.size(), 0),
massStick_(patchData_.size(), 0.0)
massStick_(patchData_.size(), 0.0),
writeFields_(this->coeffDict().lookupOrDefault("writeFields", false)),
massEscapePtr_(NULL),
massStickPtr_(NULL)
{
if (writeFields_)
{
word massEscapeName(this->owner().name() + "::massEscape");
word massStickName(this->owner().name() + "::massStick");
Info<< " Interaction fields will be written to " << massEscapeName
<< " and " << massStickName << endl;
(void)massEscape();
(void)massStick();
}
else
{
Info<< " Interaction fields will not be written" << endl;
}
// check that interactions are valid/specified
forAll(patchData_, patchI)
{
@ -74,7 +92,10 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
nEscape_(pim.nEscape_),
massEscape_(pim.massEscape_),
nStick_(pim.nStick_),
massStick_(pim.massStick_)
massStick_(pim.massStick_),
writeFields_(pim.writeFields_),
massEscapePtr_(NULL),
massStickPtr_(NULL)
{}
@ -87,6 +108,64 @@ Foam::LocalInteraction<CloudType>::~LocalInteraction()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class CloudType>
Foam::volScalarField& Foam::LocalInteraction<CloudType>::massEscape()
{
if (!massEscapePtr_.valid())
{
const fvMesh& mesh = this->owner().mesh();
massEscapePtr_.reset
(
new volScalarField
(
IOobject
(
this->owner().name() + "::massEscape",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass, 0.0)
)
);
}
return massEscapePtr_();
}
template<class CloudType>
Foam::volScalarField& Foam::LocalInteraction<CloudType>::massStick()
{
if (!massStickPtr_.valid())
{
const fvMesh& mesh = this->owner().mesh();
massStickPtr_.reset
(
new volScalarField
(
IOobject
(
this->owner().name() + "::massStick",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass, 0.0)
)
);
}
return massStickPtr_();
}
template<class CloudType>
bool Foam::LocalInteraction<CloudType>::correct
(
@ -97,14 +176,13 @@ bool Foam::LocalInteraction<CloudType>::correct
const tetIndices& tetIs
)
{
vector& U = p.U();
bool& active = p.active();
label patchI = patchData_.applyToPatch(pp.index());
if (patchI >= 0)
{
vector& U = p.U();
bool& active = p.active();
typename PatchInteractionModel<CloudType>::interactionType it =
this->wordToInteractionType
(
@ -115,20 +193,36 @@ bool Foam::LocalInteraction<CloudType>::correct
{
case PatchInteractionModel<CloudType>::itEscape:
{
scalar dm = p.mass()*p.nParticle();
keepParticle = false;
active = false;
U = vector::zero;
nEscape_[patchI]++;
massEscape_[patchI] += p.mass()*p.nParticle();
massEscape_[patchI] += dm;
if (writeFields_)
{
label pI = pp.index();
label fI = pp.whichFace(p.face());
massEscape().boundaryField()[pI][fI] += dm;
}
break;
}
case PatchInteractionModel<CloudType>::itStick:
{
scalar dm = p.mass()*p.nParticle();
keepParticle = true;
active = false;
U = vector::zero;
nStick_[patchI]++;
massStick_[patchI] += p.mass()*p.nParticle();
massStick_[patchI] += dm;
if (writeFields_)
{
label pI = pp.index();
label fI = pp.whichFace(p.face());
massStick().boundaryField()[pI][fI] += dm;
}
break;
}
case PatchInteractionModel<CloudType>::itRebound:

View File

@ -34,6 +34,7 @@ Description
#include "PatchInteractionModel.H"
#include "patchInteractionDataList.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,6 +70,16 @@ class LocalInteraction
List<scalar> massStick_;
//- Flag to output data as fields
Switch writeFields_;
//- Mass escape field
autoPtr<volScalarField> massEscapePtr_;
//- Mass stick field
autoPtr<volScalarField> massStickPtr_;
public:
//- Runtime type information
@ -99,6 +110,12 @@ public:
// Member Functions
//- Return access to the massEscape field
volScalarField& massEscape();
//- Return access to the massStick field
volScalarField& massStick();
//- Apply velocity correction
// Returns true if particle remains in same cell
virtual bool correct