CHROMA
abs_integrator.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Integrators
5  *
6  * Intregators for HMC
7  */
8 
9 #ifndef ABS_INTEGRATOR_H
10 #define ABS_INTEGRATOR_H
11 
12 #include "chromabase.h"
15 #include "io/xmllog_io.h"
16 
17 
18 namespace Chroma
19 {
20 
21  //! MD integrator that can be used as a component for other integrators
22  /*! @ingroup integrator */
23  template<typename P, typename Q>
25  public:
26  //! Virtual destructor
27  virtual ~AbsComponentIntegrator(void) {}
28 
29  //! Do an integration of length n*delta tau in n steps.
31  const Real& traj_length) const = 0;
32 
33  //! Refresh fields in this level of the integrator (for R like algorithms)
34  virtual void refreshFields(AbsFieldState<multi1d<LatticeColorMatrix>,
35  multi1d<LatticeColorMatrix> >& s) const = 0;
36 
37  //! Reset any chronological predictors for the integrator
38  virtual void resetPredictors(void) const = 0;
39  };
40 
41  //! MD component integrator that has a sub integrator (recursive)
42  /*! @ingroup integrator */
43  template<typename P, typename Q>
45  public:
46  //! Virtual destructor
47  virtual ~AbsRecursiveIntegrator(void) {}
48 
49  //! Do an integration of lenght n*delta tau in n steps.
51  const Real& traj_length) const = 0;
52 
53 
54  //! Return the next level down integrator
56 
57  //! Refresh fields in this level of the integrator and sub integrators.
58  virtual void refreshFields(AbsFieldState<multi1d<LatticeColorMatrix>,
59  multi1d<LatticeColorMatrix> >& s) const {
60  refreshFieldsThisLevel(s); // Do the fields in this level
61  getSubIntegrator().refreshFields(s); // Recurse down
62  }
63 
64  //! Reset Integrators in this level and sub integrators
65  virtual void resetPredictors(void) const {
66  resetPredictorsThisLevel(); // This level
67  getSubIntegrator().resetPredictors(); // Recurse down
68  }
69 
70  protected:
71  //! Refresh fields in just this level
72  virtual void refreshFieldsThisLevel(AbsFieldState<multi1d<LatticeColorMatrix>,
73  multi1d<LatticeColorMatrix> >& s) const = 0;
74 
75  virtual void resetPredictorsThisLevel(void) const = 0;
76  };
77 
78 
79  //! New MD integrator interface
80  /*! @ingroup integrator */
81  template<typename P, typename Q>
83  public:
84 
85  //! Virtual destructor
86  virtual ~AbsMDIntegrator(void) {}
87 
88  //! Do the trajectory for length trajLength
89  virtual void operator()(AbsFieldState<P,Q>&s, const Real& trajLength) const {
90  // Default behaviour - get the subintegrator and integrate
91  // the trajectory of length trajLength
92  AbsComponentIntegrator<P,Q>& theIntegrator = getIntegrator();
93 
94  // This is a toplevel thing - not embeddable so here is the
95  // place to reset any predictors
96  QDPIO::cout << "MD: Resetting Chrono Predictors at start of trajectory" << std::endl;
97  theIntegrator.resetPredictors();
98 
99  // This is recursive so no further resets in here.
100  theIntegrator(s, trajLength);
101  }
102 
103  //! Refresh fields in the sub integrators (for R-like algorithms)
104  virtual void refreshFields(AbsFieldState<P,Q>&s ) const {
105  getIntegrator().refreshFields(s); // Recursively refresh fields
106  }
107 
108  //! Get the trajectory length
109  virtual Real getTrajLength(void) const = 0;
110 
111  //! Copy equivalent fields into MD monomals before integration
112  /*! It is up to the toplevel integrator to keep track of which
113  fields it needs to copy internally so that this function doesn't
114  need its details exposed */
115  virtual void copyFields(void) const = 0;
116  private:
117 
118  //! Get the toplevel sub integrator
120 
121  };
122 
123 
124 } // End namespace Chroma
125 
126 #endif
Abstract Hamiltonian.
Primary include file for CHROMA library code.
MD integrator that can be used as a component for other integrators.
virtual void operator()(AbsFieldState< P, Q > &s, const Real &traj_length) const =0
Do an integration of length n*delta tau in n steps.
virtual ~AbsComponentIntegrator(void)
Virtual destructor.
virtual void resetPredictors(void) const =0
Reset any chronological predictors for the integrator.
virtual void refreshFields(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s) const =0
Refresh fields in this level of the integrator (for R like algorithms)
Abstract field state.
Definition: field_state.h:27
New MD integrator interface.
virtual void refreshFields(AbsFieldState< P, Q > &s) const
Refresh fields in the sub integrators (for R-like algorithms)
virtual AbsComponentIntegrator< P, Q > & getIntegrator() const =0
Get the toplevel sub integrator.
virtual void operator()(AbsFieldState< P, Q > &s, const Real &trajLength) const
Do the trajectory for length trajLength.
virtual ~AbsMDIntegrator(void)
Virtual destructor.
virtual void copyFields(void) const =0
Copy equivalent fields into MD monomals before integration.
virtual Real getTrajLength(void) const =0
Get the trajectory length.
MD component integrator that has a sub integrator (recursive)
virtual void refreshFields(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s) const
Refresh fields in this level of the integrator and sub integrators.
virtual void operator()(AbsFieldState< P, Q > &s, const Real &traj_length) const =0
Do an integration of lenght n*delta tau in n steps.
virtual ~AbsRecursiveIntegrator(void)
Virtual destructor.
virtual void refreshFieldsThisLevel(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s) const =0
Refresh fields in just this level.
virtual void resetPredictorsThisLevel(void) const =0
virtual AbsComponentIntegrator< P, Q > & getSubIntegrator() const =0
Return the next level down integrator.
virtual void resetPredictors(void) const
Reset Integrators in this level and sub integrators.
Field state.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
multi1d< LatticeFermion > s(Ncb)
Singleton instances of xml output.