SpeciesThermoFactory.h

Go to the documentation of this file.
00001 /**
00002  *  @file SpeciesThermoFactory.h
00003  *    Header for factory to build instances of classes that manage the
00004  *    standard-state thermodynamic properties of a set of species 
00005  *    (see \ref spthermo and class 
00006  *     \link Cantera::SpeciesThermoFactory SpeciesThermoFactory\endlink);
00007  */
00008 
00009 /*
00010  * $Revision: 306 $
00011  * $Date: 2009-12-09 12:29:23 -0500 (Wed, 09 Dec 2009) $
00012  */
00013 
00014 // Copyright 2001  California Institute of Technology
00015 
00016 #ifndef SPECIESTHERMO_FACTORY_H
00017 #define SPECIESTHERMO_FACTORY_H
00018 
00019 #include "SpeciesThermo.h"
00020 #include "ctexceptions.h"
00021 #include "FactoryBase.h"
00022 
00023 
00024 namespace Cantera {
00025 
00026   class XML_Node;
00027   class VPStandardStateTP;
00028   class VPSSMgr;
00029   class ThermoPhase;
00030 
00031   /**
00032    * Throw a named error for an unknown or missing species thermo model. 
00033    *
00034    * @ingroup thermoprops
00035    */
00036   class UnknownSpeciesThermoModel: public CanteraError {
00037   public:
00038     //! constructor
00039     /*!
00040      * @param proc Function name error occurred.
00041      * @param spName Species Name that caused the error
00042      * @param speciesThermoModel Unrecognized species thermo model name
00043      */
00044     UnknownSpeciesThermoModel(std::string proc, std::string spName,
00045                               std::string speciesThermoModel) :
00046       CanteraError(proc, "species " + spName + 
00047                    ": Specified speciesThermoPhase model "   
00048                    + speciesThermoModel + 
00049                    " does not match any known type.") {}
00050     //! destructor
00051     virtual ~UnknownSpeciesThermoModel() throw() {}
00052   };
00053 
00054   //! Factory to build instances of classes that manage the
00055   //! standard-state thermodynamic properties of a set of species.
00056   /*!
00057    *  This class is responsible for making the decision concerning
00058    *  which derivative of SpeciesThermo object to use.
00059    *  The SpeciesThermo object is used to calculate 
00060    *  thermodynamic functions for the reference state.
00061    *  It queries the database of species to understand what
00062    *  the requirements are for the submodels for all of the
00063    *  species in the phase. Then, it picks the SpeciesThermo
00064    *  object to use, and passies it back to the calling routine.
00065    *  It doesn't load any of the data into the derived
00066    *  SpeciesThermo object. 
00067    *
00068    *  Making the choice of SpeciesThermo types is the only
00069    *  thing this class does.
00070    *
00071    * This class is implemented as a singleton -- one in which
00072    * only one instance is needed.  The recommended way to access
00073    * the factory is to call this static method, which
00074    * instantiates the class if it is the first call, but
00075    * otherwise simply returns the pointer to the existing
00076    * instance.
00077    *
00078    * @ingroup thermoprops
00079    */
00080   class SpeciesThermoFactory : public FactoryBase {
00081 
00082   public:
00083 
00084     //! Static method to return an instance of this class
00085     /*!
00086      * This class is implemented as a singleton -- one in which
00087      * only one instance is needed.  The recommended way to access
00088      * the factory is to call this static method, which
00089      * instantiates the class if it is the first call, but
00090      * otherwise simply returns the pointer to the existing
00091      * instance.
00092      */
00093     static SpeciesThermoFactory* factory();
00094 
00095     //! Delete static instance of this class
00096     /**
00097      * If it is necessary to explicitly delete the factory before
00098      * the process terminates (for example, when checking for
00099      * memory leaks) then this method can be called to delete it.
00100      */
00101     void deleteFactory();
00102         
00103     //! Destructor
00104     /**
00105      * Doesn't do anything. We do not delete statically
00106      * created single instance of this class here, because it would
00107      * create an infinite loop if destructor is called for that
00108      * single instance.
00109      */
00110     virtual ~SpeciesThermoFactory();
00111 
00112     //! Create a new species property manage for the reference state.
00113     /*!
00114      *  @param type the integer type to be created.
00115      *
00116      *
00117      *  @return                 Returns the pointer to the newly malloced
00118      *                          species property manager for the reference
00119      *                          state
00120      */ 
00121     SpeciesThermo* newSpeciesThermo(int type) const;
00122 
00123     //! Create a new species thermo property manager given a string
00124     /*!
00125      * Create a new species thermo property manager, given a 
00126      * string.
00127      *
00128      *  @param stype            String name for the species thermo type
00129      *
00130      *
00131      *  @return                 Returns the pointer to the newly malloced
00132      *                          species property manager for the reference
00133      *                          state
00134      */
00135     SpeciesThermo* newSpeciesThermoManager(std::string &stype) const;
00136 
00137     //! Create a new species property manager for the reference
00138     //! state for a group of species
00139     /*!
00140      * This routine will look through species nodes. It will discover what
00141      * each species needs for its species property managers. Then,
00142      * it will malloc and return the proper species property manager to use.
00143      * 
00144      *   @param spDataNodeList  This vector contains a list
00145      *                          of species XML nodes that will be in the phase
00146      *
00147      *  @return                 Returns the pointer to the newly malloced
00148      *                          species property manager for the reference
00149      *                          state
00150      */ 
00151     SpeciesThermo* newSpeciesThermo(std::vector<XML_Node*> & spDataNodeList) const;
00152 
00153     //! Create a new species property manager for the reference state
00154     /*!
00155      * This routine will look through species nodes. It will discover what
00156      * each species needs for its species property managers. Then,
00157      * it will malloc and return the proper species property manager to use.
00158      *
00159      *
00160      *   @param spDataNodeList This vector contains a list
00161      *                         of species XML nodes that will be in the phase
00162      *
00163      *  @return                 Returns the pointer to the newly malloced
00164      *                          species property manager for the reference state
00165      *  @todo is this used? 
00166      */ 
00167     SpeciesThermo* newSpeciesThermoOpt(std::vector<XML_Node*> & spDataNodeList) const;
00168 
00169     //! Install a species thermodynamic property parameterization
00170     //! for the reference state for one species into a species thermo manager.
00171     /*!
00172      * @param k             Species number
00173      * @param speciesNode   Reference to the XML node specifying the species standard
00174      *                      state information
00175      * @param th_ptr        Pointer to the %ThermoPhase object for the species
00176      * @param spthermo      Species reference state thermo manager
00177      * @param phaseNode_ptr Optional pointer to the XML phase
00178      *                      information for the phase in which the species
00179      *                      resides
00180      */
00181     void installThermoForSpecies(int k, const XML_Node& speciesNode, 
00182                                  ThermoPhase *th_ptr, SpeciesThermo& spthermo,
00183                                  const XML_Node *phaseNode_ptr = 0) const;
00184 
00185     //! Install a species thermodynamic property parameterization
00186     //! for the standard state for one species into a species thermo manager, VPSSMgr
00187     /*!
00188      * This is a wrapper around the createInstallVPSS() function in the 
00189      * VPStandardStateTP object.
00190      *
00191      * This serves to install the species into vpss_ptr, create a PDSS file. We also
00192      * read the xml database to extract the constants for these steps.
00193      *
00194      * @param k             species number
00195      * @param speciesNode   Reference to the XML node specifying the species standard
00196      *                      state information
00197      * @param vp_ptr        variable pressure ThermoPhase object 
00198      * @param vpss_ptr      Pointer to the Manager for calculating variable pressure
00199      *                      substances.
00200      * @param spthermo_ptr  Species reference state thermo manager
00201      * @param phaseNode_ptr Optional Pointer to the XML phase
00202      *                      information for the phase in which the species
00203      *                      resides
00204      */
00205     void installVPThermoForSpecies(int k, const XML_Node& speciesNode, 
00206                                    VPStandardStateTP *vp_ptr,
00207                                    VPSSMgr *vpss_ptr,
00208                                    SpeciesThermo *spthermo_ptr,
00209                                    const XML_Node *phaseNode_ptr) const;
00210 
00211   private:
00212 
00213     //! Pointer to the sole instance of this class, which is static
00214     static SpeciesThermoFactory* s_factory;
00215 
00216 #if defined(THREAD_SAFE_CANTERA)
00217     //! Decl of the static mutex variable that locks the %SpeciesThermo factory singelton
00218     static boost::mutex species_thermo_mutex;
00219 #endif
00220 
00221     //! Constructor. This is made private, so that only the static
00222     //! method factory() can instantiate the class.
00223     SpeciesThermoFactory(){}
00224   };
00225 
00226 
00227   ////////////////////// Convenience functions ////////////////////
00228   //
00229   //  These functions allow using a different factory class that
00230   //  derives from SpeciesThermoFactory.
00231   //
00232   //////////////////////////////////////////////////////////////////
00233 
00234 
00235   //! Create a new species thermo manager instance, by specifying
00236   //!the type and (optionally) a pointer to the factory to use to create it.
00237   /*!
00238    * This utility program  will look through species nodes. It will discover what
00239    * each species needs for its species property managers. Then,
00240    * it will malloc and return the proper species property manager to use.
00241    *
00242    *  These functions allow using a different factory class that
00243    *  derives from SpeciesThermoFactory.
00244    *
00245    * @param type         Species thermo type.
00246    * @param f            Pointer to a SpeciesThermoFactory. optional parameter. 
00247    *                    Defautls to NULL.
00248    */
00249   SpeciesThermo* newSpeciesThermoMgr(int type, SpeciesThermoFactory* f=0);
00250 
00251   //! Create a new species thermo manager instance, by specifying
00252   //!the type and (optionally) a pointer to the factory to use to create it.
00253   /*!
00254    * This utility program is a basic factory operation for spawning a
00255    * new species reference-state thermo mananger
00256    *
00257    *  These functions allows for using a different factory class that
00258    *  derives from SpeciesThermoFactory. However, no applications of this
00259    *  have been done yet.
00260    *
00261    * @param stype       String specifying the species thermo type
00262    * @param f           Pointer to a SpeciesThermoFactory. optional parameter. 
00263    *                    Defautls to NULL.
00264    */
00265   SpeciesThermo* newSpeciesThermoMgr(std::string &stype, 
00266                                      SpeciesThermoFactory* f=0);
00267 
00268   //! Function to return SpeciesThermo manager
00269   /*!
00270    * This utility program  will look through species nodes. It will discover what
00271    * each species needs for its species property managers. Then,
00272    * it will malloc and return the proper species reference state manager to use.
00273    *
00274    *  These functions allow using a different factory class that
00275    *  derives from SpeciesThermoFactory.
00276    *
00277    *  @param spDataNodeList This vector contains a list
00278    *                        of species XML nodes that will be in the phase
00279    *
00280    * @param f            Pointer to a SpeciesThermoFactory. optional parameter. 
00281    *                    Defautls to NULL.
00282    * @param opt         Boolean defaults to false.
00283    */
00284   SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> spDataNodeList, 
00285                                      SpeciesThermoFactory* f=0, bool opt=false);
00286 
00287 }
00288 
00289 #endif
00290 
00291 
Generated by  doxygen 1.6.3