diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C index a1337802ec..1c7a597c05 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C @@ -45,6 +45,9 @@ makeBaseTurbulenceModel #include "Stokes.H" makeLaminarModel(Stokes); +#include "generalizedNewtonian.H" +makeLaminarModel(generalizedNewtonian); + #include "Maxwell.H" makeLaminarModel(Maxwell); diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C index da6865492a..d1a4ec52f3 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C @@ -44,6 +44,9 @@ makeBaseTurbulenceModel #include "Stokes.H" makeLaminarModel(Stokes); +#include "generalizedNewtonian.H" +makeLaminarModel(generalizedNewtonian); + #include "Maxwell.H" makeLaminarModel(Maxwell); diff --git a/src/TurbulenceModels/turbulenceModels/Make/files b/src/TurbulenceModels/turbulenceModels/Make/files index 6f35baae18..4bdf69cbe1 100644 --- a/src/TurbulenceModels/turbulenceModels/Make/files +++ b/src/TurbulenceModels/turbulenceModels/Make/files @@ -63,5 +63,14 @@ RASBCs = RAS/derivedFvPatchFields $(RASBCs)/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C $(RASBCs)/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +generalizedNewtonianViscosityModels = laminar/generalizedNewtonian/generalizedNewtonianViscosityModels +$(generalizedNewtonianViscosityModels)/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.C +$(generalizedNewtonianViscosityModels)/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C +$(generalizedNewtonianViscosityModels)/CrossPowerLaw/CrossPowerLaw.C +$(generalizedNewtonianViscosityModels)/BirdCarreau/BirdCarreau.C +$(generalizedNewtonianViscosityModels)/Casson/Casson.C +$(generalizedNewtonianViscosityModels)/HerschelBulkley/HerschelBulkley.C +$(generalizedNewtonianViscosityModels)/powerLaw/powerLaw.C +$(generalizedNewtonianViscosityModels)/strainRateFunction/strainRateFunction.C LIB = $(FOAM_LIBBIN)/libturbulenceModels diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.C new file mode 100644 index 0000000000..5f260ca145 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.C @@ -0,0 +1,264 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "generalizedNewtonian.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvcGrad.H" +#include "fvcDiv.H" +#include "fvmLaplacian.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +generalizedNewtonian::generalizedNewtonian +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +: + linearViscousStress> + ( + typeName, + alpha, + rho, + U, + alphaRhoPhi, + phi, + transport, + propertiesName + ), + + viscosityModel_ + ( + generalizedNewtonianViscosityModel::New + ( + this->coeffDict_ + ) + ), + + nu_ + ( + IOobject + ( + IOobject::groupName("generalizedNewtonian:nu", alphaRhoPhi.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + viscosityModel_->nu(this->nu(), strainRate()) + ) +{} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +Foam::tmp +generalizedNewtonian::strainRate() const +{ + return sqrt(2.0)*mag(symm(fvc::grad(this->U()))); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool generalizedNewtonian::read() +{ + viscosityModel_->read(this->coeffDict_); + + return true; +} + + +template +tmp +generalizedNewtonian::nut() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + IOobject::groupName("nut", this->alphaRhoPhi_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedScalar("nut", dimViscosity, 0.0) + ) + ); +} + + +template +tmp +generalizedNewtonian::nut +( + const label patchi +) const +{ + return tmp + ( + new scalarField(this->mesh_.boundary()[patchi].size(), 0.0) + ); +} + + +template +tmp +generalizedNewtonian::nuEff() const +{ + return tmp + ( + new volScalarField + ( + IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), nu_ + ) + ); +} + + +template +tmp +generalizedNewtonian::nuEff +( + const label patchi +) const +{ + return nu_.boundaryField()[patchi]; +} + + +template +tmp +generalizedNewtonian::k() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + IOobject::groupName("k", this->alphaRhoPhi_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedScalar("k", sqr(this->U_.dimensions()), 0.0) + ) + ); +} + + +template +tmp +generalizedNewtonian::epsilon() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedScalar + ( + "epsilon", sqr(this->U_.dimensions())/dimTime, 0.0 + ) + ) + ); +} + + +template +tmp +generalizedNewtonian::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + IOobject::groupName("R", this->alphaRhoPhi_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedSymmTensor + ( + "R", sqr(this->U_.dimensions()), Zero + ) + ) + ); +} + + +template +void generalizedNewtonian::correct() +{ + nu_ = viscosityModel_->nu(this->nu(), strainRate()); + laminarModel::correct(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace laminarModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.H new file mode 100644 index 0000000000..c4d9a51ad4 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonian.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonian + +Description + Turbulence model for shear-dependent Non-Newtonian flow. + +SourceFiles + generalizedNewtonian.C + +\*---------------------------------------------------------------------------*/ + +#ifndef generalizedNewtonian_H +#define generalizedNewtonian_H + +#include "laminarModel.H" +#include "linearViscousStress.H" +#include "generalizedNewtonianViscosityModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ + +/*---------------------------------------------------------------------------*\ + Class generalizedNewtonian Declaration +\*---------------------------------------------------------------------------*/ + +template +class generalizedNewtonian +: + public linearViscousStress> +{ + +protected: + + // Protected data + + //- Run-time selectable non-Newtonian viscosity model + autoPtr viscosityModel_; + + //- The non-Newtonian viscosity field + volScalarField nu_; + + + // Protected Member Functions + + virtual tmp strainRate() const; + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("generalizedNewtonian"); + + + // Constructors + + //- Construct from components + generalizedNewtonian + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~generalizedNewtonian() + {} + + + // Member Functions + + //- Read turbulenceProperties dictionary + virtual bool read(); + + //- Return the turbulence viscosity, + // i.e. 0 for generalized Newtonian flow + virtual tmp nut() const; + + //- Return the turbulence viscosity on patch + virtual tmp nut(const label patchi) const; + + //- Return the effective viscosity + // i.e. the generalizedNewtonian viscosity + virtual tmp nuEff() const; + + //- Return the effective viscosity on patch + virtual tmp nuEff(const label patchi) const; + + //- Return the turbulence kinetic energy + // i.e. 0 for generalizedNewtonian flow + virtual tmp k() const; + + //- Return the turbulence kinetic energy dissipation rate, + // i.e. 0 for generalizedNewtonian flow + virtual tmp epsilon() const; + + //- Return the Reynolds stress tensor + // i.e. 0 for generalizedNewtonian flow + virtual tmp R() const; + + //- Correct the generalizedNewtonian viscosity + virtual void correct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "generalizedNewtonian.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.C new file mode 100644 index 0000000000..1c7f47f253 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.C @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "BirdCarreau.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(BirdCarreau, 0); + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + BirdCarreau, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::BirdCarreau:: +BirdCarreau +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + nuInf_("nuInf", dimViscosity, 0), + k_("k", dimTime, 0), + tauStar_( "tauStar", dimViscosity/dimTime, 0), + n_("n", dimless, 0), + a_("a", dimless, 2) +{ + read(viscosityProperties); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels::BirdCarreau:: +read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + const dictionary& coeffs = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + coeffs.lookup("nuInf") >> nuInf_; + + if (coeffs.found("tauStar")) + { + coeffs.lookup("tauStar") >> tauStar_; + } + else + { + coeffs.lookup("k") >> k_; + } + + coeffs.lookup("n") >> n_; + + a_ = coeffs.lookupOrDefault + ( + "a", + dimensionedScalar("a", dimless, 2) + ); + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::BirdCarreau:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + return + nuInf_ + + (nu0 - nuInf_) + *pow + ( + scalar(1) + + pow + ( + tauStar_.value() > 0 + ? nu0*strainRate/tauStar_ + : k_*strainRate, + a_ + ), + (n_ - 1.0)/a_ + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.H new file mode 100644 index 0000000000..177b4451fa --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/BirdCarreau/BirdCarreau.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::BirdCarreau + +Description + Bird-Carreau generalized Newtonian viscosity model + + The Bird-Carreau-Yasuda form is also supported if the optional \c a + coefficient is specified. \c a defaults to 2 for the Bird-Carreau model. + + The strain rate coefficient can be specified either as the constant \c k or + the critical stress level at the transition to shear thinning \c + tauStar if \c tauStar is provided: + + Kinematic viscosity [m^2/s] + + \f[ + \nu = \nu_\infty\, + + (\nu_0 - \nu_\infty)\, + \left(1 + (k\gamma)^a \right)^{(n - 1)/a} + \f] + + or + + \f[ + \nu = \nu_\infty + + (\nu_0 - \nu_\infty) + \left(1 + (\frac{\nu_0\gamma}{\tau^*} )^a \right)^{(n - 1)/a} + \f] + + Example specification for a polymer: + \verbatim + viscosityModel BirdCarreau; + + nuInf 0; + tauStar 90; + n 0.5; + \endverbatim + +SourceFiles + BirdCarreau.C + +\*---------------------------------------------------------------------------*/ + +#ifndef BirdCarreau_H +#define BirdCarreau_H + +#include "generalizedNewtonianViscosityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class BirdCarreau Declaration +\*---------------------------------------------------------------------------*/ + +class BirdCarreau +: + public generalizedNewtonianViscosityModel +{ + // Private data + + dimensionedScalar nuInf_; + dimensionedScalar k_; + dimensionedScalar tauStar_; + dimensionedScalar n_; + dimensionedScalar a_; + + +public: + + //- Runtime type information + TypeName("BirdCarreau"); + + + // Constructors + + //- Construct from components + BirdCarreau(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~BirdCarreau() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.C new file mode 100644 index 0000000000..1e9396e282 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.C @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "Casson.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(Casson, 0); + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + Casson, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::Casson::Casson +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + m_("m", dimViscosity, 0), + tau0_("tau0", dimViscosity/dimTime, 0), + nuMin_("nuMin", dimViscosity, 0), + nuMax_("nuMax", dimViscosity, 0) +{ + read(viscosityProperties); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels::Casson::read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + const dictionary& coeffs = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + coeffs.lookup("m") >> m_; + coeffs.lookup("tau0") >> tau0_; + coeffs.lookup("nuMin_") >> nuMin_; + coeffs.lookup("nuMax_") >> nuMax_; + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::Casson:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + return max + ( + nuMin_, + min + ( + nuMax_, + sqr + ( + sqrt + ( + tau0_ + /max + ( + strainRate, + dimensionedScalar("vSmall", dimless/dimTime, vSmall) + ) + ) + sqrt(m_) + ) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.H new file mode 100644 index 0000000000..7a46f0fbec --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/Casson/Casson.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::Casson + +Description + Casson generalized Newtonian viscosity model + + References: + \verbatim + Casson, N. (1959). + Rheology of disperse systems. + In Proceedings of a Conference Organized by the + British Society of Rheology. + Pergamon Press, New York. + + Fournier, R. L. (2011). + Basic transport phenomena in biomedical engineering. + CRC Press. + \endverbatim + + Example specification for blood: + \verbatim + viscosityModel Casson; + + m 3.934986e-6; + tau0 2.9032e-6; + nuMax 13.3333e-6; + nuMin 3.9047e-6; + \endverbatim + +SourceFiles + Casson.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Casson_H +#define Casson_H + +#include "generalizedNewtonianViscosityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + + +/*---------------------------------------------------------------------------*\ + Class Casson Declaration +\*---------------------------------------------------------------------------*/ + +class Casson +: + public generalizedNewtonianViscosityModel +{ + // Private data + + dimensionedScalar m_; + dimensionedScalar tau0_; + dimensionedScalar nuMin_; + dimensionedScalar nuMax_; + + +public: + + //- Runtime type information + TypeName("Casson"); + + + // Constructors + + //- Construct from components + Casson(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~Casson() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.C new file mode 100644 index 0000000000..f6cbb8560b --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.C @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "CrossPowerLaw.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(CrossPowerLaw, 0); + + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + CrossPowerLaw, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::CrossPowerLaw:: +CrossPowerLaw +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + nuInf_("nuInf", dimViscosity, 0), + m_("m", dimTime, 0), + tauStar_( "tauStar", dimViscosity/dimTime, 0), + n_("n", dimless, 0) +{ + read(viscosityProperties); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels::CrossPowerLaw:: +read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + const dictionary& coeffs = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + coeffs.lookup("nuInf") >> nuInf_; + + if (coeffs.found("tauStar")) + { + coeffs.lookup("tauStar") >> tauStar_; + } + else + { + coeffs.lookup("m") >> m_; + } + + coeffs.lookup("n") >> n_; + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::CrossPowerLaw:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + return + nuInf_ + + (nu0 - nuInf_) + /( + scalar(1) + + pow + ( + tauStar_.value() > 0 + ? nu0*strainRate/tauStar_ + : m_*strainRate, + n_ + ) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.H new file mode 100644 index 0000000000..7a91e33ae6 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/CrossPowerLaw/CrossPowerLaw.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::CrossPowerLaw + +Description + Cross-Power law generalized Newtonian viscosity model + + The strain rate coefficient can be specified either as the constant \c m or + the critical stress level at the transition to shear thinning \c + tauStar if \c tauStar is provided: + + Kinematic viscosity [m^2/s] + + \f[ + \nu = \nu_\infty + \frac{(\nu_0 - \nu_\infty)}{1 + (m\gamma)^n} + \f] + + or + + \f[ + \nu = \nu_\infty + + \frac{(\nu_0 - \nu_\infty)} + {1 + \left(\frac{\nu_0\gamma}{\tau^*}\right)^n} + \f] + + Example specification: + \verbatim + viscosityModel CrossPowerLaw; + + nuInf 10; + m 0.4; + n 3; + \endverbatim + +SourceFiles + CrossPowerLaw.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CrossPowerLaw_H +#define CrossPowerLaw_H + +#include "generalizedNewtonianViscosityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class CrossPowerLaw Declaration +\*---------------------------------------------------------------------------*/ + +class CrossPowerLaw +: + public generalizedNewtonianViscosityModel +{ + // Private data + + dimensionedScalar nuInf_; + dimensionedScalar m_; + dimensionedScalar tauStar_; + dimensionedScalar n_; + + +public: + + //- Runtime type information + TypeName("CrossPowerLaw"); + + + // Constructors + + //- Construct from components + CrossPowerLaw(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~CrossPowerLaw() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.C new file mode 100644 index 0000000000..d437f785ce --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.C @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "HerschelBulkley.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(HerschelBulkley, 0); + + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + HerschelBulkley, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::HerschelBulkley:: +HerschelBulkley +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + k_("k", dimViscosity, 0), + n_("n", dimless, 0), + tau0_("tau0", dimViscosity/dimTime, 0) +{ + read(viscosityProperties); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels:: +HerschelBulkley::read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + const dictionary& coeffs = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + coeffs.lookup("k") >> k_; + coeffs.lookup("n") >> n_; + coeffs.lookup("tau0") >> tau0_; + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::HerschelBulkley:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + dimensionedScalar tone("tone", dimTime, 1.0); + dimensionedScalar rtone("rtone", dimless/dimTime, 1.0); + + return + ( + min + ( + nu0, + (tau0_ + k_*rtone*pow(tone*strainRate, n_)) + /max + ( + strainRate, + dimensionedScalar ("vSmall", dimless/dimTime, vSmall) + ) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.H new file mode 100644 index 0000000000..ebca13c10e --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/HerschelBulkley/HerschelBulkley.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::HerschelBulkley + +Description + Herschel-Bulkley generalized Newtonian viscosity model + +SourceFiles + HerschelBulkley.C + +\*---------------------------------------------------------------------------*/ + +#ifndef HerschelBulkley_H +#define HerschelBulkley_H + +#include "generalizedNewtonianViscosityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class HerschelBulkley Declaration +\*---------------------------------------------------------------------------*/ + +class HerschelBulkley +: + public generalizedNewtonianViscosityModel +{ + // Private data + + dimensionedScalar k_; + dimensionedScalar n_; + dimensionedScalar tau0_; + + +public: + + //- Runtime type information + TypeName("HerschelBulkley"); + + + // Constructors + + //- Construct from components + HerschelBulkley(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~HerschelBulkley() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.C new file mode 100644 index 0000000000..a5d92d5097 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "generalizedNewtonianViscosityModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ + defineTypeNameAndDebug(generalizedNewtonianViscosityModel, 0); + defineRunTimeSelectionTable(generalizedNewtonianViscosityModel, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModel:: +generalizedNewtonianViscosityModel +( + const dictionary& viscosityProperties +) +: + viscosityProperties_(viscosityProperties) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModel::read +( + const dictionary& viscosityProperties +) +{ + viscosityProperties_ = viscosityProperties; + + return true; +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.H new file mode 100644 index 0000000000..eebb57559e --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModel.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 . + +Namespace + Foam::laminarModels::generalizedNewtonianViscosityModels + +Description + A namespace for various generalized Newtonian viscosity model + implementations. + +Class + Foam::laminarModels::generalizedNewtonianViscosityModel + +Description + An abstract base class for generalized Newtonian viscosity models. + +SourceFiles + generalizedNewtonianViscosityModel.C + generalizedNewtonianViscosityModelNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef generalizedNewtonianViscosityModel_H +#define generalizedNewtonianViscosityModel_H + +#include "dictionary.H" +#include "volFieldsFwd.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ + +/*---------------------------------------------------------------------------*\ + Class generalizedNewtonianViscosityModel Declaration +\*---------------------------------------------------------------------------*/ + +class generalizedNewtonianViscosityModel +{ + +protected: + + // Protected data + + dictionary viscosityProperties_; + + + // Private Member Functions + + //- Disallow copy construct + generalizedNewtonianViscosityModel + ( + const generalizedNewtonianViscosityModel& + ); + + //- Disallow default bitwise assignment + void operator=(const generalizedNewtonianViscosityModel&); + + +public: + + //- Runtime type information + TypeName("generalizedNewtonianViscosityModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + generalizedNewtonianViscosityModel, + dictionary, + ( + const dictionary& viscosityProperties + ), + (viscosityProperties) + ); + + + // Selectors + + //- Return a reference to the selected viscosity model + static autoPtr New + ( + const dictionary& viscosityProperties + ); + + + // Constructors + + //- Construct from components + generalizedNewtonianViscosityModel + ( + const dictionary& viscosityProperties + ); + + + //- Destructor + virtual ~generalizedNewtonianViscosityModel() + {} + + + // Member Functions + + //- Return the phase transport properties dictionary + const dictionary& viscosityProperties() const + { + return viscosityProperties_; + } + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const = 0; + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C new file mode 100644 index 0000000000..20c6c783c9 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "generalizedNewtonianViscosityModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr +Foam::laminarModels::generalizedNewtonianViscosityModel::New +( + const dictionary& viscosityProperties +) +{ + const word modelType + ( + viscosityProperties.lookup("viscosityModel") + ); + + Info<< "Selecting generalized Newtonian model " << modelType << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(modelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown generalizedNewtonianViscosityModel type " + << modelType << nl << nl + << "Valid generalizedNewtonianViscosityModels are : " << endl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(viscosityProperties) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.C new file mode 100644 index 0000000000..0964ca8f38 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.C @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "powerLaw.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(powerLaw, 0); + + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + powerLaw, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::powerLaw::powerLaw +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + k_("k", dimViscosity, 0), + n_("n", dimless, 0), + nuMin_("nuMin", dimViscosity, 0), + nuMax_("nuMax", dimViscosity, 0) +{ + read(viscosityProperties); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels::powerLaw::read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + const dictionary& coeffs = + viscosityProperties.optionalSubDict(typeName + "Coeffs"); + + coeffs.lookup("k") >> k_; + coeffs.lookup("n") >> n_; + coeffs.lookup("nuMin") >> nuMin_; + coeffs.lookup("nuMax") >> nuMax_; + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::powerLaw:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + return max + ( + nuMin_, + min + ( + nuMax_, + k_*pow + ( + max + ( + dimensionedScalar("one", dimTime, 1.0)*strainRate, + dimensionedScalar("small", dimless, small) + ), + n_.value() - scalar(1) + ) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.H new file mode 100644 index 0000000000..c4579cbd01 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/powerLaw/powerLaw.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::powerLaw + +Description + Standard power-law generalized Newtonian viscosity model + +SourceFiles + powerLaw.C + +\*---------------------------------------------------------------------------*/ + +#ifndef powerLaw_H +#define powerLaw_H + +#include "generalizedNewtonianViscosityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class powerLaw Declaration +\*---------------------------------------------------------------------------*/ + +class powerLaw +: + public generalizedNewtonianViscosityModel +{ + // Private data + + dimensionedScalar k_; + dimensionedScalar n_; + dimensionedScalar nuMin_; + dimensionedScalar nuMax_; + + +public: + + //- Runtime type information + TypeName("powerLaw"); + + + // Constructors + + //- Construct from components + powerLaw(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~powerLaw() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.C new file mode 100644 index 0000000000..dd3d2c7099 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.C @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 "strainRateFunction.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + defineTypeNameAndDebug(strainRateFunction, 0); + + addToRunTimeSelectionTable + ( + generalizedNewtonianViscosityModel, + strainRateFunction, + dictionary + ); +} +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction:: +strainRateFunction +( + const dictionary& viscosityProperties +) +: + generalizedNewtonianViscosityModel(viscosityProperties), + strainRateFunction_ + ( + Function1::New + ( + "function", + viscosityProperties.optionalSubDict(typeName + "Coeffs") + ) + ) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::laminarModels::generalizedNewtonianViscosityModels:: +strainRateFunction::read +( + const dictionary& viscosityProperties +) +{ + generalizedNewtonianViscosityModel::read(viscosityProperties); + + strainRateFunction_.clear(); + strainRateFunction_ = Function1::New + ( + "function", + viscosityProperties.optionalSubDict + ( + typeName + "Coeffs" + ) + ); + + return true; +} + + +Foam::tmp +Foam::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction:: +nu +( + const volScalarField& nu0, + const volScalarField& strainRate +) const +{ + tmp tnu + ( + new volScalarField + ( + IOobject + ( + IOobject::groupName(type() + ":nu", nu0.group()), + nu0.time().timeName(), + nu0.db(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + nu0.mesh(), + dimensionedScalar("0", dimViscosity, 0) + ) + ); + + tnu.ref().primitiveFieldRef() = strainRateFunction_->value(strainRate); + + volScalarField::Boundary& nuBf = tnu.ref().boundaryFieldRef(); + const volScalarField::Boundary& sigmaBf = strainRate.boundaryField(); + + forAll(nuBf, patchi) + { + nuBf[patchi] = strainRateFunction_->value(sigmaBf[patchi]); + } + + return tnu; +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.H b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.H new file mode 100644 index 0000000000..3949daf996 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/strainRateFunction/strainRateFunction.H @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction + +Description + Run-time selected strain-rate function generalized Newtonian viscosity model + + Example linear function of strain-rate: + \verbatim + generalizedNewtonianModel strainRateFunction; + + function polynomial ((0 0.1) (1 1.3)); + \endverbatim + +See also + Foam::generalizedNewtonianViscosityModel + Foam::Function1 + +SourceFiles + strainRateFunction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef strainRateFunction_H +#define strainRateFunction_H + +#include "generalizedNewtonianViscosityModel.H" +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace laminarModels +{ +namespace generalizedNewtonianViscosityModels +{ + +/*---------------------------------------------------------------------------*\ + Class strainRateFunction Declaration +\*---------------------------------------------------------------------------*/ + +class strainRateFunction +: + public generalizedNewtonianViscosityModel +{ + // Private data + + //- Strain-rate function + autoPtr> strainRateFunction_; + + +public: + + //- Runtime type information + TypeName("strainRateFunction"); + + + // Constructors + + //- Construct from components + strainRateFunction(const dictionary& viscosityProperties); + + + //- Destructor + virtual ~strainRateFunction() + {} + + + // Member Functions + + //- Read transportProperties dictionary + virtual bool read(const dictionary& viscosityProperties); + + //- Return the laminar viscosity + virtual tmp nu + ( + const volScalarField& nu0, + const volScalarField& strainRate + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace generalizedNewtonianViscosityModels +} // End namespace laminarModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //