diff --git a/Cantera/src/numerics/Integrator.h b/Cantera/src/numerics/Integrator.h index cd442db88..2006f62e8 100644 --- a/Cantera/src/numerics/Integrator.h +++ b/Cantera/src/numerics/Integrator.h @@ -64,7 +64,14 @@ namespace Cantera { public: - virtual ~Integrator() {} + //! Default Constructor + Integrator() + { + } + + //! Destructor + virtual ~Integrator() { + } /** Set or reset the number of equations. */ //virtual void resize(int n)=0; @@ -76,7 +83,9 @@ namespace Cantera { * @param abstol array of N absolute tolerance values */ virtual void setTolerances(doublereal reltol, int n, - doublereal* abstol) { warn("setTolerances"); } + doublereal* abstol) { + warn("setTolerances"); + } //! Set error tolerances. /*! diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index 50c324461..3f409b8db 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -295,7 +295,7 @@ namespace Cantera { * make one of several transport models, and return a base class * pointer to it. */ - Transport* TransportFactory::newTransport(string transportModel, + Transport* TransportFactory::newTransport(std::string transportModel, thermo_t* phase, int log_level) { if (transportModel == "") return new Transport; @@ -362,6 +362,27 @@ namespace Cantera { return tr; } + /** + * make one of several transport models, and return a base class + * pointer to it. + */ + Transport* TransportFactory::newTransport(thermo_t* phase, int log_level) { + XML_Node &phaseNode=phase->xml(); + /* + * Find the Thermo XML node + */ + if (!phaseNode.hasChild("transport")) { + throw CanteraError("TransportFactory::newTransport", + "no transport XML node"); + } + XML_Node& transportNode = phaseNode.child("transport"); + string transportModel = transportNode.attrib("model"); + if (transportModel == "") { + throw CanteraError("TransportFactory::newTransport", + "transport XML node doesn't have a model string"); + } + return newTransport(transportModel, phase,log_level); + } /** diff --git a/Cantera/src/transport/TransportFactory.h b/Cantera/src/transport/TransportFactory.h index 299e4397f..d38603557 100644 --- a/Cantera/src/transport/TransportFactory.h +++ b/Cantera/src/transport/TransportFactory.h @@ -124,12 +124,26 @@ namespace Cantera { * single instance. */ virtual ~TransportFactory(); - - /// Build a new transport manager + //! Build a new transport manager using a transport manager + //! that may not be the same as in the phase description + /*! + * @param model String name for the transport manager + * @param thermo ThermoPhase object + * @param log_level log level + */ virtual Transport* newTransport(std::string model, thermo_t* thermo, int log_level=0); + //! Build a new transport manager using the default transport manager + //! in the phase description + /*! + * @param thermo ThermoPhase object + * @param log_level log level + */ + virtual Transport* + newTransport(thermo_t* thermo, int log_level=0); + /// Initialize an existing transport manager virtual void initTransport(Transport* tr, thermo_t* thermo, int mode=0, int log_level=0); @@ -139,8 +153,6 @@ namespace Cantera { thermo_t* thermo, int log_level=0); - - private: //! Static instance of the factor -> This is the only instance of this @@ -150,8 +162,6 @@ namespace Cantera { static boost::mutex transport_mutex ; #endif - - //! The constructor is private; use static method factory() to //! get a pointer to a factory instance /*! @@ -228,8 +238,8 @@ namespace Cantera { * Create a new transport manager instance. * @ingroup transportProps */ - inline Transport* newTransportMgr(std::string transportModel="", - thermo_t* thermo=0, int loglevel=0, + inline Transport* newTransportMgr(std::string transportModel = "", + thermo_t* thermo = 0, int loglevel=0, TransportFactory* f=0) { if (f == 0) { f = TransportFactory::factory(); @@ -241,7 +251,25 @@ namespace Cantera { * the need for multiple cantera and transport library statements * for applications that don't have transport in them. */ - //TransportFactory::deleteFactory(); + return ptr; + } + + /** + * Create a new transport manager instance. + * @ingroup transportProps + */ + inline Transport* newDefaultTransportMgr(thermo_t* thermo, int loglevel=0, + TransportFactory* f=0) { + if (f == 0) { + f = TransportFactory::factory(); + } + Transport* ptr = f->newTransport(thermo, loglevel); + /* + * Note: We delete the static s_factory instance here, instead of in + * appdelete() in misc.cpp, to avoid linking problems involving + * the need for multiple cantera and transport library statements + * for applications that don't have transport in them. + */ return ptr; }