mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new particleTrap cloud function object
This commit is contained in:
@ -31,6 +31,7 @@ License
|
||||
#include "FacePostProcessing.H"
|
||||
#include "ParticleErosion.H"
|
||||
#include "ParticleTracks.H"
|
||||
#include "ParticleTrap.H"
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "VoidFraction.H"
|
||||
|
||||
@ -43,6 +44,7 @@ License
|
||||
makeCloudFunctionObjectType(FacePostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleErosion, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(VoidFraction, CloudType);
|
||||
|
||||
|
||||
@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ParticleTrap.H"
|
||||
#include "fvcGrad.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleTrap<CloudType>::ParticleTrap
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(dict, owner, typeName),
|
||||
alphaName_
|
||||
(
|
||||
this->coeffDict().template lookupOrDefault<word>("alphaName", "alpha")
|
||||
),
|
||||
alphaPtr_(NULL),
|
||||
gradAlphaPtr_(NULL),
|
||||
threshold_(readScalar(this->coeffDict().lookup("threshold")))
|
||||
{}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleTrap<CloudType>::ParticleTrap
|
||||
(
|
||||
const ParticleTrap<CloudType>& pt
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(pt),
|
||||
alphaName_(pt.alphaName_),
|
||||
alphaPtr_(pt.alphaPtr_),
|
||||
gradAlphaPtr_(NULL),
|
||||
threshold_(pt.threshold_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleTrap<CloudType>::~ParticleTrap()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleTrap<CloudType>::preEvolve()
|
||||
{
|
||||
if (alphaPtr_ == NULL)
|
||||
{
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
const volScalarField& alpha =
|
||||
mesh.lookupObject<volScalarField>(alphaName_);
|
||||
|
||||
alphaPtr_ = α
|
||||
}
|
||||
|
||||
if (gradAlphaPtr_.valid())
|
||||
{
|
||||
gradAlphaPtr_() == fvc::grad(*alphaPtr_);
|
||||
}
|
||||
else
|
||||
{
|
||||
gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleTrap<CloudType>::postEvolve()
|
||||
{
|
||||
gradAlphaPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleTrap<CloudType>::postMove
|
||||
(
|
||||
parcelType& p,
|
||||
const label cellI,
|
||||
const scalar
|
||||
)
|
||||
{
|
||||
if (alphaPtr_->internalField()[cellI] < threshold_)
|
||||
{
|
||||
const vector& gradAlpha = gradAlphaPtr_()[cellI];
|
||||
vector nHat = gradAlpha/mag(gradAlpha);
|
||||
scalar nHatU = nHat & p.U();
|
||||
|
||||
if (nHatU < 0)
|
||||
{
|
||||
p.U() -= 2*nHat*nHatU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ParticleTrap
|
||||
|
||||
Description
|
||||
Traps particles within a given phase fraction for multi-phase cases
|
||||
|
||||
Model is activated using:
|
||||
|
||||
particleTrap
|
||||
{
|
||||
alphaName alpha; // name volume fraction field
|
||||
threshold 0.95; // alpha value below which model is active
|
||||
}
|
||||
|
||||
|
||||
SourceFiles
|
||||
ParticleTrap.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ParticleTrap_H
|
||||
#define ParticleTrap_H
|
||||
|
||||
#include "CloudFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ParticleTrap Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class CloudType>
|
||||
class ParticleTrap
|
||||
:
|
||||
public CloudFunctionObject<CloudType>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- Convenience typedef for parcel type
|
||||
typedef typename CloudType::parcelType parcelType;
|
||||
|
||||
|
||||
//- Name of vol fraction field
|
||||
const word alphaName_;
|
||||
|
||||
//- Pointer to the volume fraction field
|
||||
const volScalarField* alphaPtr_;
|
||||
|
||||
//- Gradient of the volume fraction field
|
||||
autoPtr<volVectorField> gradAlphaPtr_;
|
||||
|
||||
//- Threshold beyond which model is active
|
||||
scalar threshold_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("particleTrap");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
ParticleTrap(const dictionary& dict, CloudType& owner);
|
||||
|
||||
//- Construct copy
|
||||
ParticleTrap(const ParticleTrap<CloudType>& pe);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<CloudFunctionObject<CloudType> > clone() const
|
||||
{
|
||||
return autoPtr<CloudFunctionObject<CloudType> >
|
||||
(
|
||||
new ParticleTrap<CloudType>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ParticleTrap();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Pre-evolve hook
|
||||
virtual void preEvolve();
|
||||
|
||||
//- Post-evolve hook
|
||||
virtual void postEvolve();
|
||||
|
||||
//- Post-move hook
|
||||
virtual void postMove
|
||||
(
|
||||
typename CloudType::parcelType& p,
|
||||
const label cellI,
|
||||
const scalar dt
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ParticleTrap.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user