Use the associated Cabinet to look up an item's index
This allowed removal the m_index member and associated methods of the ThermoPhase, Kinetics, and Transport classes.
This commit is contained in:
parent
3b1694fdfb
commit
8f4f72369e
10 changed files with 16 additions and 140 deletions
|
|
@ -961,20 +961,6 @@ public:
|
|||
void selectPhase(const doublereal* data, const thermo_t* phase,
|
||||
doublereal* phase_data);
|
||||
|
||||
/// For internal use. May be removed in a future release.
|
||||
size_t index() {
|
||||
return m_index;
|
||||
}
|
||||
|
||||
//! Set the index of the Kinetics Manager
|
||||
/*!
|
||||
* @param index input index
|
||||
*/
|
||||
void setIndex(size_t index) {
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
|
@ -1048,8 +1034,6 @@ protected:
|
|||
* -1.
|
||||
*/
|
||||
std::map<std::string, size_t> m_phaseindex;
|
||||
//! Index of the Kinetics Manager
|
||||
size_t m_index;
|
||||
|
||||
//! Index in the list of phases of the one surface phase.
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -247,22 +247,6 @@ public:
|
|||
*/
|
||||
void setName(std::string nm);
|
||||
|
||||
//! Returns the index of the phase
|
||||
/*!
|
||||
* The index is used in the Python and matlab interfaces to
|
||||
* index into a list of ThermoPhase objects
|
||||
*/
|
||||
size_t index() const;
|
||||
|
||||
//! Sets the index of the phase
|
||||
/*!
|
||||
* The index is used in the Python and matlab interfaces to
|
||||
* index into a list of ThermoPhase objects
|
||||
*
|
||||
* @param m Integer index of the phase
|
||||
*/
|
||||
void setIndex(size_t m);
|
||||
|
||||
//! Returns the index of a species named 'name' within the Phase object
|
||||
/*!
|
||||
* The first species in the phase will have an index 0, and the last one in the
|
||||
|
|
@ -572,11 +556,6 @@ protected:
|
|||
* dimensionality 2.
|
||||
*/
|
||||
size_t m_ndim;
|
||||
/**
|
||||
* m_index is the index of the phase
|
||||
*
|
||||
*/
|
||||
size_t m_index;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -2035,35 +2035,6 @@ public:
|
|||
*/
|
||||
virtual void installSlavePhases(Cantera::XML_Node* phaseNode);
|
||||
|
||||
// The following methods are used by the clib interface
|
||||
// library, and should not be used by application programs.
|
||||
|
||||
/*!
|
||||
* @internal
|
||||
* Index number. This method can be used to identify the
|
||||
* location of a phase object in a list, and is used by the
|
||||
* interface library (clib) routines for this purpose.
|
||||
*/
|
||||
size_t index() const {
|
||||
return m_index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @internal Set the index number. The Cantera interface
|
||||
* library uses this method to set the index number to the
|
||||
* location of the pointer to this object in the pointer array
|
||||
* it maintains. Using this method for any other purpose will
|
||||
* lead to unpredictable results if used in conjunction with
|
||||
* the interface library.
|
||||
*
|
||||
* @param m Input the index number.
|
||||
*/
|
||||
void setIndex(size_t m) {
|
||||
m_index = m;
|
||||
}
|
||||
|
||||
|
||||
//! Set the equation of state parameters
|
||||
/*!
|
||||
* @internal
|
||||
|
|
@ -2244,16 +2215,6 @@ protected:
|
|||
*/
|
||||
std::vector<const XML_Node*> m_speciesData;
|
||||
|
||||
//! Index number of the phase
|
||||
/*!
|
||||
* The Cantera interface library uses this member to set the index number to the
|
||||
* location of the pointer to this object in the pointer array of ThermoPhase's
|
||||
* it maintains. Using this member for any other purpose will
|
||||
* lead to unpredictable results if used in conjunction with
|
||||
* the interface library.
|
||||
*/
|
||||
size_t m_index;
|
||||
|
||||
//! Stored value of the electric potential for this phase
|
||||
/*!
|
||||
* Units are Volts
|
||||
|
|
|
|||
|
|
@ -246,25 +246,6 @@ public:
|
|||
*/
|
||||
bool ready();
|
||||
|
||||
|
||||
//! Returns an integer index number.
|
||||
/*!
|
||||
* @internal This is for internal use
|
||||
* of Cantera, and may be removed in the future.
|
||||
*
|
||||
* @return Returns the index number
|
||||
*/
|
||||
size_t index() const;
|
||||
|
||||
//! Set an integer index number.
|
||||
/*!
|
||||
* @internal This is for internal use of
|
||||
* Cantera, and may be removed in the future.
|
||||
*
|
||||
* @param i index value
|
||||
*/
|
||||
void setIndex(size_t i);
|
||||
|
||||
//! Set the number of dimensions to be expected in flux expressions
|
||||
/*!
|
||||
* Internal memory will be set with this value.
|
||||
|
|
@ -862,12 +843,6 @@ protected:
|
|||
//! Number of species
|
||||
size_t m_nmin;
|
||||
|
||||
//! Value of the internal index
|
||||
/*!
|
||||
* @deprecated
|
||||
*/
|
||||
size_t m_index;
|
||||
|
||||
//! Number of dimensions used in flux expresions
|
||||
size_t m_nDim;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class Cabinet
|
|||
{
|
||||
public:
|
||||
typedef std::vector<M*>& dataRef;
|
||||
typedef typename std::vector<M*>::iterator dataIterator;
|
||||
/**
|
||||
* Destructor. Delete all objects in the list.
|
||||
*/
|
||||
|
|
@ -166,6 +167,20 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index in the Cabinet to the specified object, or -1
|
||||
* if the object is not in the cabinet.
|
||||
*/
|
||||
static int index(const M& obj) {
|
||||
dataRef data = getData();
|
||||
dataIterator loc = std::find(data.begin(), data.end(), &obj);
|
||||
if (loc != data.end()) {
|
||||
return static_cast<int>(loc-data.begin());
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1175,7 +1175,7 @@ extern "C" {
|
|||
|
||||
size_t DLL_EXPORT kin_phase(int n, size_t i)
|
||||
{
|
||||
return KineticsCabinet::item(n).thermo(i).index();
|
||||
return ThermoCabinet::index(KineticsCabinet::item(n).thermo(i));
|
||||
}
|
||||
|
||||
int DLL_EXPORT kin_getEquilibriumConstants(int n, size_t len, double* kc)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ Kinetics::Kinetics() :
|
|||
m_thermo(0),
|
||||
m_start(0),
|
||||
m_phaseindex(),
|
||||
m_index(-1),
|
||||
m_surfphase(-1),
|
||||
m_rxnphase(-1),
|
||||
m_mindim(4),
|
||||
|
|
@ -57,7 +56,6 @@ Kinetics::Kinetics(const Kinetics& right) :
|
|||
m_thermo(0),
|
||||
m_start(0),
|
||||
m_phaseindex(),
|
||||
m_index(-1),
|
||||
m_surfphase(-1),
|
||||
m_rxnphase(-1),
|
||||
m_mindim(4),
|
||||
|
|
@ -96,7 +94,6 @@ operator=(const Kinetics& right)
|
|||
|
||||
m_start = right.m_start;
|
||||
m_phaseindex = right.m_phaseindex;
|
||||
m_index = right.m_index;
|
||||
m_surfphase = right.m_surfphase;
|
||||
m_rxnphase = right.m_rxnphase;
|
||||
m_mindim = right.m_mindim;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ Phase::Phase() :
|
|||
State(),
|
||||
m_kk(0),
|
||||
m_ndim(3),
|
||||
m_index(-1),
|
||||
m_xml(new XML_Node("phase")),
|
||||
m_id("<phase>"),
|
||||
m_name("")
|
||||
|
|
@ -40,7 +39,6 @@ Phase::Phase(const Phase& right) :
|
|||
State(),
|
||||
m_kk(0),
|
||||
m_ndim(3),
|
||||
m_index(-1),
|
||||
m_xml(new XML_Node("phase")),
|
||||
m_id("<phase>"),
|
||||
m_name("")
|
||||
|
|
@ -78,7 +76,6 @@ Phase& Phase::operator=(const Phase& right)
|
|||
*/
|
||||
m_kk = right.m_kk;
|
||||
m_ndim = right.m_ndim;
|
||||
m_index = right.m_index;
|
||||
m_data = right.m_data;
|
||||
/*
|
||||
* This is a little complicated. -> Because we delete m_xml
|
||||
|
|
@ -134,16 +131,6 @@ void Phase::setName(std::string nm)
|
|||
m_name = nm;
|
||||
}
|
||||
|
||||
size_t Phase::index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
void Phase::setIndex(size_t m)
|
||||
{
|
||||
m_index = m;
|
||||
}
|
||||
|
||||
// Returns the index of a species named 'name' within the Phase object
|
||||
/*
|
||||
* The first species in the phase will have an index 0, and the last one in the
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ namespace Cantera
|
|||
ThermoPhase::ThermoPhase() :
|
||||
Phase(),
|
||||
m_spthermo(0), m_speciesData(0),
|
||||
m_index(-1),
|
||||
m_phi(0.0),
|
||||
m_hasElementPotentials(false),
|
||||
m_chargeNeutralityNecessary(false),
|
||||
|
|
@ -54,7 +53,6 @@ ThermoPhase::ThermoPhase(const ThermoPhase& right) :
|
|||
Phase(),
|
||||
m_spthermo(0),
|
||||
m_speciesData(0),
|
||||
m_index(-1),
|
||||
m_phi(0.0),
|
||||
m_hasElementPotentials(false),
|
||||
m_chargeNeutralityNecessary(false),
|
||||
|
|
@ -114,7 +112,6 @@ operator=(const ThermoPhase& right)
|
|||
m_speciesData[k] = new XML_Node(*(right.m_speciesData[k]));
|
||||
}
|
||||
|
||||
m_index = right.m_index;
|
||||
m_phi = right.m_phi;
|
||||
m_lambdaRRT = right.m_lambdaRRT;
|
||||
m_hasElementPotentials = right.m_hasElementPotentials;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ Transport::Transport(thermo_t* thermo, size_t ndim) :
|
|||
m_thermo(thermo),
|
||||
m_ready(false),
|
||||
m_nmin(0),
|
||||
m_index(npos),
|
||||
m_nDim(ndim),
|
||||
m_velocityBasis(VB_MASSAVG)
|
||||
{
|
||||
|
|
@ -44,7 +43,6 @@ Transport::Transport(const Transport& right)
|
|||
m_thermo = right.m_thermo;
|
||||
m_ready = right.m_ready;
|
||||
m_nmin = right.m_nmin;
|
||||
m_index = right.m_index;
|
||||
m_nDim = right.m_nDim;
|
||||
m_velocityBasis = right.m_velocityBasis;
|
||||
}
|
||||
|
|
@ -58,7 +56,6 @@ Transport& Transport::operator=(const Transport& right)
|
|||
m_thermo = right.m_thermo;
|
||||
m_ready = right.m_ready;
|
||||
m_nmin = right.m_nmin;
|
||||
m_index = right.m_index;
|
||||
m_nDim = right.m_nDim;
|
||||
m_velocityBasis = right.m_velocityBasis;
|
||||
return *this;
|
||||
|
|
@ -80,19 +77,6 @@ bool Transport::ready()
|
|||
return m_ready;
|
||||
}
|
||||
|
||||
size_t Transport::index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
/* Set an integer index number. This is for internal use of
|
||||
* Cantera, and may be removed in the future.
|
||||
*/
|
||||
void Transport::setIndex(size_t i)
|
||||
{
|
||||
m_index = i;
|
||||
}
|
||||
|
||||
// Set the number of dimensions to be expected in flux expressions
|
||||
/* Internal memory will be set with this value
|
||||
*/
|
||||
|
|
@ -101,9 +85,6 @@ void Transport::setNDim(const int ndim)
|
|||
m_nDim = ndim;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Set transport model parameters. This method may be
|
||||
* overloaded in subclasses to set model-specific parameters.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue