[1D] Restore domains based on sequence rather than name
Instead of searching the XML tree for nodes where the "id" attribute matches, require that the domains occur in order from left to right (corresponding to how they are saved). Fixes Issue 164.
This commit is contained in:
parent
fde8eeddcc
commit
65a97d9b62
1 changed files with 15 additions and 17 deletions
|
|
@ -121,7 +121,6 @@ void Sim1D::restore(const std::string& fname, const std::string& id,
|
||||||
int loglevel)
|
int loglevel)
|
||||||
{
|
{
|
||||||
ifstream s(fname.c_str());
|
ifstream s(fname.c_str());
|
||||||
//char buf[100];
|
|
||||||
if (!s)
|
if (!s)
|
||||||
throw CanteraError("Sim1D::restore",
|
throw CanteraError("Sim1D::restore",
|
||||||
"could not open input file "+fname);
|
"could not open input file "+fname);
|
||||||
|
|
@ -136,26 +135,25 @@ void Sim1D::restore(const std::string& fname, const std::string& id,
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<XML_Node*> xd;
|
vector<XML_Node*> xd;
|
||||||
size_t sz = 0, np, m;
|
f->getChildren("domain", xd);
|
||||||
for (m = 0; m < m_nd; m++) {
|
if (xd.size() != m_nd) {
|
||||||
XML_Node* d = f->findID(domain(m).id());
|
throw CanteraError("Sim1D::restore", "Solution does not contain the "
|
||||||
if (!d) {
|
" correct number of domains. Found " +
|
||||||
writelog("No data for domain "+domain(m).id());
|
int2str(xd.size()) + "expected " +
|
||||||
xd.push_back(0);
|
int2str(m_nd) + ".\n");
|
||||||
sz += domain(m).nComponents();
|
}
|
||||||
} else {
|
size_t sz = 0;
|
||||||
const XML_Node& node = *d;
|
for (size_t m = 0; m < m_nd; m++) {
|
||||||
xd.push_back(d);
|
if (loglevel > 0 && xd[m]->attrib("id") != domain(m).id()) {
|
||||||
np = intValue(node["points"]);
|
writelog("Warning: domain names do not match: '" +
|
||||||
sz += np*domain(m).nComponents();
|
(*xd[m])["id"] + + "' and '" + domain(m).id() + "'\n");
|
||||||
}
|
}
|
||||||
|
sz += domain(m).nComponents() * intValue((*xd[m])["points"]);
|
||||||
}
|
}
|
||||||
m_x.resize(sz);
|
m_x.resize(sz);
|
||||||
m_xnew.resize(sz);
|
m_xnew.resize(sz);
|
||||||
for (m = 0; m < m_nd; m++) {
|
for (size_t m = 0; m < m_nd; m++) {
|
||||||
if (xd[m]) {
|
domain(m).restore(*xd[m], DATA_PTR(m_x) + domain(m).loc(), loglevel);
|
||||||
domain(m).restore(*xd[m], DATA_PTR(m_x) + domain(m).loc(), loglevel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resize();
|
resize();
|
||||||
finalize();
|
finalize();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue