[Base] link managers back to SolutionBase
This commit is contained in:
parent
486e2ba9b8
commit
799ef81518
7 changed files with 60 additions and 4 deletions
|
|
@ -16,7 +16,8 @@ class Kinetics;
|
|||
class Transport;
|
||||
|
||||
//! A container class holding managers for all pieces defining a phase
|
||||
class SolutionBase {
|
||||
class SolutionBase : public std::enable_shared_from_this<SolutionBase>
|
||||
{
|
||||
public:
|
||||
SolutionBase();
|
||||
SolutionBase(const std::string& infile, const std::string& phasename);
|
||||
|
|
@ -24,6 +25,10 @@ public:
|
|||
SolutionBase(const SolutionBase&) = delete;
|
||||
SolutionBase& operator=(const SolutionBase&) = delete;
|
||||
|
||||
static shared_ptr<SolutionBase> create() {
|
||||
return shared_ptr<SolutionBase>( new SolutionBase );
|
||||
}
|
||||
|
||||
//! String indicating the type of the SolutionBase object. Corresponds
|
||||
//! to the type of phase originally instantiated
|
||||
std::string type() const {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
namespace Cantera
|
||||
{
|
||||
|
||||
class SolutionBase;
|
||||
|
||||
/**
|
||||
* @defgroup chemkinetics Chemical Kinetics
|
||||
*/
|
||||
|
|
@ -814,6 +816,11 @@ public:
|
|||
void selectPhase(const doublereal* data, const thermo_t* phase,
|
||||
doublereal* phase_data);
|
||||
|
||||
//! Set root SolutionBase holding all phase information
|
||||
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
|
||||
m_root = root;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Cache for saved calculations within each Kinetics object.
|
||||
ValueCache m_cache;
|
||||
|
|
@ -935,6 +942,9 @@ protected:
|
|||
|
||||
//! @see skipUndeclaredThirdBodies()
|
||||
bool m_skipUndeclaredThirdBodies;
|
||||
|
||||
//! reference to SolutionBase
|
||||
std::weak_ptr<SolutionBase> m_root;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ const int cSS_CONVENTION_VPSS = 1;
|
|||
const int cSS_CONVENTION_SLAVE = 2;
|
||||
//@}
|
||||
|
||||
class SolutionBase;
|
||||
|
||||
//! Base class for a phase with thermodynamic properties.
|
||||
/*!
|
||||
* Class ThermoPhase is the base class for the family of classes that represent
|
||||
|
|
@ -1616,6 +1618,11 @@ public:
|
|||
|
||||
//@}
|
||||
|
||||
//! Set root SolutionBase holding all phase information
|
||||
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
|
||||
m_root = root;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Fills `names` and `data` with the column names and species thermo
|
||||
//! properties to be included in the output of the reportCSV method.
|
||||
|
|
@ -1660,6 +1667,9 @@ protected:
|
|||
|
||||
//! last value of the temperature processed by reference state
|
||||
mutable doublereal m_tlast;
|
||||
|
||||
//! reference to SolutionBase
|
||||
std::weak_ptr<SolutionBase> m_root;
|
||||
};
|
||||
|
||||
//! typedef for the ThermoPhase class
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ const VelocityBasis VB_SPECIES_2 = 2;
|
|||
const VelocityBasis VB_SPECIES_3 = 3;
|
||||
//@}
|
||||
|
||||
class SolutionBase;
|
||||
|
||||
//! Base class for transport property managers.
|
||||
/*!
|
||||
* All classes that compute transport properties for a single phase derive from
|
||||
|
|
@ -654,6 +656,11 @@ public:
|
|||
*/
|
||||
virtual void setThermo(thermo_t& thermo);
|
||||
|
||||
//! Set root SolutionBase holding all phase information
|
||||
virtual void setRoot(std::shared_ptr<SolutionBase> root) {
|
||||
m_root = root;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Enable the transport object for use.
|
||||
/*!
|
||||
|
|
@ -680,6 +687,9 @@ protected:
|
|||
//! Velocity basis from which diffusion velocities are computed.
|
||||
//! Defaults to the mass averaged basis = -2
|
||||
int m_velocityBasis;
|
||||
|
||||
//! reference to SolutionBase
|
||||
std::weak_ptr<SolutionBase> m_root;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ cdef extern from "cantera/base/Base.h" namespace "Cantera":
|
|||
void setKinetics(shared_ptr[CxxKinetics])
|
||||
void setTransport(shared_ptr[CxxTransport])
|
||||
|
||||
cdef shared_ptr[CxxSolutionBase] CxxNewSolutionBase "Cantera::SolutionBase::create" ()
|
||||
|
||||
|
||||
cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
||||
cdef cppclass CxxThermoPhase "Cantera::ThermoPhase":
|
||||
|
|
@ -942,6 +944,7 @@ cdef class GasTransportData:
|
|||
|
||||
cdef class _SolutionBase:
|
||||
cdef CxxSolutionBase* base
|
||||
cdef shared_ptr[CxxSolutionBase] _base
|
||||
cdef shared_ptr[CxxThermoPhase] _thermo
|
||||
cdef CxxThermoPhase* thermo
|
||||
cdef shared_ptr[CxxKinetics] _kinetics
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ cdef class _SolutionBase:
|
|||
self.thermo = other.thermo
|
||||
self.kinetics = other.kinetics
|
||||
self.transport = other.transport
|
||||
self._base = other._base
|
||||
self._thermo = other._thermo
|
||||
self._kinetics = other._kinetics
|
||||
self._transport = other._transport
|
||||
|
|
@ -26,9 +27,14 @@ cdef class _SolutionBase:
|
|||
self._selected_species = other._selected_species.copy()
|
||||
return
|
||||
|
||||
# Assign type and unique_name during __init__
|
||||
self.base = new CxxSolutionBase()
|
||||
# Assign base and set managers to NULL
|
||||
self._base = CxxNewSolutionBase()
|
||||
self.base = self._base.get()
|
||||
self.thermo = NULL
|
||||
self.kinetics = NULL
|
||||
self.transport = NULL
|
||||
|
||||
# Parse inputs
|
||||
if infile.endswith('.yml') or infile.endswith('.yaml') or yaml:
|
||||
self._init_yaml(infile, phaseid, phases, yaml)
|
||||
elif infile or source:
|
||||
|
|
@ -41,7 +47,6 @@ cdef class _SolutionBase:
|
|||
# Initialization of transport is deferred to Transport.__init__
|
||||
self.base.setThermoPhase(self._thermo)
|
||||
self.base.setKinetics(self._kinetics)
|
||||
self.transport = NULL
|
||||
|
||||
self._selected_species = np.ndarray(0, dtype=np.integer)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#include "cantera/base/Base.h"
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
#include "cantera/kinetics/Kinetics.h"
|
||||
#include "cantera/transport/TransportBase.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
@ -24,15 +27,25 @@ SolutionBase::SolutionBase(const std::string& infile,
|
|||
throw NotImplementedError("SolutionBase constructor from file");
|
||||
}
|
||||
|
||||
|
||||
void SolutionBase::setThermoPhase(shared_ptr<ThermoPhase> thermo) {
|
||||
m_thermo = thermo;
|
||||
if (m_thermo) {
|
||||
m_thermo->setRoot(shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
void SolutionBase::setKinetics(shared_ptr<Kinetics> kinetics) {
|
||||
m_kinetics = kinetics;
|
||||
if (m_kinetics) {
|
||||
m_kinetics->setRoot(shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
void SolutionBase::setTransport(shared_ptr<Transport> transport) {
|
||||
m_transport = transport;
|
||||
if (m_transport) {
|
||||
m_transport->setRoot(shared_from_this());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue