From cddb8bd80e0fc52aec0ff8d2f24cb4fdfbd06709 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 2 Nov 2011 16:55:48 +0000 Subject: [PATCH] ENH: Added new ParticleErosion cloud function object --- .../include/makeParcelCloudFunctionObjects.H | 2 + .../ParticleErosion/ParticleErosion.C | 210 ++++++++++++++++++ .../ParticleErosion/ParticleErosion.H | 149 +++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.H diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index 6eadb7fea8..572be515a6 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H @@ -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); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C new file mode 100644 index 0000000000..3c649b17a9 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#include "ParticleErosion.H" + +// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * // + +template +Foam::label Foam::ParticleErosion::applyToPatch +( + const label globalPatchI +) const +{ + forAll(patchIDs_, i) + { + if (patchIDs_[i] == globalPatchI) + { + return i; + } + } + + return -1; +} + + +template +void Foam::ParticleErosion::write() +{ + if (QPtr_.valid()) + { + QPtr_->write(); + } + else + { + FatalErrorIn("void Foam::ParticleErosion::write()") + << "QPtr not valid" << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::ParticleErosion::ParticleErosion +( + const dictionary& dict, + CloudType& owner +) +: + CloudFunctionObject(dict, owner, typeName), + QPtr_(NULL), + patchIDs_(), + p_(readScalar(this->coeffDict().lookup("p"))), + psi_(this->coeffDict().template lookupOrDefault("psi", 2.0)), + K_(this->coeffDict().template lookupOrDefault("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::ParticleErosion" + "(" + "const dictionary&, " + "CloudType& " + ")" + ) << "Cannot find any patch names matching " << patchName[i] + << endl; + } + + uniquePatchIDs.insert(patchIDs); + } + + patchIDs_ = uniquePatchIDs.toc(); +} + + +template +Foam::ParticleErosion::ParticleErosion +( + const ParticleErosion& pe +) +: + CloudFunctionObject(pe), + QPtr_(NULL), + patchIDs_(pe.patchIDs_), + p_(pe.p_), + psi_(pe.psi_), + K_(pe.K_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::ParticleErosion::~ParticleErosion() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::ParticleErosion::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 +void Foam::ParticleErosion::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); + } + } +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.H new file mode 100644 index 0000000000..c23dfc4c40 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleErosion/ParticleErosion.H @@ -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 . + +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 ParticleErosion +: + public CloudFunctionObject +{ + // Private Data + + // Typedefs + + //- Convenience typedef for parcel type + typedef typename CloudType::parcelType parcelType; + + + //- Particle erosion field + autoPtr 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& pe); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new ParticleErosion(*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 + +// ************************************************************************* //