Filled the copy constructors, assignment operators, and duplication

functions for the remaining ThermoPhase objects.
This commit is contained in:
Harry Moffat 2007-06-05 15:17:14 +00:00
parent 91e463cf74
commit d36aa23362
18 changed files with 512 additions and 40 deletions

View file

@ -43,9 +43,24 @@ namespace Cantera {
*/
EdgePhase(doublereal n0 = 0.0);
//! Copy Constructor
/*!
* @param right Object to be copied
*/
EdgePhase(const EdgePhase & right);
//! Assignment Operator
/*!
* @param right Object to be copied
*/
EdgePhase& operator=(const EdgePhase & right);
//! Destructor
virtual ~EdgePhase() {}
//! Duplicator from a ThermoPhase object
ThermoPhase *duplMyselfAsThermoPhase() const;
//! returns the equation of state type
virtual int eosType() const { return cEdge; }

View file

@ -72,6 +72,12 @@ namespace Cantera {
IdealGasPDSS::~IdealGasPDSS() {
}
//! Duplicator
ThermoPhase *IdealGasPDSS::duplMyselfAsThermoPhase() const {
IdealGasPDSS * idg = new IdealGasPDSS(*this);
return (ThermoPhase *) idg;
}
void IdealGasPDSS::constructPDSS(ThermoPhase *tp, int spindex) {
initThermo();
}

View file

@ -37,11 +37,29 @@ namespace Cantera {
* Basic list of constructors and duplicators
*/
IdealGasPDSS(ThermoPhase *tp, int spindex);
//! Copy Constructur
/*!
* @param b Object to be copied
*/
IdealGasPDSS(const IdealGasPDSS &b);
//! Assignment operator
/*!
* @param b Object to be copeid
*/
IdealGasPDSS& operator=(const IdealGasPDSS&b);
IdealGasPDSS(ThermoPhase *tp, int spindex, std::string inputFile, std::string id = "");
IdealGasPDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRef, std::string id = "");
IdealGasPDSS(ThermoPhase *tp, int spindex,
std::string inputFile, std::string id = "");
IdealGasPDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRef,
std::string id = "");
//! Destructor
virtual ~IdealGasPDSS();
//! Duplicator
virtual ThermoPhase *duplMyselfAsThermoPhase() const;
/**
*

View file

@ -95,7 +95,7 @@ namespace Cantera {
//! Copy Constructor
IdealMolalSoln(const IdealMolalSoln &);
//! Equality operator
//! Assignment operator
IdealMolalSoln& operator=(const IdealMolalSoln&);
//! Constructor for phase initialization

View file

@ -21,6 +21,63 @@
namespace Cantera {
//! Base Empty constructor
LatticePhase::LatticePhase() :
m_tlast(0.0)
{
}
//! Copy Constructor
/*!
* @param right Object to be copied
*/
LatticePhase::LatticePhase(const LatticePhase &right) :
m_tlast(0.0)
{
*this = operator=(right);
}
//! Assignment operator
/*!
* @param right Object to be copied
*/
LatticePhase& LatticePhase::operator=(const LatticePhase& right) {
if (&right != this) {
ThermoPhase::operator=(right);
m_mm = right.m_mm;
m_tmin = right.m_tmin;
m_tmax = right.m_tmax;
m_p0 = right.m_p0;
m_tlast = right.m_tlast;
m_h0_RT = right.m_h0_RT;
m_cp0_R = right.m_cp0_R;
m_g0_RT = right.m_g0_RT;
m_s0_R = right.m_s0_R;
m_press = right.m_press;
m_vacancy = right.m_vacancy;
m_molar_density = right.m_molar_density;
}
return *this;
}
//! Destructor
LatticePhase::~LatticePhase() {
}
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *LatticePhase::duplMyselfAsThermoPhase() const {
LatticePhase *igp = new LatticePhase(*this);
return (ThermoPhase *) igp;
}
doublereal LatticePhase::
enthalpy_mole() const {
doublereal p0 = m_spthermo->refPressure();

View file

@ -31,9 +31,33 @@ namespace Cantera {
public:
LatticePhase() : m_tlast(0.0) {}
//! Base Empty constructor
LatticePhase();
virtual ~LatticePhase() {}
//! Copy Constructor
/*!
* @param right Object to be copied
*/
LatticePhase(const LatticePhase &right);
//! Assignment operator
/*!
* @param right Object to be copied
*/
LatticePhase& operator=(const LatticePhase& right);
//! Destructor
virtual ~LatticePhase();
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *duplMyselfAsThermoPhase() const;
virtual int eosType() const { return cLattice; }
@ -134,7 +158,9 @@ namespace Cantera {
protected:
int m_mm;
doublereal m_tmin, m_tmax, m_p0;
doublereal m_tmin;
doublereal m_tmax;
doublereal m_p0;
mutable doublereal m_tlast;
mutable array_fp m_h0_RT;
mutable array_fp m_cp0_R;

View file

@ -26,6 +26,59 @@ using namespace std;
namespace Cantera {
// Base empty constructor
LatticeSolidPhase::LatticeSolidPhase() :
m_tlast(0.0)
{
}
// Copy Constructor
/*
* @param right Object to be copied
*/
LatticeSolidPhase::LatticeSolidPhase(const LatticeSolidPhase &right) :
m_tlast(0.0)
{
*this = operator=(right);
}
// Assignment operator
/*
* @param right Object to be copied
*/
LatticeSolidPhase&
LatticeSolidPhase::operator=(const LatticeSolidPhase& right) {
if (&right != this) {
ThermoPhase::operator=(right);
m_mm = right.m_mm;
m_kk = right.m_kk;
m_tlast = right.m_tlast;
m_press = right.m_press;
m_molar_density = right.m_molar_density;
m_nlattice = right.m_nlattice;
m_x = right.m_x;
}
return *this;
}
//! Destructor
LatticeSolidPhase::~LatticeSolidPhase() {
}
// Duplication function
/*
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a %ThermoPhase pointer.
*/
ThermoPhase *LatticeSolidPhase::duplMyselfAsThermoPhase() const {
LatticeSolidPhase *igp = new LatticeSolidPhase(*this);
return (ThermoPhase *) igp;
}
doublereal LatticeSolidPhase::
enthalpy_mole() const {
_updateThermo();

View file

@ -34,9 +34,33 @@ namespace Cantera {
public:
LatticeSolidPhase() : m_tlast(0.0) {}
//! Base empty constructor
LatticeSolidPhase();
virtual ~LatticeSolidPhase() {}
//! Copy Constructor
/*!
* @param right Object to be copied
*/
LatticeSolidPhase(const LatticeSolidPhase &right);
//! Assignment operator
/*!
* @param right Object to be copied
*/
LatticeSolidPhase& operator=(const LatticeSolidPhase& right);
//! Destructor
virtual ~LatticeSolidPhase();
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *duplMyselfAsThermoPhase() const;
virtual int eosType() const { return cLatticeSolid; }

View file

@ -35,9 +35,27 @@ namespace Cantera {
MetalPhase() {}
virtual ~MetalPhase() {}
MetalPhase(const MetalPhase &right) {
*this = operator=(right);
}
// Overloaded methoods of class ThermoPhase
MetalPhase& operator=(const MetalPhase &right) {
if (&right != this) {
ThermoPhase::operator=(right);
m_press = right.m_press;
}
return *this;
}
virtual ~MetalPhase() {}
//! Duplicator
virtual ThermoPhase *duplMyselfAsThermoPhase() const {
MetalPhase * idg = new MetalPhase(*this);
return (ThermoPhase *) idg;
}
// Overloaded methods of class ThermoPhase
virtual int eosType() const { return cMetal; }

View file

@ -41,8 +41,19 @@ namespace Cantera {
*/
PDSS();
PDSS(ThermoPhase *tp, int spindex);
//! Copy Constructor
/*!
* @param b object to be copied
*/
PDSS(const PDSS &b);
//! Assignment operator
/*!
* @param b Object to be copied
*/
PDSS& operator=(const PDSS&b);
PDSS(ThermoPhase *tp, int spindex, std::string inputFile, std::string id = "");
PDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRef, std::string id = "");
virtual ~PDSS();

View file

@ -1,6 +1,7 @@
/**
* @file PureFluidPhase.cpp
* Definitions for a ThermoPhase object for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid
* Definitions for a ThermoPhase object for a pure fluid phase consisting
* of gas, liquid, mixed-gas-liquid
* and supercritical fluid (see \ref thermoprops
* and class \link Cantera::PureFluidPhase PureFluidPhase\endlink).
*/
@ -17,7 +18,64 @@
namespace Cantera {
PureFluidPhase::~PureFluidPhase() { delete m_sub; }
// Base Constructor
PureFluidPhase::PureFluidPhase() :
ThermoPhase(),
m_sub(0),
m_subflag(0),
m_mw(-1.0),
m_verbose(false)
{
}
// CopyConstructor
PureFluidPhase::PureFluidPhase(const PureFluidPhase& right) :
ThermoPhase(),
m_sub(0),
m_subflag(0),
m_mw(-1.0),
m_verbose(false)
{
*this = right;
}
//! Assignment operator
/*!
* @param right Object to be copied
*/
PureFluidPhase& PureFluidPhase::operator=(const PureFluidPhase& right) {
if (&right != this) {
ThermoPhase::operator=(right);
if (m_sub) {
delete m_sub;
}
m_subflag = right.m_subflag;
m_sub = tpx::GetSub(m_subflag);
m_mw = right.m_mw;
m_verbose = right.m_verbose;
}
return *this;
}
// Duplicator from the %ThermoPhase parent class
/*
* Given a pointer to a %ThermoPhase object, this function will
* duplicate the %ThermoPhase object and all underlying structures.
* This is basically a wrapper around the copy constructor.
*
* @return returns a pointer to a %ThermoPhase
*/
ThermoPhase *PureFluidPhase::duplMyselfAsThermoPhase() const {
PureFluidPhase *igp = new PureFluidPhase(*this);
return (ThermoPhase *) igp;
}
PureFluidPhase::~PureFluidPhase() {
delete m_sub;
}
void PureFluidPhase::
initThermo() {

View file

@ -63,13 +63,34 @@ namespace Cantera {
public:
//! Base Constructor
PureFluidPhase() : ThermoPhase(), m_sub(0), m_subflag(0),
m_mw(-1.0), m_verbose(false) {}
//! Empty Base Constructor
PureFluidPhase();
//! Copy Constructor
/*!
* @param right Object to be copied
*/
PureFluidPhase(const PureFluidPhase &right);
//! Assignment operator
/*!
* @param right Object to be copied
*/
PureFluidPhase& operator=(const PureFluidPhase& right);
//! Destructor
virtual ~PureFluidPhase();
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *duplMyselfAsThermoPhase() const;
//! Equation of state type
virtual int eosType() const { return cPureFluid; }

View file

@ -28,9 +28,8 @@ namespace Cantera {
*
*/
/**
* SingleSpeciesTP():
*
// Base empty constructor.
/*
* Base constructor -> does nothing but called the inherited
* class constructor
*/
@ -44,15 +43,62 @@ namespace Cantera {
{
}
/**
* ~SingleSpeciesTP():
*
//! Copy constructor
/*!
* @param right Object to be copied
*/
SingleSpeciesTP::SingleSpeciesTP(const SingleSpeciesTP &right):
ThermoPhase(),
m_tmin(0.0),
m_tmax(0.0),
m_press(OneAtm),
m_p0(OneAtm),
m_tlast(-1.0)
{
*this = operator=(right);
}
//! Assignment operator
/*!
* @param right Object to be copied
*/
SingleSpeciesTP & SingleSpeciesTP::operator=(const SingleSpeciesTP & right) {
if (&right != this) {
ThermoPhase::operator=(right);
m_tmin = right.m_tmin;
m_tmax = right.m_tmax;
m_press = right.m_press;
m_p0 = right.m_p0;
m_tlast = right.m_tlast;
m_h0_RT = right.m_h0_RT;
m_cp0_R = right.m_cp0_R;
m_s0_R = right.m_s0_R;
}
return *this;
}
/*
* destructor -> does nothing but implicitly calls the inherited
* class destructors.
*/
SingleSpeciesTP::~SingleSpeciesTP()
{
}
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *SingleSpeciesTP::duplMyselfAsThermoPhase() const {
SingleSpeciesTP *stp = new SingleSpeciesTP(*this);
return (ThermoPhase *) stp;
}
/**
*
* ------------------- Utilities ----------------------------------

View file

@ -67,7 +67,8 @@ namespace Cantera {
* of such a compound even past the phase equilibrium point, up to the
* point where the phase itself ceases to be a stable phase.
*
* This class doesn't do much at the initialization level. It's SingleSpeciesTP::initThermo()
* This class doesn't do much at the initialization level.
* It's SingleSpeciesTP::initThermo()
* member does check that one and only one species has been defined
* to occupy the phase.
*
@ -77,12 +78,34 @@ namespace Cantera {
public:
/// Constructor.
//! Base empty constructor.
SingleSpeciesTP();
/// Destructor
//! Copy constructor
/*!
* @param right Object to be copied
*/
SingleSpeciesTP(const SingleSpeciesTP &right);
//! Assignment operator
/*!
* @param right Object to be copied
*/
SingleSpeciesTP & operator=(const SingleSpeciesTP & right);
//! Destructor
virtual ~SingleSpeciesTP();
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *duplMyselfAsThermoPhase() const;
/**
*
* @name Information Methods

View file

@ -39,6 +39,11 @@ namespace Cantera {
{
}
// Full Constructor.
/*
* @param phaseRef XML node pointing to a StoichSubstanceSSTP description
* @param id Id of the phase.
*/
StoichSubstanceSSTP::StoichSubstanceSSTP(XML_Node& xmlphase, std::string id) {
if (id != "") {
std::string idxml = xmlphase["id"];
@ -56,6 +61,28 @@ namespace Cantera {
importPhase(xmlphase, this);
}
//! Copy constructor
/*!
* @param right Object to be copied
*/
StoichSubstanceSSTP::StoichSubstanceSSTP(const StoichSubstanceSSTP &right) :
SingleSpeciesTP()
{
*this = operator=(right);
}
//! Assignment operator
/*!
* @param right Object to be copied
*/
StoichSubstanceSSTP &
StoichSubstanceSSTP::operator=(const StoichSubstanceSSTP & right) {
if (&right != this) {
SingleSpeciesTP::operator=(right);
}
return *this;
}
/*
* Destructor for the routine (virtual)
*
@ -64,6 +91,20 @@ namespace Cantera {
{
}
// Duplication function
/*
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *StoichSubstanceSSTP::duplMyselfAsThermoPhase() const {
StoichSubstanceSSTP *stp = new StoichSubstanceSSTP(*this);
return (ThermoPhase *) stp;
}
/*
* ---- Utilities -----
*/

View file

@ -53,7 +53,8 @@ namespace Cantera {
* The enthalpy function is given by the following relation.
*
* \f[
* \raggedright h^o_k(T,P) = h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right)
* \raggedright h^o_k(T,P) =
* h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right)
* \f]
*
* For an incompressible,
@ -166,25 +167,42 @@ namespace Cantera {
class StoichSubstanceSSTP : public SingleSpeciesTP {
public:
/**
* Default Constructor for the StoichSubstanceSSTP class
*/
//! Default Constructor for the StoichSubstanceSSTP class
StoichSubstanceSSTP();
//! Constructor.
//! Full Constructor.
/*!
* @param phaseRef XML node pointing to a StoichSubstanceSSTP description
* @param id Id of the phase.
*/
StoichSubstanceSSTP(XML_Node& phaseRef, std::string id = "");
/**
* Destructor for the routine (virtual)
*
//! Copy constructor
/*!
* @param right Object to be copied
*/
StoichSubstanceSSTP(const StoichSubstanceSSTP &right);
//! Assignment operator
/*!
* @param right Object to be copied
*/
StoichSubstanceSSTP & operator=(const StoichSubstanceSSTP & right);
//! Destructor for the routine (virtual)
virtual ~StoichSubstanceSSTP();
//! Duplication function
/*!
* This virtual function is used to create a duplicate of the
* current phase. It's used to duplicate the phase when given
* a ThermoPhase pointer to the phase.
*
* @return It returns a ThermoPhase pointer.
*/
ThermoPhase *duplMyselfAsThermoPhase() const;
/**
*
* @name Utilities
@ -399,8 +417,8 @@ namespace Cantera {
* term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
* enthalpy to compute the standard state molar internal energy.
*
* @param urt output vector of nondimensional standard state internal energies
* of the species. Length: m_kk.
* @param urt output vector of nondimensional standard state
* internal energies of the species. Length: m_kk.
*/
virtual void getIntEnergy_RT(doublereal* urt) const;

View file

@ -113,7 +113,7 @@ namespace Cantera {
* @return returns a pointer to a %ThermoPhase
*/
ThermoPhase *SurfPhase::duplMyselfAsThermoPhase() const {
ThermoPhase *igp = new SurfPhase(*this);
SurfPhase *igp = new SurfPhase(*this);
return (ThermoPhase *) igp;
}
@ -441,10 +441,46 @@ namespace Cantera {
}
}
// Default constructor
EdgePhase::EdgePhase(doublereal n0) : SurfPhase(n0) {
setNDim(1);
}
EdgePhase::EdgePhase(doublereal n0) : SurfPhase(n0) {
setNDim(1);
// Copy Constructor
/*
* @param right Object to be copied
*/
EdgePhase::EdgePhase(const EdgePhase & right) :
SurfPhase(right.m_n0)
{
setNDim(1);
*this = operator=(right);
}
// Assignment Operator
/*
* @param right Object to be copied
*/
EdgePhase& EdgePhase::operator=(const EdgePhase & right) {
if (&right != this) {
SurfPhase::operator=(right);
setNDim(1);
}
return *this;
}
// Duplicator from the %ThermoPhase parent class
/*
* Given a pointer to a %ThermoPhase object, this function will
* duplicate the %ThermoPhase object and all underlying structures.
* This is basically a wrapper around the copy constructor.
*
* @return returns a pointer to a %ThermoPhase
*/
ThermoPhase *EdgePhase::duplMyselfAsThermoPhase() const {
EdgePhase *igp = new EdgePhase(*this);
return (ThermoPhase *) igp;
}
void EdgePhase::
setParametersFromXML(const XML_Node& eosdata) {

View file

@ -65,7 +65,8 @@ namespace Cantera {
* The virtual function #_updateRefStateThermo() is supplied to do this
* and may be reimplemented in child routines. A default implementation
* based on the speciesThermo class is supplied in this base class.
* #_updateStandardStateThermo() is called whenever a reference state property is needed.
* #_updateStandardStateThermo() is called whenever a reference state
* property is needed.
*
* When #m_useTmpStandardStateStorage is true, then the following
* internal arrays, containing information on the standard state properties