abs_integrator.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: abs_integrator.h,v 3.7 2009/04/17 02:05:37 bjoo Exp $
00003 
00004 /*! @file
00005  * @brief Integrators
00006  *
00007  * Intregators for HMC
00008  */
00009 
00010 #ifndef ABS_INTEGRATOR_H
00011 #define ABS_INTEGRATOR_H
00012 
00013 #include "chromabase.h"
00014 #include "update/molecdyn/field_state.h"
00015 #include "update/molecdyn/hamiltonian/abs_hamiltonian.h"
00016 #include "io/xmllog_io.h"
00017 
00018 
00019 namespace Chroma 
00020 {
00021   
00022   //! MD integrator that can be used as a component for other integrators
00023   /*! @ingroup integrator */
00024   template<typename P, typename Q>
00025   class AbsComponentIntegrator { 
00026   public:
00027     //! Virtual destructor
00028     virtual ~AbsComponentIntegrator(void) {} 
00029 
00030     //! Do an integration of length n*delta tau in n steps.
00031     virtual void operator()(AbsFieldState<P,Q>& s, 
00032                             const Real& traj_length) const = 0;
00033 
00034     //! Refresh fields in this level of the integrator (for R like algorithms)
00035     virtual void refreshFields(AbsFieldState<multi1d<LatticeColorMatrix>,
00036                                    multi1d<LatticeColorMatrix> >& s) const = 0;
00037 
00038     //! Reset any chronological predictors for the integrator
00039     virtual void resetPredictors(void) const = 0;
00040   };
00041 
00042   //! MD component integrator that has a sub integrator (recursive)
00043   /*! @ingroup integrator */
00044   template<typename P, typename Q>
00045   class AbsRecursiveIntegrator : public AbsComponentIntegrator<P,Q> { 
00046   public: 
00047     //! Virtual destructor 
00048     virtual ~AbsRecursiveIntegrator(void) {}
00049 
00050     //! Do an integration of lenght n*delta tau in n steps.
00051     virtual  void operator()(AbsFieldState<P,Q>& s, 
00052                              const Real& traj_length) const = 0;
00053                             
00054 
00055     //! Return the next level down integrator
00056     virtual AbsComponentIntegrator<P,Q>& getSubIntegrator() const = 0;
00057 
00058     //! Refresh fields in this level of the integrator and sub integrators.
00059     virtual void refreshFields(AbsFieldState<multi1d<LatticeColorMatrix>,
00060                                    multi1d<LatticeColorMatrix> >& s) const {
00061       refreshFieldsThisLevel(s); // Do the fields in this level
00062       getSubIntegrator().refreshFields(s); // Recurse down 
00063     }
00064 
00065     //! Reset Integrators in this level and sub integrators
00066     virtual void resetPredictors(void) const {
00067       resetPredictorsThisLevel();  // This level 
00068       getSubIntegrator().resetPredictors(); // Recurse down
00069     }
00070 
00071   protected:
00072     //! Refresh fields in just this level
00073     virtual void refreshFieldsThisLevel(AbsFieldState<multi1d<LatticeColorMatrix>,
00074                                    multi1d<LatticeColorMatrix> >& s) const = 0;
00075 
00076     virtual void resetPredictorsThisLevel(void) const = 0;
00077   };
00078   
00079 
00080   //! New MD integrator interface 
00081   /*! @ingroup integrator */
00082   template<typename P, typename Q>
00083   class AbsMDIntegrator {
00084   public:
00085 
00086     //! Virtual destructor
00087     virtual ~AbsMDIntegrator(void) {}
00088 
00089     //! Do the trajectory for length trajLength 
00090     virtual void operator()(AbsFieldState<P,Q>&s, const Real& trajLength) const {
00091       // Default behaviour - get the subintegrator and integrate
00092       // the trajectory of length trajLength
00093       AbsComponentIntegrator<P,Q>& theIntegrator = getIntegrator();
00094 
00095       // This is a toplevel thing - not embeddable so here is the 
00096       // place to reset any predictors
00097       QDPIO::cout << "MD: Resetting Chrono Predictors at start of trajectory" << endl;
00098       theIntegrator.resetPredictors();
00099 
00100       // This is recursive so no further resets in here.
00101       theIntegrator(s, trajLength);
00102     }
00103     
00104     //! Refresh fields in the sub integrators (for R-like algorithms)
00105     virtual void refreshFields(AbsFieldState<P,Q>&s ) const { 
00106       getIntegrator().refreshFields(s); // Recursively refresh fields
00107     }
00108 
00109     //! Get the trajectory length
00110     virtual Real getTrajLength(void) const = 0;
00111 
00112     //! Copy equivalent fields into MD monomals before integration
00113     /*! It is up to the toplevel integrator to keep track of which 
00114         fields it needs to copy internally so that this function doesn't
00115         need its details exposed */
00116     virtual void copyFields(void) const = 0;
00117   private:
00118 
00119     //! Get the toplevel sub integrator
00120     virtual AbsComponentIntegrator<P,Q>& getIntegrator() const = 0;
00121     
00122   };
00123 
00124 
00125 } // End namespace Chroma
00126 
00127 #endif

Generated on Sun Nov 22 04:28:48 2009 for CHROMA by  doxygen 1.4.7