ENH: Enabled use of incompressible turbulence models in lagrangian libraries

This commit is contained in:
andy
2012-02-29 14:20:33 +00:00
parent 326063d3cb
commit 86bf116b04
7 changed files with 142 additions and 77 deletions

View File

@ -14,10 +14,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
@ -42,6 +39,7 @@ LIB_LIBS = \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lLESdeltas \
-lincompressibleTransportModels \
-lregionModels \
-lsurfaceFilmModels \
-ldynamicFvMesh \

View File

@ -13,10 +13,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
@ -36,10 +33,14 @@ LIB_LIBS = \
-lreactionThermophysicalModels \
-lSLGThermo \
-lradiationModels \
-lincompressibleTurbulenceModel \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lcompressibleTurbulenceModel \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lLESdeltas \
-lincompressibleTransportModels \
-lregionModels \
-lsurfaceFilmModels \
-ldynamicFvMesh \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,80 @@ License
#include "DispersionRASModel.H"
#include "demandDrivenData.H"
#include "incompressible/turbulenceModel/turbulenceModel.H"
#include "compressible/turbulenceModel/turbulenceModel.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
Foam::tmp<Foam::volScalarField>
Foam::DispersionRASModel<CloudType>::kModel() const
{
const objectRegistry& obr = this->owner().mesh();
const word turbName = "turbulenceModel";
if (obr.foundObject<compressible::turbulenceModel>(turbName))
{
const compressible::turbulenceModel& model =
obr.lookupObject<compressible::turbulenceModel>(turbName);
return model.k();
}
else if (obr.foundObject<incompressible::turbulenceModel>(turbName))
{
const incompressible::turbulenceModel& model =
obr.lookupObject<incompressible::turbulenceModel>(turbName);
return model.k();
}
else
{
FatalErrorIn
(
"Foam::tmp<Foam::volScalarField>"
"Foam::DispersionRASModel<CloudType>::kModel() const"
)
<< "Turbulence model not found in mesh database" << nl
<< "Database objects include: " << obr.sortedToc()
<< abort(FatalError);
return tmp<volScalarField>(NULL);
}
}
template<class CloudType>
Foam::tmp<Foam::volScalarField>
Foam::DispersionRASModel<CloudType>::epsilonModel() const
{
const objectRegistry& obr = this->owner().mesh();
const word turbName = "turbulenceModel";
if (obr.foundObject<compressible::turbulenceModel>(turbName))
{
const compressible::turbulenceModel& model =
obr.lookupObject<compressible::turbulenceModel>(turbName);
return model.epsilon();
}
else if (obr.foundObject<incompressible::turbulenceModel>(turbName))
{
const incompressible::turbulenceModel& model =
obr.lookupObject<incompressible::turbulenceModel>(turbName);
return model.epsilon();
}
else
{
FatalErrorIn
(
"Foam::tmp<Foam::volScalarField>"
"Foam::DispersionRASModel<CloudType>::epsilonModel() const"
)
<< "Turbulence model not found in mesh database" << nl
<< "Database objects include: " << obr.sortedToc()
<< abort(FatalError);
return tmp<volScalarField>(NULL);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -36,16 +110,6 @@ Foam::DispersionRASModel<CloudType>::DispersionRASModel
)
:
DispersionModel<CloudType>(owner),
turbulence_
(
owner.mesh().objectRegistry::template lookupObject
<
compressible::RASModel
>
(
"RASProperties"
)
),
kPtr_(NULL),
ownK_(false),
epsilonPtr_(NULL),
@ -60,7 +124,6 @@ Foam::DispersionRASModel<CloudType>::DispersionRASModel
)
:
DispersionModel<CloudType>(dm),
turbulence_(dm.turbulence_),
kPtr_(dm.kPtr_),
ownK_(dm.ownK_),
epsilonPtr_(dm.epsilonPtr_),
@ -87,7 +150,7 @@ void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
{
if (store)
{
tmp<volScalarField> tk = this->turbulence().k();
tmp<volScalarField> tk = this->kModel();
if (tk.isTmp())
{
kPtr_ = tk.ptr();
@ -99,7 +162,7 @@ void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
ownK_ = false;
}
tmp<volScalarField> tepsilon = this->turbulence().epsilon();
tmp<volScalarField> tepsilon = this->epsilonModel();
if (tepsilon.isTmp())
{
epsilonPtr_ = tepsilon.ptr();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ Class
Foam::DispersionRASModel
Description
Base class for particle dispersion models based on RAS turbulence.
\*---------------------------------------------------------------------------*/
@ -32,7 +33,6 @@ Description
#define DispersionRASModel_H
#include "DispersionModel.H"
#include "RASModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,9 +53,6 @@ protected:
// Protected data
//- Reference to the compressible turbulence model
const compressible::RASModel& turbulence_;
// Locally cached turbulence fields
//- Turbulence k
@ -71,6 +68,15 @@ protected:
bool ownEpsilon_;
// Protected Functions
//- Return the k field from the turbulence model
tmp<volScalarField> kModel() const;
//- Return the epsilon field from the turbulence model
tmp<volScalarField> epsilonModel() const;
public:
//- Runtime type information
@ -104,12 +110,6 @@ public:
//- Cache carrier fields
virtual void cacheFields(const bool store);
//- Return const access to the turbulence model
const compressible::RASModel& turbulence() const
{
return turbulence_;
}
// I-O

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,8 @@ License
#include "BrownianMotionForce.H"
#include "mathematicalConstants.H"
#include "demandDrivenData.H"
#include "incompressible/turbulenceModel/turbulenceModel.H"
#include "compressible/turbulenceModel/turbulenceModel.H"
using namespace Foam::constant;
@ -50,6 +52,41 @@ Foam::scalar Foam::BrownianMotionForce<CloudType>::erfInv(const scalar y) const
}
template<class CloudType>
Foam::tmp<Foam::volScalarField>
Foam::BrownianMotionForce<CloudType>::kModel() const
{
const objectRegistry& obr = this->owner().mesh();
const word turbName = "turbulenceModel";
if (obr.foundObject<compressible::turbulenceModel>(turbName))
{
const compressible::turbulenceModel& model =
obr.lookupObject<compressible::turbulenceModel>(turbName);
return model.k();
}
else if (obr.foundObject<incompressible::turbulenceModel>(turbName))
{
const incompressible::turbulenceModel& model =
obr.lookupObject<incompressible::turbulenceModel>(turbName);
return model.k();
}
else
{
FatalErrorIn
(
"Foam::tmp<Foam::volScalarField>"
"Foam::BrownianMotionForce<CloudType>::kModel() const"
)
<< "Turbulence model not found in mesh database" << nl
<< "Database objects include: " << obr.sortedToc()
<< abort(FatalError);
return tmp<volScalarField>(NULL);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
@ -64,37 +101,9 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
rndGen_(owner.rndGen()),
lambda_(readScalar(this->coeffs().lookup("lambda"))),
turbulence_(readBool(this->coeffs().lookup("turbulence"))),
turbulenceModelPtr_(NULL),
kPtr_(NULL),
ownK_(false)
{
if (turbulence_)
{
HashTable<const compressible::turbulenceModel*> models =
this->mesh().objectRegistry::template lookupClass
<
compressible::turbulenceModel
>();
if (models.size() == 1)
{
turbulenceModelPtr_ = models.begin()();
}
else
{
FatalErrorIn
(
"Foam::BrownianMotionForce<CloudType>::BrownianMotionForce"
"("
"CloudType&, "
"const fvMesh&, "
"const dictionary&"
")"
) << "Unable to find a valid turbulence model in mesh database"
<< exit(FatalError);
}
}
}
{}
template<class CloudType>
@ -107,7 +116,6 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
rndGen_(bmf.rndGen_),
lambda_(bmf.lambda_),
turbulence_(bmf.turbulence_),
turbulenceModelPtr_(NULL),
kPtr_(NULL),
ownK_(false)
{}
@ -117,9 +125,7 @@ Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
template<class CloudType>
Foam::BrownianMotionForce<CloudType>::~BrownianMotionForce()
{
turbulenceModelPtr_ = NULL;
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -131,7 +137,7 @@ void Foam::BrownianMotionForce<CloudType>::cacheFields(const bool store)
{
if (store)
{
tmp<volScalarField> tk = turbulenceModelPtr_->k();
tmp<volScalarField> tk = kModel();
if (tk.isTmp())
{
kPtr_ = tk.ptr();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,7 +38,6 @@ SourceFiles
#include "ParticleForce.H"
#include "cachedRandom.H"
#include "turbulenceModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -65,9 +64,6 @@ class BrownianMotionForce
//- Turbulence flag
bool turbulence_;
//- Reference to a compressible turbulence model
const compressible::turbulenceModel* turbulenceModelPtr_;
//- Pointer to the turbulence kinetic energy field
const volScalarField* kPtr_;
@ -80,6 +76,9 @@ class BrownianMotionForce
//- Inverse erf for Gaussian distribution
scalar erfInv(const scalar y) const;
//- Return the k field from the turbulence model
tmp<volScalarField> kModel() const;
public:

View File

@ -14,10 +14,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
@ -42,6 +39,7 @@ LIB_LIBS = \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lLESdeltas \
-lincompressibleTransportModels \
-lregionModels \
-lsurfaceFilmModels \
-ldynamicFvMesh \