LaheyKEpsilon.C 7.24 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2013-2016 OpenFOAM Foundation
9
    Copyright (C) 2019-2020 OpenCFD Ltd.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
-------------------------------------------------------------------------------
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 <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "LaheyKEpsilon.H"
30
#include "fvOptions.H"
31
#include "twoPhaseSystem.H"
32
#include "dragModel.H"
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace RASModels
{

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class BasicTurbulenceModel>
LaheyKEpsilon<BasicTurbulenceModel>::LaheyKEpsilon
(
    const alphaField& alpha,
    const rhoField& rho,
    const volVectorField& U,
49
    const surfaceScalarField& alphaRhoPhi,
50 51 52 53 54 55 56 57 58 59 60
    const surfaceScalarField& phi,
    const transportModel& transport,
    const word& propertiesName,
    const word& type
)
:
    kEpsilon<BasicTurbulenceModel>
    (
        alpha,
        rho,
        U,
61
        alphaRhoPhi,
62 63 64 65 66 67
        phi,
        transport,
        propertiesName,
        type
    ),

68
    gasTurbulencePtr_(nullptr),
69 70 71

    alphaInversion_
    (
72
        dimensioned<scalar>::getOrAddToDict
73 74 75 76 77 78 79 80 81
        (
            "alphaInversion",
            this->coeffDict_,
            0.3
        )
    ),

    Cp_
    (
82
        dimensioned<scalar>::getOrAddToDict
83 84 85 86 87 88 89
        (
            "Cp",
            this->coeffDict_,
            0.25
        )
    ),

Henry's avatar
Henry committed
90 91
    C3_
    (
92
        dimensioned<scalar>::getOrAddToDict
Henry's avatar
Henry committed
93
        (
Henry's avatar
Henry committed
94
            "C3",
Henry's avatar
Henry committed
95 96 97 98 99
            this->coeffDict_,
            this->C2_.value()
        )
    ),

100 101
    Cmub_
    (
102
        dimensioned<scalar>::getOrAddToDict
103 104 105 106 107 108 109 110 111
        (
            "Cmub",
            this->coeffDict_,
            0.6
        )
    )
{
    if (type == typeName)
    {
112
        this->printCoeffs(type);
113 114 115 116 117 118 119 120 121 122 123 124 125
    }
}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class BasicTurbulenceModel>
bool LaheyKEpsilon<BasicTurbulenceModel>::read()
{
    if (kEpsilon<BasicTurbulenceModel>::read())
    {
        alphaInversion_.readIfPresent(this->coeffDict());
        Cp_.readIfPresent(this->coeffDict());
Henry's avatar
Henry committed
126
        C3_.readIfPresent(this->coeffDict());
127 128 129 130
        Cmub_.readIfPresent(this->coeffDict());

        return true;
    }
131 132

    return false;
133 134 135 136
}


template<class BasicTurbulenceModel>
137
const PhaseCompressibleTurbulenceModel
138 139 140 141 142 143 144 145 146 147
<
    typename BasicTurbulenceModel::transportModel
>&
LaheyKEpsilon<BasicTurbulenceModel>::gasTurbulence() const
{
    if (!gasTurbulencePtr_)
    {
        const volVectorField& U = this->U_;

        const transportModel& liquid = this->transport();
148 149
        const twoPhaseSystem& fluid =
            refCast<const twoPhaseSystem>(liquid.fluid());
150 151 152 153
        const transportModel& gas = fluid.otherPhase(liquid);

        gasTurbulencePtr_ =
           &U.db()
154
           .lookupObject<PhaseCompressibleTurbulenceModel<transportModel>>
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
            (
                IOobject::groupName
                (
                    turbulenceModel::propertiesName,
                    gas.name()
                )
            );
    }

    return *gasTurbulencePtr_;
}


template<class BasicTurbulenceModel>
void LaheyKEpsilon<BasicTurbulenceModel>::correctNut()
{
171
    const PhaseCompressibleTurbulenceModel<transportModel>& gasTurbulence =
172 173 174 175 176 177 178 179
        this->gasTurbulence();

    this->nut_ =
        this->Cmu_*sqr(this->k_)/this->epsilon_
      + Cmub_*gasTurbulence.transport().d()*gasTurbulence.alpha()
       *(mag(this->U_ - gasTurbulence.U()));

    this->nut_.correctBoundaryConditions();
180 181 182
    fv::options::New(this->mesh_).correct(this->nut_);

    BasicTurbulenceModel::correctNut();
183 184 185 186 187 188
}


template<class BasicTurbulenceModel>
tmp<volScalarField> LaheyKEpsilon<BasicTurbulenceModel>::bubbleG() const
{
189
    const PhaseCompressibleTurbulenceModel<transportModel>& gasTurbulence =
190 191 192
        this->gasTurbulence();

    const transportModel& liquid = this->transport();
193
    const twoPhaseSystem& fluid = refCast<const twoPhaseSystem>(liquid.fluid());
194 195
    const transportModel& gas = fluid.otherPhase(liquid);

196 197
    const dragModel& drag = fluid.lookupSubModel<dragModel>(gas, liquid);

198 199 200 201 202 203 204
    volScalarField magUr(mag(this->U_ - gasTurbulence.U()));

    tmp<volScalarField> bubbleG
    (
        Cp_
       *(
            pow3(magUr)
205
          + pow(drag.CdRe()*liquid.nu()/gas.d(), 4.0/3.0)
206
           *pow(magUr, 5.0/3.0)
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
        )
       *gas
       /gas.d()
    );

    return bubbleG;
}


template<class BasicTurbulenceModel>
tmp<volScalarField>
LaheyKEpsilon<BasicTurbulenceModel>::phaseTransferCoeff() const
{
    const volVectorField& U = this->U_;
    const alphaField& alpha = this->alpha_;
    const rhoField& rho = this->rho_;

    const turbulenceModel& gasTurbulence = this->gasTurbulence();

    return
    (
Henry's avatar
Henry committed
228
        max(alphaInversion_ - alpha, scalar(0))
229 230 231 232 233 234 235 236 237 238 239 240
       *rho
       *min(gasTurbulence.epsilon()/gasTurbulence.k(), 1.0/U.time().deltaT())
    );
}


template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> LaheyKEpsilon<BasicTurbulenceModel>::kSource() const
{
    const alphaField& alpha = this->alpha_;
    const rhoField& rho = this->rho_;

241
    const PhaseCompressibleTurbulenceModel<transportModel>& gasTurbulence =
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
        this->gasTurbulence();

    const volScalarField phaseTransferCoeff(this->phaseTransferCoeff());

    return
        alpha*rho*bubbleG()
      + phaseTransferCoeff*gasTurbulence.k()
      - fvm::Sp(phaseTransferCoeff, this->k_);
}


template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> LaheyKEpsilon<BasicTurbulenceModel>::epsilonSource() const
{
    const alphaField& alpha = this->alpha_;
    const rhoField& rho = this->rho_;

259
    const PhaseCompressibleTurbulenceModel<transportModel>& gasTurbulence =
260 261 262 263 264
        this->gasTurbulence();

    const volScalarField phaseTransferCoeff(this->phaseTransferCoeff());

    return
Henry's avatar
Henry committed
265
        alpha*rho*this->C3_*this->epsilon_*bubbleG()/this->k_
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
      + phaseTransferCoeff*gasTurbulence.epsilon()
      - fvm::Sp(phaseTransferCoeff, this->epsilon_);
}


template<class BasicTurbulenceModel>
void LaheyKEpsilon<BasicTurbulenceModel>::correct()
{
    kEpsilon<BasicTurbulenceModel>::correct();
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace RASModels
} // End namespace Foam

// ************************************************************************* //