mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new ParticleErosion cloud function object
This commit is contained in:
@ -29,6 +29,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "FacePostProcessing.H"
|
||||
#include "ParticleErosion.H"
|
||||
#include "ParticleTracks.H"
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "VoidFraction.H"
|
||||
@ -40,6 +41,7 @@ License
|
||||
makeCloudFunctionObject(CloudType); \
|
||||
\
|
||||
makeCloudFunctionObjectType(FacePostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleErosion, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(VoidFraction, CloudType);
|
||||
|
||||
@ -0,0 +1,210 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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 "ParticleErosion.H"
|
||||
|
||||
// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::label Foam::ParticleErosion<CloudType>::applyToPatch
|
||||
(
|
||||
const label globalPatchI
|
||||
) const
|
||||
{
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
if (patchIDs_[i] == globalPatchI)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleErosion<CloudType>::write()
|
||||
{
|
||||
if (QPtr_.valid())
|
||||
{
|
||||
QPtr_->write();
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::ParticleErosion<CloudType>::write()")
|
||||
<< "QPtr not valid" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleErosion<CloudType>::ParticleErosion
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(dict, owner, typeName),
|
||||
QPtr_(NULL),
|
||||
patchIDs_(),
|
||||
p_(readScalar(this->coeffDict().lookup("p"))),
|
||||
psi_(this->coeffDict().template lookupOrDefault<scalar>("psi", 2.0)),
|
||||
K_(this->coeffDict().template lookupOrDefault<scalar>("K", 2.0))
|
||||
{
|
||||
const wordList allPatchNames = owner.mesh().boundaryMesh().names();
|
||||
wordList patchName(this->coeffDict().lookup("patches"));
|
||||
|
||||
labelHashSet uniquePatchIDs;
|
||||
forAllReverse(patchName, i)
|
||||
{
|
||||
labelList patchIDs = findStrings(patchName[i], allPatchNames);
|
||||
|
||||
if (patchIDs.empty())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::ParticleErosion<CloudType>::ParticleErosion"
|
||||
"("
|
||||
"const dictionary&, "
|
||||
"CloudType& "
|
||||
")"
|
||||
) << "Cannot find any patch names matching " << patchName[i]
|
||||
<< endl;
|
||||
}
|
||||
|
||||
uniquePatchIDs.insert(patchIDs);
|
||||
}
|
||||
|
||||
patchIDs_ = uniquePatchIDs.toc();
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleErosion<CloudType>::ParticleErosion
|
||||
(
|
||||
const ParticleErosion<CloudType>& pe
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(pe),
|
||||
QPtr_(NULL),
|
||||
patchIDs_(pe.patchIDs_),
|
||||
p_(pe.p_),
|
||||
psi_(pe.psi_),
|
||||
K_(pe.K_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticleErosion<CloudType>::~ParticleErosion()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleErosion<CloudType>::preEvolve()
|
||||
{
|
||||
if (QPtr_.valid())
|
||||
{
|
||||
QPtr_->internalField() = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
|
||||
QPtr_.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
this->owner().name() + "Q",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("zero", dimVolume, 0.0)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticleErosion<CloudType>::postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const label patchI,
|
||||
const label patchFaceI
|
||||
)
|
||||
{
|
||||
const label localPatchI = applyToPatch(patchI);
|
||||
|
||||
if (localPatchI != -1)
|
||||
{
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
|
||||
// patch-normal direction
|
||||
vector nw = p.currentTetIndices().faceTri(mesh).normal();
|
||||
|
||||
// particle direction of travel
|
||||
const vector& U = p.U();
|
||||
|
||||
// quick reject if particle travelling away from the patch
|
||||
if ((-nw & U) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nw /= mag(nw);
|
||||
const scalar magU = mag(U);
|
||||
const vector Udir = U/magU;
|
||||
|
||||
// determine impact angle, alpha
|
||||
const scalar alpha = mathematical::pi/2.0 - acos(nw & Udir);
|
||||
|
||||
const scalar coeff = p.nParticle()*p.mass()*sqr(magU)/(p_*psi_*K_);
|
||||
|
||||
scalar& Q = QPtr_->boundaryField()[patchI][patchFaceI];
|
||||
if (tan(alpha) < K_/6.0)
|
||||
{
|
||||
Q += coeff*(sin(2.0*alpha) - 6.0/K_*sqr(sin(alpha)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Q += coeff*(K_*sqr(cos(alpha))/6.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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::ParticleErosion
|
||||
|
||||
Description
|
||||
Creates particle erosion field, Q
|
||||
|
||||
SourceFiles
|
||||
ParticleErosion.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ParticleErosion_H
|
||||
#define ParticleErosion_H
|
||||
|
||||
#include "CloudFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ParticleErosion Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class CloudType>
|
||||
class ParticleErosion
|
||||
:
|
||||
public CloudFunctionObject<CloudType>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- Convenience typedef for parcel type
|
||||
typedef typename CloudType::parcelType parcelType;
|
||||
|
||||
|
||||
//- Particle erosion field
|
||||
autoPtr<volScalarField> QPtr_;
|
||||
|
||||
//- List of patch indices to post-process
|
||||
labelList patchIDs_;
|
||||
|
||||
//- Plastic flow stress - typical metal value = 2.7 GPa
|
||||
scalar p_;
|
||||
|
||||
//- Ratio between depth of contact and length of cut - default=2
|
||||
scalar psi_;
|
||||
|
||||
//- Ratio of normal and tangential forces - default=2
|
||||
scalar K_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Returns local patchI if patch is in patchIds_ list
|
||||
label applyToPatch(const label globalPatchI) const;
|
||||
|
||||
//- Write post-processing info
|
||||
virtual void write();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("particleErosion");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
ParticleErosion(const dictionary& dict, CloudType& owner);
|
||||
|
||||
//- Construct copy
|
||||
ParticleErosion(const ParticleErosion<CloudType>& pe);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<CloudFunctionObject<CloudType> > clone() const
|
||||
{
|
||||
return autoPtr<CloudFunctionObject<CloudType> >
|
||||
(
|
||||
new ParticleErosion<CloudType>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ParticleErosion();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Pre-evolve hook
|
||||
virtual void preEvolve();
|
||||
|
||||
//- Post-patch hook
|
||||
virtual void postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const label patchI,
|
||||
const label patchFaceI
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ParticleErosion.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user