[1D] add function for getting info about a solution component

This commit is contained in:
Ray Speth 2016-01-19 18:04:06 -05:00
parent 39a6819bf3
commit d20ab891e8
2 changed files with 18 additions and 0 deletions

View file

@ -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<std::string, size_t, std::string> component(size_t i);
/// Jacobian bandwidth.
size_t bandwidth() const {
return m_bw;

View file

@ -54,6 +54,20 @@ size_t OneDim::domainIndex(const std::string& name)
throw CanteraError("OneDim::domainIndex","no domain named >>"+name+"<<");
}
std::tuple<std::string, size_t, std::string> 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