Fixed errors in the copy and assignment operator functions

for the IonsFromNeutralVPSSTP object.
This commit is contained in:
Harry Moffat 2009-12-02 18:06:09 +00:00
parent c0249fa3d2
commit 1f9d937d15
5 changed files with 61 additions and 29 deletions

View file

@ -45,7 +45,7 @@ namespace Cantera {
GibbsExcessVPSSTP::GibbsExcessVPSSTP(const GibbsExcessVPSSTP &b) :
VPStandardStateTP()
{
*this = operator=(b);
GibbsExcessVPSSTP::operator=(b);
}
/*
@ -56,10 +56,12 @@ namespace Cantera {
*/
GibbsExcessVPSSTP& GibbsExcessVPSSTP::
operator=(const GibbsExcessVPSSTP &b) {
if (&b != this) {
VPStandardStateTP::operator=(b);
if (&b == this) {
return *this;
}
VPStandardStateTP::operator=(b);
moleFractions_ = b.moleFractions_;
lnActCoeff_Scaled_ = b.lnActCoeff_Scaled_;
dlnActCoeffdT_Scaled_ = b.dlnActCoeffdT_Scaled_;

View file

@ -141,7 +141,7 @@ namespace Cantera {
neutralMoleculePhase_(0),
IOwnNThermoPhase_(true)
{
*this = operator=(b);
IonsFromNeutralVPSSTP::operator=(b);
}
/*
@ -152,14 +152,18 @@ namespace Cantera {
*/
IonsFromNeutralVPSSTP& IonsFromNeutralVPSSTP::
operator=(const IonsFromNeutralVPSSTP &b) {
if (&b != this) {
GibbsExcessVPSSTP::operator=(b);
}
if (&b == this) {
return *this;
}
GibbsExcessVPSSTP::operator=(b);
ionSolnType_ = b.ionSolnType_;
numNeutralMoleculeSpecies_ = b.numNeutralMoleculeSpecies_;
indexSpecialSpecies_ = b.indexSpecialSpecies_;
indexSecondSpecialSpecies_ = b.indexSecondSpecialSpecies_;
fm_neutralMolec_ions_ = b.fm_neutralMolec_ions_;
fm_invert_ionForNeutral = b.fm_invert_ionForNeutral;
NeutralMolecMoleFractions_ = b.NeutralMolecMoleFractions_;
cationList_ = b.cationList_;
numCationSpecies_ = b.numCationSpecies_;
@ -167,21 +171,35 @@ namespace Cantera {
numAnionSpecies_ = b.numAnionSpecies_;
passThroughList_ = b.passThroughList_;
numPassThroughSpecies_ = b.numPassThroughSpecies_;
/*
* This is a shallow copy. We need to figure this out
*/
neutralMoleculePhase_ = b.neutralMoleculePhase_;
if (neutralMoleculePhase_) {
exit(-1);
}
IOwnNThermoPhase_ = b.IOwnNThermoPhase_;
/*
* If we own the underlying neutral molecule phase, then we do a deep
* copy. If not, we do a shallow copy.
*/
if (IOwnNThermoPhase_) {
if (b.neutralMoleculePhase_) {
if (neutralMoleculePhase_) {
delete neutralMoleculePhase_;
}
neutralMoleculePhase_ = (b.neutralMoleculePhase_)->duplMyselfAsThermoPhase();
} else {
neutralMoleculePhase_ = 0;
}
} else {
neutralMoleculePhase_ = b.neutralMoleculePhase_;
}
IOwnNThermoPhase_ = b.IOwnNThermoPhase_;
moleFractionsTmp_ = b.moleFractionsTmp_;
muNeutralMolecule_ = b.muNeutralMolecule_;
gammaNeutralMolecule_ = b.gammaNeutralMolecule_;
dlnActCoeffdT_NeutralMolecule_ = b.dlnActCoeffdT_NeutralMolecule_;
dlnActCoeffdlnC_NeutralMolecule_ = b.dlnActCoeffdlnC_NeutralMolecule_;
return *this;
}
/**
/*
*
* ~IonsFromNeutralVPSSTP(): (virtual)
*
@ -191,7 +209,7 @@ namespace Cantera {
IonsFromNeutralVPSSTP::~IonsFromNeutralVPSSTP() {
if (IOwnNThermoPhase_) {
delete neutralMoleculePhase_;
neutralMoleculePhase_=0;
neutralMoleculePhase_ = 0;
}
}

View file

@ -152,9 +152,9 @@ namespace Cantera {
/// Destructor.
virtual ~IonsFromNeutralVPSSTP();
//! Duplication routine for objects which inherit from ThermoPhase.
//! Duplication routine for objects which inherit from ThermoPhase.
/*!
* This virtual routine can be used to duplicate thermophase objects
* This virtual routine can be used to duplicate ThermoPhase objects
* inherited from ThermoPhase even if the application only has
* a pointer to ThermoPhase to work with.
*/
@ -720,7 +720,7 @@ namespace Cantera {
//! Index of special species
int indexSpecialSpecies_;
//! Index of special species
//! Index of special species
int indexSecondSpecialSpecies_;
//! Formula Matrix for composition of neutral molecules
@ -768,7 +768,7 @@ namespace Cantera {
int numCationSpecies_;
//! List of the species in this ThermoPhase which are anion species
std::vector<int>anionList_;
std::vector<int> anionList_;
//! Number of anion species
int numAnionSpecies_;
@ -785,9 +785,22 @@ namespace Cantera {
int numPassThroughSpecies_;
public:
//! This is a pointer to the neutral Molecule Phase
/*!
* If the variable, IOwnNThermoPhase_ is true, then we own
* the pointer. If not, then this is considered a shallow pointer.
*/
ThermoPhase *neutralMoleculePhase_;
protected:
private:
//! If true then we own the underlying neutral Molecule Phase
/*!
* If this is false, then the neutral molecule phase is considered
* as a shallow pointer.
*/
bool IOwnNThermoPhase_;
//! ThermoPhase for the cation lattice
/*!
* Currently this is unimplemented and may be deleted
@ -808,9 +821,6 @@ namespace Cantera {
mutable std::vector<doublereal> dlnActCoeffdT_NeutralMolecule_;
mutable std::vector<doublereal> dlnActCoeffdlnC_NeutralMolecule_;
private:
};

View file

@ -75,7 +75,7 @@ namespace Cantera {
MargulesVPSSTP::MargulesVPSSTP(const MargulesVPSSTP &b) :
GibbsExcessVPSSTP()
{
*this = operator=(b);
MargulesVPSSTP::operator=(b);
}
/*
@ -86,9 +86,11 @@ namespace Cantera {
*/
MargulesVPSSTP& MargulesVPSSTP::
operator=(const MargulesVPSSTP &b) {
if (&b != this) {
GibbsExcessVPSSTP::operator=(b);
if (&b == this) {
return *this;
}
GibbsExcessVPSSTP::operator=(b);
numBinaryInteractions_ = b.numBinaryInteractions_ ;
m_HE_b_ij = b.m_HE_b_ij;

View file

@ -60,7 +60,7 @@ namespace Cantera {
m_P0(OneAtm),
m_VPSS_ptr(0)
{
*this = b;
VPStandardStateTP::operator=(b);
}
/*