From 35c2b4b603c3f47e5e94262690dbca740181a03c Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Thu, 16 Mar 2023 09:01:33 +0000 Subject: [PATCH] BUG: splash model - correction and code refactoring --- .../KinematicSurfaceFilm.C | 100 +++++++----------- .../KinematicSurfaceFilm.H | 29 +++-- .../ThermoSurfaceFilm/ThermoSurfaceFilm.C | 12 +-- 3 files changed, 56 insertions(+), 85 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.C b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.C index 9805153880..e3fb81f101 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.C @@ -37,51 +37,18 @@ using namespace Foam::constant::mathematical; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template -Foam::wordList Foam::KinematicSurfaceFilm::interactionTypeNames_ +const Foam::Enum +< + typename Foam::KinematicSurfaceFilm::interactionType +> +Foam::KinematicSurfaceFilm::interactionTypeNames ({ - "absorb", "bounce", "splashBai" + { interactionType::absorb, "absorb" }, + { interactionType::bounce, "bounce" }, + { interactionType::splashBai, "splashBai" }, }); -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template -typename Foam::KinematicSurfaceFilm::interactionType -Foam::KinematicSurfaceFilm::interactionTypeEnum(const word& it) const -{ - forAll(interactionTypeNames_, i) - { - if (interactionTypeNames_[i] == it) - { - return interactionType(i); - } - } - - FatalErrorInFunction - << "Unknown interaction type " << it - << ". Valid interaction types include: " << interactionTypeNames_ - << abort(FatalError); - - return interactionType(0); -} - - -template -Foam::word Foam::KinematicSurfaceFilm::interactionTypeStr -( - const interactionType& it -) const -{ - if (it >= interactionTypeNames_.size()) - { - FatalErrorInFunction - << "Unknown interaction type enumeration" << abort(FatalError); - } - - return interactionTypeNames_[it]; -} - - // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template @@ -415,8 +382,8 @@ void Foam::KinematicSurfaceFilm::splashInteraction const scalar dBarSplash = 1/cbrt(6.0)*cbrt(mRatio/Ns)*d + ROOTVSMALL; // Cumulative diameter splash distribution - const scalar dMax = 0.9*cbrt(mRatio)*d; - const scalar dMin = 0.1*dMax; + const scalar dMax = dMaxSplash_ > 0 ? dMaxSplash_ : 0.9*cbrt(mRatio)*d; + const scalar dMin = dMinSplash_ > 0 ? dMinSplash_ : 0.1*dMax; const scalar K = exp(-dMin/dBarSplash) - exp(-dMax/dBarSplash); // Surface energy of secondary parcels [J] @@ -457,7 +424,9 @@ void Foam::KinematicSurfaceFilm::splashInteraction const scalar logD = log(d); const scalar coeff2 = log(dNew[0]) - logD + ROOTVSMALL; scalar coeff1 = 0.0; - forAll(dNew, i) + + // Note: loop from i = 1 to (p-1) + for (int i = 1; i < parcelsPerSplash_; ++i) { coeff1 += sqr(log(dNew[i]) - logD); } @@ -527,27 +496,32 @@ Foam::KinematicSurfaceFilm::KinematicSurfaceFilm areaFilms_(), interactionType_ ( - interactionTypeEnum(this->coeffDict().getWord("interactionType")) + interactionTypeNames.get("interactionType", this->coeffDict()) ), parcelTypes_(this->coeffDict().getOrDefault("parcelTypes", labelList())), - deltaWet_(0.0), + deltaWet_(Zero), splashParcelType_(0), parcelsPerSplash_(0), - Adry_(0.0), - Awet_(0.0), - Cf_(0.0), + dMaxSplash_(-1), + dMinSplash_(-1), + Adry_(Zero), + Awet_(Zero), + Cf_(Zero), nParcelsSplashed_(0) { - Info<< " Applying " << interactionTypeStr(interactionType_) + Info<< " Applying " << interactionTypeNames[interactionType_] << " interaction model" << endl; - if (interactionType_ == itSplashBai) + if (interactionType_ == interactionType::splashBai) { this->coeffDict().readEntry("deltaWet", deltaWet_); splashParcelType_ = this->coeffDict().getOrDefault("splashParcelType", -1); parcelsPerSplash_ = this->coeffDict().getOrDefault("parcelsPerSplash", 2); + dMinSplash_ = this->coeffDict().getOrDefault("dMinSplash", -1); + dMaxSplash_ = this->coeffDict().getOrDefault("dMaxSplash", -1); + this->coeffDict().readEntry("Adry", Adry_); this->coeffDict().readEntry("Awet", Awet_); this->coeffDict().readEntry("Cf", Cf_); @@ -573,12 +547,14 @@ Foam::KinematicSurfaceFilm::KinematicSurfaceFilm deltaWet_(sfm.deltaWet_), splashParcelType_(sfm.splashParcelType_), parcelsPerSplash_(sfm.parcelsPerSplash_), + dMaxSplash_(sfm.dMaxSplash_), + dMinSplash_(sfm.dMinSplash_), Adry_(sfm.Adry_), Awet_(sfm.Awet_), Cf_(sfm.Cf_), nParcelsSplashed_(sfm.nParcelsSplashed_) { - if (interactionType_ == itSplashBai) + if (interactionType_ == interactionType::splashBai) { init(initThermo); } @@ -620,14 +596,14 @@ bool Foam::KinematicSurfaceFilm::transferParcel switch (interactionType_) { - case itBounce: + case interactionType::bounce: { bounceInteraction(p, pp, facei, keepParticle); break; } - case itAbsorb: + case interactionType::absorb: { const scalar m = p.nParticle()*p.mass(); @@ -637,7 +613,7 @@ bool Foam::KinematicSurfaceFilm::transferParcel break; } - case itSplashBai: + case interactionType::splashBai: { const scalarField X(thermo_->size(), 1); const scalar mu = thermo_->mu(pRef_, TRef_, X); @@ -693,14 +669,14 @@ bool Foam::KinematicSurfaceFilm::transferParcel switch (interactionType_) { - case itBounce: + case interactionType::bounce: { bounceInteraction(p, pp, facei, keepParticle); break; } - case itAbsorb: + case interactionType::absorb: { const scalar m = p.nParticle()*p.mass(); @@ -711,7 +687,7 @@ bool Foam::KinematicSurfaceFilm::transferParcel break; } - case itSplashBai: + case interactionType::splashBai: { auto& liqFilm = refCast @@ -725,13 +701,9 @@ bool Foam::KinematicSurfaceFilm::transferParcel const scalar TRef = liqFilm.Tref(); const scalar mu = liqFilm.thermo().mu(pRef, TRef, X); - const scalar sigma = - liqFilm.thermo().sigma(pRef, TRef, X); + const scalar sigma = liqFilm.thermo().sigma(pRef, TRef, X); - const bool dry - ( - film.h()[filmFacei] < this->deltaWet_ - ); + const bool dry = film.h()[filmFacei] < this->deltaWet_; if (dry) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.H b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.H index d0300ef2d6..3c54dd001e 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/KinematicSurfaceFilm/KinematicSurfaceFilm.H @@ -33,7 +33,7 @@ Description Kinematic parcel surface film model. Responsible for: - - injecting parcelss from the film model into the cloud, e.g. for dripping + - injecting parcels from the film model into the cloud, e.g. for dripping - parcel interaction with the film, e.g absorb, bounce, splash SourceFiles @@ -48,6 +48,7 @@ SourceFiles #include "SurfaceFilmModel.H" #include "UPtrList.H" #include "liquidMixtureProperties.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -81,24 +82,15 @@ public: // Public Data //- Options for the interaction types - enum interactionType + enum class interactionType { - itAbsorb, //!< "absorb" - itBounce, //!< "bounce" - itSplashBai //!< "splashBai" + absorb, //!< absorb + bounce, //!< bounce + splashBai //!< Bai splash model }; //- Names for interactionType - static wordList interactionTypeNames_; - - - // Public Member Functions - - //- Return interaction type enum from word - interactionType interactionTypeEnum(const word& it) const; - - //- Return word from interaction type enum - word interactionTypeStr(const interactionType& it) const; + static const Enum interactionTypeNames; protected: @@ -162,6 +154,13 @@ protected: //- Number of new parcels resulting from splash event label parcelsPerSplash_; + //- Maximum splash particle diameter for Chi-square distribution + // Default is incident particle diameter + scalar dMaxSplash_; + + //- Minimum splash particle diameter for Chi-square distribution + // Default is 0.1 dMaxSplash + scalar dMinSplash_; // Surface roughness coefficient typically in the range 1300 - 5200 // and decreases with increasing surface roughness diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C index dbef189cc8..b44429cdb1 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C @@ -83,14 +83,14 @@ bool Foam::ThermoSurfaceFilm::transferParcel switch (this->interactionType_) { - case KinematicSurfaceFilm::itBounce: + case KinematicSurfaceFilm::interactionType::bounce: { this->bounceInteraction(p, pp, facei, keepParticle); break; } - case KinematicSurfaceFilm::itAbsorb: + case KinematicSurfaceFilm::interactionType::absorb: { const scalar m = p.nParticle()*p.mass(); @@ -100,7 +100,7 @@ bool Foam::ThermoSurfaceFilm::transferParcel break; } - case KinematicSurfaceFilm::itSplashBai: + case KinematicSurfaceFilm::interactionType::splashBai: { // Local pressure const scalar pc = thermo_.thermo().p()[p.cell()]; @@ -158,14 +158,14 @@ bool Foam::ThermoSurfaceFilm::transferParcel switch (this->interactionType_) { - case KinematicSurfaceFilm::itBounce: + case KinematicSurfaceFilm::interactionType::bounce: { this->bounceInteraction(p, pp, facei, keepParticle); break; } - case KinematicSurfaceFilm::itAbsorb: + case KinematicSurfaceFilm::interactionType::absorb: { const scalar m = p.nParticle()*p.mass(); @@ -176,7 +176,7 @@ bool Foam::ThermoSurfaceFilm::transferParcel break; } - case KinematicSurfaceFilm::itSplashBai: + case KinematicSurfaceFilm::interactionType::splashBai: { // Local pressure const scalar pc = thermo_.thermo().p()[p.cell()];