From 380a10a863a5cedfda069008db380a3bb41f2482 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sun, 6 Dec 2009 18:03:35 +0000 Subject: [PATCH] Added another function initAllPts() to handle shallow pointer concerns. --- Cantera/src/thermo/Phase.h | 1 + Cantera/src/thermo/VPSSMgr_General.cpp | 42 +++++++++++++++++++++++--- Cantera/src/thermo/VPSSMgr_General.h | 15 +++++++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Cantera/src/thermo/Phase.h b/Cantera/src/thermo/Phase.h index 8512f8aae..60c5ec06a 100644 --- a/Cantera/src/thermo/Phase.h +++ b/Cantera/src/thermo/Phase.h @@ -502,6 +502,7 @@ namespace Cantera { * base classes become hidden. */ int m_kk; + /** * m_ndim is the dimensionality of the phase. Volumetric * phases have dimensionality 3 and surface phases have diff --git a/Cantera/src/thermo/VPSSMgr_General.cpp b/Cantera/src/thermo/VPSSMgr_General.cpp index fc90e6e4e..442eeda59 100644 --- a/Cantera/src/thermo/VPSSMgr_General.cpp +++ b/Cantera/src/thermo/VPSSMgr_General.cpp @@ -63,12 +63,23 @@ namespace Cantera { m_useTmpRefStateStorage = true; *this = right; } - - + //==================================================================================================================== VPSSMgr_General& VPSSMgr_General::operator=(const VPSSMgr_General &b) { - if (&b == this) return *this; + if (&b == this) { + return *this; + } VPSSMgr::operator=(b); + /* + * Must fill in the shallow pointers. These must have already been transfered + * and storred in the owning VPStandardStateTP class. Note we are aware that at this point + * m_vptr_ptr may refer back to the wrong ThermoPhase object. However, the shallow copy + * performed here is consistent with the assignment operator's general functionality. + */ + m_PDSS_ptrs.resize(m_kk); + for (int k = 0; k < m_kk; k++) { + m_PDSS_ptrs[k] = m_vptp_ptr->providePDSS(k); + } return *this; } @@ -76,8 +87,29 @@ namespace Cantera { VPSSMgr_General *vpm = new VPSSMgr_General(*this); return (VPSSMgr *) vpm; } - - + //==================================================================================================================== + // Initialize the internal shallow pointers in this object + /* + * There are a bunch of internal shallow pointers that point to the owning + * VPStandardStateTP and SpeciesThermo objects. This function reinitializes + * them. This function is called like an onion. + * + * @param vp_ptr Pointer to the VPStandardStateTP standard state + * @param sp_ptr Poitner to the SpeciesThermo standard state + */ + void VPSSMgr_General::initAllPtrs(VPStandardStateTP *vp_ptr, SpeciesThermo *sp_ptr) + { + VPSSMgr::initAllPtrs(vp_ptr, sp_ptr); + /* + * Must fill in the shallow pointers. These must have already been transfered + * and storred in the owning VPStandardStateTP class. + */ + m_PDSS_ptrs.resize(m_kk); + for (int k = 0; k < m_kk; k++) { + m_PDSS_ptrs[k] = m_vptp_ptr->providePDSS(k); + } + } + //==================================================================================================================== void VPSSMgr_General::_updateRefStateThermo() const { if (m_useTmpRefStateStorage) { diff --git a/Cantera/src/thermo/VPSSMgr_General.h b/Cantera/src/thermo/VPSSMgr_General.h index 458c5e5c4..fe43a307b 100644 --- a/Cantera/src/thermo/VPSSMgr_General.h +++ b/Cantera/src/thermo/VPSSMgr_General.h @@ -266,8 +266,18 @@ namespace Cantera { */ virtual VPSSMgr_enumType reportVPSSMgrType() const ; - - protected: + //! Initialize the internal shallow pointers in this object + /*! + * There are a bunch of internal shallow pointers that point to the owning + * VPStandardStateTP and SpeciesThermo objects. This function reinitializes + * them. This function is called like an onion. + * + * @param vp_ptr Pointer to the VPStandardStateTP standard state + * @param sp_ptr Poitner to the SpeciesThermo standard state + */ + virtual void initAllPtrs(VPStandardStateTP *vp_ptr, SpeciesThermo *sp_ptr); + + private: //! Shallow pointers containing the PDSS objects for the species //! in this phase. @@ -276,7 +286,6 @@ namespace Cantera { */ std::vector m_PDSS_ptrs; - private: //! VPStandardStateTP has its own err routine /*!