From bde0f1466d488f69f321b50593c07900a61a0f89 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 10 Mar 2015 14:17:13 -0400 Subject: [PATCH] [Thermo] Add index-based accessor for Species objects --- include/cantera/thermo/Phase.h | 3 +++ src/thermo/Phase.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index 8a8009e49..dddc81e11 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -781,6 +781,9 @@ public: //! Return the Species object for the named species. shared_ptr species(const std::string& name) const; + //! Return the Species object for species whose index is *k*. + shared_ptr species(size_t k) const; + //! Set behavior when adding a species containing undefined elements to just //! skip the species. void ignoreUndefinedElements(); diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 7379d5974..4486f7bdc 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -971,6 +971,11 @@ shared_ptr Phase::species(const std::string& name) const return getValue(m_species, name); } +shared_ptr Phase::species(size_t k) const +{ + return species(m_speciesNames[k]); +} + void Phase::ignoreUndefinedElements() { m_undefinedElementBehavior = UndefElement::ignore; }