MCPcopy Create free account
hub / github.com/Cantera/cantera / readEntry

Method readEntry

src/base/SolutionArray.cpp:1660–1828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1658}
1659
1660void SolutionArray::readEntry(const string& fname, const string& name,
1661 const string& sub)
1662{
1663 Storage file(fname, false);
1664 if (name == "") {
1665 throw CanteraError("SolutionArray::readEntry",
1666 "Group name specifying root location must not be empty.");
1667 }
1668 string path = name;
1669 if (sub != "" && file.checkGroup(name + "/" + sub, true)) {
1670 path += "/" + sub;
1671 } else if (sub == "" && file.checkGroup(name + "/data", true)) {
1672 // default data location
1673 path += "/data";
1674 }
1675 if (!file.checkGroup(path)) {
1676 throw CanteraError("SolutionArray::readEntry",
1677 "Group name specifying data entry is empty.");
1678 }
1679 m_extra->clear();
1680 auto [size, names] = file.contents(path);
1681 m_meta = file.readAttributes(path, true);
1682 if (m_meta.hasKey("size")) {
1683 // one-dimensional array
1684 resize(m_meta["size"].as<long int>());
1685 m_meta.erase("size");
1686 } else if (m_meta.hasKey("api-shape")) {
1687 // API uses multiple dimensions to interpret C++ SolutionArray
1688 setApiShape(m_meta["api-shape"].asVector<long int>());
1689 m_meta.erase("api-shape");
1690 } else {
1691 // legacy format; size needs to be detected
1692 resize(static_cast<int>(size));
1693 }
1694
1695 if (m_size == 0) {
1696 return;
1697 }
1698
1699 // determine storage mode of state data
1700 string mode = _detectMode(names);
1701 set<string> states = _stateProperties(mode);
1702 if (states.count("C")) {
1703 if (names.count("X")) {
1704 states.erase("C");
1705 states.insert("X");
1706 mode = mode.substr(0, 2) + "X";
1707 } else if (names.count("Y")) {
1708 states.erase("C");
1709 states.insert("Y");
1710 mode = mode.substr(0, 2) + "Y";
1711 }
1712 }
1713
1714 // restore state data
1715 size_t nSpecies = m_sol->thermo()->nSpecies();
1716 size_t nState = m_sol->thermo()->stateSize();
1717 const auto& nativeStates = m_sol->thermo()->nativeState();

Callers 1

restoreMethod · 0.80

Calls 15

CanteraErrorClass · 0.85
getNameFunction · 0.85
warn_userFunction · 0.85
NotImplementedErrorClass · 0.85
checkGroupMethod · 0.80
contentsMethod · 0.80
readAttributesMethod · 0.80
hasKeyMethod · 0.80
eraseMethod · 0.80
stateSizeMethod · 0.80
readDataMethod · 0.80

Tested by

no test coverage detected