mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[oneD] Enable Kinetics/Transport setters for smart pointers
This commit is contained in:
parent
6f8b151e72
commit
ffebb8dcd3
@ -298,6 +298,9 @@ public:
|
||||
ReactingSurf1D();
|
||||
ReactingSurf1D(shared_ptr<Solution> solution, const std::string& id="");
|
||||
|
||||
virtual void setKinetics(shared_ptr<Kinetics> kin);
|
||||
|
||||
//! @deprecated To be removed after Cantera 3.0; replaced by setKinetics
|
||||
void setKineticsMgr(InterfaceKinetics* kin);
|
||||
|
||||
void enableCoverageEquations(bool docov) {
|
||||
|
@ -28,6 +28,8 @@ class MultiJac;
|
||||
class OneDim;
|
||||
class Refiner;
|
||||
class AnyMap;
|
||||
class Kinetics;
|
||||
class Transport;
|
||||
class Solution;
|
||||
class SolutionArray;
|
||||
|
||||
@ -65,6 +67,24 @@ public:
|
||||
return (m_type >= cConnectorType);
|
||||
}
|
||||
|
||||
//! Set the solution manager.
|
||||
//! @since New in Cantera 3.0.
|
||||
void setSolution(shared_ptr<Solution> sol) {
|
||||
m_solution = sol;
|
||||
}
|
||||
|
||||
//! Set the kinetics manager.
|
||||
//! @since New in Cantera 3.0.
|
||||
virtual void setKinetics(shared_ptr<Kinetics> kin) {
|
||||
throw NotImplementedError("Domain1D::setKinetics");
|
||||
}
|
||||
|
||||
//! Set transport model to existing instance
|
||||
//! @since New in Cantera 3.0.
|
||||
virtual void setTransport(shared_ptr<Transport> trans) {
|
||||
throw NotImplementedError("Domain1D::setTransport");
|
||||
}
|
||||
|
||||
//! The container holding this domain.
|
||||
const OneDim& container() const {
|
||||
return *m_container;
|
||||
@ -398,12 +418,18 @@ public:
|
||||
*/
|
||||
void linkLeft(Domain1D* left) {
|
||||
m_left = left;
|
||||
if (!m_solution && left && left->solution()) {
|
||||
m_solution = left->solution();
|
||||
}
|
||||
locate();
|
||||
}
|
||||
|
||||
//! Set the right neighbor to domain 'right.'
|
||||
void linkRight(Domain1D* right) {
|
||||
m_right = right;
|
||||
if (!m_solution && right && right->solution()) {
|
||||
m_solution = right->solution();
|
||||
}
|
||||
}
|
||||
|
||||
//! Append domain 'right' to this one, and update all links.
|
||||
|
@ -52,9 +52,7 @@ public:
|
||||
StFlow(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1);
|
||||
|
||||
//! Delegating constructor
|
||||
StFlow(shared_ptr<ThermoPhase> th, size_t nsp = 1, size_t points = 1) :
|
||||
StFlow(th.get(), nsp, points) {
|
||||
}
|
||||
StFlow(shared_ptr<ThermoPhase> th, size_t nsp = 1, size_t points = 1);
|
||||
|
||||
//! Create a new flow domain.
|
||||
//! @param sol Solution object used to evaluate all thermodynamic, kinetic, and
|
||||
@ -88,12 +86,16 @@ public:
|
||||
*/
|
||||
void setThermo(IdealGasPhase& th);
|
||||
|
||||
//! Set the kinetics manager. The kinetics manager must
|
||||
void setKinetics(Kinetics& kin) {
|
||||
m_kin = &kin;
|
||||
}
|
||||
virtual void setKinetics(shared_ptr<Kinetics> kin);
|
||||
|
||||
//! Set the kinetics manager.
|
||||
//! @deprecated To be removed after Cantera 3.0; replaced by Domain1D::setKinetics
|
||||
void setKinetics(Kinetics& kin);
|
||||
|
||||
virtual void setTransport(shared_ptr<Transport> trans);
|
||||
|
||||
//! Set transport model to existing instance
|
||||
//! @deprecated To be removed after Cantera 3.0; replaced by Domain1D::setKinetics
|
||||
void setTransport(Transport& trans);
|
||||
|
||||
//! Set the transport model
|
||||
|
@ -644,8 +644,23 @@ ReactingSurf1D::ReactingSurf1D(shared_ptr<Solution> solution, const std::string&
|
||||
m_enabled = true;
|
||||
}
|
||||
|
||||
void ReactingSurf1D::setKinetics(shared_ptr<Kinetics> kin)
|
||||
{
|
||||
m_solution = Solution::create();
|
||||
m_solution->setThermo(kin->reactionPhase());
|
||||
m_solution->setKinetics(kin);
|
||||
m_solution->setTransportModel("none");
|
||||
m_kin = dynamic_pointer_cast<InterfaceKinetics>(kin).get();
|
||||
m_surfindex = kin->reactionPhaseIndex();
|
||||
m_sphase = dynamic_pointer_cast<SurfPhase>(kin->reactionPhase()).get();
|
||||
m_nsp = m_sphase->nSpecies();
|
||||
m_enabled = true;
|
||||
}
|
||||
|
||||
void ReactingSurf1D::setKineticsMgr(InterfaceKinetics* kin)
|
||||
{
|
||||
warn_deprecated("ReactingSurf1D::setKineticsMgr",
|
||||
"To be removed after Cantera 3.0. Replaced by Domain1D::setKinetics.");
|
||||
m_kin = kin;
|
||||
m_surfindex = kin->reactionPhaseIndex();
|
||||
m_sphase = (SurfPhase*)&kin->thermo(m_surfindex);
|
||||
|
@ -108,6 +108,13 @@ StFlow::StFlow(ThermoPhase* ph, size_t nsp, size_t points) :
|
||||
m_kRadiating[1] = m_thermo->speciesIndex("H2O");
|
||||
}
|
||||
|
||||
StFlow::StFlow(shared_ptr<ThermoPhase> th, size_t nsp, size_t points)
|
||||
: StFlow(th.get(), nsp, points)
|
||||
{
|
||||
m_solution = Solution::create();
|
||||
m_solution->setThermo(th);
|
||||
}
|
||||
|
||||
StFlow::StFlow(shared_ptr<Solution> sol, const std::string& id, size_t points)
|
||||
: StFlow(sol->thermo().get(), sol->thermo()->nSpecies(), points)
|
||||
{
|
||||
@ -141,6 +148,50 @@ void StFlow::setThermo(IdealGasPhase& th) {
|
||||
m_thermo = &th;
|
||||
}
|
||||
|
||||
void StFlow::setKinetics(shared_ptr<Kinetics> kin)
|
||||
{
|
||||
if (!m_solution) {
|
||||
// @todo remove after Cantera 3.0
|
||||
throw CanteraError("StFlow::setKinetics",
|
||||
"Unable to update object that was not constructed from smart pointers.");
|
||||
}
|
||||
m_kin = kin.get();
|
||||
m_solution->setKinetics(kin);
|
||||
}
|
||||
|
||||
void StFlow::setKinetics(Kinetics& kin)
|
||||
{
|
||||
// @todo: resolve crash for updated m_solution->registerChangedCallback
|
||||
// warn_deprecated("StFlow::setKinetics",
|
||||
// "To be removed after Cantera 3.0. Replaced by Domain1D::setKinetics.");
|
||||
m_kin = &kin;
|
||||
}
|
||||
|
||||
void StFlow::setTransport(shared_ptr<Transport> trans)
|
||||
{
|
||||
if (!m_solution) {
|
||||
// @todo remove after Cantera 3.0
|
||||
throw CanteraError("StFlow::setTransport",
|
||||
"Unable to update object that was not constructed from smart pointers.");
|
||||
}
|
||||
if (!trans) {
|
||||
throw CanteraError("StFlow::setTransport", "Unable to set empty transport.");
|
||||
}
|
||||
m_trans = trans.get();
|
||||
if (m_trans->transportModel() == "None") {
|
||||
throw CanteraError("StFlow::setTransport", "Invalid Transport model 'None'.");
|
||||
}
|
||||
m_do_multicomponent = (m_trans->transportModel() == "Multi" ||
|
||||
m_trans->transportModel() == "CK_Multi");
|
||||
|
||||
m_diff.resize(m_nsp * m_points);
|
||||
if (m_do_multicomponent) {
|
||||
m_multidiff.resize(m_nsp * m_nsp*m_points);
|
||||
m_dthermal.resize(m_nsp, m_points, 0.0);
|
||||
}
|
||||
m_solution->setTransport(trans);
|
||||
}
|
||||
|
||||
void StFlow::resize(size_t ncomponents, size_t points)
|
||||
{
|
||||
Domain1D::resize(ncomponents, points);
|
||||
@ -193,6 +244,7 @@ void StFlow::resetBadValues(double* xg)
|
||||
void StFlow::setTransportModel(const std::string& trans)
|
||||
{
|
||||
if (!m_solution) {
|
||||
// @todo remove after Cantera 3.0
|
||||
throw CanteraError("StFlow::setTransportModel",
|
||||
"Unable to set Transport manager by name as object was not initialized\n"
|
||||
"from a Solution manager: set Transport object directly instead.");
|
||||
@ -206,6 +258,9 @@ std::string StFlow::transportModel() const {
|
||||
|
||||
void StFlow::setTransport(Transport& trans)
|
||||
{
|
||||
// @todo: resolve crash for updated m_solution->registerChangedCallback
|
||||
// warn_deprecated("StFlow::setTransport",
|
||||
// "To be removed after Cantera 3.0. Replaced by Domain1D::setTransport.");
|
||||
m_trans = &trans;
|
||||
if (m_trans->transportModel() == "None") {
|
||||
throw CanteraError("StFlow::setTransport",
|
||||
|
Loading…
Reference in New Issue
Block a user