diff --git a/include/cantera/equil/vcs_IntStarStar.h b/include/cantera/equil/vcs_IntStarStar.h deleted file mode 100644 index 231961c13..000000000 --- a/include/cantera/equil/vcs_IntStarStar.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file vcs_IntStarStar.h Header file for class IntStarStar - */ -#ifndef VCS_INTSTARSTAR_H -#define VCS_INTSTARSTAR_H - -#include - -namespace VCSnonideal -{ -using std::size_t; - -//! A class for 2D int arrays stored in column-major -//! (Fortran-compatible) form. -/*! - * In this form, the data entry for an `n` row, `m` colum matrix is index = - * `i + (n-1) * j` where `Matrix[j][i]` references the element in row `i`, - * column `j`. - */ -class IntStarStar -{ -public: - //! Default constructor. Create an empty array. - IntStarStar(); - - //! Constructor. - /*! - * Create an \c nrow by \c mcol int array, and initialize - * all elements to \c v. - * - * @param mcol Number of columns - * @param nrow Number of rows - * @param v value used to initialize elements - */ - IntStarStar(size_t mcol, size_t nrow, int v = 0); - - IntStarStar(const IntStarStar& y); - IntStarStar& operator=(const IntStarStar& y); - - //! Resize the array, and fill the new entries with 'v' - /*! - * @param mcol This is the number of columns in the new matrix - * @param nrow This is the number of rows - * @param v Default fill value -> defaults to zero. - */ - void resize(size_t mcol, size_t nrow, int v = 0); - - //! Pointer to the top of the column - /*! - * @param jcol Pointer to the top of the jth column - */ - int* operator[](size_t jcol); - - //! Pointer to the top of the column - /*! - * @param jcol Pointer to the top of the jth column - */ - const int* operator[](size_t jcol) const; - - //! Returns a `int**` pointer to the base address - /*! - * This is the second way to get to the data This returns a `int**` which - * can later be used in `Imatrix[icol][irow]` notation to get to the data - */ - int* const* baseDataAddr(); - - //! Number of rows - size_t nRows() const; - - //! Number of columns - size_t nColumns() const; - -private: - //! Storage area for the matrix, layed out in Fortran style, row-inner, - //! column outer format - /*! - * Length = m_nrows * m_ncols - */ - std::vector m_data; - - //! Vector of column addresses - /*! - * Length = number of columns = m_ncols - */ - std::vector m_colAddr; - - //! number of rows - size_t m_nrows; - - //! number of columns - size_t m_ncols; -}; - -} - -#endif diff --git a/include/cantera/equil/vcs_prob.h b/include/cantera/equil/vcs_prob.h index 8456bdb0a..d41d42cb0 100644 --- a/include/cantera/equil/vcs_prob.h +++ b/include/cantera/equil/vcs_prob.h @@ -12,7 +12,6 @@ #define _VCS_PROB_H #include "cantera/base/Array.h" -#include "vcs_IntStarStar.h" #include "cantera/equil/vcs_defs.h" #include diff --git a/include/cantera/equil/vcs_solve.h b/include/cantera/equil/vcs_solve.h index f48fc9843..ff60f0514 100644 --- a/include/cantera/equil/vcs_solve.h +++ b/include/cantera/equil/vcs_solve.h @@ -25,7 +25,6 @@ #include "cantera/base/ct_defs.h" #include "cantera/equil/vcs_defs.h" -#include "cantera/equil/vcs_IntStarStar.h" #include "cantera/equil/vcs_internal.h" #include "cantera/base/Array.h" @@ -199,7 +198,7 @@ public: * irxn_th non-component species. * - #m_deltaMolNumPhase(iphase,irxn): Change in the number of moles in * phase, iphase, due to the noncomponent formation reaction, irxn. - * - #m_phaseParticipation[irxn]: This is 1 if the phase, iphase, + * - #m_phaseParticipation(iphase,irxn): This is 1 if the phase, iphase, * participates in the formation reaction, irxn, and zero otherwise. */ int vcs_basopt(const bool doJustComponents, double aw[], double sa[], double sm[], @@ -1633,8 +1632,8 @@ public: Cantera::Array2D m_deltaMolNumPhase; //! This is 1 if the phase, iphase, participates in the formation reaction - //! irxn, and zero otherwise. PhaseParticipation[irxn][iphase] - IntStarStar m_phaseParticipation; + //! irxn, and zero otherwise. PhaseParticipation(iphase,irxn) + Cantera::Array2D m_phaseParticipation; //! electric potential of the iph phase std::vector m_phasePhi; diff --git a/src/equil/vcs_IntStarStar.cpp b/src/equil/vcs_IntStarStar.cpp deleted file mode 100644 index 81ef8d301..000000000 --- a/src/equil/vcs_IntStarStar.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @file vcs_IntStarStar.cpp Implementation of class IntStarStar - */ -#include "cantera/equil/vcs_IntStarStar.h" - -namespace VCSnonideal -{ -IntStarStar::IntStarStar() : - m_nrows(0), - m_ncols(0) -{ - m_data.clear(); - m_colAddr.clear(); -} - -IntStarStar::IntStarStar(size_t m, size_t n, int v) : - m_nrows(n), - m_ncols(m) -{ - m_data.resize(n*m); - std::fill(m_data.begin(), m_data.end(), v); - m_colAddr.resize(m); - if (!m_data.empty()) { - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); - } - } -} - -IntStarStar::IntStarStar(const IntStarStar& y) -{ - m_nrows = y.m_nrows; - m_ncols = y.m_ncols; - m_data.resize(m_nrows*m_ncols); - m_data = y.m_data; - m_colAddr.resize(m_ncols); - if (!m_data.empty()) { - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); - } - } -} - -IntStarStar& IntStarStar::operator=(const IntStarStar& y) -{ - if (&y == this) { - return *this; - } - m_nrows = y.m_nrows; - m_ncols = y.m_ncols; - m_data.resize(m_nrows*m_ncols); - m_data = y.m_data; - m_colAddr.resize(m_ncols); - if (!m_data.empty()) { - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); - } - } - return *this; -} - -void IntStarStar::resize(size_t m, size_t n, int v) -{ - std::vector old_data; - bool doCopy = false; - if (m_nrows > 0 && m_ncols > 0) { - if (m_ncols != m) { - doCopy = true; - old_data = m_data; - } - } - m_data.resize(n*m, v); - if (doCopy) { - if (n >= m_nrows && m >= m_ncols) { - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - for (size_t irow = 0; irow < m_nrows; irow++) { - m_data[jcol*m + irow] = old_data[jcol*m_ncols + irow]; - } - for (size_t irow = m_nrows; irow < n; irow++) { - m_data[jcol*m + irow] = v; - } - } - for (size_t jcol = m_ncols; jcol < m; jcol++) { - for (size_t irow = 0; irow < n; irow++) { - m_data[jcol*m + irow] = v; - } - } - } else { - std::fill(m_data.begin(), m_data.end(), v); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - for (size_t irow = 0; irow < m_nrows; irow++) { - m_data[jcol*m + irow] = old_data[jcol*m_ncols + irow]; - } - } - } - } - m_nrows = n; - m_ncols = m; - m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); - } -} - -int* IntStarStar::operator[](size_t jcol) -{ - return m_colAddr[jcol]; -} - -const int* IntStarStar::operator[](size_t jcol) const -{ - return (const int*) m_colAddr[jcol]; -} - -int* const* IntStarStar::baseDataAddr() -{ - return (int* const*) &(m_colAddr[0]); -} - -size_t IntStarStar::nRows() const -{ - return m_nrows; -} - -size_t IntStarStar::nColumns() const -{ - return m_ncols; -} - -} diff --git a/src/equil/vcs_prep.cpp b/src/equil/vcs_prep.cpp index 6e81adc2a..c4858531a 100644 --- a/src/equil/vcs_prep.cpp +++ b/src/equil/vcs_prep.cpp @@ -214,7 +214,7 @@ int VCS_SOLVE::vcs_prep() vcs_vdzero(m_feSpecies_new, m_numSpeciesTot); vcs_vdzero(m_molNumSpecies_new, m_numSpeciesTot); vcs_dzero(&(m_deltaMolNumPhase(0,0)), m_numSpeciesTot * m_numPhases); - vcs_izero(&(m_phaseParticipation[0][0]), m_numSpeciesTot * m_numPhases); + m_phaseParticipation.zero(); vcs_dzero(VCS_DATA_PTR(m_deltaPhaseMoles), m_numPhases); vcs_dzero(VCS_DATA_PTR(m_tPhaseMoles_new), m_numPhases); /* diff --git a/src/equil/vcs_rxnadj.cpp b/src/equil/vcs_rxnadj.cpp index 27271b628..68a520d91 100644 --- a/src/equil/vcs_rxnadj.cpp +++ b/src/equil/vcs_rxnadj.cpp @@ -659,9 +659,8 @@ double VCS_SOLVE::deltaG_Recalc_Rxn(const int stateCalc, const size_t irxn, cons double* const mu_i) { size_t kspec = irxn + m_numComponents; - int* pp_ptr = m_phaseParticipation[irxn]; for (size_t iphase = 0; iphase < m_numPhases; iphase++) { - if (pp_ptr[iphase]) { + if (m_phaseParticipation(iphase,irxn)) { vcs_chemPotPhase(stateCalc, iphase, molNum, ac, mu_i); } } diff --git a/src/equil/vcs_solve.cpp b/src/equil/vcs_solve.cpp index cdeadfdf3..9ac0d61a4 100644 --- a/src/equil/vcs_solve.cpp +++ b/src/equil/vcs_solve.cpp @@ -109,7 +109,7 @@ void VCS_SOLVE::vcs_initSizes(const size_t nspecies0, const size_t nelements, m_speciesUnknownType.resize(nspecies0, VCS_SPECIES_TYPE_MOLNUM); m_deltaMolNumPhase.resize(nphase0, nspecies0, 0.0); - m_phaseParticipation.resize(nspecies0, nphase0, 0); + m_phaseParticipation.resize(nphase0, nspecies0, 0); m_phasePhi.resize(nphase0, 0.0); m_molNumSpecies_new.resize(nspecies0, 0.0); diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index a1281177d..505a72d7f 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -3077,7 +3077,7 @@ L_END_LOOP: * Zero out the change of Phase Moles array */ vcs_dzero(&m_deltaMolNumPhase(0,0), (NSPECIES0)*(NPHASE0)); - vcs_izero(m_phaseParticipation[0], (NSPECIES0)*(NPHASE0)); + m_phaseParticipation.zero(); /* * Loop over each reaction, creating the change in Phase Moles * array, m_deltaMolNumPhase(iphase,irxn), @@ -3087,16 +3087,15 @@ L_END_LOOP: scrxn_ptr = m_stoichCoeffRxnMatrix.ptrColumn(irxn); size_t kspec = m_indexRxnToSpecies[irxn]; size_t iph = m_phaseID[kspec]; - int* pp_ptr = m_phaseParticipation[irxn]; m_deltaMolNumPhase(iph,irxn) = 1.0; - pp_ptr[iph]++; + m_phaseParticipation(iph,irxn)++; for (size_t j = 0; j < ncTrial; ++j) { iph = m_phaseID[j]; if (fabs(scrxn_ptr[j]) <= 1.0e-6) { scrxn_ptr[j] = 0.0; } else { m_deltaMolNumPhase(iph,irxn) += scrxn_ptr[j]; - pp_ptr[iph]++; + m_phaseParticipation(iph,irxn)++; } } } @@ -4506,8 +4505,8 @@ void VCS_SOLVE::vcs_switch_pos(const bool ifunc, const size_t k1, const size_t k std::swap(m_scSize[i1], m_scSize[i2]); for (size_t iph = 0; iph < m_numPhases; iph++) { std::swap(m_deltaMolNumPhase(iph,i1), m_deltaMolNumPhase(iph,i2)); - std::swap(m_phaseParticipation[i1][iph], - m_phaseParticipation[i2][iph]); + std::swap(m_phaseParticipation(iph,i1), + m_phaseParticipation(iph,i2)); } std::swap(m_deltaGRxn_new[i1], m_deltaGRxn_new[i2]); std::swap(m_deltaGRxn_old[i1], m_deltaGRxn_old[i2]);