From 69a9a20eb816308eff293af58235bf43bca05829 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Sun, 11 Feb 2007 16:27:38 +0000 Subject: [PATCH] added option to specify domain bandwidths --- Cantera/src/oneD/Domain1D.h | 27 +++++++++++++++++++++++++++ Cantera/src/oneD/OneDim.cpp | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Cantera/src/oneD/Domain1D.h b/Cantera/src/oneD/Domain1D.h index 217c863f7..d02481d38 100644 --- a/Cantera/src/oneD/Domain1D.h +++ b/Cantera/src/oneD/Domain1D.h @@ -91,6 +91,32 @@ namespace Cantera { m_index = index; } + /* + * Set the Jacobian bandwidth. See the discussion of method bandwidth. + */ + void setBandwidth(int bw = -1) { + m_bw = bw; + } + + /** + * Set the Jacobian bandwith for this domain. When class + * OneDim computes the bandwidth of the overall multi-domain + * problem (in OneDim::resize()), it calls this method for the + * bandwidth of each domain. If setBandwidth has not been + * called, then a negative bandwidth is returned, in which + * case OneDim assumes that this domain is dense -- that is, + * at each point, all components depend on the value of all + * other components at that point. In this case, the bandwidth + * is bw = 2*nComponents() - 1. However, if this domain + * contains some components that are uncoupled from other + * components at the same point, then this default bandwidth + * may greatly overestimate the true bandwidth, with a + * substantial penalty in performance. For such domains, use + * method setBandwidth to specify the bandwidth before passing + * this domain to the Sim1D or OneDim constructor. + */ + int bandwidth() { return m_bw; } + /** * Initialize. This method is called by OneDim::init() for * each domain once at the beginning of a simulation. Base @@ -471,6 +497,7 @@ namespace Cantera { Refiner* m_refiner; vector_int m_td; std::vector m_name; + int m_bw; private: diff --git a/Cantera/src/oneD/OneDim.cpp b/Cantera/src/oneD/OneDim.cpp index b01a4b03f..1ddf27493 100644 --- a/Cantera/src/oneD/OneDim.cpp +++ b/Cantera/src/oneD/OneDim.cpp @@ -171,12 +171,17 @@ namespace Cantera { int bw1, bw2 = 0; // bandwidth of the local block - bw1 = 2*d->nComponents() - 1; + bw1 = d->bandwidth(); + if (bw1 < 0) + bw1 = 2*d->nComponents() - 1; // bandwidth of the block coupling the first point of this // domain to the last point of the previous domain if (i > 0) { - bw2 = d->nComponents() + m_dom[i-1]->nComponents() - 1; + bw2 = m_dom[i-1]->bandwidth(); + if (bw2 < 0) + bw2 = m_dom[i-1]->nComponents(); + bw2 += d->nComponents() - 1; } if (bw1 > m_bw) m_bw = bw1; if (bw2 > m_bw) m_bw = bw2;