diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index aa0c8cedfe..a7990be458 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -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 void Foam::KinematicCloud::cloudSolution::read() { dict_.lookup("coupled") >> coupled_; + dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_; } @@ -55,7 +56,8 @@ Foam::KinematicCloud::cloudSolution::cloudSolution mesh_(mesh), dict_(dict), active_(dict.lookup("active")), - coupled_(false) + coupled_(false), + cellValueSourceCorrection_(false) { if (active_) { @@ -73,7 +75,8 @@ Foam::KinematicCloud::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::cloudSolution::cloudSolution mesh_(mesh), dict_(dictionary::null), active_(false), - coupled_(false) + coupled_(false), + cellValueSourceCorrection_(false) {} @@ -95,6 +99,29 @@ Foam::KinematicCloud::cloudSolution::~cloudSolution() {} +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::KinematicCloud::storeState() +{ + cloudCopyPtr_.reset + ( + static_cast*> + ( + clone(this->name() + "Copy").ptr() + ) + ); +} + + +template +void Foam::KinematicCloud::restoreState() +{ + cloudReset(cloudCopyPtr_()); + cloudCopyPtr_.clear(); +} + + // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template @@ -259,6 +286,24 @@ void Foam::KinematicCloud::postEvolve() } +template +void Foam::KinematicCloud::cloudReset(KinematicCloud& c) +{ + Cloud::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 @@ -274,6 +319,7 @@ Foam::KinematicCloud::KinematicCloud : Cloud(rho.mesh(), cloudName, false), kinematicCloud(), + cloudCopyPtr_(NULL), mesh_(rho.mesh()), particleProperties_ ( @@ -289,10 +335,6 @@ Foam::KinematicCloud::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::KinematicCloud mu_(mu), g_(g), forces_(mesh_, particleProperties_, g_.value()), + collisionModel_ + ( + CollisionModel >::New + ( + subModelProperties_, + *this + ) + ), dispersionModel_ ( DispersionModel >::New @@ -328,14 +378,6 @@ Foam::KinematicCloud::KinematicCloud *this ) ), - collisionModel_ - ( - CollisionModel >::New - ( - subModelProperties_, - *this - ) - ), patchInteractionModel_ ( PatchInteractionModel >::New @@ -371,17 +413,20 @@ Foam::KinematicCloud::KinematicCloud ), UTrans_ ( - IOobject + new DimensionedField ( - 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::KinematicCloud } +template +Foam::KinematicCloud::KinematicCloud +( + KinematicCloud& c, + const word& name +) +: + Cloud(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 + ( + 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 +Foam::KinematicCloud::KinematicCloud +( + const fvMesh& mesh, + const word& name, + const KinematicCloud& c +) +: + Cloud(mesh, name, IDLList()), + 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 @@ -421,7 +563,7 @@ void Foam::KinematicCloud::checkParcelProperties template void Foam::KinematicCloud::resetSourceTerms() { - UTrans_.field() = vector::zero; + UTrans_->field() = vector::zero; } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index 4e95184bec..b041c4c2df 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -64,6 +64,9 @@ namespace Foam // Forward declaration of classes +template +class CollisionModel; + template class DispersionModel; @@ -73,9 +76,6 @@ class DragModel; template class InjectionModel; -template -class CollisionModel; - template class PatchInteractionModel; @@ -96,8 +96,20 @@ class KinematicCloud public Cloud, public kinematicCloud { + // Private data + + //- Cloud copy pointer + autoPtr > 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_; + //- Dispersion model autoPtr > > dispersionModel_; @@ -247,10 +259,6 @@ protected: autoPtr > > injectionModel_; - //- Collision model - autoPtr > > - collisionModel_; - //- Patch interaction model autoPtr > > patchInteractionModel_; @@ -273,7 +281,7 @@ protected: // Sources //- Momentum - DimensionedField UTrans_; + autoPtr > UTrans_; // Cloud evolution functions @@ -300,6 +308,9 @@ protected: //- Post-evolve void postEvolve(); + //- Reset state of cloud + void cloudReset(KinematicCloud& c); + public: @@ -316,6 +327,35 @@ public: bool readFields = true ); + //- Copy constructor with new name + KinematicCloud(KinematicCloud& c, const word& name); + + //- Copy constructor with new name - creates bare cloud + KinematicCloud + ( + const fvMesh& mesh, + const word& name, + const KinematicCloud& c + ); + + //- Construct and return clone based on (this) with new name + virtual autoPtr > clone(const word& name) + { + return autoPtr > + ( + new KinematicCloud(*this, name) + ); + } + + //- Construct and return bare clone based on (this) with new name + virtual autoPtr > cloneBare(const word& name) const + { + return autoPtr > + ( + 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 >& + collision() const; + + //- Return reference to the collision model + inline CollisionModel >& + collision(); + //- Return const-access to the dispersion model inline const DispersionModel >& dispersion() const; @@ -411,15 +459,6 @@ public: inline InjectionModel >& injection(); - //- Return const access to the collision model - inline - const CollisionModel >& - collision() const; - - //- Return reference to the collision model - inline CollisionModel >& - collision(); - //- Return const-access to the patch interaction model inline const PatchInteractionModel >& patchInteraction() const; @@ -450,6 +489,10 @@ public: //- Return reference to momentum source inline DimensionedField& UTrans(); + //- Return const reference to momentum source + inline const DimensionedField& + UTrans() const; + //- Return tmp momentum source term - fully explicit inline tmp > SU() const; diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 96cd40ef7e..916ad156f1 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -170,6 +170,22 @@ Foam::KinematicCloud::forces() const } +template +inline const Foam::CollisionModel >& +Foam::KinematicCloud::collision() const +{ + return collisionModel_(); +} + + +template +inline Foam::CollisionModel >& +Foam::KinematicCloud::collision() +{ + return collisionModel_(); +} + + template inline const Foam::DispersionModel >& Foam::KinematicCloud::dispersion() const @@ -218,22 +234,6 @@ Foam::KinematicCloud::injection() } -template -inline const Foam::CollisionModel >& -Foam::KinematicCloud::collision() const -{ - return collisionModel_(); -} - - -template -inline Foam::CollisionModel >& -Foam::KinematicCloud::collision() -{ - return collisionModel_(); -} - - template inline Foam::PostProcessingModel >& Foam::KinematicCloud::postProcessing() @@ -357,7 +357,15 @@ template inline Foam::DimensionedField& Foam::KinematicCloud::UTrans() { - return UTrans_; + return UTrans_(); +} + + +template +inline const Foam::DimensionedField& +Foam::KinematicCloud::UTrans() const +{ + return UTrans_(); } @@ -388,7 +396,7 @@ Foam::KinematicCloud::SU() const ); vectorField& SU = tSU().field(); - SU = UTrans_/(mesh_.V()*this->db().time().deltaT()); + SU = UTrans()/(mesh_.V()*this->db().time().deltaT()); return tSU; } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index dfec32bc4b..cf1521e842 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -28,6 +28,29 @@ License #include "CompositionModel.H" #include "PhaseChangeModel.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::ReactingCloud::storeState() +{ + cloudCopyPtr_.reset + ( + static_cast*> + ( + clone(this->name() + "Copy").ptr() + ) + ); +} + + +template +void Foam::ReactingCloud::restoreState() +{ + cloudReset(cloudCopyPtr_()); + cloudCopyPtr_.clear(); +} + + // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // template @@ -112,6 +135,18 @@ void Foam::ReactingCloud::postEvolve() } +template +void Foam::ReactingCloud::cloudReset(ReactingCloud& c) +{ + ThermoCloud::cloudReset(c); + + compositionModel_ = c.compositionModel_->clone(); + phaseChangeModel_ = c.phaseChangeModel_->clone(); + + dMassPhaseChange_ = c.dMassPhaseChange_; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -127,6 +162,7 @@ Foam::ReactingCloud::ReactingCloud : ThermoCloud(cloudName, rho, U, g, thermo, false), reactingCloud(), + cloudCopyPtr_(NULL), constProps_(this->particleProperties()), compositionModel_ ( @@ -178,6 +214,52 @@ Foam::ReactingCloud::ReactingCloud } +template +Foam::ReactingCloud::ReactingCloud +( + ReactingCloud& c, + const word& name +) +: + ThermoCloud(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(c.rhoTrans_[i]) + ); + } +} + + +template +Foam::ReactingCloud::ReactingCloud +( + const fvMesh& mesh, + const word& name, + const ReactingCloud& c +) +: + ThermoCloud(mesh, name, c), + reactingCloud(), + cloudCopyPtr_(NULL), + constProps_(c.constProps_), + compositionModel_(NULL), + phaseChangeModel_(NULL), + rhoTrans_(0), + dMassPhaseChange_(0.0) +{} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H index def51f8955..4fa3153d6e 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -69,7 +69,19 @@ class ReactingCloud private: - // Private Member Functions + // Private data + + //- Cloud copy pointer + autoPtr > 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& c); + public: @@ -152,6 +167,35 @@ public: bool readFields = true ); + //- Copy constructor with new name + ReactingCloud(ReactingCloud& c, const word& name); + + //- Copy constructor with new name - creates bare cloud + ReactingCloud + ( + const fvMesh& mesh, + const word& name, + const ReactingCloud& c + ); + + //- Construct and return clone based on (this) with new name + virtual autoPtr > clone(const word& name) + { + return autoPtr > + ( + new ReactingCloud(*this, name) + ); + } + + //- Construct and return bare clone based on (this) with new name + virtual autoPtr > cloneBare(const word& name) const + { + return autoPtr > + ( + new ReactingCloud(this->mesh(), name, *this) + ); + } + //- Destructor virtual ~ReactingCloud(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index b383f38f10..ca41f74572 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -28,6 +28,29 @@ License #include "DevolatilisationModel.H" #include "SurfaceReactionModel.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::ReactingMultiphaseCloud::storeState() +{ + cloudCopyPtr_.reset + ( + static_cast*> + ( + clone(this->name() + "Copy").ptr() + ) + ); +} + + +template +void Foam::ReactingMultiphaseCloud::restoreState() +{ + cloudReset(cloudCopyPtr_()); + cloudCopyPtr_.clear(); +} + + // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template @@ -85,6 +108,22 @@ void Foam::ReactingMultiphaseCloud::postEvolve() } +template +void Foam::ReactingMultiphaseCloud::cloudReset +( + ReactingMultiphaseCloud& c +) +{ + ReactingCloud::cloudReset(c); + + devolatilisationModel_ = c.devolatilisationModel_->clone(); + surfaceReactionModel_ = c.surfaceReactionModel_->clone(); + + dMassDevolatilisation_ = c.dMassDevolatilisation_; + dMassSurfaceReaction_ = c.dMassSurfaceReaction_; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -100,6 +139,7 @@ Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud : ReactingCloud(cloudName, rho, U, g, thermo, false), reactingMultiphaseCloud(), + cloudCopyPtr_(NULL), constProps_(this->particleProperties()), devolatilisationModel_ ( @@ -117,7 +157,8 @@ Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud *this ) ), - dMassDevolatilisation_(0.0) + dMassDevolatilisation_(0.0), + dMassSurfaceReaction_(0.0) { if (readFields) { @@ -126,6 +167,43 @@ Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud } +template +Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud +( + ReactingMultiphaseCloud& c, + const word& name +) +: + ReactingCloud(c, name), + reactingMultiphaseCloud(), + cloudCopyPtr_(NULL), + constProps_(c.constProps_), + devolatilisationModel_(c.devolatilisationModel_->clone()), + surfaceReactionModel_(c.surfaceReactionModel_->clone()), + dMassDevolatilisation_(c.dMassDevolatilisation_), + dMassSurfaceReaction_(c.dMassSurfaceReaction_) +{} + + +template +Foam::ReactingMultiphaseCloud::ReactingMultiphaseCloud +( + const fvMesh& mesh, + const word& name, + const ReactingMultiphaseCloud& c +) +: + ReactingCloud(mesh, name, c), + reactingMultiphaseCloud(), + cloudCopyPtr_(NULL), + constProps_(c.constProps_), + devolatilisationModel_(NULL), + surfaceReactionModel_(NULL), + dMassDevolatilisation_(0.0), + dMassSurfaceReaction_(0.0) +{} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H index af2199261e..86302703d3 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H @@ -67,7 +67,19 @@ class ReactingMultiphaseCloud public ReactingCloud, public reactingMultiphaseCloud { - // Private Member Functions + // Private data + + //- Cloud copy pointer + autoPtr > 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& c); + public: @@ -144,6 +159,40 @@ public: ); + //- Copy constructor with new name + ReactingMultiphaseCloud + ( + ReactingMultiphaseCloud& c, + const word& name + ); + + //- Copy constructor with new name - creates bare cloud + ReactingMultiphaseCloud + ( + const fvMesh& mesh, + const word& name, + const ReactingMultiphaseCloud& c + ); + + //- Construct and return clone based on (this) with new name + virtual autoPtr > clone(const word& name) + { + return autoPtr > + ( + new ReactingMultiphaseCloud(*this, name) + ); + } + + //- Construct and return bare clone based on (this) with new name + virtual autoPtr > cloneBare(const word& name) const + { + return autoPtr > + ( + new ReactingMultiphaseCloud(this->mesh(), name, *this) + ); + } + + //- Destructor virtual ~ReactingMultiphaseCloud(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 17469774af..52190e52c4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -29,6 +29,29 @@ License #include "HeatTransferModel.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::ThermoCloud::storeState() +{ + cloudCopyPtr_.reset + ( + static_cast*> + ( + clone(this->name() + "Copy").ptr() + ) + ); +} + + +template +void Foam::ThermoCloud::restoreState() +{ + cloudReset(cloudCopyPtr_()); + cloudCopyPtr_.clear(); +} + + // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template @@ -86,6 +109,18 @@ void Foam::ThermoCloud::postEvolve() } +template +void Foam::ThermoCloud::cloudReset(ThermoCloud& c) +{ + KinematicCloud::cloudReset(c); + + heatTransferModel_ = c.heatTransferModel_->clone(); + TIntegrator_ = c.TIntegrator_->clone(); + + radiation_ = c.radiation_; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -109,6 +144,7 @@ Foam::ThermoCloud::ThermoCloud false ), thermoCloud(), + cloudCopyPtr_(NULL), constProps_(this->particleProperties()), thermo_(thermo), T_(thermo.thermo().T()), @@ -132,17 +168,20 @@ Foam::ThermoCloud::ThermoCloud radiation_(this->subModelProperties().lookup("radiation")), hsTrans_ ( - IOobject + new DimensionedField ( - 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::ThermoCloud } +template +Foam::ThermoCloud::ThermoCloud +( + ThermoCloud& c, + const word& name +) +: + KinematicCloud(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 + ( + IOobject + ( + this->name() + "hsTrans", + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + c.hsTrans() + ) + ) +{} + + +template +Foam::ThermoCloud::ThermoCloud +( + const fvMesh& mesh, + const word& name, + const ThermoCloud& c +) +: + KinematicCloud(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 @@ -188,7 +285,7 @@ template void Foam::ThermoCloud::resetSourceTerms() { KinematicCloud::resetSourceTerms(); - hsTrans_.field() = 0.0; + hsTrans_->field() = 0.0; } diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H index ec7dc35627..d7b9cc7d8d 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -63,7 +63,19 @@ class ThermoCloud public KinematicCloud, public thermoCloud { - // Private Member Functions + // Private data + + //- Cloud copy pointer + autoPtr > 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 hsTrans_; + autoPtr > hsTrans_; // Protected Member Functions @@ -133,6 +145,9 @@ protected: //- Post-evolve void postEvolve(); + //- Reset state of cloud + void cloudReset(ThermoCloud& c); + public: @@ -149,6 +164,35 @@ public: bool readFields = true ); + //- Copy constructor with new name + ThermoCloud(ThermoCloud& c, const word& name); + + //- Copy constructor with new name - creates bare cloud + ThermoCloud + ( + const fvMesh& mesh, + const word& name, + const ThermoCloud& c + ); + + //- Construct and return clone based on (this) with new name + virtual autoPtr > clone(const word& name) + { + return autoPtr > + ( + new ThermoCloud(*this, name) + ); + } + + //- Construct and return bare clone based on (this) with new name + virtual autoPtr > cloneBare(const word& name) const + { + return autoPtr > + ( + new ThermoCloud(this->mesh(), name, *this) + ); + } + //- Destructor virtual ~ThermoCloud(); @@ -202,6 +246,10 @@ public: //- Sensible enthalpy transfer [J/kg] inline DimensionedField& hsTrans(); + //- Sensible enthalpy transfer [J/kg] + inline const DimensionedField& + hsTrans() const; + //- Return enthalpy source [J/kg/m3/s] inline tmp > Sh() const; diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H index 887fbd30f2..6af79f2cbc 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H @@ -85,7 +85,15 @@ template inline Foam::DimensionedField& Foam::ThermoCloud::hsTrans() { - return hsTrans_; + return hsTrans_(); +} + + +template +inline const Foam::DimensionedField& +Foam::ThermoCloud::hsTrans() const +{ + return hsTrans_(); } @@ -106,7 +114,7 @@ Foam::ThermoCloud::Sh() const IOobject::AUTO_WRITE, false ), - hsTrans_/(this->mesh().V()*this->db().time().deltaT()) + hsTrans_()/(this->mesh().V()*this->db().time().deltaT()) ) ); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/CollisionModel/CollisionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/CollisionModel/CollisionModel.H index baef80996f..e51e14afcf 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/CollisionModel/CollisionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/CollisionModel/CollisionModel.H @@ -39,6 +39,7 @@ SourceFiles #include "IOdictionary.H" #include "autoPtr.H" #include "runTimeSelectionTables.H" +#include "SubModelBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //