diff --git a/Cantera/src/transport/DustyGasTransport.cpp b/Cantera/src/transport/DustyGasTransport.cpp index a6d3cd404..827a0bdd6 100644 --- a/Cantera/src/transport/DustyGasTransport.cpp +++ b/Cantera/src/transport/DustyGasTransport.cpp @@ -114,14 +114,19 @@ namespace Cantera { m_diam = right.m_diam; m_perm = right.m_perm; - // Warning -> This is a shallow pointer copy. gastran may not point to the correct object + // Warning -> gastran may not point to the correct object // after this copy. The routine initialize() must be called - m_gastran = right.m_gastran; + if (m_gastran) { + delete m_gastran; + } + m_gastran = right.duplMyselfAsTransport(); + return *this; } //==================================================================================================================== DustyGasTransport::~DustyGasTransport() { + delete m_gastran; } //==================================================================================================================== // Duplication routine for objects which inherit from %Transport @@ -182,7 +187,12 @@ namespace Cantera { // constant mixture attributes m_thermo = phase; m_nsp = m_thermo->nSpecies(); - m_gastran = gastr; + if (m_gastran != gastr) { + if (m_gastran) { + delete m_gastran; + } + m_gastran = gastr; + } // make a local copy of the molecular weights m_mw.resize(m_nsp); diff --git a/Cantera/src/transport/DustyGasTransport.h b/Cantera/src/transport/DustyGasTransport.h index 2a9e96813..83304364b 100644 --- a/Cantera/src/transport/DustyGasTransport.h +++ b/Cantera/src/transport/DustyGasTransport.h @@ -378,6 +378,9 @@ namespace Cantera { doublereal m_perm; //! Pointer to the transport object for the gas phase + /*! + * Note, this object owns the gastran object + */ Transport* m_gastran; }; diff --git a/Cantera/src/transport/TransportBase.h b/Cantera/src/transport/TransportBase.h index 1e1d07e55..e605836ed 100644 --- a/Cantera/src/transport/TransportBase.h +++ b/Cantera/src/transport/TransportBase.h @@ -746,10 +746,9 @@ namespace Cantera { //! Set model parameters for derived classes /*! - * This method may be - * overloaded in subclasses to set model-specific parameters. - * The primary use of this class is to set parameters while in the - * middle of a calculation. + * This method may be derived in subclasses to set model-specific parameters. + * The primary use of this class is to set parameters while in the middle of a calculation + * without actually having to dynamically cast the base Transport pointer. * * @param type Specifies the type of parameters to set * 0 : Diffusion coefficient @@ -759,8 +758,7 @@ namespace Cantera { * @param p Vector of parameters. The length of the vector * varies with the parameterization */ - virtual void setParameters(const int type, const int k, - const doublereal* const p); + virtual void setParameters(const int type, const int k, const doublereal* const p); //! Sets the velocity basis /*!