|
[Sponsors] |
Added Stokes Number CloudFunctionObject to V2106 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 28, 2021, 17:22 |
Added Stokes Number CloudFunctionObject to V2106
|
#1 |
Member
Join Date: Aug 2017
Posts: 32
Rep Power: 8 |
Howdy Yall,
V2106 came with some new CloudFunctionObjects including ReynoldsNumber and NusseltNumber Both implemented in the constant/dustCloudProperties file as follows Code:
cloudFunctions { ReynoldsNumber { type ReynoldsNumber; } NusseltNumber { type NusseltNumber; } } With the template code for Reynolds and Nusselt Numbers implemented you can imagine it was quite simple to copy and modify the code for reynolds number into a cloud function object for the Stokes Number. If you look at my forum posts you will clearly see I am not the best FOAMER or coder. So please if you can improve the code, by all means go for it! I just ask that you share it here for others to find and learn. Alrighty what I want to do is add a cloudFunctionObject to ThermoParcel. I am assuming at this point you, as the coder, know how to compile custom code and the general structure of the OF lagrangian libraries. Firstly make a copy of your lagrangian source, which we will be modifying, and place it where you will. This is where we will be working. the first thing to do is to copy the KinematicReynoldsNumber inside the cloudFunctionObject folder found in the following directory: /lagrangian/intermediate/subModels/CloudFunctionObjects and rename it to StokesNumber. go into the StokesNumber folder and rename the corresponding files from KinematicReynoldsNumber.C -> StokesNumber.C KinematicReynoldsNumber.H -> StokesNumber.H you'll want to open these file and changes instances of Re -> Stk and ReynoldsNumber -> StokesNumber. There are not many changes to make and since they are trivial I am including the contents of both files below. StokesNumber.C Code:
#include "StokesNumber.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> Foam::StokesNumber<CloudType>::StokesNumber ( const dictionary& dict, CloudType& owner, const word& modelName ) : CloudFunctionObject<CloudType>(dict, owner, modelName, typeName), L0_(this->coeffDict().template getOrDefault<scalar>("L0", 1.0)) {} template<class CloudType> Foam::StokesNumber<CloudType>::StokesNumber ( const StokesNumber<CloudType>& stk ) : CloudFunctionObject<CloudType>(stk) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> void Foam::StokesNumber<CloudType>::postEvolve ( const typename parcelType::trackingData& td ) { auto& c = this->owner(); if (!c.template foundObject<IOField<scalar>>("Stk")) { auto* StkPtr = new IOField<scalar> ( IOobject ( "Stk", c.time().timeName(), c, IOobject::NO_READ ) ); StkPtr->store(); } auto& Stk = c.template lookupObjectRef<IOField<scalar>>("Stk"); Stk.setSize(c.size()); label parceli = 0; forAllConstIters(c, parcelIter) { const parcelType& p = parcelIter(); Stk[parceli++] = p.Stk(td, L0_); } if (c.size() && c.time().writeTime()) { Stk.write(); } } and StokesNumber.H Code:
\*---------------------------------------------------------------------------*/ #ifndef StokesNumber_H #define StokesNumber_H #include "CloudFunctionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class KinematicReynoldsNumber Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> class StokesNumber : public CloudFunctionObject<CloudType> { // Private Data // Typedefs //- Convenience typedef for parcel type typedef typename CloudType::parcelType parcelType; public: //- Runtime type information TypeName("StokesNumber"); // Generated Methods scalar L0_; //- No copy assignment void operator=(const StokesNumber<CloudType>&) = delete; // Constructors //- Construct from dictionary StokesNumber ( const dictionary& dict, CloudType& owner, const word& modelName ); //- Copy construct StokesNumber(const StokesNumber<CloudType>& vf); //- Construct and return a clone virtual autoPtr<CloudFunctionObject<CloudType>> clone() const { return autoPtr<CloudFunctionObject<CloudType>> ( new StokesNumber<CloudType>(*this) ); } //- Destructor virtual ~StokesNumber() = default; // Member Functions //- Post-evolve hook virtual void postEvolve(const typename parcelType::trackingData& td); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository #include "StokesNumber.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif Go to the following subDirectory: lagrangian/intermediate/parcels/Template/KinematicParcel/ You might be asking why I am going to the KinematicParcel subDirectory when I just said I would be adding this to the ThermoParcel. The reason has to do with templating and the fact that the ThermoParcel inherits the behaviors of the KinematicParcel. From what I understand, you could add this to the ThermoParcel only. But by adding it to the KinematicParcel you ensure that derivative parcels inherit the cloudFunctionObject StokesNumber as well. Proceeding onwards, add the following line of code to the file: lagrangian/intermediate/parcels/Template/KinematicParcelKinematicParcelI.H I added them under the definition of the Reynolds Number Function for ease of coding. Code:
template<class ParcelType> inline Foam::scalar Foam::KinematicParcel<ParcelType>::Stk ( const trackingData& td, const scalar L0_ ) const { return Trelax(rho_,d_,td.muc())*mag(td.Uc())/L0_; } template<class ParcelType> inline Foam::scalar Foam::KinematicParcel<ParcelType>::Trelax ( const scalar rhop, const scalar d, const scalar muc ) { return rhop*d*d/(18*max(muc, ROOTVSMALL)); } lagrangian/intermediate/parcels/Template/KinematicParcelKinematicParcel.H again, because I am a dirty copy-cat, I like to paste this text next to the definition of the reynolds number. Code:
//- Relaxation Time inline static scalar Trelax ( const scalar rhop, const scalar d, const scalar muc ); //- Stokes number inline scalar Stk(const trackingData& td, const scalar L0_) const; This is not done through the: lagrangian/intermediate/Make/file but rather the: lagrangian/intermediate/parcels/include/makeThermoParcelCloudFunctionObjects.H file. The file contents are pasted below with the two added lines bolded: Code:
#ifndef makeThermoParcelCloudFunctionObjects_H #define makeThermoParcelCloudFunctionObjects_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "FacePostProcessing.H" #include "ParticleCollector.H" #include "ParticleErosion.H" #include "ParticleTracks.H" #include "ParticleTrap.H" #include "PatchCollisionDensity.H" #include "PatchInteractionFields.H" #include "PatchPostProcessing.H" #include "PatchParticleHistogram.H" #include "RemoveParcels.H" #include "VoidFraction.H" #include "NusseltNumber.H" #include "HeatTransferCoeff.H" #include "ThermoReynoldsNumber.H" #include "StokesNumber.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #define makeThermoParcelCloudFunctionObjects(CloudType) \ \ makeCloudFunctionObject(CloudType); \ \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ makeCloudFunctionObjectType(ParticleTracks, CloudType); \ makeCloudFunctionObjectType(ParticleTrap, CloudType); \ makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \ makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \ makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \ makeCloudFunctionObjectType(PatchParticleHistogram, CloudType); \ makeCloudFunctionObjectType(RemoveParcels, CloudType); \ makeCloudFunctionObjectType(VoidFraction, CloudType); \ makeCloudFunctionObjectType(NusseltNumber, CloudType); \ makeCloudFunctionObjectType(HeatTransferCoeff, CloudType); \ makeCloudFunctionObjectType(ThermoReynoldsNumber, CloudType); \ makeCloudFunctionObjectType(StokesNumber, CloudType); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif The implementation of the cloudFunctionObject StokesNumber is just like the reynolds and nusselt numbers in the constant/dustCloudProperties file. But there is an added mandatory entry for the characteristic length which is used to calculate the hydrodynamic timescale. Code:
StokesNumber { type StokesNumber; L0 4; } The calculation of the stokes number is as follows: Stk = Trelax * Ufluid / LCharacteristic where Trelax is the particle relaxation Time and is defined as follows: Trelax = (rho_particle*D_particle^2)/(18*mu_gas) mu_gas = gas dynamic viscosity. The characteristic length is input by the user in the dust cloud dictionary. Image that is attached is of a compressible-supersonic flow past a circular cylinder. The particles being introduced have a log-normal size distribution with a constant injection velocity and temperature. The reported velocity is that of the eulerian fluid. Stk is for lagrangian particles. Stk_cyl.PNG |
|
Tags |
cloudfunctionobject, lagrangian, particles, stokes number |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 05:38 |
[mesh manipulation] mergeMeshes for more than two fluid domains | Vishsel | OpenFOAM Meshing & Mesh Conversion | 17 | May 20, 2019 07:05 |
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops | avinashjagdale | OpenFOAM Meshing & Mesh Conversion | 53 | March 8, 2019 09:42 |
[OpenFOAM.org] OF2.3.1 + OS13.2 - Trying to use the dummy Pstream library | aylalisa | OpenFOAM Installation | 23 | June 15, 2015 14:49 |
Compressor Simulation using rhoPimpleDyMFoam | Jetfire | OpenFOAM Running, Solving & CFD | 107 | December 9, 2014 13:38 |