Nominally finished the copy constructors/assignment operators

for the Kinetics class and friends.

However, I have not done any testing on this, none.
This commit is contained in:
Harry Moffat 2010-06-25 20:56:45 +00:00
parent 0cbec89c52
commit 0766b9469d
5 changed files with 229 additions and 38 deletions

View file

@ -30,7 +30,50 @@
using namespace std;
namespace Cantera {
//====================================================================================================================
AqueousKineticsData::AqueousKineticsData() :
m_logp_ref(0.0),
m_logc_ref(0.0),
m_ROP_ok(false),
m_temp(0.0)
{
}
//====================================================================================================================
AqueousKineticsData::~AqueousKineticsData()
{
}
//====================================================================================================================
AqueousKineticsData::AqueousKineticsData(const AqueousKineticsData &right) :
m_logp_ref(0.0),
m_logc_ref(0.0),
m_ROP_ok(false),
m_temp(0.0)
{
*this=right;
}
//====================================================================================================================
AqueousKineticsData& AqueousKineticsData::operator=(const AqueousKineticsData &right)
{
if (this != &right) {
m_logp_ref = right.m_logp_ref;
m_logc_ref = right.m_logc_ref;
m_ropf = right.m_ropf;
m_ropr = right.m_ropr;
m_ropnet = right.m_ropnet;
m_rfn_low = right.m_rfn_low;
m_rfn_high = right.m_rfn_high;
m_ROP_ok = right.m_ROP_ok;
m_temp = right.m_temp;
m_rfn = right.m_rfn;
m_rkcn = right.m_rkcn;
}
return *this;
}
//====================================================================================================================
//====================================================================================================================
/**
* Construct an empty reaction mechanism.
*/
@ -47,12 +90,70 @@ namespace Cantera {
m_kdata->m_temp = 0.0;
m_rxnstoich = new ReactionStoichMgr;
}
//====================================================================================================================
AqueousKinetics::AqueousKinetics(const AqueousKinetics &right) :
Kinetics(),
m_kk(0),
m_nfall(0),
m_nirrev(0),
m_nrev(0),
m_finalized(false)
{
*this = right;
}
//====================================================================================================================
AqueousKinetics::~AqueousKinetics() {
delete m_kdata;
delete m_rxnstoich;
}
}
//====================================================================================================================
AqueousKinetics& AqueousKinetics::operator=(const AqueousKinetics &right)
{
if (this == &right) return *this;
Kinetics::operator=(right);
m_kk = right.m_kk;
m_nfall = right.m_nfall;
m_rates = right.m_rates;
m_index = right.m_index;
m_irrev = right.m_irrev;
*m_rxnstoich = *(right.m_rxnstoich);
m_fwdOrder = right.m_fwdOrder;
m_nirrev = right.m_nirrev;
m_nrev = right.m_nrev;
m_rgroups = right.m_rgroups;
m_pgroups = right.m_pgroups;
m_rxntype = right.m_rxntype;
m_rrxn = right.m_rrxn;
m_prxn = right.m_prxn;
m_dn = right.m_dn;
m_revindex = right.m_revindex;
m_rxneqn = right.m_rxneqn;
*m_kdata = *(right.m_kdata);
m_conc = right.m_conc;
m_grt = right.m_grt;
m_finalized = right.m_finalized;
throw CanteraError("GasKinetics::operator=()",
"Unfinished implementation");
return *this;
}
//====================================================================================================================
Kinetics *AqueousKinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const
{
AqueousKinetics* gK = new AqueousKinetics(*this);
gK->assignShallowPointers(tpVector);
return dynamic_cast<Kinetics *>(gK);
}
//====================================================================================================================
/**
* Update temperature-dependent portions of reaction rates and
* falloff functions.

View file

@ -46,18 +46,21 @@ namespace Cantera {
*/
class AqueousKineticsData {
public:
AqueousKineticsData() :
m_logp_ref(0.0),
m_logc_ref(0.0),
m_ROP_ok(false),
m_temp(0.0)
{}
virtual ~AqueousKineticsData(){}
AqueousKineticsData();
doublereal m_logp_ref, m_logc_ref;
~AqueousKineticsData();
AqueousKineticsData(const AqueousKineticsData &right);
AqueousKineticsData& operator=(const AqueousKineticsData &right);
doublereal m_logp_ref;
doublereal m_logc_ref;
array_fp m_ropf;
array_fp m_ropr, m_ropnet;
array_fp m_rfn_low, m_rfn_high;
array_fp m_ropr;
array_fp m_ropnet;
array_fp m_rfn_low;
array_fp m_rfn_high;
bool m_ROP_ok;
doublereal m_temp;
@ -88,9 +91,27 @@ namespace Cantera {
/// Constructor.
AqueousKinetics(thermo_t* thermo = 0);
AqueousKinetics(const AqueousKinetics &right);
AqueousKinetics& operator=(const AqueousKinetics &right);
/// Destructor.
virtual ~AqueousKinetics();
//! Duplication routine for objects which inherit from Kinetics
/*!
* This virtual routine can be used to duplicate %Kinetics objects
* inherited from %Kinetics even if the application only has
* a pointer to %Kinetics to work with.
*
* These routines are basically wrappers around the derived copy constructor.
*
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
* m_thermo vector within this object
*/
virtual Kinetics *duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
virtual int ID() const { return cAqueousKinetics; }
virtual int type() const { return cAqueousKinetics; }

View file

@ -37,6 +37,38 @@ namespace Cantera {
/// Destructor.
virtual ~EdgeKinetics() {}
EdgeKinetics(const EdgeKinetics &right) :
InterfaceKinetics(right)
{
*this=right;
}
EdgeKinetics & operator=(const EdgeKinetics &right)
{
if (this != &right) {
InterfaceKinetics::operator=(right);
}
return *this;
}
//! Duplication routine for objects which inherit from Kinetics
/*!
* This virtual routine can be used to duplicate %Kinetics objects
* inherited from %Kinetics even if the application only has
* a pointer to %Kinetics to work with.
*
* These routines are basically wrappers around the derived copy constructor.
*
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
* m_thermo vector within this object
*/
virtual Kinetics *duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const
{
EdgeKinetics* iK = new EdgeKinetics(*this);
iK->assignShallowPointers(tpVector);
return dynamic_cast<Kinetics *>(iK);
}
/**
* Identifies the subclass of the Kinetics manager type.
* These are listed in mix_defs.h.

View file

@ -24,7 +24,45 @@
using namespace std;
namespace Cantera {
//====================================================================================================================
InterfaceKineticsData::InterfaceKineticsData() :
m_logp0(0.0),
m_logc0(0.0),
m_ROP_ok(false),
m_temp(0.0),
m_logtemp(0.0)
{
}
//====================================================================================================================
InterfaceKineticsData:: InterfaceKineticsData(const InterfaceKineticsData &right) :
m_logp0(0.0),
m_logc0(0.0),
m_ROP_ok(false),
m_temp(0.0),
m_logtemp(0.0)
{
*this = right;
}
//====================================================================================================================
InterfaceKineticsData::~InterfaceKineticsData()
{
}
//====================================================================================================================
InterfaceKineticsData & InterfaceKineticsData::operator=(const InterfaceKineticsData &right)
{
if (this == &right) return *this;
m_logp0 = right.m_logp0;
m_logc0 = right.m_logc0;
m_ropf = right.m_ropf;
m_ropr = right.m_ropr;
m_ropnet = right.m_ropnet;
m_ROP_ok = right.m_ROP_ok;
m_temp = right.m_temp;
m_logtemp = right.m_logtemp;
m_rfn = right.m_rfn;
m_rkcn = right.m_rkcn;
return *this;
}
//====================================================================================================================
/*
* Construct an empty InterfaceKinetics reaction mechanism.
@ -136,8 +174,7 @@ namespace Cantera {
Kinetics::operator=(right);
m_grt = right.m_grt;
m_kk = right.m_kk;
m_revindex = right.m_revindex;
m_rates = right.m_rates;
@ -150,7 +187,8 @@ namespace Cantera {
m_rrxn = right.m_rrxn;
m_prxn = right.m_prxn;
m_rxneqn = right.m_rxneqn;
*m_kdata = *right.m_kdata; // needs to be developed
*m_kdata = *right.m_kdata;
m_conc = right.m_conc;
m_mu0 = right.m_mu0;
m_phi = right.m_phi;
m_pot = right.m_pot;
@ -171,7 +209,6 @@ namespace Cantera {
m_phaseExistsCheck = right.m_phaseExistsCheck;
m_phaseExists = right.m_phaseExists;
m_rxnPhaseIsReactant.resize(m_ii, 0);
m_rxnPhaseIsProduct.resize(m_ii, 0);
int np = nPhases();
@ -183,7 +220,7 @@ namespace Cantera {
m_rxnPhaseIsProduct[i][p] = right.m_rxnPhaseIsProduct[i][p];
}
}
m_rxnPhaseIsProduct = right.m_rxnPhaseIsProduct;
m_ioFlag = right.m_ioFlag;
return *this;
@ -197,17 +234,6 @@ namespace Cantera {
int InterfaceKinetics::type() const {
return cInterfaceKinetics;
}
//====================================================================================================================
// Set the electric potential in the nth phase
/*
* @param n phase Index in this kinetics object.
* @param V Electric potential (volts)
*/
void InterfaceKinetics::setElectricPotential(int n, doublereal V) {
thermo(n).setElectricPotential(V);
m_redo_rates = true;
}
//====================================================================================================================
// Duplication routine for objects which inherit from Kinetics
/*
@ -227,6 +253,16 @@ namespace Cantera {
return dynamic_cast<Kinetics *>(iK);
}
//====================================================================================================================
// Set the electric potential in the nth phase
/*
* @param n phase Index in this kinetics object.
* @param V Electric potential (volts)
*/
void InterfaceKinetics::setElectricPotential(int n, doublereal V) {
thermo(n).setElectricPotential(V);
m_redo_rates = true;
}
//====================================================================================================================
// Update properties that depend on temperature
/*
* This is called to update all of the properties that depend on temperature

View file

@ -44,16 +44,17 @@ namespace Cantera {
*/
class InterfaceKineticsData {
public:
InterfaceKineticsData() :
m_logp0(0.0),
m_logc0(0.0),
m_ROP_ok(false),
m_temp(0.0),
m_logtemp(0.0)
{}
InterfaceKineticsData();
InterfaceKineticsData(const InterfaceKineticsData &right);
InterfaceKineticsData &operator=(const InterfaceKineticsData &right);
//! Virtual destructor
virtual ~InterfaceKineticsData() {
}
/*!
* todo - why is this virtual
*/
virtual ~InterfaceKineticsData();
doublereal m_logp0;
doublereal m_logc0;