From 45422cda59e62450cbf6b4d0ce3c61ba1cd2d230 Mon Sep 17 00:00:00 2001
From: henry <Henry Weller h.weller@opencfd.co.uk>
Date: Thu, 9 Oct 2008 11:23:05 +0100
Subject: [PATCH] Changed the access to derived properties to ensure the
 old-time level values are stored if required.

---
 .../basic/hThermo/hThermo.C                   | 54 ++++++------
 .../hMixtureThermo/hMixtureThermo.C           | 52 ++++++------
 .../hhuMixtureThermo/hhuMixtureThermo.C       | 82 +++++++++++--------
 3 files changed, 101 insertions(+), 87 deletions(-)

diff --git a/src/thermophysicalModels/basic/hThermo/hThermo.C b/src/thermophysicalModels/basic/hThermo/hThermo.C
index 19e43d24108..7e32f7a0636 100644
--- a/src/thermophysicalModels/basic/hThermo/hThermo.C
+++ b/src/thermophysicalModels/basic/hThermo/hThermo.C
@@ -28,15 +28,10 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hThermo<MixtureType>::hThermo(const fvMesh& mesh)
+Foam::hThermo<MixtureType>::hThermo(const fvMesh& mesh)
 :
     basicThermo(mesh),
     MixtureType(*this, mesh),
@@ -56,9 +51,12 @@ hThermo<MixtureType>::hThermo(const fvMesh& mesh)
         hBoundaryTypes()
     )
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    const scalarField& TCells = T_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -76,25 +74,33 @@ hThermo<MixtureType>::hThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hThermo<MixtureType>::~hThermo()
+Foam::hThermo<MixtureType>::~hThermo()
 {}
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 template<class MixtureType>
-void hThermo<MixtureType>::calculate()
+void Foam::hThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
         const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -143,7 +149,7 @@ void hThermo<MixtureType>::calculate()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-void hThermo<MixtureType>::correct()
+void Foam::hThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -163,7 +169,7 @@ void hThermo<MixtureType>::correct()
 
 
 template<class MixtureType>
-tmp<scalarField>  hThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -182,7 +188,7 @@ tmp<scalarField>  hThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField>  hThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -201,7 +207,7 @@ tmp<scalarField>  hThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -220,7 +226,7 @@ tmp<scalarField> hThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -258,7 +264,7 @@ tmp<volScalarField> hThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hThermo<MixtureType>::Cv() const
+Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -303,7 +309,7 @@ tmp<volScalarField> hThermo<MixtureType>::Cv() const
 
 
 template<class MixtureType>
-bool hThermo<MixtureType>::read()
+bool Foam::hThermo<MixtureType>::read()
 {
     if (basicThermo::read())
     {
@@ -317,8 +323,4 @@ bool hThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
index 2d72a4f6887..064e7c3ebaf 100644
--- a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
+++ b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C
@@ -28,22 +28,20 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
+Foam::hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
 :
     hCombustionThermo(mesh),
     MixtureType(*this, mesh)
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    const scalarField& TCells = T_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -61,25 +59,33 @@ hMixtureThermo<MixtureType>::hMixtureThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hMixtureThermo<MixtureType>::~hMixtureThermo()
+Foam::hMixtureThermo<MixtureType>::~hMixtureThermo()
 {}
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 template<class MixtureType>
-void hMixtureThermo<MixtureType>::calculate()
+void Foam::hMixtureThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
         const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -128,7 +134,7 @@ void hMixtureThermo<MixtureType>::calculate()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -147,7 +153,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -166,7 +172,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hMixtureThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -186,7 +192,7 @@ tmp<scalarField> hMixtureThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hMixtureThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hMixtureThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -224,7 +230,7 @@ tmp<volScalarField> hMixtureThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-void hMixtureThermo<MixtureType>::correct()
+void Foam::hMixtureThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -244,7 +250,7 @@ void hMixtureThermo<MixtureType>::correct()
 
 
 template<class MixtureType>
-bool hMixtureThermo<MixtureType>::read()
+bool Foam::hMixtureThermo<MixtureType>::read()
 {
     if (hCombustionThermo::read())
     {
@@ -258,8 +264,4 @@ bool hMixtureThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
index 04bf08e3302..0086e8cd147 100644
--- a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
+++ b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C
@@ -28,23 +28,23 @@ License
 #include "fvMesh.H"
 #include "fixedValueFvPatchFields.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
+Foam::hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
 :
     hhuCombustionThermo(mesh),
     MixtureType(*this, mesh)
 {
-    forAll(h_, celli)
+    scalarField& hCells = h_.internalField();
+    scalarField& huCells = hu_.internalField();
+    const scalarField& TCells = T_.internalField();
+    const scalarField& TuCells = Tu_.internalField();
+
+    forAll(hCells, celli)
     {
-        h_[celli] = this->cellMixture(celli).H(T_[celli]);
-        hu_[celli] = this->cellReactants(celli).H(Tu_[celli]);
+        hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
+        huCells[celli] = this->cellReactants(celli).H(TuCells[celli]);
     }
 
     forAll(h_.boundaryField(), patchi)
@@ -71,27 +71,38 @@ hhuMixtureThermo<MixtureType>::hhuMixtureThermo(const fvMesh& mesh)
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 template<class MixtureType>
-hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
+Foam::hhuMixtureThermo<MixtureType>::~hhuMixtureThermo()
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class MixtureType>
-void hhuMixtureThermo<MixtureType>::calculate()
+void Foam::hhuMixtureThermo<MixtureType>::calculate()
 {
-    forAll(T_, celli)
+    const scalarField& hCells = h_.internalField();
+    const scalarField& huCells = hu_.internalField();
+    const scalarField& pCells = p_.internalField();
+
+    scalarField& TCells = T_.internalField();
+    scalarField& TuCells = Tu_.internalField();
+    scalarField& psiCells = psi_.internalField();
+    scalarField& muCells = mu_.internalField();
+    scalarField& alphaCells = alpha_.internalField();
+
+    forAll(TCells, celli)
     {
-        const typename MixtureType::thermoType& mixture_ = 
+        const typename MixtureType::thermoType& mixture_ =
             this->cellMixture(celli);
 
-        T_[celli] = mixture_.TH(h_[celli], T_[celli]);
-        psi_[celli] = mixture_.psi(p_[celli], T_[celli]);
+        TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
+        psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
 
-        mu_[celli] = mixture_.mu(T_[celli]);
-        alpha_[celli] = mixture_.alpha(T_[celli]);
+        muCells[celli] = mixture_.mu(TCells[celli]);
+        alphaCells[celli] = mixture_.alpha(TCells[celli]);
 
-        Tu_[celli] = this->cellReactants(celli).TH(hu_[celli], Tu_[celli]);
+        TuCells[celli] =
+            this->cellReactants(celli).TH(huCells[celli], TuCells[celli]);
     }
 
     forAll(T_.boundaryField(), patchi)
@@ -144,7 +155,7 @@ void hhuMixtureThermo<MixtureType>::calculate()
 
 
 template<class MixtureType>
-void hhuMixtureThermo<MixtureType>::correct()
+void Foam::hhuMixtureThermo<MixtureType>::correct()
 {
     if (debug)
     {
@@ -163,7 +174,7 @@ void hhuMixtureThermo<MixtureType>::correct()
 }
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const labelList& cells
@@ -182,7 +193,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::h
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::h
 (
     const scalarField& T,
     const label patchi
@@ -201,7 +212,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::h
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::Cp
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::Cp
 (
     const scalarField& T,
     const label patchi
@@ -221,7 +232,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::Cp
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::Cp() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::Cp() const
 {
     const fvMesh& mesh = T_.mesh();
 
@@ -260,7 +271,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::Cp() const
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::hu
 (
     const scalarField& Tu,
     const labelList& cells
@@ -279,7 +290,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
 
 
 template<class MixtureType>
-tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
+Foam::tmp<Foam::scalarField> Foam::hhuMixtureThermo<MixtureType>::hu
 (
     const scalarField& Tu,
     const label patchi
@@ -298,7 +309,7 @@ tmp<scalarField> hhuMixtureThermo<MixtureType>::hu
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::Tb() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::Tb() const
 {
     tmp<volScalarField> tTb
     (
@@ -342,7 +353,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::Tb() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::psiu() const
+Foam::tmp<Foam::volScalarField>
+Foam::hhuMixtureThermo<MixtureType>::psiu() const
 {
     tmp<volScalarField> tpsiu
     (
@@ -388,7 +400,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psiu() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
+Foam::tmp<Foam::volScalarField>
+Foam::hhuMixtureThermo<MixtureType>::psib() const
 {
     tmp<volScalarField> tpsib
     (
@@ -426,7 +439,8 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
         forAll(ppsib, facei)
         {
             ppsib[facei] =
-                this->patchFaceReactants(patchi, facei).psi(pp[facei], pTb[facei]);
+                this->patchFaceReactants
+                (patchi, facei).psi(pp[facei], pTb[facei]);
         }
     }
 
@@ -435,7 +449,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::psib() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::muu() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::muu() const
 {
     tmp<volScalarField> tmuu
     (
@@ -478,7 +492,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::muu() const
 
 
 template<class MixtureType>
-tmp<volScalarField> hhuMixtureThermo<MixtureType>::mub() const
+Foam::tmp<Foam::volScalarField> Foam::hhuMixtureThermo<MixtureType>::mub() const
 {
     tmp<volScalarField> tmub
     (
@@ -521,7 +535,7 @@ tmp<volScalarField> hhuMixtureThermo<MixtureType>::mub() const
 
 
 template<class MixtureType>
-bool hhuMixtureThermo<MixtureType>::read()
+bool Foam::hhuMixtureThermo<MixtureType>::read()
 {
     if (hhuCombustionThermo::read())
     {
@@ -535,8 +549,4 @@ bool hhuMixtureThermo<MixtureType>::read()
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
-- 
GitLab