FalloffFactory.h

Go to the documentation of this file.
00001 /**
00002  *  @file FalloffFactory.h
00003  *  Parameterizations for reaction falloff functions. Used by classes
00004  *  that implement gas-phase kinetics (GasKinetics, GRI_30_Kinetics)
00005  *  (see \ref falloffGroup and class \link Cantera::Falloff Falloff\endlink).
00006  */
00007 
00008 /*
00009  *  $Date: 2009-12-10 18:20:44 -0500 (Thu, 10 Dec 2009) $
00010  *  $Revision: 309 $
00011  */
00012 
00013 // Copyright 2001  California Institute of Technology
00014 
00015 #ifndef CT_NEWFALLOFF_H
00016 #define CT_NEWFALLOFF_H
00017 
00018 #include "ct_defs.h"
00019 #include "reaction_defs.h"
00020 #include "FactoryBase.h"
00021 
00022 #if defined(THREAD_SAFE_CANTERA)
00023 #include <boost/thread/mutex.hpp>
00024 #endif
00025 
00026 namespace Cantera {
00027 
00028   /**
00029    *     @defgroup falloffGroup  Falloff Parameterizations
00030    *    This section describes the parameterizations used 
00031    *    to describe the fall-off in reaction rate constants
00032    *    due to intermolecular energy transfer.
00033    *
00034    *    @ingroup chemkinetics
00035    */
00036 
00037   /**
00038    * Base class for falloff function calculators. Each instance of a
00039    * subclass of Falloff computes one falloff function.
00040    *
00041    * @ingroup falloffGroup 
00042    */
00043   class Falloff {
00044   public:
00045 
00046     //! Default constructor is empty
00047     Falloff(){}
00048 
00049     //! default destructor is empty
00050     virtual ~Falloff(){}
00051 
00052     /** 
00053      * Initialize. Must be called before any other method is
00054      * invoked.
00055      *
00056      * @param c Vector of coefficients of the parameterization.
00057      * The number and meaning of these coefficients is
00058      * subclass-dependent.
00059      */
00060     virtual void init(const vector_fp& c) =0;
00061 
00062     /** 
00063      * Update the temperature-dependent portions of the falloff
00064      * function, if any. This method evaluates temperature-dependent
00065      * intermediate results and stores them in the 'work' array. 
00066      * If not overloaded, the default behavior is to do nothing.
00067      * @param T Temperature [K].
00068      * @param work storage space for intermediate results.
00069      */
00070     virtual void updateTemp(doublereal T, workPtr work) const {}
00071 
00072     /**
00073      * The falloff function. This is defined so that the 
00074      * rate coefficient is
00075      *
00076      * \f[  k = F(Pr)\frac{Pr}{1 + Pr}. \f]
00077      *
00078      * Here \f$ Pr \f$ is the reduced pressure, defined by
00079      *
00080      * \f[
00081      * Pr = \frac{k_0 [M]}{k_\infty}.
00082      * \f]
00083      *
00084      * @param pr reduced pressure (dimensionless).
00085      * @param work array of size workSize() containing cached 
00086      *             temperature-dependent intermediate results from a prior call
00087      *             to updateTemp. 
00088      *
00089      * @return Returns the value of the falloff function \f$ F \f$ defined above
00090      */
00091     virtual doublereal F(doublereal pr, const_workPtr work) const =0;
00092 
00093     /**
00094      * The size of the work array required.
00095      */
00096     virtual size_t workSize() =0;
00097 
00098   protected:
00099   private:
00100   };
00101       
00102 
00103 
00104   /**
00105    * Factory class to construct falloff function calculators. 
00106    * The falloff factory is accessed through static method factory:
00107    *
00108    * @code
00109    * Falloff* f = FalloffFactory::factory()->newFalloff(type, c)
00110    * @endcode
00111    *
00112    * @ingroup falloffGroup  
00113    */
00114   class FalloffFactory : public FactoryBase {
00115   public:
00116 
00117     /**
00118      * Return a pointer to the factory. On the first call, a new
00119      * instance is created. Since there is no need to instantiate
00120      * more than one factory, on all subsequent calls, a pointer
00121      * to the existing factory is returned.
00122      */  
00123     static FalloffFactory* factory() { 
00124 #if defined(THREAD_SAFE_CANTERA)
00125       boost::mutex::scoped_lock   lock(falloff_mutex) ;
00126 #endif
00127       if (!s_factory) s_factory = new FalloffFactory;
00128       return s_factory;
00129     }
00130 
00131     virtual void deleteFactory() {
00132 #if defined(THREAD_SAFE_CANTERA)
00133       boost::mutex::scoped_lock   lock(falloff_mutex) ;
00134 #endif
00135       if (s_factory) {
00136         delete s_factory;
00137         s_factory = 0;
00138       }
00139     }
00140 
00141     /**
00142      * Destructor doesn't do anything. We do not delete statically
00143      * created single instance of this class here, because it would
00144      * create an infinite loop if destructor is called for that
00145      * single instance. Instead, to delete single instance, we
00146      * call delete[] from FalloffMng's destructor.
00147      */
00148     virtual ~FalloffFactory() {
00149     }
00150 
00151      
00152     //! Return a pointer to a new falloff function calculator.
00153     /*!
00154      *
00155      * @param type Integer flag specifying the type of falloff function.
00156      *              The standard types are defined in file reaction_defs.h. A factory 
00157      *              class derived from FalloffFactory may define other types as well.
00158      *
00159      * @param c    input vector of doubles which populates the falloff 
00160      *             parameterization.
00161      *
00162      * @return    Returns a pointer to a new Falloff class.
00163      */
00164     virtual Falloff* newFalloff(int type, const vector_fp& c);
00165 
00166   private:
00167     //! Pointer to the single instance of the factory
00168     static FalloffFactory* s_factory;
00169 
00170     //! default constructor, which is defined as private
00171     FalloffFactory(){}
00172 
00173 #if defined(THREAD_SAFE_CANTERA)
00174     //!  Mutex for use when calling the factory
00175     static boost::mutex falloff_mutex ;
00176 #endif
00177   };
00178 
00179 }
00180 #endif
00181 
00182 
Generated by  doxygen 1.6.3