diff --git a/include/cantera/thermo/NasaPoly1.h b/include/cantera/thermo/NasaPoly1.h index c5643d0c7..09c28643c 100644 --- a/include/cantera/thermo/NasaPoly1.h +++ b/include/cantera/thermo/NasaPoly1.h @@ -55,7 +55,7 @@ public: //! Empty constructor NasaPoly1() : m_lowT(0.0), m_highT(0.0), - m_Pref(0.0), m_index(0), m_coeff(vector_fp(7)) {} + m_Pref(0.0), m_index(0), m_coeff(7, 0.0) {} //! constructor used in templated instantiations diff --git a/src/thermo/NasaPoly2.h b/src/thermo/NasaPoly2.h index 5991cae02..c7fd8739e 100644 --- a/src/thermo/NasaPoly2.h +++ b/src/thermo/NasaPoly2.h @@ -59,10 +59,8 @@ public: m_midT(0.0), m_highT(0.0), m_Pref(0.0), - mnp_low(0), - mnp_high(0), m_index(0), - m_coeff(vector_fp(15)) { + m_coeff(15, 0.0) { } //! Full Constructor @@ -79,17 +77,13 @@ public: m_lowT(tlow), m_highT(thigh), m_Pref(pref), - mnp_low(0), - mnp_high(0), + mnp_low(n, tlow, coeffs[0], pref, coeffs +1), + mnp_high(n, tlow, thigh, pref, coeffs + 8), m_index(n), - m_coeff(vector_fp(15)) { + m_coeff(15, 0.0) { std::copy(coeffs, coeffs + 15, m_coeff.begin()); m_midT = coeffs[0]; - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); } //! Copy Constructor @@ -101,18 +95,10 @@ public: m_midT(b.m_midT), m_highT(b.m_highT), m_Pref(b.m_Pref), - mnp_low(0), - mnp_high(0), + mnp_low(b.mnp_low), + mnp_high(b.mnp_high), m_index(b.m_index), - m_coeff(vector_fp(15)) { - - std::copy(b.m_coeff.begin(), - b.m_coeff.begin() + 15, - m_coeff.begin()); - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); + m_coeff(b.m_coeff) { } //! Assignment operator @@ -126,28 +112,15 @@ public: m_highT = b.m_highT; m_Pref = b.m_Pref; m_index = b.m_index; - std::copy(b.m_coeff.begin(), - b.m_coeff.begin() + 15, - m_coeff.begin()); - if (mnp_low) { - delete mnp_low; - } - if (mnp_high) { - delete mnp_high; - } - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); + m_coeff = b.m_coeff; + mnp_low = b.mnp_low; + mnp_high = b.mnp_high; } return *this; } //! destructor - virtual ~NasaPoly2() { - delete mnp_low; - delete mnp_high; - } + virtual ~NasaPoly2() { } //! duplicator virtual SpeciesThermoInterpType* @@ -212,9 +185,9 @@ public: double T = tt[0]; if (T <= m_midT) { - mnp_low->updateProperties(tt, cp_R, h_RT, s_R); + mnp_low.updateProperties(tt, cp_R, h_RT, s_R); } else { - mnp_high->updateProperties(tt, cp_R, h_RT, s_R); + mnp_high.updateProperties(tt, cp_R, h_RT, s_R); } } @@ -239,9 +212,9 @@ public: doublereal* h_RT, doublereal* s_R) const { if (temp <= m_midT) { - mnp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R); + mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R); } else { - mnp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R); + mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R); } } @@ -278,9 +251,9 @@ public: doublereal reportHf298(doublereal* const h298 = 0) const { double h; if (298.15 <= m_midT) { - h = mnp_low->reportHf298(0); + h = mnp_low.reportHf298(0); } else { - h = mnp_high->reportHf298(0); + h = mnp_high.reportHf298(0); } if (h298) { h298[m_index] = h; @@ -295,12 +268,12 @@ public: doublereal h298now = reportHf298(0); doublereal delH = Hf298New - h298now; - double h = mnp_low->reportHf298(0); + double h = mnp_low.reportHf298(0); double hnew = h + delH; - mnp_low->modifyOneHf298(k, hnew); - h = mnp_high->reportHf298(0); + mnp_low.modifyOneHf298(k, hnew); + h = mnp_high.reportHf298(0); hnew = h + delH; - mnp_high->modifyOneHf298(k, hnew); + mnp_high.modifyOneHf298(k, hnew); } #endif @@ -314,10 +287,10 @@ protected: doublereal m_highT; //! Reference state pressure doublereal m_Pref; - //! pointer to the NasaPoly1 object for the low temperature region. - NasaPoly1* mnp_low; - //! pointer to the NasaPoly1 object for the high temperature region. - NasaPoly1* mnp_high; + //! NasaPoly1 object for the low temperature region. + NasaPoly1 mnp_low; + //! NasaPoly1 object for the high temperature region. + NasaPoly1 mnp_high; //! species index size_t m_index; //! array of polynomial coefficients