From 1cbb707a8657a7bd7fb249a5ac37d11a9fc710f4 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 2 Sep 2020 15:17:28 +0100 Subject: [PATCH] multiphaseEulerFoam/.../populationBalance: Added fvOption source terms Patch contributed by Institute of Fluid Dynamics, Helmholtz-Zentrum Dresden - Rossendorf (HZDR) --- .../phaseSystems/Make/files | 1 - .../driftModels/constantDrift/constantDrift.C | 31 +---- .../driftModels/constantDrift/constantDrift.H | 10 +- .../constantNucleation/constantNucleation.C | 113 ------------------ .../constantNucleation/constantNucleation.H | 107 ----------------- .../populationBalanceModel.C | 5 + .../drift/constant/phaseProperties | 5 +- .../negativeDrift/constant/phaseProperties | 5 +- 8 files changed, 17 insertions(+), 260 deletions(-) delete mode 100644 applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.C delete mode 100644 applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.H diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/Make/files b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/Make/files index 9b190dfb67..48d9022d2f 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/Make/files +++ b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/Make/files @@ -77,7 +77,6 @@ $(driftModels)/phaseChange/phaseChange.C nucleationModels = populationBalanceModel/nucleationModels $(nucleationModels)/nucleationModel/nucleationModel.C -$(nucleationModels)/constantNucleation/constantNucleation.C $(nucleationModels)/reactionDriven/reactionDriven.C $(nucleationModels)/wallBoiling/wallBoiling.C diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.C b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.C index 1097f09919..de960a56b0 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.C @@ -51,46 +51,19 @@ Foam::diameterModels::driftModels::constantDrift::constantDrift ) : driftModel(popBal, dict), - N_ - ( - IOobject - ( - "N", - popBal.mesh().time().timeName(), - popBal.mesh() - ), - popBal.mesh(), - dimensionedScalar(inv(dimVolume), Zero) - ) + rate_("rate", dimVolume/dimTime, dict) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::diameterModels::driftModels::constantDrift::precompute() -{ - N_ = Zero; - - forAll(popBal_.sizeGroups(), i) - { - const sizeGroup& fi = popBal_.sizeGroups()[i]; - - N_ += fi*fi.phase()/fi.x(); - } -} - - void Foam::diameterModels::driftModels::constantDrift::addToDriftRate ( volScalarField& driftRate, const label i ) { - const sizeGroup& fi = popBal_.sizeGroups()[i]; - phaseModel& phase = const_cast(fi.phase()); - volScalarField& rho = phase.thermoRef().rho(); - - driftRate += (popBal_.fluid().fvOptions()(phase, rho)&rho)/(N_*rho); + driftRate += rate_; } diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.H b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.H index 9e9447e495..5bd83e8baa 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/driftModels/constantDrift/constantDrift.H @@ -24,9 +24,6 @@ License Class Foam::diameterModels::driftModels::constantDrift -Description - Constant drift rate within all classes computed from fvOptions mass source. - SourceFiles constant.C @@ -56,8 +53,8 @@ class constantDrift { // Private Data - //- Total number concentration - volScalarField N_; + //- Drift rate + dimensionedScalar rate_; public: @@ -81,9 +78,6 @@ public: // Member Functions - //- Precompute diameter independent expressions - virtual void precompute(); - //- Add to driftRate virtual void addToDriftRate ( diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.C b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.C deleted file mode 100644 index e0d706bd22..0000000000 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.C +++ /dev/null @@ -1,113 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 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 "constantNucleation.H" -#include "phaseSystem.H" -#include "addToRunTimeSelectionTable.H" -#include "mathematicalConstants.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace diameterModels -{ -namespace nucleationModels -{ - defineTypeNameAndDebug(constantNucleation, 0); - addToRunTimeSelectionTable - ( - nucleationModel, - constantNucleation, - dictionary - ); -} -} -} - -using Foam::constant::mathematical::pi; - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::diameterModels::nucleationModels::constantNucleation:: -constantNucleation -( - const populationBalanceModel& popBal, - const dictionary& dict -) -: - nucleationModel(popBal, dict), - dNuc_("nucleationDiameter", dimLength, dict), - velGroup_ - ( - refCast - ( - popBal.mesh().lookupObject - ( - IOobject::groupName - ( - "alpha", - dict.lookup("velocityGroup") - ) - ).dPtr()() - ) - ) -{ - if - ( - dNuc_.value() < velGroup_.sizeGroups().first().dSph().value() - || dNuc_.value() > velGroup_.sizeGroups().last().dSph().value() - ) - { - FatalIOErrorInFunction(dict) - << "Nucleation diameter " << dNuc_.value() << "m outside of range [" - << velGroup_.sizeGroups().first().dSph().value() << ", " - << velGroup_.sizeGroups().last().dSph().value() << "]." << nl - << exit(FatalIOError); - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void -Foam::diameterModels::nucleationModels::constantNucleation::addToNucleationRate -( - volScalarField& nucleationRate, - const label i -) -{ - const sizeGroup& fi = popBal_.sizeGroups()[i]; - phaseModel& phase = const_cast(fi.phase()); - volScalarField& rho = phase.thermoRef().rho(); - - nucleationRate += - popBal_.eta(i, pi/6.0*pow3(dNuc_)) - *(popBal_.fluid().fvOptions()(phase, rho)&rho)/rho/fi.x(); -} - - -// ************************************************************************* // diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.H b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.H deleted file mode 100644 index 263c9b7499..0000000000 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/nucleationModels/constantNucleation/constantNucleation.H +++ /dev/null @@ -1,107 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 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::diameterModels::nucleationModels::constantNucleation - -Description - Constant nucleation rate within all classes computed from fvOptions mass - source. - -SourceFiles - constant.C - -\*---------------------------------------------------------------------------*/ - -#ifndef constantNucleation_H -#define constantNucleation_H - -#include "nucleationModel.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace diameterModels -{ -namespace nucleationModels -{ - -/*---------------------------------------------------------------------------*\ - Class constantNucleation Declaration -\*---------------------------------------------------------------------------*/ - -class constantNucleation -: - public nucleationModel -{ - // Private Data - - //- Nucleation diameter - dimensionedScalar dNuc_; - - //- Velocity group in which the nucleation occurs - const velocityGroup& velGroup_; - - -public: - - //- Runtime type information - TypeName("constant"); - - // Constructor - - constantNucleation - ( - const populationBalanceModel& popBal, - const dictionary& dict - ); - - - //- Destructor - virtual ~constantNucleation() - {} - - - // Member Functions - - //- Add to nucleationRate - virtual void addToNucleationRate - ( - volScalarField& nucleationRate, - const label i - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace nucleationModels -} // End namespace diameterModels -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C index 533a533f00..74ed4943a3 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C +++ b/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C @@ -1261,6 +1261,7 @@ void Foam::diameterModels::populationBalanceModel::solve() const phaseModel& phase = fi.phase(); const volScalarField& alpha = phase; const dimensionedScalar& residualAlpha = phase.residualAlpha(); + const volScalarField& rho = phase.thermo().rho(); fvScalarMatrix sizeGroupEqn ( @@ -1269,17 +1270,21 @@ void Foam::diameterModels::populationBalanceModel::solve() == Su_[i] - fvm::SuSp(SuSp_[i], fi) + + fluid_.fvOptions()(alpha, rho, fi)/rho + fvc::ddt(residualAlpha, fi) - fvm::ddt(residualAlpha, fi) ); sizeGroupEqn.relax(); + fluid_.fvOptions().constrain(sizeGroupEqn); maxInitialResidual = max ( sizeGroupEqn.solve().initialResidual(), maxInitialResidual ); + + fluid_.fvOptions().correct(fi); } } diff --git a/test/multiphase/multiphaseEulerFoam/populationBalance/drift/constant/phaseProperties b/test/multiphase/multiphaseEulerFoam/populationBalance/drift/constant/phaseProperties index ffa58915cd..a1346ce891 100644 --- a/test/multiphase/multiphaseEulerFoam/populationBalance/drift/constant/phaseProperties +++ b/test/multiphase/multiphaseEulerFoam/populationBalance/drift/constant/phaseProperties @@ -101,7 +101,10 @@ populationBalanceCoeffs driftModels ( - constant{} + constant + { + rate 1; + } ); nucleationModels diff --git a/test/multiphase/multiphaseEulerFoam/populationBalance/negativeDrift/constant/phaseProperties b/test/multiphase/multiphaseEulerFoam/populationBalance/negativeDrift/constant/phaseProperties index 4859ab81dd..c64427f3eb 100644 --- a/test/multiphase/multiphaseEulerFoam/populationBalance/negativeDrift/constant/phaseProperties +++ b/test/multiphase/multiphaseEulerFoam/populationBalance/negativeDrift/constant/phaseProperties @@ -95,7 +95,10 @@ populationBalanceCoeffs driftModels ( - constant{} + constant + { + rate -1; + } ); nucleationModels