| 732 | } |
| 733 | |
| 734 | void SolutionArray::setComponent(const string& name, const AnyValue& data) |
| 735 | { |
| 736 | if (!hasComponent(name)) { |
| 737 | throw CanteraError("SolutionArray::setComponent", |
| 738 | "Unknown component '{}'.", name); |
| 739 | } |
| 740 | if (m_extra->count(name)) { |
| 741 | _setExtra(name, data); |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | size_t size = data.vectorSize(); |
| 746 | if (size == npos) { |
| 747 | throw CanteraError("SolutionArray::setComponent", |
| 748 | "Invalid type of component '{}': expected simple array type, " |
| 749 | "but received '{}'.", name, data.type_str()); |
| 750 | } |
| 751 | if (size != m_size) { |
| 752 | throw CanteraError("SolutionArray::setComponent", |
| 753 | "Invalid size of component '{}': expected size {} but received {}.", |
| 754 | name, m_size, size); |
| 755 | } |
| 756 | |
| 757 | auto& vec = data.asVector<double>(); |
| 758 | size_t ix = m_sol->thermo()->speciesIndex(name); |
| 759 | if (ix == npos) { |
| 760 | ix = m_sol->thermo()->nativeState()[name]; |
| 761 | } else { |
| 762 | ix += m_stride - m_sol->thermo()->nSpecies(); |
| 763 | } |
| 764 | for (size_t k = 0; k < m_size; ++k) { |
| 765 | (*m_data)[m_active[k] * m_stride + ix] = vec[k]; |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | void SolutionArray::setLoc(int loc, bool restore) |
| 770 | { |