From 681a4aea6ae67816fb30175142a5822b430cf12f Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 31 Jul 2008 22:33:19 +0000 Subject: [PATCH] vcs_VolPhase: Made more members private --- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 4 +- Cantera/src/equil/vcs_VolPhase.cpp | 58 +++++++++++++++-------- Cantera/src/equil/vcs_VolPhase.h | 38 +++++++++++---- Cantera/src/equil/vcs_prob.cpp | 2 +- 4 files changed, 69 insertions(+), 33 deletions(-) diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index f578b74de..cae3f8ad0 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -975,7 +975,7 @@ namespace VCSnonideal { /* * Tell the vcs_VolPhase pointer about cantera */ - VolPhase->m_VCS_UnitsFormat = vprob->m_VCS_UnitsFormat; + VolPhase->p_VCS_UnitsFormat = vprob->m_VCS_UnitsFormat; VolPhase->setPtrThermoPhase(tPhase); VolPhase->setTotalMoles(0.0); /* @@ -1127,7 +1127,7 @@ namespace VCSnonideal { * vprob->SpeciesThermo[] */ ts_ptr->UseCanteraCalls = VolPhase->usingCanteraCalls(); - ts_ptr->m_VCS_UnitsFormat = VolPhase->m_VCS_UnitsFormat; + ts_ptr->m_VCS_UnitsFormat = VolPhase->p_VCS_UnitsFormat; /* * Add lookback connectivity into the thermo object first */ diff --git a/Cantera/src/equil/vcs_VolPhase.cpp b/Cantera/src/equil/vcs_VolPhase.cpp index c9ca477c5..9de383f69 100644 --- a/Cantera/src/equil/vcs_VolPhase.cpp +++ b/Cantera/src/equil/vcs_VolPhase.cpp @@ -48,7 +48,7 @@ namespace VCSnonideal { m_MFStartIndex(0), IndSpecies(0), //IndSpeciesContig(true), - m_VCS_UnitsFormat(VCS_UNITS_MKS), + p_VCS_UnitsFormat(VCS_UNITS_MKS), m_useCanteraCalls(false), TP_ptr(0), v_totalMoles(0.0), @@ -107,7 +107,7 @@ namespace VCSnonideal { m_isIdealSoln(b.m_isIdealSoln), m_existence(b.m_existence), m_MFStartIndex(b.m_MFStartIndex), - m_VCS_UnitsFormat(b.m_VCS_UnitsFormat), + p_VCS_UnitsFormat(b.p_VCS_UnitsFormat), m_useCanteraCalls(b.m_useCanteraCalls), TP_ptr(b.TP_ptr), v_totalMoles(b.v_totalMoles), @@ -158,13 +158,13 @@ namespace VCSnonideal { ChargeNeutralityElement = b.ChargeNeutralityElement; - ElName.resize(b.m_numElemConstraints); + m_elementNames.resize(b.m_numElemConstraints); for (int e = 0; e < b.m_numElemConstraints; e++) { - ElName[e] = b.ElName[e]; + m_elementNames[e] = b.m_elementNames[e]; } ElActive = b.ElActive; - m_elType = b.m_elType; + m_elementType = b.m_elementType; FormulaMatrix.resize(m_numElemConstraints, NVolSpecies, 0.0); for (int e = 0; e < m_numElemConstraints; e++) { @@ -201,7 +201,7 @@ namespace VCSnonideal { new vcs_SpeciesProperties(*(b.ListSpeciesPtr[k])); } - m_VCS_UnitsFormat = b.m_VCS_UnitsFormat; + p_VCS_UnitsFormat = b.p_VCS_UnitsFormat; m_useCanteraCalls = b.m_useCanteraCalls; /* * Do a shallow copy of the ThermoPhase object pointer. @@ -337,13 +337,13 @@ namespace VCSnonideal { void vcs_VolPhase::elemResize(const int numElemConstraints) { - ElName.resize(numElemConstraints); + m_elementNames.resize(numElemConstraints); ElActive.resize(numElemConstraints+1, 1); - m_elType.resize(numElemConstraints, VCS_ELEM_TYPE_ABSPOS); + m_elementType.resize(numElemConstraints, VCS_ELEM_TYPE_ABSPOS); FormulaMatrix.resize(numElemConstraints, NVolSpecies, 0.0); - ElName.resize(numElemConstraints, ""); + m_elementNames.resize(numElemConstraints, ""); m_elemGlobalIndex.resize(numElemConstraints, -1); m_numElemConstraints = numElemConstraints; @@ -392,7 +392,7 @@ namespace VCSnonideal { if (m_useCanteraCalls) { TP_ptr->getGibbs_ref(VCS_DATA_PTR(SS0ChemicalPotential)); } else { - double R = vcsUtil_gasConstant(m_VCS_UnitsFormat); + double R = vcsUtil_gasConstant(p_VCS_UnitsFormat); for (int k = 0; k < NVolSpecies; k++) { int kglob = IndSpecies[k]; vcs_SpeciesProperties *sProp = ListSpeciesPtr[k]; @@ -433,7 +433,7 @@ namespace VCSnonideal { if (m_useCanteraCalls) { TP_ptr->getStandardChemPotentials(VCS_DATA_PTR(StarChemicalPotential)); } else { - double R = vcsUtil_gasConstant(m_VCS_UnitsFormat); + double R = vcsUtil_gasConstant(p_VCS_UnitsFormat); for (int k = 0; k < NVolSpecies; k++) { int kglob = IndSpecies[k]; vcs_SpeciesProperties *sProp = ListSpeciesPtr[k]; @@ -1028,7 +1028,7 @@ namespace VCSnonideal { Temp = TP_ptr->temperature(); Pres = TP_ptr->pressure(); setState_TP(Temp, Pres); - m_VCS_UnitsFormat = VCS_UNITS_MKS; + p_VCS_UnitsFormat = VCS_UNITS_MKS; m_phi = TP_ptr->electricPotential(); int nsp = TP_ptr->nSpecies(); int nelem = TP_ptr->nElements(); @@ -1333,7 +1333,7 @@ namespace VCSnonideal { } std::string vcs_VolPhase::elementName(const int e) const { - return ElName[e]; + return m_elementNames[e]; } /*! @@ -1396,8 +1396,7 @@ namespace VCSnonideal { if (ChargeNeutralityElement >= 0) { - m_elType[ChargeNeutralityElement] = - VCS_ELEM_TYPE_CHARGENEUTRALITY; + m_elementType[ChargeNeutralityElement] = VCS_ELEM_TYPE_CHARGENEUTRALITY; } if (hasChargedSpecies(tPhase)) { @@ -1416,7 +1415,7 @@ namespace VCSnonideal { if (ename == "E") { eFound = eT; ElActive[eT] = 0; - m_elType[eT] = VCS_ELEM_TYPE_ELECTRONCHARGE; + m_elementType[eT] = VCS_ELEM_TYPE_ELECTRONCHARGE; } } } else { @@ -1424,16 +1423,16 @@ namespace VCSnonideal { ename = tPhase->elementName(eT); if (ename == "E") { eFound = eT; - m_elType[eT] = VCS_ELEM_TYPE_ELECTRONCHARGE; + m_elementType[eT] = VCS_ELEM_TYPE_ELECTRONCHARGE; } } } if (eFound == -2) { eFound = ne; - m_elType[ne] = VCS_ELEM_TYPE_ELECTRONCHARGE; + m_elementType[ne] = VCS_ELEM_TYPE_ELECTRONCHARGE; ElActive[ne] = 0; std::string ename = "E"; - ElName[ne] = ename; + m_elementNames[ne] = ename; ne++; elemResize(ne); } @@ -1451,7 +1450,7 @@ namespace VCSnonideal { e = 0; for (eT = 0; eT < nebase; eT++) { ename = tPhase->elementName(eT); - ElName[e] = ename; + m_elementNames[e] = ename; e++; } @@ -1464,7 +1463,7 @@ namespace VCSnonideal { } ename = "cn_" + pname; e = ChargeNeutralityElement; - ElName[e] = ename; + m_elementNames[e] = ename; } double * const * const fm = FormulaMatrix.baseDataAddr(); @@ -1500,5 +1499,22 @@ namespace VCSnonideal { return ne; } + + // Type of the element constraint with index \c e. + /* + * @param e Element index. + */ + int vcs_VolPhase::elementType(const int e) const { + return m_elementType[e]; + } + + // Set the element Type of the element constraint with index \c e. + /* + * @param e Element index + * @param eType type of the element. + */ + void vcs_VolPhase::setElementType(const int e, const int eType) { + m_elementType[e] = eType; + } } diff --git a/Cantera/src/equil/vcs_VolPhase.h b/Cantera/src/equil/vcs_VolPhase.h index 66032676b..4477dae8e 100644 --- a/Cantera/src/equil/vcs_VolPhase.h +++ b/Cantera/src/equil/vcs_VolPhase.h @@ -478,12 +478,28 @@ namespace VCSnonideal { */ void setElemGlobalIndex(const int eLocal, const int eGlobal); + //! Returns the number of element constraints int nElemConstraints() const; + //! Name of the element constraint with index \c e. + /*! + * @param e Element index. + */ std::string elementName(const int e) const; + //! Type of the element constraint with index \c e. + /*! + * @param e Element index. + */ + int elementType(const int e) const; + + //! Set the element Type of the element constraint with index \c e. + /*! + * @param e Element index + * @param eType type of the element. + */ + void setElementType(const int e, const int eType); - //! Transfer all of the element information from the //! ThermoPhase object to the vcs_VolPhase object. /*! @@ -495,7 +511,6 @@ namespace VCSnonideal { */ int transferElementsFM(const Cantera::ThermoPhase * const tPhase); - private: //! Evaluate the activity coefficients at the current conditions @@ -620,7 +635,7 @@ namespace VCSnonideal { int m_numElemConstraints; public: - //! This is the element number for the charge neutrality + //! This is the element number for the charge neutrality //! condition of the phase /*! * If it has one. If it does not have a charge neutrality @@ -629,17 +644,19 @@ namespace VCSnonideal { int ChargeNeutralityElement; private: - //! vector of strings containing the element names + //! vector of strings containing the element constraint names /*! * Length = nElemConstraints */ - std::vector ElName; + std::vector m_elementNames; + public: //! boolean indicating whether an element constraint is active //! for the current problem std::vector ElActive; - //! Type of the element + private: + //! Type of the element constraint /*! * m_elType[j] = type of the element * 0 VCS_ELEM_TYPE_ABSPOS Normal element that is positive @@ -650,8 +667,9 @@ namespace VCSnonideal { * mean that a species has neg 0 or pos value * of that constraint (other than charge) */ - std::vector m_elType; + std::vector m_elementType; + public: //! Formula Matrix for the phase /*! * FormulaMatrix[j][kspec] @@ -713,7 +731,6 @@ namespace VCSnonideal { */ int m_existence; - // Index of the first MF species in the list of unknowns for this phase /*! * This is always equal to zero. @@ -759,8 +776,11 @@ namespace VCSnonideal { * * Currently, this value should be the same as the owning VCS_PROB or * VCS_SOLVE object. There is no code for handling anything else atm. + * + * (This variable is needed for the vcsc code, where it is not equal + * to VCS_UNITS_MKS). */ - int m_VCS_UnitsFormat; + int p_VCS_UnitsFormat; private: //! If this is true, then calculations are actually performed within diff --git a/Cantera/src/equil/vcs_prob.cpp b/Cantera/src/equil/vcs_prob.cpp index 8408c3807..3e8952bed 100644 --- a/Cantera/src/equil/vcs_prob.cpp +++ b/Cantera/src/equil/vcs_prob.cpp @@ -383,7 +383,7 @@ namespace VCSnonideal { } } if (foundPos == -1) { - int elType = volPhase->m_elType[eVP]; + int elType = volPhase->elementType(eVP); int elactive = volPhase->ElActive[eVP]; e = addElement(enVP.c_str(), elType, elactive); volPhase->setElemGlobalIndex(eVP, e);