Removed some vector functions that duplicated built-in functionality

This commit is contained in:
Ray Speth 2012-01-20 23:13:44 +00:00
parent f922a9c348
commit ea2c3b977c
4 changed files with 18 additions and 75 deletions

View file

@ -166,63 +166,6 @@ namespace Cantera {
return maxval;
}
//! Copy a vector of doubles in an efficient, fast manner.
/*!
* No checking is done other that to check that len is greater than 0
*
* @param copyTo Vector to receive the copy
* @param copyFrom Vector from which the copy is coming
* @param len Length of the copy
*/
inline void fbo_copy_dbl_1(doublereal * const copyTo, const doublereal * const copyFrom,
const size_t len) {
if (len > 0) {
(void) memcpy((void *)copyTo, (const void *)copyFrom, len * sizeof(doublereal));
}
}
//! Copy a vector<doubles> in an efficient, fast manner.
/*!
* No checking is done other that to check that len is greater than 0
*
* @param copyTo Vector to receive the copy
* @param copyFrom Vector from which the copy is coming
* @param len Length of the copy
*/
inline void fvo_copy_dbl_1(std::vector<doublereal> &copyTo, const std::vector<doublereal> &copyFrom,
const size_t len) {
if (len > 0) {
(void) memcpy((void *)(&copyTo[0]), (const void *)(&copyFrom[0]), len * sizeof(doublereal));
}
}
//! Zero a double vector in an efficient, fast manner.
/*!
* No checking is done other that to check that len is greater than 0
*
* @param v Vector to be zeroed
* @param len Length of the copy
*/
inline void fbo_zero_dbl_1(doublereal * const v, const size_t len) {
if (len > 0) {
(void) memset((void *)v, 0, len * sizeof(doublereal));
}
}
//! Zero a vector<doubles> in an efficient, fast manner.
/*!
* No checking is done other that to check that len is greater than 0
*
* @param v Vector to be zeroed
* @param len Length of the copy
*/
inline void fvo_zero_dbl_1(std::vector<doublereal> &v, const size_t len) {
if (len > 0) {
(void) memset((void *)(&v[0]), 0, len * sizeof(doublereal));
}
}
}
#endif

View file

@ -3409,7 +3409,7 @@ namespace Cantera {
/*
* Zero the unscaled 2nd derivatives
*/
fbo_zero_dbl_1(DATA_PTR(m_dlnActCoeffMolaldT_Unscaled), m_kk);
m_dlnActCoeffMolaldT_Unscaled.assign(m_kk, 0.0);
/*
* Do the actual calculation of the unscaled temperature derivatives
*/
@ -4274,7 +4274,7 @@ namespace Cantera {
/*
* Zero the unscaled 2nd derivatives
*/
fbo_zero_dbl_1(DATA_PTR(m_d2lnActCoeffMolaldT2_Unscaled), m_kk);
m_d2lnActCoeffMolaldT2_Unscaled.assign(m_kk, 0.0);
/*
* Calculate the unscaled 2nd derivatives
*/
@ -5164,9 +5164,7 @@ namespace Cantera {
* scale. It's derivative is too.
*/
void HMWSoln::s_update_dlnMolalityActCoeff_dP() const {
fbo_zero_dbl_1(DATA_PTR(m_dlnActCoeffMolaldP_Unscaled), m_kk);
m_dlnActCoeffMolaldP_Unscaled.assign(m_kk, 0.0);
s_updatePitzer_dlnMolalityActCoeff_dP();
@ -6364,7 +6362,7 @@ namespace Cantera {
*/
void HMWSoln::s_updateScaling_pHScaling() const {
if (m_pHScalingType == PHSCALE_PITZER) {
fvo_copy_dbl_1(m_lnActCoeffMolal_Scaled, m_lnActCoeffMolal_Unscaled, m_kk);
m_lnActCoeffMolal_Scaled = m_lnActCoeffMolal_Unscaled;
return;
}
AssertTrace(m_pHScalingType == PHSCALE_NBS);
@ -6384,7 +6382,7 @@ namespace Cantera {
*/
void HMWSoln::s_updateScaling_pHScaling_dT() const {
if (m_pHScalingType == PHSCALE_PITZER) {
fvo_copy_dbl_1(m_dlnActCoeffMolaldT_Scaled, m_dlnActCoeffMolaldT_Unscaled, m_kk);
m_dlnActCoeffMolaldT_Scaled = m_dlnActCoeffMolaldT_Unscaled;
return;
}
AssertTrace(m_pHScalingType == PHSCALE_NBS);
@ -6404,7 +6402,7 @@ namespace Cantera {
*/
void HMWSoln::s_updateScaling_pHScaling_dT2() const {
if (m_pHScalingType == PHSCALE_PITZER) {
fvo_copy_dbl_1(m_d2lnActCoeffMolaldT2_Scaled, m_d2lnActCoeffMolaldT2_Unscaled, m_kk);
m_d2lnActCoeffMolaldT2_Scaled = m_d2lnActCoeffMolaldT2_Unscaled;
return;
}
AssertTrace(m_pHScalingType == PHSCALE_NBS);
@ -6423,7 +6421,7 @@ namespace Cantera {
*/
void HMWSoln::s_updateScaling_pHScaling_dP() const {
if (m_pHScalingType == PHSCALE_PITZER) {
fvo_copy_dbl_1(m_dlnActCoeffMolaldP_Scaled, m_dlnActCoeffMolaldP_Unscaled, m_kk);
m_dlnActCoeffMolaldP_Scaled = m_dlnActCoeffMolaldP_Unscaled;
return;
}
AssertTrace(m_pHScalingType == PHSCALE_NBS);

View file

@ -694,7 +694,9 @@ namespace Cantera {
neutralMoleculePhase_->getMoleFractions(DATA_PTR(NeutralMolecMoleFractions_));
// Zero the mole fractions
fbo_zero_dbl_1(mf, m_kk);
for (size_t k = 0; k < m_kk; k++) {
mf[k] = 0.0;
}
/*
* Use the formula matrix to calculate the relative mole numbers.
@ -1291,7 +1293,7 @@ namespace Cantera {
elemVectorN[m] = neutralMoleculePhase_->nAtoms(jNeut, m);
}
elemVectorN_orig = elemVectorN;
fvo_zero_dbl_1(fm_tmp, m_kk);
fm_tmp.assign(m_kk, 0.0);
for (size_t m = 0; m < nElementsI; m++) {
elemVectorI[m] = nAtoms(indexSpecialSpecies_, m);
@ -1505,7 +1507,7 @@ namespace Cantera {
*/
GibbsExcessVPSSTP *geThermo = dynamic_cast<GibbsExcessVPSSTP *>(neutralMoleculePhase_);
if (!geThermo) {
fvo_zero_dbl_1(dlnActCoeffdT_Scaled_, m_kk);
dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
return;
}
@ -1563,7 +1565,7 @@ namespace Cantera {
*/
GibbsExcessVPSSTP *geThermo = dynamic_cast<GibbsExcessVPSSTP *>(neutralMoleculePhase_);
if (!geThermo) {
fvo_zero_dbl_1(dlnActCoeffdlnX_Scaled_, m_kk);
dlnActCoeffdlnX_Scaled_.assign(m_kk, 0);
return;
}
@ -1621,7 +1623,7 @@ namespace Cantera {
*/
GibbsExcessVPSSTP *geThermo = dynamic_cast<GibbsExcessVPSSTP *>(neutralMoleculePhase_);
if (!geThermo) {
fvo_zero_dbl_1(dlnActCoeffdlnN_Scaled_, m_kk);
dlnActCoeffdlnN_Scaled_.assign(m_kk, 0.0);
return;
}

View file

@ -652,7 +652,7 @@ namespace Cantera {
double T = temperature();
double RT = GasConstant*T;
fvo_zero_dbl_1(lnActCoeff_Scaled_, m_kk);
lnActCoeff_Scaled_.assign(m_kk, 0.0);
for ( iK = 0; iK < m_kk; iK++ ){
for (size_t i = 0; i < numBinaryInteractions_; i++) {
@ -719,7 +719,7 @@ namespace Cantera {
double T = temperature();
double RTT = GasConstant*T*T;
fvo_zero_dbl_1(dlnActCoeffdT_Scaled_, m_kk);
dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
for ( iK = 0; iK < m_kk; iK++ ){
for (size_t i = 0; i < numBinaryInteractions_; i++) {
@ -833,7 +833,7 @@ namespace Cantera {
double T = temperature();
double RT = GasConstant*T;
fvo_zero_dbl_1(dlnActCoeffdlnN_Scaled_, m_kk);
dlnActCoeffdlnN_Scaled_.assign(m_kk, 0.0);
for ( iK = 0; iK < m_kk; iK++ ){
@ -867,7 +867,7 @@ namespace Cantera {
doublereal XA, XB, g0 , g1;
doublereal T = temperature();
fvo_zero_dbl_1(dlnActCoeffdlnX_Scaled_, m_kk);
dlnActCoeffdlnX_Scaled_.assign(m_kk, 0.0);
doublereal RT = GasConstant * T;