added option to specify domain bandwidths
This commit is contained in:
parent
f50e48e54f
commit
69a9a20eb8
2 changed files with 34 additions and 2 deletions
|
|
@ -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<std::string> m_name;
|
||||
int m_bw;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue