From ef39baacfc59f80c78acba8169efbe961188b05a Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 14 Apr 2009 17:06:44 +0100 Subject: [PATCH] re-packaged particle forces into class --- src/lagrangian/intermediate/Make/files | 4 + .../Templates/KinematicCloud/KinematicCloud.C | 5 +- .../Templates/KinematicCloud/KinematicCloud.H | 24 +-- .../KinematicCloud/KinematicCloudI.H | 32 ++-- .../KinematicParcel/KinematicParcel.C | 23 +-- .../KinematicParcel/KinematicParcel.H | 6 - .../KinematicParcel/KinematicParcelI.H | 11 +- .../particleForces/particleForces.C | 156 ++++++++++++++++++ .../particleForces/particleForces.H | 156 ++++++++++++++++++ 9 files changed, 338 insertions(+), 79 deletions(-) create mode 100644 src/lagrangian/intermediate/particleForces/particleForces.C create mode 100644 src/lagrangian/intermediate/particleForces/particleForces.H diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 93572202fc..4b371547f8 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -76,6 +76,10 @@ submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C IntegrationScheme/makeIntegrationSchemes.C +/* particle forces */ +particleForces/particleForces.C + + /* phase properties */ phaseProperties/phaseProperties/phaseProperties.C phaseProperties/phaseProperties/phasePropertiesIO.C diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index eeee670009..ecbb926651 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -101,11 +101,8 @@ Foam::KinematicCloud::KinematicCloud U_(U), mu_(mu), g_(g), + forces_(mesh_, particleProperties_, g_.value()), interpolationSchemes_(particleProperties_.subDict("interpolationSchemes")), - forcesDict_(particleProperties_.subDict("forces")), - forceGravity_(forcesDict_.lookup("gravity")), - forceVirtualMass_(forcesDict_.lookup("virtualMass")), - forcePressureGradient_(forcesDict_.lookup("pressureGradient")), dispersionModel_ ( DispersionModel >::New diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index 7f39808f83..785b981919 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -51,7 +51,7 @@ SourceFiles #include "fvMesh.H" #include "volFields.H" #include "fvMatrices.H" -#include "fvm.H" +#include "particleForces.H" #include "IntegrationSchemesFwd.H" @@ -129,25 +129,13 @@ class KinematicCloud const dimensionedVector& g_; + //- Optional particle forces + particleForces forces_; + //- Interpolation schemes dictionary dictionary interpolationSchemes_; - // Forces to include in particle motion evaluation - - //- Dictionary of forces - dictionary forcesDict_; - - //- Gravity - Switch forceGravity_; - - //- Virtual mass - Switch forceVirtualMass_; - - //- Pressure gradient - Switch forcePressureGradient_; - - // References to the cloud sub-models //- Dispersion model @@ -261,6 +249,10 @@ public: inline const dimensionedVector& g() const; + //- Optional particle forces + inline const particleForces& forces() const; + + // Interpolations //- Return reference to the interpolation dictionary diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index adae027b87..dde35a4298 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ +#include "fvmSup.H" + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -100,6 +102,14 @@ Foam::KinematicCloud::g() const } +template +inline const Foam::particleForces& +Foam::KinematicCloud::forces() const +{ + return forces_; +} + + template inline const Foam::dictionary& Foam::KinematicCloud::interpolationSchemes() const @@ -108,28 +118,6 @@ Foam::KinematicCloud::interpolationSchemes() const } -template -inline Foam::Switch Foam::KinematicCloud::forceGravity() const -{ - return forceGravity_; -} - - -template -inline Foam::Switch Foam::KinematicCloud::forceVirtualMass() const -{ - return forceVirtualMass_; -} - - -template -inline Foam::Switch Foam::KinematicCloud:: -forcePressureGradient() const -{ - return forcePressureGradient_; -} - - template inline const Foam::DispersionModel >& Foam::KinematicCloud::dispersion() const diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index 007e5aac47..f318c5c73d 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -142,27 +142,8 @@ const Foam::vector Foam::KinematicParcel::calcVelocity // Return linearised term from drag model Cud = td.cloud().drag().Cu(U - Uc_, d, rhoc_, rho, muc_); - // Initialise total force (per unit mass) - vector Ftot = vector::zero; - - // Gravity force - if (td.cloud().forceGravity()) - { - Ftot += td.g()*(1 - rhoc_/rho); - } - - // Virtual mass force - if (td.cloud().forceVirtualMass()) - { -// Ftot += td.constProps().Cvm()*rhoc_/rho*d(Uc - U)/dt; - } - - // Pressure gradient force - if (td.cloud().forcePressureGradient()) - { -// const vector& delta = td.cloud().mesh().deltaCoeffs()[cellI]; -// Ftot += rhoc_/rho*(U & (delta^Uc_)); - } + // Calculate particle forces + vector Ftot = td.cloud().forces().calc(cellI, dt, rhoc_, rho, Uc_, U); // New particle velocity diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 2e816bd6ad..c2ed55c2c0 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -95,9 +95,6 @@ public: //- Minimum particle mass [kg] const scalar minParticleMass_; - //- Virtual mass coefficient [] - const scalar Cvm_; - public: @@ -114,9 +111,6 @@ public: //- Return const access to the minimum particle mass inline scalar minParticleMass() const; - - //- Return const access to the virtual mass coefficient - inline scalar Cvm() const; }; diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H index ca3e5015d0..edf4b0771e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H @@ -37,8 +37,7 @@ inline Foam::KinematicParcel::constantProperties::constantProperties minParticleMass_ ( dimensionedScalar(dict_.lookup("minParticleMass")).value() - ), - Cvm_(dimensionedScalar(dict_.lookup("Cvm")).value()) + ) {} @@ -116,14 +115,6 @@ Foam::KinematicParcel::constantProperties::minParticleMass() const } -template -inline Foam::scalar -Foam::KinematicParcel::constantProperties::Cvm() const -{ - return Cvm_; -} - - // * * * * * * * * * * * trackData Member Functions * * * * * * * * * * * * // template diff --git a/src/lagrangian/intermediate/particleForces/particleForces.C b/src/lagrangian/intermediate/particleForces/particleForces.C new file mode 100644 index 0000000000..44d758351f --- /dev/null +++ b/src/lagrangian/intermediate/particleForces/particleForces.C @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "particleForces.H" +#include "fvMesh.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::particleForces::particleForces +( + const fvMesh& mesh, + const dictionary& dict, + const vector& g +) +: + mesh_(mesh), + dict_(dict.subDict("particleForces")), + g_(g), + gravity_(dict_.lookup("gravity")), + virtualMass_(dict_.lookup("virtualMass")), + Cvm_(0.0), + pressureGradient_(dict_.lookup("pressureGradient")), + gradUName_("unknown_gradUName") +{ + if (gravity_) + { + dict_.lookup("Cvm") >> Cvm_; + } + + if (pressureGradient_) + { + dict_.lookup("gradU") >> gradUName_; + } +} + + +Foam::particleForces::particleForces(const particleForces& f) +: + mesh_(f.mesh_), + dict_(f.dict_), + g_(f.g_), + gravity_(f.gravity_), + virtualMass_(f.virtualMass_), + Cvm_(f.Cvm_), + pressureGradient_(f.pressureGradient_), + gradUName_(f.gradUName_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::particleForces::~particleForces() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::dictionary& Foam::particleForces::dict() const +{ + return dict_; +} + + +const Foam::vector& Foam::particleForces::g() const +{ + return g_; +} + + +Foam::Switch Foam::particleForces::gravity() const +{ + return gravity_; +} + + +Foam::Switch Foam::particleForces::virtualMass() const +{ + return virtualMass_; +} + + +Foam::Switch Foam::particleForces::pressureGradient() const +{ + return pressureGradient_; +} + + +const Foam::word& Foam::particleForces::gradUName() const +{ + return gradUName_; +} + + +Foam::vector Foam::particleForces::calc +( + const label cellI, + const scalar dt, + const scalar rhoc, + const scalar rho, + const vector& Uc, + const vector& U +) const +{ + vector Ftot = vector::zero; + + // Gravity force + if (gravity_) + { + Ftot += g_*(1.0 - rhoc/rho); + } + + // Virtual mass force + if (virtualMass_) + { + notImplemented("Foam::particleForces::calc(...) - virtualMass force"); +// Ftot += Cvm_*rhoc/rho*d(Uc - U)/dt; + } + + // Pressure gradient force + if (pressureGradient_) + { + const volSymmTensorField& gradU = + mesh_.lookupObject(gradUName_); + Ftot += rhoc/rho*(U & gradU[cellI]); + } + + return Ftot; +} + + +// ************************************************************************* // + diff --git a/src/lagrangian/intermediate/particleForces/particleForces.H b/src/lagrangian/intermediate/particleForces/particleForces.H new file mode 100644 index 0000000000..8258e35be2 --- /dev/null +++ b/src/lagrangian/intermediate/particleForces/particleForces.H @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::particleForces + +Description + Particle forces + +SourceFiles + particleForces.C + +\*---------------------------------------------------------------------------*/ + +#ifndef particleForces_H +#define particleForces_H + +#include "dictionary.H" +#include "Switch.H" +#include "vector.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward class declarations +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class particleForces Declaration +\*---------------------------------------------------------------------------*/ + +class particleForces +{ + // Private data + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- The particleForces dictionary + const dictionary& dict_; + + //- Gravity + const vector g_; + + + // Forces to include in particle motion evaluation + + //- Gravity + Switch gravity_; + + //- Virtual mass + Switch virtualMass_; + + //- Virtual mass force coefficient + scalar Cvm_; + + //- Pressure gradient + Switch pressureGradient_; + + //- Name of velocity gradient field for pressure gradient force + word gradUName_; + + +public: + + // Constructors + + //- Construct from mesh, dictionary and gravity + particleForces + ( + const fvMesh& mesh, + const dictionary& dict, + const vector& g + ); + + //- Construct copy + particleForces(const particleForces& f); + + + //- Destructor + ~particleForces(); + + + // Member Functions + + // Access + + //- Return the particleForces dictionary + const dictionary& dict() const; + + //- Return the gravity vector + const vector& g() const; + + //- Return gravity force activate switch + Switch gravity() const; + + //- Return virtual mass force activate switch + Switch virtualMass() const; + + //- Return virtual mass force coefficient + Switch Cvm() const; + + //- Return pressure gradient force activate switch + Switch pressureGradient() const; + + //- Return the name of the velocity gradient field + const word& gradUName() const; + + + // Evaluation + + //- Calculate the net particle force + vector calc + ( + const label cellI, + const scalar dt, + const scalar rhoc, + const scalar rho, + const vector& Uc, + const vector& U + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //