kOmegaSSTBase.C 13.5 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
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2015 OpenFOAM Foundation
9
    Copyright (C) 2016-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 "kOmegaSSTBase.H"
30
#include "fvOptions.H"
31 32 33 34 35 36 37 38
#include "bound.H"
#include "wallDist.H"

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

namespace Foam
{

Henry Weller's avatar
Henry Weller committed
39
// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

template<class BasicEddyViscosityModel>
tmp<volScalarField> kOmegaSSTBase<BasicEddyViscosityModel>::F1
(
    const volScalarField& CDkOmega
) const
{
    tmp<volScalarField> CDkOmegaPlus = max
    (
        CDkOmega,
        dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10)
    );

    tmp<volScalarField> arg1 = min
    (
        min
        (
            max
            (
                (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_),
                scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_)
            ),
            (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_))
        ),
        scalar(10)
    );

    return tanh(pow4(arg1));
}


template<class BasicEddyViscosityModel>
tmp<volScalarField> kOmegaSSTBase<BasicEddyViscosityModel>::F2() const
{
    tmp<volScalarField> arg2 = min
    (
        max
        (
            (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_),
            scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_)
        ),
        scalar(100)
    );

    return tanh(sqr(arg2));
}


template<class BasicEddyViscosityModel>
tmp<volScalarField> kOmegaSSTBase<BasicEddyViscosityModel>::F3() const
{
    tmp<volScalarField> arg3 = min
    (
        150*(this->mu()/this->rho_)/(omega_*sqr(y_)),
        scalar(10)
    );

    return 1 - tanh(pow4(arg3));
}


template<class BasicEddyViscosityModel>
tmp<volScalarField> kOmegaSSTBase<BasicEddyViscosityModel>::F23() const
{
    tmp<volScalarField> f23(F2());

    if (F3_)
    {
108
        f23.ref() *= F3();
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    }

    return f23;
}


template<class BasicEddyViscosityModel>
void kOmegaSSTBase<BasicEddyViscosityModel>::correctNut
(
    const volScalarField& S2
)
{
    // Correct the turbulence viscosity
    this->nut_ = a1_*k_/max(a1_*omega_, b1_*F23()*sqrt(S2));
    this->nut_.correctBoundaryConditions();
124
    fv::options::New(this->mesh_).correct(this->nut_);
125 126 127 128 129 130 131 132 133 134
}


template<class BasicEddyViscosityModel>
void kOmegaSSTBase<BasicEddyViscosityModel>::correctNut()
{
    correctNut(2*magSqr(symm(fvc::grad(this->U_))));
}


135 136 137 138 139 140 141 142 143 144 145 146 147 148
template<class BasicEddyViscosityModel>
tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::Pk
(
    const volScalarField::Internal& G
) const
{
    return min(G, (c1_*betaStar_)*this->k_()*this->omega_());
}


template<class BasicEddyViscosityModel>
tmp<volScalarField::Internal>
kOmegaSSTBase<BasicEddyViscosityModel>::epsilonByk
(
149 150
    const volScalarField& F1,
    const volTensorField& gradU
151 152 153 154 155 156
) const
{
    return betaStar_*omega_();
}


157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
template<class BasicEddyViscosityModel>
tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::GbyNu
(
    const volScalarField::Internal& GbyNu0,
    const volScalarField::Internal& F2,
    const volScalarField::Internal& S2
) const
{
    return min
    (
        GbyNu0,
        (c1_/a1_)*betaStar_*omega_()
       *max(a1_*omega_(), b1_*F2*sqrt(S2))
    );
}


174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
template<class BasicEddyViscosityModel>
tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::kSource() const
{
    return tmp<fvScalarMatrix>
    (
        new fvScalarMatrix
        (
            k_,
            dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
        )
    );
}


template<class BasicEddyViscosityModel>
tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::omegaSource() const
{
    return tmp<fvScalarMatrix>
    (
        new fvScalarMatrix
        (
            omega_,
            dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
        )
    );
}


template<class BasicEddyViscosityModel>
tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::Qsas
(
205 206 207
    const volScalarField::Internal& S2,
    const volScalarField::Internal& gamma,
    const volScalarField::Internal& beta
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
) const
{
    return tmp<fvScalarMatrix>
    (
        new fvScalarMatrix
        (
            omega_,
            dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
        )
    );
}


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

template<class BasicEddyViscosityModel>
kOmegaSSTBase<BasicEddyViscosityModel>::kOmegaSSTBase
(
    const word& type,
    const alphaField& alpha,
    const rhoField& rho,
    const volVectorField& U,
    const surfaceScalarField& alphaRhoPhi,
    const surfaceScalarField& phi,
    const transportModel& transport,
    const word& propertiesName
)
:
    BasicEddyViscosityModel
    (
        type,
        alpha,
        rho,
        U,
        alphaRhoPhi,
        phi,
        transport,
        propertiesName
    ),

    alphaK1_
    (
250
        dimensioned<scalar>::getOrAddToDict
251 252 253 254 255 256 257 258
        (
            "alphaK1",
            this->coeffDict_,
            0.85
        )
    ),
    alphaK2_
    (
259
        dimensioned<scalar>::getOrAddToDict
260 261 262 263 264 265 266 267
        (
            "alphaK2",
            this->coeffDict_,
            1.0
        )
    ),
    alphaOmega1_
    (
268
        dimensioned<scalar>::getOrAddToDict
269 270 271 272 273 274 275 276
        (
            "alphaOmega1",
            this->coeffDict_,
            0.5
        )
    ),
    alphaOmega2_
    (
277
        dimensioned<scalar>::getOrAddToDict
278 279 280 281 282 283 284 285
        (
            "alphaOmega2",
            this->coeffDict_,
            0.856
        )
    ),
    gamma1_
    (
286
        dimensioned<scalar>::getOrAddToDict
287 288 289 290 291 292 293 294
        (
            "gamma1",
            this->coeffDict_,
            5.0/9.0
        )
    ),
    gamma2_
    (
295
        dimensioned<scalar>::getOrAddToDict
296 297 298 299 300 301 302 303
        (
            "gamma2",
            this->coeffDict_,
            0.44
        )
    ),
    beta1_
    (
304
        dimensioned<scalar>::getOrAddToDict
305 306 307 308 309 310 311 312
        (
            "beta1",
            this->coeffDict_,
            0.075
        )
    ),
    beta2_
    (
313
        dimensioned<scalar>::getOrAddToDict
314 315 316 317 318 319 320 321
        (
            "beta2",
            this->coeffDict_,
            0.0828
        )
    ),
    betaStar_
    (
322
        dimensioned<scalar>::getOrAddToDict
323 324 325 326 327 328 329 330
        (
            "betaStar",
            this->coeffDict_,
            0.09
        )
    ),
    a1_
    (
331
        dimensioned<scalar>::getOrAddToDict
332 333 334 335 336 337 338 339
        (
            "a1",
            this->coeffDict_,
            0.31
        )
    ),
    b1_
    (
340
        dimensioned<scalar>::getOrAddToDict
341 342 343 344 345 346 347 348
        (
            "b1",
            this->coeffDict_,
            1.0
        )
    ),
    c1_
    (
349
        dimensioned<scalar>::getOrAddToDict
350 351 352 353 354 355 356 357
        (
            "c1",
            this->coeffDict_,
            10.0
        )
    ),
    F3_
    (
358
        Switch::getOrAddToDict
359 360 361 362 363 364 365 366 367 368 369 370 371
        (
            "F3",
            this->coeffDict_,
            false
        )
    ),

    y_(wallDist::New(this->mesh_).y()),

    k_
    (
        IOobject
        (
372
            IOobject::groupName("k", alphaRhoPhi.group()),
373 374 375 376 377 378 379 380 381 382 383
            this->runTime_.timeName(),
            this->mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        this->mesh_
    ),
    omega_
    (
        IOobject
        (
384
            IOobject::groupName("omega", alphaRhoPhi.group()),
385 386 387 388 389 390
            this->runTime_.timeName(),
            this->mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        this->mesh_
391 392 393
    ),
    decayControl_
    (
394
        Switch::getOrAddToDict
395 396 397 398 399 400 401 402
        (
            "decayControl",
            this->coeffDict_,
            false
        )
    ),
    kInf_
    (
403
        dimensioned<scalar>::getOrAddToDict
404 405 406 407 408 409 410 411 412
        (
            "kInf",
            this->coeffDict_,
            k_.dimensions(),
            0
        )
    ),
    omegaInf_
    (
413
        dimensioned<scalar>::getOrAddToDict
414 415 416 417 418 419
        (
            "omegaInf",
            this->coeffDict_,
            omega_.dimensions(),
            0
        )
420 421 422 423
    )
{
    bound(k_, this->kMin_);
    bound(omega_, this->omegaMin_);
424 425

    setDecayControl(this->coeffDict_);
426 427 428 429 430
}


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

431 432 433 434 435 436
template<class BasicEddyViscosityModel>
void kOmegaSSTBase<BasicEddyViscosityModel>::setDecayControl
(
    const dictionary& dict
)
{
437
    decayControl_.readIfPresent("decayControl", dict);
438 439 440

    if (decayControl_)
    {
441 442
        kInf_.read(dict);
        omegaInf_.read(dict);
443 444 445 446

        Info<< "    Employing decay control with kInf:" << kInf_
            << " and omegaInf:" << omegaInf_ << endl;
    }
447 448 449 450 451
    else
    {
        kInf_.value() = 0;
        omegaInf_.value() = 0;
    }
452 453 454
}


455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
template<class BasicEddyViscosityModel>
bool kOmegaSSTBase<BasicEddyViscosityModel>::read()
{
    if (BasicEddyViscosityModel::read())
    {
        alphaK1_.readIfPresent(this->coeffDict());
        alphaK2_.readIfPresent(this->coeffDict());
        alphaOmega1_.readIfPresent(this->coeffDict());
        alphaOmega2_.readIfPresent(this->coeffDict());
        gamma1_.readIfPresent(this->coeffDict());
        gamma2_.readIfPresent(this->coeffDict());
        beta1_.readIfPresent(this->coeffDict());
        beta2_.readIfPresent(this->coeffDict());
        betaStar_.readIfPresent(this->coeffDict());
        a1_.readIfPresent(this->coeffDict());
        b1_.readIfPresent(this->coeffDict());
        c1_.readIfPresent(this->coeffDict());
        F3_.readIfPresent("F3", this->coeffDict());

474 475
        setDecayControl(this->coeffDict());

476 477
        return true;
    }
478 479

    return false;
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
}


template<class BasicEddyViscosityModel>
void kOmegaSSTBase<BasicEddyViscosityModel>::correct()
{
    if (!this->turbulence_)
    {
        return;
    }

    // Local references
    const alphaField& alpha = this->alpha_;
    const rhoField& rho = this->rho_;
    const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
    const volVectorField& U = this->U_;
    volScalarField& nut = this->nut_;
497
    fv::options& fvOptions(fv::options::New(this->mesh_));
498 499 500

    BasicEddyViscosityModel::correct();

501
    volScalarField::Internal divU(fvc::div(fvc::absolute(this->phi(), U)));
502 503 504

    tmp<volTensorField> tgradU = fvc::grad(U);
    volScalarField S2(2*magSqr(symm(tgradU())));
505 506 507 508 509
    volScalarField::Internal GbyNu0
    (
        this->type() + ":GbyNu",
        (tgradU() && dev(twoSymm(tgradU())))
    );
510
    volScalarField::Internal G(this->GName(), nut*GbyNu0);
511 512

    // Update omega and G at the wall
513
    omega_.boundaryFieldRef().updateCoeffs();
514 515 516 517 518 519 520

    volScalarField CDkOmega
    (
        (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_
    );

    volScalarField F1(this->F1(CDkOmega));
521
    volScalarField F23(this->F23());
522 523

    {
524 525
        volScalarField::Internal gamma(this->gamma(F1));
        volScalarField::Internal beta(this->beta(F1));
526

527 528
        GbyNu0 = GbyNu(GbyNu0, F23(), S2());

529 530 531 532 533 534 535
        // Turbulent frequency equation
        tmp<fvScalarMatrix> omegaEqn
        (
            fvm::ddt(alpha, rho, omega_)
          + fvm::div(alphaRhoPhi, omega_)
          - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)
         ==
536
            alpha()*rho()*gamma*GbyNu0
537 538
          - fvm::SuSp((2.0/3.0)*alpha()*rho()*gamma*divU, omega_)
          - fvm::Sp(alpha()*rho()*beta*omega_(), omega_)
539 540
          - fvm::SuSp
            (
541
                alpha()*rho()*(F1() - scalar(1))*CDkOmega()/omega_(),
542 543
                omega_
            )
544
          + alpha()*rho()*beta*sqr(omegaInf_)
545
          + Qsas(S2(), gamma, beta)
546
          + omegaSource()
547
          + fvOptions(alpha, rho, omega_)
548 549
        );

550 551
        omegaEqn.ref().relax();
        fvOptions.constrain(omegaEqn.ref());
552
        omegaEqn.ref().boundaryManipulate(omega_.boundaryFieldRef());
553
        solve(omegaEqn);
554
        fvOptions.correct(omega_);
555 556 557 558 559 560 561 562 563 564
        bound(omega_, this->omegaMin_);
    }

    // Turbulent kinetic energy equation
    tmp<fvScalarMatrix> kEqn
    (
        fvm::ddt(alpha, rho, k_)
      + fvm::div(alphaRhoPhi, k_)
      - fvm::laplacian(alpha*rho*DkEff(F1), k_)
     ==
565 566 567
        alpha()*rho()*Pk(G)
      - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
      - fvm::Sp(alpha()*rho()*epsilonByk(F1, tgradU()), k_)
568
      + alpha()*rho()*betaStar_*omegaInf_*kInf_
569
      + kSource()
570
      + fvOptions(alpha, rho, k_)
571 572
    );

573 574
    tgradU.clear();

575 576
    kEqn.ref().relax();
    fvOptions.constrain(kEqn.ref());
577
    solve(kEqn);
578
    fvOptions.correct(k_);
579 580 581 582 583 584 585 586 587 588 589
    bound(k_, this->kMin_);

    correctNut(S2);
}


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

} // End namespace Foam

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