CHROMA
field_state.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! \file
4  * \brief Field state
5  *
6  * Abstract classes to define the states of fields
7  * This is basically a collection class...
8  *
9  * Templated to allow generic situations
10  */
11 
12 #ifndef field_state_h
13 #define field_state_h
14 
15 #include "chromabase.h"
16 
17 namespace Chroma
18 {
19  //! Abstract field state
20  /*! @ingroup molecdyn
21  *
22  * An abstract field state. The templates P and Q are the
23  * types of the coordinates and momenta
24  */
25  template <typename P, typename Q>
27  {
28  public:
29 
30  //! Virtual destructor
31  virtual ~AbsFieldState<P,Q>() {}
32 
33  //! Clone the state -- this will be needed for the virtual
34  // copy ideas for derived classes
35  virtual AbsFieldState<P,Q>* clone(void) const = 0;
36 
37  //! Accessors
38  virtual const P& getP(void) const = 0;
39  virtual const Q& getQ(void) const = 0;
40 
41  //! Mutators
42  virtual P& getP(void) = 0;
43  virtual Q& getQ(void) = 0;
44 
45  // And that is all we can do here
46  };
47 
48  /*
49  template <typename P, typename Q, typename Phi>
50  class AbsPFFieldState : public AbsFieldState<P,Q> {
51  public:
52 
53  //! Virtual destructor
54  virtual ~AbsPFFieldState<P,Q,Phi>() {}
55 
56  //! Clone the state -- this will be needed for the virtual
57  // copy ideas for derived classes
58  virtual AbsPFFieldState<P,Q,Phi>* clone(void) const = 0;
59 
60  //! Accessors
61  virtual const P& getP(void) const = 0;
62  virtual const Q& getQ(void) const = 0;
63 
64  virtual const int numPhi(void) const =0;
65  virtual const Phi& getPhi(int i) const = 0;
66 
67  //! Mutators
68  virtual P& getP(void) = 0;
69  virtual Q& getQ(void) = 0;
70  virtual Phi& getPhi(int i) = 0;
71 
72  // And that is all we can do here
73  };
74  */
75 
76  //! Pure gauge field state
77  /*! @ingroup molecdyn
78  *
79  * A pure Gauge field state type field state.
80  */
81  class GaugeFieldState : public AbsFieldState<multi1d<LatticeColorMatrix>,
82  multi1d<LatticeColorMatrix> >
83  {
84  public:
85 
86  // Constructor
87  GaugeFieldState(const multi1d<LatticeColorMatrix>& p_,
88  const multi1d<LatticeColorMatrix>& q_) {
89  p.resize(Nd);
90  q.resize(Nd);
91  for(int mu=0; mu < Nd; mu++) {
92  p[mu] = p_[mu];
93  q[mu] = q_[mu];
94  }
95  }
96 
97  // Copy Constructor
99  p.resize(Nd);
100  q.resize(Nd);
101  for(int mu=0; mu < Nd; mu++) {
102  p[mu] = s.p[mu];
103  q[mu] = s.q[mu];
104  }
105 
106  }
107 
108  // Destructor
110 
111  // Clone function -- covariant return type
112  GaugeFieldState* clone(void) const {
113  return new GaugeFieldState(*this);
114  }
115 
116  // Accessors
117  const multi1d<LatticeColorMatrix>& getP(void) const { return p; }
118  const multi1d<LatticeColorMatrix>& getQ(void) const { return q; }
119 
120  // Mutators
121  multi1d<LatticeColorMatrix>& getP(void) { return p; }
122  multi1d<LatticeColorMatrix>& getQ(void) { return q; }
123 
124  private:
125  multi1d<LatticeColorMatrix> p;
126  multi1d<LatticeColorMatrix> q;
127  };
128 
129 } // End namespace Chroma
130 
131 #endif
Primary include file for CHROMA library code.
Abstract field state.
Definition: field_state.h:27
virtual const Q & getQ(void) const =0
virtual const P & getP(void) const =0
Accessors.
virtual AbsFieldState< P, Q > * clone(void) const =0
Clone the state – this will be needed for the virtual.
virtual Q & getQ(void)=0
virtual P & getP(void)=0
Mutators.
Pure gauge field state.
Definition: field_state.h:83
GaugeFieldState(const multi1d< LatticeColorMatrix > &p_, const multi1d< LatticeColorMatrix > &q_)
Definition: field_state.h:87
GaugeFieldState(const GaugeFieldState &s)
Definition: field_state.h:98
const multi1d< LatticeColorMatrix > & getP(void) const
Accessors.
Definition: field_state.h:117
const multi1d< LatticeColorMatrix > & getQ(void) const
Definition: field_state.h:118
GaugeFieldState * clone(void) const
Clone the state – this will be needed for the virtual.
Definition: field_state.h:112
multi1d< LatticeColorMatrix > q
Definition: field_state.h:126
multi1d< LatticeColorMatrix > p
Definition: field_state.h:125
multi1d< LatticeColorMatrix > & getQ(void)
Definition: field_state.h:122
multi1d< LatticeColorMatrix > & getP(void)
Mutators.
Definition: field_state.h:121
int mu
Definition: cool.cc:24
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
multi1d< LatticeFermion > s(Ncb)
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13