mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[SolutionArray] Add species lock
This commit is contained in:
parent
fbd2d37df0
commit
46913c88cc
@ -39,7 +39,7 @@ private:
|
||||
SolutionArray(const SolutionArray& arr, const vector<int>& indices);
|
||||
|
||||
public:
|
||||
virtual ~SolutionArray() {}
|
||||
virtual ~SolutionArray();
|
||||
|
||||
/**
|
||||
* Instantiate a new SolutionArray reference.
|
||||
|
@ -44,11 +44,12 @@ SolutionArray::SolutionArray(const shared_ptr<Solution>& sol,
|
||||
, m_dataSize(size)
|
||||
, m_meta(meta)
|
||||
{
|
||||
if (!m_sol) {
|
||||
if (!m_sol || !m_sol->thermo()) {
|
||||
throw CanteraError("SolutionArray::SolutionArray",
|
||||
"Unable to create SolutionArray from invalid Solution object.");
|
||||
}
|
||||
m_stride = m_sol->thermo()->stateSize();
|
||||
m_sol->thermo()->addSpeciesLock();
|
||||
m_data = make_shared<vector<double>>(m_dataSize * m_stride, 0.);
|
||||
m_extra = make_shared<map<string, AnyValue>>();
|
||||
m_order = make_shared<map<int, string>>();
|
||||
@ -72,6 +73,7 @@ SolutionArray::SolutionArray(const SolutionArray& other,
|
||||
, m_shared(true)
|
||||
, m_active(selected)
|
||||
{
|
||||
m_sol->thermo()->addSpeciesLock();
|
||||
for (auto loc : m_active) {
|
||||
if (loc < 0 || loc >= (int)m_dataSize) {
|
||||
IndexError("SolutionArray::SolutionArray", "indices", loc, m_dataSize);
|
||||
@ -83,6 +85,11 @@ SolutionArray::SolutionArray(const SolutionArray& other,
|
||||
}
|
||||
}
|
||||
|
||||
SolutionArray::~SolutionArray()
|
||||
{
|
||||
m_sol->thermo()->removeSpeciesLock();
|
||||
}
|
||||
|
||||
namespace { // restrict scope of helper functions to local translation unit
|
||||
|
||||
template<class T>
|
||||
|
Loading…
Reference in New Issue
Block a user