diff --git a/include/cantera/oneD/OneDim.h b/include/cantera/oneD/OneDim.h index 80572977f..fa158c3f8 100644 --- a/include/cantera/oneD/OneDim.h +++ b/include/cantera/oneD/OneDim.h @@ -105,6 +105,10 @@ public: return m_loc[jg]; } + //! Return the domain, local point index, and component name for the i-th + //! component of the global solution vector + std::tuple component(size_t i); + /// Jacobian bandwidth. size_t bandwidth() const { return m_bw; diff --git a/src/oneD/OneDim.cpp b/src/oneD/OneDim.cpp index afbe58517..8a3a0b5d3 100644 --- a/src/oneD/OneDim.cpp +++ b/src/oneD/OneDim.cpp @@ -54,6 +54,20 @@ size_t OneDim::domainIndex(const std::string& name) throw CanteraError("OneDim::domainIndex","no domain named >>"+name+"<<"); } +std::tuple OneDim::component(size_t i) { + size_t n; + for (n = nDomains()-1; n != npos; n--) { + if (i >= start(n)) { + break; + } + } + Domain1D& dom = domain(n); + size_t offset = i - start(n); + size_t pt = offset / dom.nComponents(); + size_t comp = offset - pt*dom.nComponents(); + return make_tuple(dom.id(), pt, dom.componentName(comp)); +} + void OneDim::addDomain(Domain1D* d) { // if 'd' is not the first domain, link it to the last domain