diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 19424fcb0f63428969e6d40b619787dd19dff073..efa21e2a5b7edde7c1ad041ae3aa4c1508cdd19c 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -140,30 +140,41 @@ bool Foam::KinematicCloud<ParcelType>::cloudSolution::writeThisStep() const } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template<class ParcelType> -void Foam::KinematicCloud<ParcelType>::storeState() +void Foam::KinematicCloud<ParcelType>::solve +( + typename ParcelType::trackData& td +) { - cloudCopyPtr_.reset - ( - static_cast<KinematicCloud<ParcelType>*> - ( - clone(this->name() + "Copy").ptr() - ) - ); -} + if (solution_.transient()) + { + preEvolve(); + evolveCloud(td); + } + else + { + td.cloud().storeState(); -template<class ParcelType> -void Foam::KinematicCloud<ParcelType>::restoreState() -{ - cloudReset(cloudCopyPtr_()); - cloudCopyPtr_.clear(); -} + preEvolve(); + evolveCloud(td); + + td.cloud().relaxSources(); + } + + td.cloud().info(); + + postEvolve(); + + if (solution_.steadyState()) + { + td.cloud().restoreState(); + } +} -// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template<class ParcelType> void Foam::KinematicCloud<ParcelType>::preEvolve() @@ -362,13 +373,6 @@ void Foam::KinematicCloud<ParcelType>::cloudReset(KinematicCloud<ParcelType>& c) } -template<class ParcelType> -void Foam::KinematicCloud<ParcelType>::relaxSources() -{ - this->relax(UTrans_(), cloudCopyPtr_->UTrans(), "U"); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class ParcelType> @@ -485,9 +489,8 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud this->name() + "UTrans", this->db().time().timeName(), this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE ), mesh_, dimensionedVector("zero", dimMass*dimVelocity, vector::zero) @@ -630,6 +633,27 @@ void Foam::KinematicCloud<ParcelType>::checkParcelProperties } +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(); +} + + template<class ParcelType> void Foam::KinematicCloud<ParcelType>::resetSourceTerms() { @@ -652,6 +676,13 @@ void Foam::KinematicCloud<ParcelType>::relax } +template<class ParcelType> +void Foam::KinematicCloud<ParcelType>::relaxSources() +{ + this->relax(UTrans_(), cloudCopyPtr_->UTrans(), "U"); +} + + template<class ParcelType> void Foam::KinematicCloud<ParcelType>::evolve() { @@ -659,31 +690,7 @@ void Foam::KinematicCloud<ParcelType>::evolve() { typename ParcelType::trackData td(*this); - if (solution_.transient()) - { - preEvolve(); - - evolveCloud(td); - } - else - { - storeState(); - - preEvolve(); - - evolveCloud(td); - - relaxSources(); - } - - info(); - - postEvolve(); - - if (solution_.steadyState()) - { - restoreState(); - } + solve(td); } } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index 4c0edac7ca0be4f8658d87a251b791ca85bde087..55b3aa3339c0c45152448ef09f01febebca9410e 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -106,12 +106,6 @@ class KinematicCloud // 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&); @@ -332,6 +326,9 @@ protected: // Cloud evolution functions + //- Solve the cloud - calls all evolution functions + void solve(typename ParcelType::trackData& td); + //- Pre-evolve void preEvolve(); @@ -357,9 +354,6 @@ protected: //- Reset state of cloud void cloudReset(KinematicCloud<ParcelType>& c); - //- Apply relaxation to (steady state) cloud sources - void relaxSources(); - public: @@ -563,9 +557,6 @@ public: //- Total rotational kinetic energy in the system inline scalar rotationalKineticEnergyOfSystem() const; - //- Print cloud information - void info() const; - // Fields @@ -592,6 +583,12 @@ public: const bool fullyDescribed ); + //- Store the current cloud state + void storeState(); + + //- Reset the current cloud to the previously stored state + void restoreState(); + //- Reset the cloud source terms void resetSourceTerms(); @@ -604,8 +601,14 @@ public: const word& name ) const; + //- Apply relaxation to (steady state) cloud sources + void relaxSources(); + //- Evolve the cloud void evolve(); + + //- Print cloud information + void info() const; }; diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 49e663922fd4e3b7259354c098a70aa7cfe268fb..bb4938849fa8387b659bfdb9a02b2f7d9713869a 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -28,29 +28,6 @@ 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> @@ -92,22 +69,6 @@ void Foam::ReactingCloud<ParcelType>::cloudReset(ReactingCloud<ParcelType>& c) } -template<class ParcelType> -void Foam::ReactingCloud<ParcelType>::relaxSources() -{ - ThermoCloud<ParcelType>::relaxSources(); - - forAll(rhoTrans_, fieldI) - { - DimensionedField<scalar, volMesh>& rhoT = - rhoTrans_[fieldI]; - const DimensionedField<scalar, volMesh>& rhoT0 = - cloudCopyPtr_->rhoTrans()[fieldI]; - this->relax(rhoT, rhoT0, "rho"); - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class ParcelType> @@ -158,9 +119,8 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud this->name() + "rhoTrans_" + specieName, this->db().time().timeName(), this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE ), this->mesh(), dimensionedScalar("zero", dimMass, 0.0) @@ -198,10 +158,23 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud { forAll(c.rhoTrans_, i) { + const word& specieName = this->thermo().carrier().species()[i]; rhoTrans_.set ( i, - new DimensionedField<scalar, volMesh>(c.rhoTrans_[i]) + new DimensionedField<scalar, volMesh> + ( + IOobject + ( + this->name() + "rhoTrans_" + specieName, + this->db().time().timeName(), + this->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + c.rhoTrans_[i] + ) ); } } @@ -269,6 +242,27 @@ void Foam::ReactingCloud<ParcelType>::checkParcelProperties } +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(); +} + + template<class ParcelType> void Foam::ReactingCloud<ParcelType>::resetSourceTerms() { @@ -280,6 +274,22 @@ void Foam::ReactingCloud<ParcelType>::resetSourceTerms() } +template<class ParcelType> +void Foam::ReactingCloud<ParcelType>::relaxSources() +{ + ThermoCloud<ParcelType>::relaxSources(); + + forAll(rhoTrans_, fieldI) + { + DimensionedField<scalar, volMesh>& rhoT = + rhoTrans_[fieldI]; + const DimensionedField<scalar, volMesh>& rhoT0 = + cloudCopyPtr_->rhoTrans()[fieldI]; + this->relax(rhoT, rhoT0, "rho"); + } +} + + template<class ParcelType> void Foam::ReactingCloud<ParcelType>::evolve() { @@ -287,32 +297,15 @@ void Foam::ReactingCloud<ParcelType>::evolve() { typename ParcelType::trackData td(*this); - if (this->solution().transient()) - { - this->preEvolve(); - - this->evolveCloud(td); - } - else - { - storeState(); - - this->preEvolve(); - - this->evolveCloud(td); - - relaxSources(); - } - - info(); + this->solve(td); + } +} - this->postEvolve(); - if (this->solution().steadyState()) - { - restoreState(); - } - } +template<class ParcelType> +void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass) +{ + dMassPhaseChange_ += dMass; } @@ -326,11 +319,4 @@ void Foam::ReactingCloud<ParcelType>::info() const } -template<class ParcelType> -void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass) -{ - dMassPhaseChange_ += dMass; -} - - // ************************************************************************* // diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H index 3f5d459a8edfed0765858878af70168e4ad36b2f..539c787c10260df5c407b096fd6b772257adeaab 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -77,12 +77,6 @@ private: // 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&); @@ -139,9 +133,6 @@ protected: //- Reset state of cloud void cloudReset(ReactingCloud<ParcelType>& c); - //- Apply relaxation to (steady state) cloud sources - void relaxSources(); - public: @@ -239,9 +230,6 @@ public: // Check - //- Print cloud information - void info() const; - //- Add to cumulative phase change mass transfer void addToMassPhaseChange(const scalar dMass); @@ -256,11 +244,23 @@ public: const bool fullyDescribed ); + //- Store the current cloud state + void storeState(); + + //- Reset the current cloud to the previously stored state + void restoreState(); + //- Reset the cloud source terms void resetSourceTerms(); + //- Apply relaxation to (steady state) cloud sources + void relaxSources(); + //- Evolve the cloud void evolve(); + + //- Print cloud information + void info() const; }; diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 6be798312854aa381c1b18ad51b57d2b240c6edc..57e540ca5bd3a619cebf99655c8b43a197fe8f92 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -28,29 +28,6 @@ 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> @@ -212,6 +189,27 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::checkParcelProperties } +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(); +} + + template<class ParcelType> void Foam::ReactingMultiphaseCloud<ParcelType>::resetSourceTerms() { @@ -226,46 +224,11 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::evolve() { typename ParcelType::trackData td(*this); - if (this->solution().transient()) - { - this->preEvolve(); - - this->evolveCloud(td); - } - else - { - storeState(); - - this->preEvolve(); - - this->evolveCloud(td); - - this->relaxSources(); - } - - info(); - - this->postEvolve(); - - if (this->solution().steadyState()) - { - restoreState(); - } + this->solve(td); } } -template<class ParcelType> -void Foam::ReactingMultiphaseCloud<ParcelType>::info() const -{ - ReactingCloud<ParcelType>::info(); - Info<< " Mass transfer devolatilisation = " - << returnReduce(dMassDevolatilisation_, sumOp<scalar>()) << nl; - Info<< " Mass transfer surface reaction = " - << returnReduce(dMassSurfaceReaction_, sumOp<scalar>()) << nl; -} - - template<class ParcelType> void Foam::ReactingMultiphaseCloud<ParcelType>::addToMassDevolatilisation ( @@ -286,4 +249,15 @@ void Foam::ReactingMultiphaseCloud<ParcelType>::addToMassSurfaceReaction } +template<class ParcelType> +void Foam::ReactingMultiphaseCloud<ParcelType>::info() const +{ + ReactingCloud<ParcelType>::info(); + Info<< " Mass transfer devolatilisation = " + << returnReduce(dMassDevolatilisation_, sumOp<scalar>()) << nl; + Info<< " Mass transfer surface reaction = " + << returnReduce(dMassSurfaceReaction_, sumOp<scalar>()) << nl; +} + + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H index fbe01703b45dce75fbecc5541916dfadc67c3c67..2a554c5b36f2c003c215bc8257f87fa2d500f0d9 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H @@ -75,12 +75,6 @@ class ReactingMultiphaseCloud // 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&); @@ -217,9 +211,6 @@ public: // Check - //- Print cloud information - void info() const; - //- Add to cumulative volatilisation mass transfer void addToMassDevolatilisation(const scalar dMass); @@ -237,11 +228,20 @@ public: const bool fullyDescribed ); + //- Store the current cloud state + void storeState(); + + //- Reset the current cloud to the previously stored state + void restoreState(); + //- Reset the cloud source terms void resetSourceTerms(); //- Evolve the cloud void evolve(); + + //- Print cloud information + void info() const; }; diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index d30683c269677bc7c964372d285e348d10750893..32f5061dd07ba17fc6d1e17d62a13da8965f3922 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -29,29 +29,6 @@ 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> @@ -66,15 +43,6 @@ void Foam::ThermoCloud<ParcelType>::cloudReset(ThermoCloud<ParcelType>& c) } -template<class ParcelType> -void Foam::ThermoCloud<ParcelType>::relaxSources() -{ - KinematicCloud<ParcelType>::relaxSources(); - - this->relax(hsTrans_(), cloudCopyPtr_->hsTrans(), "hs"); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class ParcelType> @@ -129,9 +97,8 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud this->name() + "hsTrans", this->db().time().timeName(), this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE ), this->mesh(), dimensionedScalar("zero", dimEnergy, 0.0) @@ -241,45 +208,51 @@ void Foam::ThermoCloud<ParcelType>::checkParcelProperties template<class ParcelType> -void Foam::ThermoCloud<ParcelType>::resetSourceTerms() +void Foam::ThermoCloud<ParcelType>::storeState() { - KinematicCloud<ParcelType>::resetSourceTerms(); - hsTrans_->field() = 0.0; + cloudCopyPtr_.reset + ( + static_cast<ThermoCloud<ParcelType>*> + ( + clone(this->name() + "Copy").ptr() + ) + ); } template<class ParcelType> -void Foam::ThermoCloud<ParcelType>::evolve() +void Foam::ThermoCloud<ParcelType>::restoreState() { - if (this->solution().active()) - { - typename ParcelType::trackData td(*this); + cloudReset(cloudCopyPtr_()); + cloudCopyPtr_.clear(); +} - if (this->solution().transient()) - { - this->preEvolve(); - this->evolveCloud(td); - } - else - { - storeState(); +template<class ParcelType> +void Foam::ThermoCloud<ParcelType>::resetSourceTerms() +{ + KinematicCloud<ParcelType>::resetSourceTerms(); + hsTrans_->field() = 0.0; +} - this->preEvolve(); - this->evolveCloud(td); +template<class ParcelType> +void Foam::ThermoCloud<ParcelType>::relaxSources() +{ + KinematicCloud<ParcelType>::relaxSources(); - relaxSources(); - } + this->relax(hsTrans_(), cloudCopyPtr_->hsTrans(), "hs"); +} - info(); - this->postEvolve(); +template<class ParcelType> +void Foam::ThermoCloud<ParcelType>::evolve() +{ + if (this->solution().active()) + { + typename ParcelType::trackData td(*this); - if (this->solution().steadyState()) - { - restoreState(); - } + this->solve(td); } } diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H index f78fd4c76a0a0f4ec9313e6fe49fcaed4d37a233..f730bc04b6ceebb6b4ef381aea770f0e10b0c466 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -71,12 +71,6 @@ class ThermoCloud // 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&); @@ -136,9 +130,6 @@ protected: //- Reset state of cloud void cloudReset(ThermoCloud<ParcelType>& c); - //- Apply relaxation to (steady state) cloud sources - void relaxSources(); - public: @@ -257,12 +248,6 @@ public: inline tmp<volScalarField> sigmap() const; - // Check - - //- Print cloud information - void info() const; - - // Cloud evolution functions //- Check parcel properties @@ -273,11 +258,27 @@ public: const bool fullyDescribed ); + //- Store the current cloud state + void storeState(); + + //- Reset the current cloud to the previously stored state + void restoreState(); + //- Reset the cloud source terms void resetSourceTerms(); + //- Apply relaxation to (steady state) cloud sources + void relaxSources(); + //- Evolve the cloud void evolve(); + + + // Check + + //- Print cloud information + void info() const; + };