Added copy/clone functionality to templated clouds

This commit is contained in:
andy
2010-10-21 11:59:40 +01:00
parent c1678f897a
commit 77752b9ede
11 changed files with 684 additions and 84 deletions

View File

@ -28,10 +28,10 @@ License
#include "interpolation.H"
#include "subCycleTime.H"
#include "CollisionModel.H"
#include "DispersionModel.H"
#include "DragModel.H"
#include "InjectionModel.H"
#include "CollisionModel.H"
#include "PatchInteractionModel.H"
#include "PostProcessingModel.H"
#include "SurfaceFilmModel.H"
@ -42,6 +42,7 @@ template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::cloudSolution::read()
{
dict_.lookup("coupled") >> coupled_;
dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_;
}
@ -55,7 +56,8 @@ Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
mesh_(mesh),
dict_(dict),
active_(dict.lookup("active")),
coupled_(false)
coupled_(false),
cellValueSourceCorrection_(false)
{
if (active_)
{
@ -73,7 +75,8 @@ Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
mesh_(cs.mesh_),
dict_(cs.dict_),
active_(cs.active_),
coupled_(cs.coupled_)
coupled_(cs.coupled_),
cellValueSourceCorrection_(cs.cellValueSourceCorrection_)
{}
@ -86,7 +89,8 @@ Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
mesh_(mesh),
dict_(dictionary::null),
active_(false),
coupled_(false)
coupled_(false),
cellValueSourceCorrection_(false)
{}
@ -95,6 +99,29 @@ Foam::KinematicCloud<ParcelType>::cloudSolution::~cloudSolution()
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<KinematicCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class ParcelType>
@ -259,6 +286,24 @@ void Foam::KinematicCloud<ParcelType>::postEvolve()
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::cloudReset(KinematicCloud<ParcelType>& c)
{
Cloud<ParcelType>::cloudReset(c);
rndGen_ = c.rndGen_;
collisionModel_ = c.collisionModel_->clone();
dispersionModel_= c.dispersionModel_->clone();
dragModel_ = c.dragModel_->clone();
injectionModel_ = c.injectionModel_->clone();
patchInteractionModel_ = c.patchInteractionModel_->clone();
postProcessingModel_ = c.postProcessingModel_->clone();
UIntegrator_ = c.UIntegrator_->clone();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
@ -274,6 +319,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
:
Cloud<ParcelType>(rho.mesh(), cloudName, false),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(rho.mesh()),
particleProperties_
(
@ -289,10 +335,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
solution_(mesh_, particleProperties_.subDict("solution")),
constProps_(particleProperties_),
subModelProperties_(particleProperties_.subDict("subModels")),
cellValueSourceCorrection_
(
particleProperties_.lookup("cellValueSourceCorrection")
),
rndGen_
(
label(0),
@ -304,6 +346,14 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
mu_(mu),
g_(g),
forces_(mesh_, particleProperties_, g_.value()),
collisionModel_
(
CollisionModel<KinematicCloud<ParcelType> >::New
(
subModelProperties_,
*this
)
),
dispersionModel_
(
DispersionModel<KinematicCloud<ParcelType> >::New
@ -328,14 +378,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
*this
)
),
collisionModel_
(
CollisionModel<KinematicCloud<ParcelType> >::New
(
subModelProperties_,
*this
)
),
patchInteractionModel_
(
PatchInteractionModel<KinematicCloud<ParcelType> >::New
@ -371,17 +413,20 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
),
UTrans_
(
IOobject
new DimensionedField<vector, volMesh>
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedVector("zero", dimMass*dimVelocity, vector::zero)
IOobject
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedVector("zero", dimMass*dimVelocity, vector::zero)
)
)
{
if (readFields)
@ -391,6 +436,103 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::KinematicCloud
(
KinematicCloud<ParcelType>& c,
const word& name
)
:
Cloud<ParcelType>(c.mesh(), name, c),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(c.mesh()),
particleProperties_(c.particleProperties_),
solution_(c.solution_),
constProps_(c.constProps_),
subModelProperties_(c.subModelProperties_),
rndGen_(c.rndGen_, true),
cellOccupancyPtr_(c.cellOccupancyPtr_->clone()),
rho_(c.rho_),
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
forces_(c.forces_),
collisionModel_(c.collisionModel_->clone()),
dispersionModel_(c.dispersionModel_->clone()),
dragModel_(c.dragModel_->clone()),
injectionModel_(c.injectionModel_->clone()),
patchInteractionModel_(c.patchInteractionModel_->clone()),
postProcessingModel_(c.postProcessingModel_->clone()),
surfaceFilmModel_(c.surfaceFilmModel_->clone()),
UIntegrator_(c.UIntegrator_->clone()),
UTrans_
(
new DimensionedField<vector, volMesh>
(
IOobject
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
c.UTrans_().dimensions(),
c.UTrans_().field()
)
)
{}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::KinematicCloud
(
const fvMesh& mesh,
const word& name,
const KinematicCloud<ParcelType>& c
)
:
Cloud<ParcelType>(mesh, name, IDLList<ParcelType>()),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(mesh),
particleProperties_
(
IOobject
(
name + "Properties",
mesh.time().constant(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
),
solution_(mesh),
constProps_(dictionary::null),
subModelProperties_(dictionary::null),
rndGen_(0, 0),
cellOccupancyPtr_(NULL),
rho_(c.rho_),
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
forces_(mesh),
collisionModel_(NULL),
dispersionModel_(NULL),
dragModel_(NULL),
injectionModel_(NULL),
patchInteractionModel_(NULL),
postProcessingModel_(NULL),
surfaceFilmModel_(NULL),
UIntegrator_(NULL),
UTrans_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
@ -421,7 +563,7 @@ void Foam::KinematicCloud<ParcelType>::checkParcelProperties
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::resetSourceTerms()
{
UTrans_.field() = vector::zero;
UTrans_->field() = vector::zero;
}

View File

@ -64,6 +64,9 @@ namespace Foam
// Forward declaration of classes
template<class CloudType>
class CollisionModel;
template<class CloudType>
class DispersionModel;
@ -73,9 +76,6 @@ class DragModel;
template<class CloudType>
class InjectionModel;
template<class CloudType>
class CollisionModel;
template<class CloudType>
class PatchInteractionModel;
@ -96,8 +96,20 @@ class KinematicCloud
public Cloud<ParcelType>,
public kinematicCloud
{
// Private data
//- Cloud copy pointer
autoPtr<KinematicCloud<ParcelType> > cloudCopyPtr_;
// Private Member Functions
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Disallow default bitwise copy construct
KinematicCloud(const KinematicCloud&);
@ -201,10 +213,6 @@ protected:
//- Sub-models dictionary
const dictionary& subModelProperties_;
//- Flag to correct cell values with latest transfer information
// during the lagrangian timestep
const Switch cellValueSourceCorrection_;
//- Random number generator - used by some injection routines
cachedRandom rndGen_;
@ -236,6 +244,10 @@ protected:
// References to the cloud sub-models
//- Collision model
autoPtr<CollisionModel<KinematicCloud<ParcelType> > >
collisionModel_;
//- Dispersion model
autoPtr<DispersionModel<KinematicCloud<ParcelType> > >
dispersionModel_;
@ -247,10 +259,6 @@ protected:
autoPtr<InjectionModel<KinematicCloud<ParcelType> > >
injectionModel_;
//- Collision model
autoPtr<CollisionModel<KinematicCloud<ParcelType> > >
collisionModel_;
//- Patch interaction model
autoPtr<PatchInteractionModel<KinematicCloud<ParcelType> > >
patchInteractionModel_;
@ -273,7 +281,7 @@ protected:
// Sources
//- Momentum
DimensionedField<vector, volMesh> UTrans_;
autoPtr<DimensionedField<vector, volMesh> > UTrans_;
// Cloud evolution functions
@ -300,6 +308,9 @@ protected:
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(KinematicCloud<ParcelType>& c);
public:
@ -316,6 +327,35 @@ public:
bool readFields = true
);
//- Copy constructor with new name
KinematicCloud(KinematicCloud<ParcelType>& c, const word& name);
//- Copy constructor with new name - creates bare cloud
KinematicCloud
(
const fvMesh& mesh,
const word& name,
const KinematicCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new KinematicCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new KinematicCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~KinematicCloud();
@ -391,6 +431,14 @@ public:
// Sub-models
//- Return const access to the collision model
inline const CollisionModel<KinematicCloud<ParcelType> >&
collision() const;
//- Return reference to the collision model
inline CollisionModel<KinematicCloud<ParcelType> >&
collision();
//- Return const-access to the dispersion model
inline const DispersionModel<KinematicCloud<ParcelType> >&
dispersion() const;
@ -411,15 +459,6 @@ public:
inline InjectionModel<KinematicCloud<ParcelType> >&
injection();
//- Return const access to the collision model
inline
const CollisionModel<KinematicCloud<ParcelType> >&
collision() const;
//- Return reference to the collision model
inline CollisionModel<KinematicCloud<ParcelType> >&
collision();
//- Return const-access to the patch interaction model
inline const PatchInteractionModel<KinematicCloud<ParcelType> >&
patchInteraction() const;
@ -450,6 +489,10 @@ public:
//- Return reference to momentum source
inline DimensionedField<vector, volMesh>& UTrans();
//- Return const reference to momentum source
inline const DimensionedField<vector, volMesh>&
UTrans() const;
//- Return tmp momentum source term - fully explicit
inline tmp<DimensionedField<vector, volMesh> > SU() const;

View File

@ -170,6 +170,22 @@ Foam::KinematicCloud<ParcelType>::forces() const
}
template<class ParcelType>
inline const Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision() const
{
return collisionModel_();
}
template<class ParcelType>
inline Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision()
{
return collisionModel_();
}
template<class ParcelType>
inline const Foam::DispersionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::dispersion() const
@ -218,22 +234,6 @@ Foam::KinematicCloud<ParcelType>::injection()
}
template<class ParcelType>
inline const Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision() const
{
return collisionModel_();
}
template<class ParcelType>
inline Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision()
{
return collisionModel_();
}
template<class ParcelType>
inline Foam::PostProcessingModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::postProcessing()
@ -357,7 +357,15 @@ template<class ParcelType>
inline Foam::DimensionedField<Foam::vector, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UTrans()
{
return UTrans_;
return UTrans_();
}
template<class ParcelType>
inline const Foam::DimensionedField<Foam::vector, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UTrans() const
{
return UTrans_();
}
@ -388,7 +396,7 @@ Foam::KinematicCloud<ParcelType>::SU() const
);
vectorField& SU = tSU().field();
SU = UTrans_/(mesh_.V()*this->db().time().deltaT());
SU = UTrans()/(mesh_.V()*this->db().time().deltaT());
return tSU;
}

View File

@ -28,6 +28,29 @@ License
#include "CompositionModel.H"
#include "PhaseChangeModel.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<ReactingCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
@ -112,6 +135,18 @@ void Foam::ReactingCloud<ParcelType>::postEvolve()
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::cloudReset(ReactingCloud<ParcelType>& c)
{
ThermoCloud<ParcelType>::cloudReset(c);
compositionModel_ = c.compositionModel_->clone();
phaseChangeModel_ = c.phaseChangeModel_->clone();
dMassPhaseChange_ = c.dMassPhaseChange_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
@ -127,6 +162,7 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
:
ThermoCloud<ParcelType>(cloudName, rho, U, g, thermo, false),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(this->particleProperties()),
compositionModel_
(
@ -178,6 +214,52 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
}
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::ReactingCloud
(
ReactingCloud<ParcelType>& c,
const word& name
)
:
ThermoCloud<ParcelType>(c, name),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(c.constProps_),
compositionModel_(c.compositionModel_->clone()),
phaseChangeModel_(c.phaseChangeModel_->clone()),
rhoTrans_(c.rhoTrans_.size()),
dMassPhaseChange_(c.dMassPhaseChange_)
{
forAll(c.rhoTrans_, i)
{
rhoTrans_.set
(
i,
new DimensionedField<scalar, volMesh>(c.rhoTrans_[i])
);
}
}
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::ReactingCloud
(
const fvMesh& mesh,
const word& name,
const ReactingCloud<ParcelType>& c
)
:
ThermoCloud<ParcelType>(mesh, name, c),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(c.constProps_),
compositionModel_(NULL),
phaseChangeModel_(NULL),
rhoTrans_(0),
dMassPhaseChange_(0.0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>

View File

@ -69,7 +69,19 @@ class ReactingCloud
private:
// Private Member Functions
// Private data
//- Cloud copy pointer
autoPtr<ReactingCloud<ParcelType> > cloudCopyPtr_;
// Private member functions
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Disallow default bitwise copy construct
ReactingCloud(const ReactingCloud&);
@ -136,6 +148,9 @@ protected:
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(ReactingCloud<ParcelType>& c);
public:
@ -152,6 +167,35 @@ public:
bool readFields = true
);
//- Copy constructor with new name
ReactingCloud(ReactingCloud<ParcelType>& c, const word& name);
//- Copy constructor with new name - creates bare cloud
ReactingCloud
(
const fvMesh& mesh,
const word& name,
const ReactingCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~ReactingCloud();

View File

@ -28,6 +28,29 @@ License
#include "DevolatilisationModel.H"
#include "SurfaceReactionModel.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParcelType>
void Foam::ReactingMultiphaseCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<ReactingMultiphaseCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::ReactingMultiphaseCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class ParcelType>
@ -85,6 +108,22 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::postEvolve()
}
template<class ParcelType>
void Foam::ReactingMultiphaseCloud<ParcelType>::cloudReset
(
ReactingMultiphaseCloud<ParcelType>& c
)
{
ReactingCloud<ParcelType>::cloudReset(c);
devolatilisationModel_ = c.devolatilisationModel_->clone();
surfaceReactionModel_ = c.surfaceReactionModel_->clone();
dMassDevolatilisation_ = c.dMassDevolatilisation_;
dMassSurfaceReaction_ = c.dMassSurfaceReaction_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
@ -100,6 +139,7 @@ Foam::ReactingMultiphaseCloud<ParcelType>::ReactingMultiphaseCloud
:
ReactingCloud<ParcelType>(cloudName, rho, U, g, thermo, false),
reactingMultiphaseCloud(),
cloudCopyPtr_(NULL),
constProps_(this->particleProperties()),
devolatilisationModel_
(
@ -117,7 +157,8 @@ Foam::ReactingMultiphaseCloud<ParcelType>::ReactingMultiphaseCloud
*this
)
),
dMassDevolatilisation_(0.0)
dMassDevolatilisation_(0.0),
dMassSurfaceReaction_(0.0)
{
if (readFields)
{
@ -126,6 +167,43 @@ Foam::ReactingMultiphaseCloud<ParcelType>::ReactingMultiphaseCloud
}
template<class ParcelType>
Foam::ReactingMultiphaseCloud<ParcelType>::ReactingMultiphaseCloud
(
ReactingMultiphaseCloud<ParcelType>& c,
const word& name
)
:
ReactingCloud<ParcelType>(c, name),
reactingMultiphaseCloud(),
cloudCopyPtr_(NULL),
constProps_(c.constProps_),
devolatilisationModel_(c.devolatilisationModel_->clone()),
surfaceReactionModel_(c.surfaceReactionModel_->clone()),
dMassDevolatilisation_(c.dMassDevolatilisation_),
dMassSurfaceReaction_(c.dMassSurfaceReaction_)
{}
template<class ParcelType>
Foam::ReactingMultiphaseCloud<ParcelType>::ReactingMultiphaseCloud
(
const fvMesh& mesh,
const word& name,
const ReactingMultiphaseCloud<ParcelType>& c
)
:
ReactingCloud<ParcelType>(mesh, name, c),
reactingMultiphaseCloud(),
cloudCopyPtr_(NULL),
constProps_(c.constProps_),
devolatilisationModel_(NULL),
surfaceReactionModel_(NULL),
dMassDevolatilisation_(0.0),
dMassSurfaceReaction_(0.0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>

View File

@ -67,7 +67,19 @@ class ReactingMultiphaseCloud
public ReactingCloud<ParcelType>,
public reactingMultiphaseCloud
{
// Private Member Functions
// Private data
//- Cloud copy pointer
autoPtr<ReactingMultiphaseCloud<ParcelType> > cloudCopyPtr_;
// Private member functions
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Disallow default bitwise copy construct
ReactingMultiphaseCloud(const ReactingMultiphaseCloud&);
@ -127,6 +139,9 @@ protected:
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(ReactingMultiphaseCloud<ParcelType>& c);
public:
@ -144,6 +159,40 @@ public:
);
//- Copy constructor with new name
ReactingMultiphaseCloud
(
ReactingMultiphaseCloud<ParcelType>& c,
const word& name
);
//- Copy constructor with new name - creates bare cloud
ReactingMultiphaseCloud
(
const fvMesh& mesh,
const word& name,
const ReactingMultiphaseCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingMultiphaseCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingMultiphaseCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~ReactingMultiphaseCloud();

View File

@ -29,6 +29,29 @@ License
#include "HeatTransferModel.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParcelType>
void Foam::ThermoCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<ThermoCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::ThermoCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class ParcelType>
@ -86,6 +109,18 @@ void Foam::ThermoCloud<ParcelType>::postEvolve()
}
template<class ParcelType>
void Foam::ThermoCloud<ParcelType>::cloudReset(ThermoCloud<ParcelType>& c)
{
KinematicCloud<ParcelType>::cloudReset(c);
heatTransferModel_ = c.heatTransferModel_->clone();
TIntegrator_ = c.TIntegrator_->clone();
radiation_ = c.radiation_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
@ -109,6 +144,7 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud
false
),
thermoCloud(),
cloudCopyPtr_(NULL),
constProps_(this->particleProperties()),
thermo_(thermo),
T_(thermo.thermo().T()),
@ -132,17 +168,20 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud
radiation_(this->subModelProperties().lookup("radiation")),
hsTrans_
(
IOobject
new DimensionedField<scalar, volMesh>
(
this->name() + "hsTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh(),
dimensionedScalar("zero", dimEnergy, 0.0)
IOobject
(
this->name() + "hsTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh(),
dimensionedScalar("zero", dimEnergy, 0.0)
)
)
{
if (readFields)
@ -152,6 +191,64 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud
}
template<class ParcelType>
Foam::ThermoCloud<ParcelType>::ThermoCloud
(
ThermoCloud<ParcelType>& c,
const word& name
)
:
KinematicCloud<ParcelType>(c, name),
thermoCloud(),
cloudCopyPtr_(NULL),
constProps_(c.particleProperties_),
thermo_(c.thermo_),
T_(c.T()),
p_(c.p()),
heatTransferModel_(c.heatTransferModel_->clone()),
TIntegrator_(c.TIntegrator_->clone()),
radiation_(c.radiation_),
hsTrans_
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
this->name() + "hsTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
c.hsTrans()
)
)
{}
template<class ParcelType>
Foam::ThermoCloud<ParcelType>::ThermoCloud
(
const fvMesh& mesh,
const word& name,
const ThermoCloud<ParcelType>& c
)
:
KinematicCloud<ParcelType>(mesh, name, c),
thermoCloud(),
cloudCopyPtr_(NULL),
constProps_(c.particleProperties_),
thermo_(c.thermo()),
T_(c.T()),
p_(c.p()),
heatTransferModel_(NULL),
TIntegrator_(NULL),
radiation_(false),
hsTrans_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
@ -188,7 +285,7 @@ template<class ParcelType>
void Foam::ThermoCloud<ParcelType>::resetSourceTerms()
{
KinematicCloud<ParcelType>::resetSourceTerms();
hsTrans_.field() = 0.0;
hsTrans_->field() = 0.0;
}

View File

@ -63,7 +63,19 @@ class ThermoCloud
public KinematicCloud<ParcelType>,
public thermoCloud
{
// Private Member Functions
// Private data
//- Cloud copy pointer
autoPtr<ThermoCloud<ParcelType> > cloudCopyPtr_;
// Private member functions
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Disallow default bitwise copy construct
ThermoCloud(const ThermoCloud&);
@ -114,7 +126,7 @@ protected:
// Sources
//- Sensible enthalpy transfer [J/kg]
DimensionedField<scalar, volMesh> hsTrans_;
autoPtr<DimensionedField<scalar, volMesh> > hsTrans_;
// Protected Member Functions
@ -133,6 +145,9 @@ protected:
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(ThermoCloud<ParcelType>& c);
public:
@ -149,6 +164,35 @@ public:
bool readFields = true
);
//- Copy constructor with new name
ThermoCloud(ThermoCloud<ParcelType>& c, const word& name);
//- Copy constructor with new name - creates bare cloud
ThermoCloud
(
const fvMesh& mesh,
const word& name,
const ThermoCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new ThermoCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new ThermoCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~ThermoCloud();
@ -202,6 +246,10 @@ public:
//- Sensible enthalpy transfer [J/kg]
inline DimensionedField<scalar, volMesh>& hsTrans();
//- Sensible enthalpy transfer [J/kg]
inline const DimensionedField<scalar, volMesh>&
hsTrans() const;
//- Return enthalpy source [J/kg/m3/s]
inline tmp<DimensionedField<scalar, volMesh> > Sh() const;

View File

@ -85,7 +85,15 @@ template<class ParcelType>
inline Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ThermoCloud<ParcelType>::hsTrans()
{
return hsTrans_;
return hsTrans_();
}
template<class ParcelType>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::ThermoCloud<ParcelType>::hsTrans() const
{
return hsTrans_();
}
@ -106,7 +114,7 @@ Foam::ThermoCloud<ParcelType>::Sh() const
IOobject::AUTO_WRITE,
false
),
hsTrans_/(this->mesh().V()*this->db().time().deltaT())
hsTrans_()/(this->mesh().V()*this->db().time().deltaT())
)
);

View File

@ -39,6 +39,7 @@ SourceFiles
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "SubModelBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //