TurbulenceModels: Created a general base-class and selection mechanism for laminar stress models

Renamed the original 'laminar' model to 'Stokes' to indicate it is a
linear stress model supporting both Newtonian and non-Newtonian
viscosity.

This general framework will support linear, non-linear, visco-elastic
etc. laminar transport models.

For backward compatibility the 'Stokes' laminar stress model can be
selected either the original 'laminar' 'simulationType'
specification in turbulenceProperties:

    simulationType laminar;

or using the new more general 'laminarModel' specification:

    simulationType laminar;

    laminar
    {
        laminarModel        Stokes;
    }

which allows other laminar stress models to be selected.
This commit is contained in:
Henry Weller
2016-09-20 15:05:43 +01:00
parent eb8d593df2
commit 855f424635
18 changed files with 750 additions and 87 deletions

View File

@ -28,8 +28,8 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H" #include "makeTurbulenceModel.H"
#include "laminar.H" #include "laminarModel.H"
#include "turbulentTransportModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,6 +52,10 @@ makeBaseTurbulenceModel
singlePhaseTransportModel singlePhaseTransportModel
); );
#define makeLaminarModel(Type) \
makeTemplatedTurbulenceModel \
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type) (singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type)
@ -60,6 +64,9 @@ makeBaseTurbulenceModel
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type) (singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H" #include "kEpsilon.H"
makeRASModel(kEpsilon); makeRASModel(kEpsilon);

View File

@ -28,7 +28,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H" #include "makeTurbulenceModel.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -52,6 +52,14 @@ makeBaseTurbulenceModel
incompressibleTwoPhaseInteractingMixture incompressibleTwoPhaseInteractingMixture
); );
#define makeLaminarModel(Type) \
makeTemplatedTurbulenceModel \
( \
incompressibleTwoPhaseInteractingMixtureCompressibleTurbulenceModel, \
laminar, \
Type \
)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
( \ ( \
@ -68,6 +76,9 @@ makeBaseTurbulenceModel
Type \ Type \
) )
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H" #include "kEpsilon.H"
makeRASModel(kEpsilon); makeRASModel(kEpsilon);

View File

@ -27,7 +27,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H" #include "makeTurbulenceModel.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -53,6 +53,10 @@ makeBaseTurbulenceModel
phaseModel phaseModel
); );
#define makeLaminarModel(Type) \
makeTemplatedLaminarModel \
(phaseModelPhaseCompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, RAS, Type) (phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)
@ -61,6 +65,9 @@ makeBaseTurbulenceModel
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, LES, Type) (phaseModelPhaseCompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H" #include "kEpsilon.H"
makeRASModel(kEpsilon); makeRASModel(kEpsilon);

View File

@ -27,7 +27,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H" #include "makeTurbulenceModel.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -53,6 +53,10 @@ makeBaseTurbulenceModel
phaseModel phaseModel
); );
#define makeLaminarModel(Type) \
makeTemplatedLaminarModel \
(phaseModelPhaseCompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, RAS, Type) (phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)
@ -61,6 +65,9 @@ makeBaseTurbulenceModel
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, LES, Type) (phaseModelPhaseCompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H" #include "kEpsilon.H"
makeRASModel(kEpsilon); makeRASModel(kEpsilon);

View File

@ -32,7 +32,7 @@ License
#include "ThermalDiffusivity.H" #include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H" #include "EddyDiffusivity.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -58,6 +58,10 @@ makeBaseTurbulenceModel
phaseModel phaseModel
); );
#define makeLaminarModel(Type) \
makeTemplatedLaminarModel \
(phaseModelPhaseCompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, RAS, Type) (phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)
@ -66,6 +70,9 @@ makeBaseTurbulenceModel
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(phaseModelPhaseCompressibleTurbulenceModel, LES, Type) (phaseModelPhaseCompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H" #include "kEpsilon.H"
makeRASModel(kEpsilon); makeRASModel(kEpsilon);

View File

@ -34,7 +34,8 @@ License
{ \ { \
typedef TDModel<BaseModel<Transport>> \ typedef TDModel<BaseModel<Transport>> \
Transport##BaseModel; \ Transport##BaseModel; \
typedef laminar<Transport##BaseModel> Laminar##Transport##BaseModel; \ typedef laminarModel<Transport##BaseModel> \
laminar##Transport##BaseModel; \
typedef RASModel<EddyDiffusivity<Transport##BaseModel>> \ typedef RASModel<EddyDiffusivity<Transport##BaseModel>> \
RAS##Transport##BaseModel; \ RAS##Transport##BaseModel; \
typedef LESModel<EddyDiffusivity<Transport##BaseModel>> \ typedef LESModel<EddyDiffusivity<Transport##BaseModel>> \
@ -65,14 +66,18 @@ License
Transport##BaseModel; \ Transport##BaseModel; \
\ \
\ \
typedef laminar<Transport##BaseModel> Laminar##Transport##BaseModel; \ typedef laminarModel<Transport##BaseModel> \
laminar##Transport##BaseModel; \
\ \
defineNamedTemplateTypeNameAndDebug(Laminar##Transport##BaseModel, 0); \ defineNamedTemplateTypeNameAndDebug(laminar##Transport##BaseModel, 0); \
\
defineTemplateRunTimeSelectionTable \
(laminar##Transport##BaseModel, dictionary); \
\ \
addToRunTimeSelectionTable \ addToRunTimeSelectionTable \
( \ ( \
Transport##baseModel, \ Transport##baseModel, \
Laminar##Transport##BaseModel, \ laminar##Transport##BaseModel, \
dictionary \ dictionary \
); \ ); \
\ \
@ -110,6 +115,27 @@ License
} }
#define makeTemplatedLaminarModel(BaseModel, SType, Type) \
typedef Foam::SType##Models::Type<Foam::BaseModel> \
Type##SType##BaseModel; \
defineNamedTemplateTypeNameAndDebug(Type##SType##BaseModel, 0); \
\
namespace Foam \
{ \
namespace SType##Models \
{ \
typedef Type<BaseModel> Type##SType##BaseModel; \
\
addToRunTimeSelectionTable \
( \
SType##BaseModel, \
Type##SType##BaseModel, \
dictionary \
); \
} \
}
#define makeTemplatedTurbulenceModel(BaseModel, SType, Type) \ #define makeTemplatedTurbulenceModel(BaseModel, SType, Type) \
typedef Foam::SType##Models::Type<Foam::EddyDiffusivity<Foam::BaseModel>> \ typedef Foam::SType##Models::Type<Foam::EddyDiffusivity<Foam::BaseModel>> \
Type##SType##BaseModel; \ Type##SType##BaseModel; \

View File

@ -46,6 +46,7 @@ SourceFiles
#include "CompressibleTurbulenceModel.H" #include "CompressibleTurbulenceModel.H"
#include "ThermalDiffusivity.H" #include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H" #include "EddyDiffusivity.H"
#include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
#include "fluidThermo.H" #include "fluidThermo.H"
@ -59,6 +60,7 @@ namespace Foam
typedef ThermalDiffusivity<CompressibleTurbulenceModel<fluidThermo>> typedef ThermalDiffusivity<CompressibleTurbulenceModel<fluidThermo>>
turbulenceModel; turbulenceModel;
typedef laminarModel<turbulenceModel> laminarModel;
typedef RASModel<EddyDiffusivity<turbulenceModel>> RASModel; typedef RASModel<EddyDiffusivity<turbulenceModel>> RASModel;
typedef LESModel<EddyDiffusivity<turbulenceModel>> LESModel; typedef LESModel<EddyDiffusivity<turbulenceModel>> LESModel;

View File

@ -37,6 +37,15 @@ makeBaseTurbulenceModel
fluidThermo fluidThermo
); );
// -------------------------------------------------------------------------- //
// Laminar models
// -------------------------------------------------------------------------- //
#include "Stokes.H"
makeLaminarModel(Stokes);
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
// RAS models // RAS models
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //

View File

@ -32,7 +32,7 @@ License
#include "ThermalDiffusivity.H" #include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H" #include "EddyDiffusivity.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -48,6 +48,10 @@ makeTurbulenceModelTypes
fluidThermo fluidThermo
); );
#define makeLaminarModel(Type) \
makeTemplatedLaminarModel \
(fluidThermoCompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(fluidThermoCompressibleTurbulenceModel, RAS, Type) (fluidThermoCompressibleTurbulenceModel, RAS, Type)

View File

@ -44,6 +44,7 @@ SourceFiles
#define turbulentTransportModel_H #define turbulentTransportModel_H
#include "IncompressibleTurbulenceModel.H" #include "IncompressibleTurbulenceModel.H"
#include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
#include "incompressible/transportModel/transportModel.H" #include "incompressible/transportModel/transportModel.H"
@ -56,6 +57,7 @@ namespace Foam
{ {
typedef IncompressibleTurbulenceModel<transportModel> turbulenceModel; typedef IncompressibleTurbulenceModel<transportModel> turbulenceModel;
typedef laminarModel<turbulenceModel> laminarModel;
typedef RASModel<turbulenceModel> RASModel; typedef RASModel<turbulenceModel> RASModel;
typedef LESModel<turbulenceModel> LESModel; typedef LESModel<turbulenceModel> LESModel;

View File

@ -36,6 +36,15 @@ makeBaseTurbulenceModel
transportModel transportModel
); );
// -------------------------------------------------------------------------- //
// Laminar models
// -------------------------------------------------------------------------- //
#include "Stokes.H"
makeLaminarModel(Stokes);
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
// RAS models // RAS models
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //

View File

@ -28,7 +28,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H" #include "makeTurbulenceModel.H"
#include "laminar.H" #include "laminarModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "LESModel.H" #include "LESModel.H"
@ -43,6 +43,10 @@ makeTurbulenceModelTypes
transportModel transportModel
); );
#define makeLaminarModel(Type) \
makeTemplatedTurbulenceModel \
(transportModelIncompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \ #define makeRASModel(Type) \
makeTemplatedTurbulenceModel \ makeTemplatedTurbulenceModel \
(transportModelIncompressibleTurbulenceModel, RAS, Type) (transportModelIncompressibleTurbulenceModel, RAS, Type)

View File

@ -23,17 +23,24 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "laminar.H" #include "Stokes.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "fvcGrad.H" #include "fvcGrad.H"
#include "fvcDiv.H" #include "fvcDiv.H"
#include "fvmLaplacian.H" #include "fvmLaplacian.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace laminarModels
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::laminar<BasicTurbulenceModel>::laminar Stokes<BasicTurbulenceModel>::Stokes
( (
const alphaField& alpha, const alphaField& alpha,
const rhoField& rho, const rhoField& rho,
@ -44,7 +51,7 @@ Foam::laminar<BasicTurbulenceModel>::laminar
const word& propertiesName const word& propertiesName
) )
: :
linearViscousStress<BasicTurbulenceModel> linearViscousStress<laminarModel<BasicTurbulenceModel>>
( (
typeName, typeName,
alpha, alpha,
@ -58,57 +65,26 @@ Foam::laminar<BasicTurbulenceModel>::laminar
{} {}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
Foam::autoPtr<Foam::laminar<BasicTurbulenceModel>>
Foam::laminar<BasicTurbulenceModel>::New
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
{
return autoPtr<laminar>
(
new laminar
(
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport,
propertiesName
)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
const Foam::dictionary& const dictionary&
Foam::laminar<BasicTurbulenceModel>::coeffDict() const Stokes<BasicTurbulenceModel>::coeffDict() const
{ {
return dictionary::null; return dictionary::null;
} }
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
bool Foam::laminar<BasicTurbulenceModel>::read() bool Stokes<BasicTurbulenceModel>::read()
{ {
return true; return true;
} }
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField> tmp<volScalarField>
Foam::laminar<BasicTurbulenceModel>::nut() const Stokes<BasicTurbulenceModel>::nut() const
{ {
return tmp<volScalarField> return tmp<volScalarField>
( (
@ -131,8 +107,8 @@ Foam::laminar<BasicTurbulenceModel>::nut() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::scalarField> tmp<scalarField>
Foam::laminar<BasicTurbulenceModel>::nut Stokes<BasicTurbulenceModel>::nut
( (
const label patchi const label patchi
) const ) const
@ -145,8 +121,8 @@ Foam::laminar<BasicTurbulenceModel>::nut
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField> tmp<volScalarField>
Foam::laminar<BasicTurbulenceModel>::nuEff() const Stokes<BasicTurbulenceModel>::nuEff() const
{ {
return tmp<volScalarField> return tmp<volScalarField>
( (
@ -159,8 +135,8 @@ Foam::laminar<BasicTurbulenceModel>::nuEff() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::scalarField> tmp<scalarField>
Foam::laminar<BasicTurbulenceModel>::nuEff Stokes<BasicTurbulenceModel>::nuEff
( (
const label patchi const label patchi
) const ) const
@ -170,8 +146,8 @@ Foam::laminar<BasicTurbulenceModel>::nuEff
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField> tmp<volScalarField>
Foam::laminar<BasicTurbulenceModel>::k() const Stokes<BasicTurbulenceModel>::k() const
{ {
return tmp<volScalarField> return tmp<volScalarField>
( (
@ -194,8 +170,8 @@ Foam::laminar<BasicTurbulenceModel>::k() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField> tmp<volScalarField>
Foam::laminar<BasicTurbulenceModel>::epsilon() const Stokes<BasicTurbulenceModel>::epsilon() const
{ {
return tmp<volScalarField> return tmp<volScalarField>
( (
@ -221,8 +197,8 @@ Foam::laminar<BasicTurbulenceModel>::epsilon() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
Foam::tmp<Foam::volSymmTensorField> tmp<volSymmTensorField>
Foam::laminar<BasicTurbulenceModel>::R() const Stokes<BasicTurbulenceModel>::R() const
{ {
return tmp<volSymmTensorField> return tmp<volSymmTensorField>
( (
@ -248,10 +224,15 @@ Foam::laminar<BasicTurbulenceModel>::R() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
void Foam::laminar<BasicTurbulenceModel>::correct() void Stokes<BasicTurbulenceModel>::correct()
{ {
BasicTurbulenceModel::correct(); laminarModel<BasicTurbulenceModel>::correct();
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace laminarModels
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,34 +22,37 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::laminar Foam::Stokes
Description Description
Turbulence model for laminar flow. Turbulence model for Stokes flow.
SourceFiles SourceFiles
laminar.C Stokes.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef laminar_H #ifndef Stokes_H
#define laminar_H #define Stokes_H
#include "laminarModel.H"
#include "linearViscousStress.H" #include "linearViscousStress.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace laminarModels
{
/*---------------------------------------------------------------------------* \ /*---------------------------------------------------------------------------* \
Class laminar Declaration Class Stokes Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
class laminar class Stokes
: :
public linearViscousStress<BasicTurbulenceModel> public linearViscousStress<laminarModel<BasicTurbulenceModel>>
{ {
public: public:
@ -60,13 +63,13 @@ public:
//- Runtime type information //- Runtime type information
TypeName("laminar"); TypeName("Stokes");
// Constructors // Constructors
//- Construct from components //- Construct from components
laminar Stokes
( (
const alphaField& alpha, const alphaField& alpha,
const rhoField& rho, const rhoField& rho,
@ -81,7 +84,7 @@ public:
// Selectors // Selectors
//- Return a reference to the selected turbulence model //- Return a reference to the selected turbulence model
static autoPtr<laminar> New static autoPtr<Stokes> New
( (
const alphaField& alpha, const alphaField& alpha,
const rhoField& rho, const rhoField& rho,
@ -94,7 +97,7 @@ public:
//- Destructor //- Destructor
virtual ~laminar() virtual ~Stokes()
{} {}
@ -106,41 +109,42 @@ public:
//- Read turbulenceProperties dictionary //- Read turbulenceProperties dictionary
virtual bool read(); virtual bool read();
//- Return the turbulence viscosity, i.e. 0 for laminar flow //- Return the turbulence viscosity, i.e. 0 for Stokes flow
virtual tmp<volScalarField> nut() const; virtual tmp<volScalarField> nut() const;
//- Return the turbulence viscosity on patch //- Return the turbulence viscosity on patch
virtual tmp<scalarField> nut(const label patchi) const; virtual tmp<scalarField> nut(const label patchi) const;
//- Return the effective viscosity, i.e. the laminar viscosity //- Return the effective viscosity, i.e. the Stokes viscosity
virtual tmp<volScalarField> nuEff() const; virtual tmp<volScalarField> nuEff() const;
//- Return the effective viscosity on patch //- Return the effective viscosity on patch
virtual tmp<scalarField> nuEff(const label patchi) const; virtual tmp<scalarField> nuEff(const label patchi) const;
//- Return the turbulence kinetic energy, i.e. 0 for laminar flow //- Return the turbulence kinetic energy, i.e. 0 for Stokes flow
virtual tmp<volScalarField> k() const; virtual tmp<volScalarField> k() const;
//- Return the turbulence kinetic energy dissipation rate, //- Return the turbulence kinetic energy dissipation rate,
// i.e. 0 for laminar flow // i.e. 0 for Stokes flow
virtual tmp<volScalarField> epsilon() const; virtual tmp<volScalarField> epsilon() const;
//- Return the Reynolds stress tensor, i.e. 0 for laminar flow //- Return the Reynolds stress tensor, i.e. 0 for Stokes flow
virtual tmp<volSymmTensorField> R() const; virtual tmp<volSymmTensorField> R() const;
//- Correct the laminar viscosity //- Correct the Stokes viscosity
virtual void correct(); virtual void correct();
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace laminarModels
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "laminar.C" #include "Stokes.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,339 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "laminarModel.H"
#include "Stokes.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class BasicTurbulenceModel>
void Foam::laminarModel<BasicTurbulenceModel>::printCoeffs(const word& type)
{
if (printCoeffs_)
{
Info<< type << "Coeffs" << coeffDict_ << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
Foam::laminarModel<BasicTurbulenceModel>::laminarModel
(
const word& type,
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
:
BasicTurbulenceModel
(
type,
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport,
propertiesName
),
laminarDict_(this->subOrEmptyDict("laminar")),
printCoeffs_(laminarDict_.lookupOrDefault<Switch>("printCoeffs", false)),
coeffDict_(laminarDict_.subOrEmptyDict(type + "Coeffs"))
{
// Force the construction of the mesh deltaCoeffs which may be needed
// for the construction of the derived models and BCs
this->mesh_.deltaCoeffs();
}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
Foam::autoPtr<Foam::laminarModel<BasicTurbulenceModel>>
Foam::laminarModel<BasicTurbulenceModel>::New
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
{
IOdictionary modelDict
(
IOobject
(
IOobject::groupName(propertiesName, U.group()),
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
if (modelDict.found("laminar"))
{
// get model name, but do not register the dictionary
// otherwise it is registered in the database twice
const word modelType
(
modelDict.subDict("laminar").lookup("laminarModel")
);
Info<< "Selecting laminar stress model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown laminarModel type "
<< modelType << nl << nl
<< "Valid laminarModel types:" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<laminarModel>
(
cstrIter()
(
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport, propertiesName)
);
}
else
{
Info<< "Selecting laminar stress model "
<< laminarModels::Stokes<BasicTurbulenceModel>::typeName << endl;
return autoPtr<laminarModel>
(
new laminarModels::Stokes<BasicTurbulenceModel>
(
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport,
propertiesName
)
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
bool Foam::laminarModel<BasicTurbulenceModel>::read()
{
if (BasicTurbulenceModel::read())
{
laminarDict_ <<= this->subDict("laminar");
if
(
const dictionary* dictPtr =
laminarDict_.subDictPtr(type() + "Coeffs")
)
{
coeffDict_ <<= *dictPtr;
}
return true;
}
else
{
return false;
}
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::nut() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("nut", this->U_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh_,
dimensionedScalar("nut", dimViscosity, 0.0)
)
);
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::scalarField>
Foam::laminarModel<BasicTurbulenceModel>::nut
(
const label patchi
) const
{
return tmp<scalarField>
(
new scalarField(this->mesh_.boundary()[patchi].size(), 0.0)
);
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::nuEff() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject::groupName("nuEff", this->U_.group()), this->nu()
)
);
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::scalarField>
Foam::laminarModel<BasicTurbulenceModel>::nuEff
(
const label patchi
) const
{
return this->nu(patchi);
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::k() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("k", this->U_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh_,
dimensionedScalar("k", sqr(this->U_.dimensions()), 0.0)
)
);
}
template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::epsilon() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("epsilon", this->U_.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<class BasicTurbulenceModel>
Foam::tmp<Foam::volSymmTensorField>
Foam::laminarModel<BasicTurbulenceModel>::R() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
IOobject::groupName("R", this->U_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh_,
dimensionedSymmTensor
(
"R", sqr(this->U_.dimensions()), Zero
)
)
);
}
template<class BasicTurbulenceModel>
void Foam::laminarModel<BasicTurbulenceModel>::correct()
{
BasicTurbulenceModel::correct();
}
// ************************************************************************* //

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
Class
Foam::laminarModel
Description
Templated abstract base class for laminar transport models
SourceFiles
laminarModel.C
\*---------------------------------------------------------------------------*/
#ifndef laminarModel_H
#define laminarModel_H
#include "TurbulenceModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class laminarModel Declaration
\*---------------------------------------------------------------------------*/
template<class BasicTurbulenceModel>
class laminarModel
:
public BasicTurbulenceModel
{
protected:
// Protected data
//- laminar coefficients dictionary
dictionary laminarDict_;
//- Flag to print the model coeffs at run-time
Switch printCoeffs_;
//- Model coefficients dictionary
dictionary coeffDict_;
// Protected Member Functions
//- Print model coefficients
virtual void printCoeffs(const word& type);
private:
// Private Member Functions
//- Disallow default bitwise copy construct
laminarModel(const laminarModel&);
//- Disallow default bitwise assignment
void operator=(const laminarModel&);
public:
typedef typename BasicTurbulenceModel::alphaField alphaField;
typedef typename BasicTurbulenceModel::rhoField rhoField;
typedef typename BasicTurbulenceModel::transportModel transportModel;
//- Runtime type information
TypeName("laminar");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
laminarModel,
dictionary,
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
),
(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
);
// Constructors
//- Construct from components
laminarModel
(
const word& type,
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
);
// Selectors
//- Return a reference to the selected laminar model
static autoPtr<laminarModel> 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 ~laminarModel()
{}
// Member Functions
//- Read model coefficients if they have changed
virtual bool read();
// Access
//- Const access to the coefficients dictionary
virtual const dictionary& coeffDict() const
{
return coeffDict_;
}
//- Return the turbulence viscosity, i.e. 0 for laminar flow
virtual tmp<volScalarField> nut() const;
//- Return the turbulence viscosity on patch
virtual tmp<scalarField> nut(const label patchi) const;
//- Return the effective viscosity, i.e. the laminar viscosity
virtual tmp<volScalarField> nuEff() const;
//- Return the effective viscosity on patch
virtual tmp<scalarField> nuEff(const label patchi) const;
//- Return the turbulence kinetic energy, i.e. 0 for laminar flow
virtual tmp<volScalarField> k() const;
//- Return the turbulence kinetic energy dissipation rate,
// i.e. 0 for laminar flow
virtual tmp<volScalarField> epsilon() const;
//- Return the Reynolds stress tensor, i.e. 0 for laminar flow
virtual tmp<volSymmTensorField> R() const;
//- Correct the laminar transport
virtual void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "laminarModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
\defgroup grpLaminar laminar transport model
@{
\ingroup grpTurbulence
This group contains laminar models.
@}
\*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,8 @@ License
namespace Foam \ namespace Foam \
{ \ { \
typedef BaseModel<Transport> Transport##BaseModel; \ typedef BaseModel<Transport> Transport##BaseModel; \
typedef laminar<Transport##BaseModel> Laminar##Transport##BaseModel; \ typedef laminarModel<Transport##BaseModel> \
laminar##Transport##BaseModel; \
typedef RASModel<Transport##BaseModel> RAS##Transport##BaseModel; \ typedef RASModel<Transport##BaseModel> RAS##Transport##BaseModel; \
typedef LESModel<Transport##BaseModel> LES##Transport##BaseModel; \ typedef LESModel<Transport##BaseModel> LES##Transport##BaseModel; \
} }
@ -53,12 +54,15 @@ License
); \ ); \
\ \
\ \
defineNamedTemplateTypeNameAndDebug(Laminar##Transport##BaseModel, 0); \ defineNamedTemplateTypeNameAndDebug(laminar##Transport##BaseModel, 0); \
\
defineTemplateRunTimeSelectionTable \
(laminar##Transport##BaseModel, dictionary); \
\ \
addToRunTimeSelectionTable \ addToRunTimeSelectionTable \
( \ ( \
Transport##baseModel, \ Transport##baseModel, \
Laminar##Transport##BaseModel, \ laminar##Transport##BaseModel, \
dictionary \ dictionary \
); \ ); \
\ \