mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
updated dispersion models - carrier fields now cached
This commit is contained in:
@ -173,9 +173,32 @@ void Foam::KinematicCloud<ParcelType>::resetSourceTerms()
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::preEvolve()
|
||||
{
|
||||
this->dispersion().cacheFields(true);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::postEvolve()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
this->writePositions();
|
||||
}
|
||||
|
||||
this->dispersion().cacheFields(false);
|
||||
|
||||
this->postProcessing().post();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::KinematicCloud<ParcelType>::evolve()
|
||||
{
|
||||
preEvolve();
|
||||
|
||||
autoPtr<interpolation<scalar> > rhoInterpolator =
|
||||
interpolation<scalar>::New
|
||||
(
|
||||
@ -209,11 +232,6 @@ void Foam::KinematicCloud<ParcelType>::evolve()
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
this->writePositions();
|
||||
}
|
||||
|
||||
if (coupled_)
|
||||
{
|
||||
resetSourceTerms();
|
||||
@ -221,7 +239,7 @@ void Foam::KinematicCloud<ParcelType>::evolve()
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
|
||||
this->postProcessing().post();
|
||||
postEvolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -184,6 +184,15 @@ protected:
|
||||
DimensionedField<vector, volMesh> UTrans_;
|
||||
|
||||
|
||||
// Cloud evolution functions
|
||||
|
||||
//- Pre-evolve
|
||||
void preEvolve();
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -175,9 +175,25 @@ void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingCloud<ParcelType>::preEvolve()
|
||||
{
|
||||
ThermoCloud<ParcelType>::preEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingCloud<ParcelType>::postEvolve()
|
||||
{
|
||||
ThermoCloud<ParcelType>::postEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingCloud<ParcelType>::evolve()
|
||||
{
|
||||
preEvolve();
|
||||
|
||||
const volScalarField& T = this->carrierThermo().T();
|
||||
const volScalarField cp = this->carrierThermo().Cp();
|
||||
const volScalarField& p = this->carrierThermo().p();
|
||||
@ -233,11 +249,6 @@ void Foam::ReactingCloud<ParcelType>::evolve()
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
this->writePositions();
|
||||
}
|
||||
|
||||
if (this->coupled())
|
||||
{
|
||||
resetSourceTerms();
|
||||
@ -245,7 +256,7 @@ void Foam::ReactingCloud<ParcelType>::evolve()
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
|
||||
this->postProcessing().post();
|
||||
postEvolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -132,6 +132,15 @@ protected:
|
||||
);
|
||||
|
||||
|
||||
// Cloud evolution functions
|
||||
|
||||
//- Pre-evolve
|
||||
void preEvolve();
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -129,9 +129,25 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::resetSourceTerms()
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingMultiphaseCloud<ParcelType>::preEvolve()
|
||||
{
|
||||
ReactingCloud<ParcelType>::preEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingMultiphaseCloud<ParcelType>::postEvolve()
|
||||
{
|
||||
ReactingCloud<ParcelType>::postEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ReactingMultiphaseCloud<ParcelType>::evolve()
|
||||
{
|
||||
preEvolve();
|
||||
|
||||
const volScalarField& T = this->carrierThermo().T();
|
||||
const volScalarField cp = this->carrierThermo().Cp();
|
||||
const volScalarField& p = this->carrierThermo().p();
|
||||
@ -187,11 +203,6 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::evolve()
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
this->writePositions();
|
||||
}
|
||||
|
||||
if (this->coupled())
|
||||
{
|
||||
resetSourceTerms();
|
||||
@ -199,7 +210,7 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::evolve()
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
|
||||
this->postProcessing().post();
|
||||
postEvolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ class ReactingMultiphaseCloud
|
||||
public ReactingCloud<ParcelType>,
|
||||
public reactingMultiphaseCloud
|
||||
{
|
||||
// Private Member Functions
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ReactingMultiphaseCloud(const ReactingMultiphaseCloud&);
|
||||
@ -112,6 +112,17 @@ protected:
|
||||
scalar dMassSurfaceReaction_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
// Cloud evolution functions
|
||||
|
||||
//- Pre-evolve
|
||||
void preEvolve();
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -142,9 +142,25 @@ void Foam::ThermoCloud<ParcelType>::resetSourceTerms()
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ThermoCloud<ParcelType>::preEvolve()
|
||||
{
|
||||
KinematicCloud<ParcelType>::preEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ThermoCloud<ParcelType>::postEvolve()
|
||||
{
|
||||
KinematicCloud<ParcelType>::postEvolve();
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
void Foam::ThermoCloud<ParcelType>::evolve()
|
||||
{
|
||||
preEvolve();
|
||||
|
||||
const volScalarField& T = carrierThermo_.T();
|
||||
const volScalarField cp = carrierThermo_.Cp();
|
||||
|
||||
@ -192,11 +208,6 @@ void Foam::ThermoCloud<ParcelType>::evolve()
|
||||
|
||||
this->injection().inject(td);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
this->writePositions();
|
||||
}
|
||||
|
||||
if (this->coupled())
|
||||
{
|
||||
resetSourceTerms();
|
||||
@ -204,7 +215,7 @@ void Foam::ThermoCloud<ParcelType>::evolve()
|
||||
|
||||
Cloud<ParcelType>::move(td);
|
||||
|
||||
this->postProcessing().post();
|
||||
postEvolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,6 +118,17 @@ protected:
|
||||
DimensionedField<scalar, volMesh> hcTrans_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
// Cloud evolution functions
|
||||
|
||||
//- Pre-evolve
|
||||
void preEvolve();
|
||||
|
||||
//- Post-evolve
|
||||
void postEvolve();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -121,6 +121,9 @@ public:
|
||||
//- Flag to indicate whether model activates injection model
|
||||
virtual bool active() const = 0;
|
||||
|
||||
//- Cache carrier fields
|
||||
virtual void cacheFields(const bool store) = 0;
|
||||
|
||||
//- Update (disperse particles)
|
||||
virtual vector update
|
||||
(
|
||||
|
||||
@ -42,7 +42,11 @@ Foam::DispersionRASModel<CloudType>::DispersionRASModel
|
||||
(
|
||||
"RASProperties"
|
||||
)
|
||||
)
|
||||
),
|
||||
kPtr_(NULL),
|
||||
ownK_(false),
|
||||
epsilonPtr_(NULL),
|
||||
ownEpsilon_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -50,7 +54,56 @@ Foam::DispersionRASModel<CloudType>::DispersionRASModel
|
||||
|
||||
template<class CloudType>
|
||||
Foam::DispersionRASModel<CloudType>::~DispersionRASModel()
|
||||
{}
|
||||
{
|
||||
cacheFields(false);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
|
||||
{
|
||||
if (store)
|
||||
{
|
||||
tmp<volScalarField> tk = this->turbulence().k();
|
||||
if (tk.isTmp())
|
||||
{
|
||||
kPtr_ = tk.ptr();
|
||||
ownK_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
kPtr_ = tk.operator->();
|
||||
ownK_ = false;
|
||||
}
|
||||
|
||||
tmp<volScalarField> tepsilon = this->turbulence().epsilon();
|
||||
if (tepsilon.isTmp())
|
||||
{
|
||||
epsilonPtr_ = tepsilon.ptr();
|
||||
ownEpsilon_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
epsilonPtr_ = tepsilon.operator->();
|
||||
ownEpsilon_ = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ownK_ && kPtr_)
|
||||
{
|
||||
delete kPtr_;
|
||||
ownK_ = false;
|
||||
}
|
||||
if (ownEpsilon_ && epsilonPtr_)
|
||||
{
|
||||
delete epsilonPtr_;
|
||||
ownEpsilon_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -50,11 +50,27 @@ class DispersionRASModel
|
||||
:
|
||||
public DispersionModel<CloudType>
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the compressible turbulence model
|
||||
const compressible::RASModel& turbulence_;
|
||||
|
||||
// Locally cached turbulence fields
|
||||
|
||||
//- Turbulence k
|
||||
const volScalarField* kPtr_;
|
||||
|
||||
//- Take ownership of the k field
|
||||
bool ownK_;
|
||||
|
||||
//- Turbulence epsilon
|
||||
const volScalarField* epsilonPtr_;
|
||||
|
||||
//- Take ownership of the epsilon field
|
||||
bool ownEpsilon_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -78,6 +94,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Cache carrier fields
|
||||
virtual void cacheFields(const bool store);
|
||||
|
||||
//- Return const access to the turbulence model
|
||||
const compressible::RASModel& turbulence() const
|
||||
{
|
||||
|
||||
@ -35,7 +35,8 @@ Foam::GradientDispersionRAS<CloudType>::GradientDispersionRAS
|
||||
CloudType& owner
|
||||
)
|
||||
:
|
||||
DispersionRASModel<CloudType>(dict, owner)
|
||||
DispersionRASModel<CloudType>(dict, owner),
|
||||
gradkPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
@ -43,7 +44,9 @@ Foam::GradientDispersionRAS<CloudType>::GradientDispersionRAS
|
||||
|
||||
template<class CloudType>
|
||||
Foam::GradientDispersionRAS<CloudType>::~GradientDispersionRAS()
|
||||
{}
|
||||
{
|
||||
cacheFields(false);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -55,6 +58,25 @@ bool Foam::GradientDispersionRAS<CloudType>::active() const
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::GradientDispersionRAS<CloudType>::cacheFields(const bool store)
|
||||
{
|
||||
DispersionRASModel<CloudType>::cacheFields(store);
|
||||
|
||||
if (store)
|
||||
{
|
||||
gradkPtr_ = fvc::grad(*this->kPtr_).ptr();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gradkPtr_)
|
||||
{
|
||||
delete gradkPtr_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::vector Foam::GradientDispersionRAS<CloudType>::update
|
||||
(
|
||||
@ -68,12 +90,9 @@ Foam::vector Foam::GradientDispersionRAS<CloudType>::update
|
||||
{
|
||||
const scalar cps = 0.16432;
|
||||
|
||||
const tmp<volScalarField> tk = this->turbulence().k();
|
||||
const volScalarField& k = tk();
|
||||
const tmp<volScalarField> tepsilon = this->turbulence().epsilon();
|
||||
const volScalarField& epsilon = tepsilon();
|
||||
|
||||
const volVectorField gradk = fvc::grad(k);
|
||||
const volScalarField& k = *this->kPtr_;
|
||||
const volScalarField& epsilon = *this->epsilonPtr_;
|
||||
const volVectorField& gradk = *this->gradkPtr_;
|
||||
|
||||
const scalar UrelMag = mag(U - Uc - UTurb);
|
||||
|
||||
|
||||
@ -51,6 +51,14 @@ class GradientDispersionRAS
|
||||
:
|
||||
public DispersionRASModel<CloudType>
|
||||
{
|
||||
protected:
|
||||
|
||||
// Locally cached turbulence fields
|
||||
|
||||
//- Gradient of k
|
||||
const volVectorField* gradkPtr_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -76,8 +84,11 @@ public:
|
||||
//- Flag to indicate whether model activates injection model
|
||||
bool active() const;
|
||||
|
||||
//- Cache carrier fields
|
||||
virtual void cacheFields(const bool store);
|
||||
|
||||
//- Update (disperse particles)
|
||||
vector update
|
||||
virtual vector update
|
||||
(
|
||||
const scalar dt,
|
||||
const label celli,
|
||||
|
||||
@ -55,6 +55,13 @@ bool Foam::NoDispersion<CloudType>::active() const
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::NoDispersion<CloudType>::cacheFields(const bool)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::vector Foam::NoDispersion<CloudType>::update
|
||||
(
|
||||
|
||||
@ -72,10 +72,13 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Flag to indicate whether model activates injection model
|
||||
bool active() const;
|
||||
virtual bool active() const;
|
||||
|
||||
//- Cache carrier fields
|
||||
virtual void cacheFields(const bool store);
|
||||
|
||||
//- Update (disperse particles)
|
||||
vector update
|
||||
virtual vector update
|
||||
(
|
||||
const scalar dt,
|
||||
const label celli,
|
||||
|
||||
@ -68,10 +68,8 @@ Foam::vector Foam::StochasticDispersionRAS<CloudType>::update
|
||||
{
|
||||
const scalar cps = 0.16432;
|
||||
|
||||
const tmp<volScalarField> tk = this->turbulence().k();
|
||||
const volScalarField& k = tk();
|
||||
const tmp<volScalarField> tepsilon = this->turbulence().epsilon();
|
||||
const volScalarField& epsilon = tepsilon();
|
||||
const volScalarField& k = *this->kPtr_;
|
||||
const volScalarField& epsilon = *this->epsilonPtr_;
|
||||
|
||||
const scalar UrelMag = mag(U - Uc - UTurb);
|
||||
|
||||
|
||||
@ -74,10 +74,10 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Flag to indicate whether model activates injection model
|
||||
bool active() const;
|
||||
virtual bool active() const;
|
||||
|
||||
//- Update (disperse particles)
|
||||
vector update
|
||||
virtual vector update
|
||||
(
|
||||
const scalar dt,
|
||||
const label celli,
|
||||
|
||||
Reference in New Issue
Block a user