CHROMA
stout_gaugestate.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Stout gauge state and a creator
5  */
6 
7 #ifndef __stout_gaugestate_h__
8 #define __stout_gaugestate_h__
9 
10 #include "state.h"
11 #include "create_state.h"
12 #include "handle.h"
13 
15 #include "util/gauge/stout_utils.h"
16 
17 namespace Chroma
18 {
19 
20  /*! @ingroup gaugestates */
21  namespace CreateStoutGaugeStateEnv
22  {
23  extern const std::string name;
24  bool registerAll();
25  }
26 
27 
28  //! Stout version of GaugeState
29  /*! @ingroup gaugestates
30  *
31  * Only needs to hold a gauge field and gauge bc
32  */
33  template<typename P, typename Q>
34  class StoutGaugeState : public GaugeState<P,Q>
35  {
36  public:
37  //! Full constructor
39  const StoutFermStateParams& p_,
40  const Q& q_)
41  {
42  START_CODE();
43  create(gbc_, p_, q_);
44  END_CODE();
45  }
46 
47  //! Return the gauge BC object for this state
48  const GaugeBC<P,Q>& getBC() const {return *gbc;}
49 
50  //! Destructor
51  virtual ~StoutGaugeState() {}
52 
53  //! Return the link fields needed in constructing linear operators
54  const Q& getLinks() const {
55  return smeared_links[ params.n_smear ];
56  }
57 
58  const Q& getThinLinks() const {
59  return smeared_links[0];
60  }
61 
62  /* Recurse the thick force to compute the thin force. */
63  /* I pull this out because SLIC like actions may want to do
64  this without slapping on the final list of thin U's
65  F_thin is resize internally */
66  void fatForceToThin(const P& F_fat, P& F_thin) const
67  {
68  START_CODE();
69 
70  F_thin.resize(Nd);
71  F_thin = F_fat;
72 
73  // Zero out fixed BCs
74  // gbc->zero(F_thin);
75 
76  // Now if the state is smeared recurse down.
77 
78  for(int level=params.n_smear; level > 0; level--) {
79  QDPIO::cout << "Recursing level " << level << " to level " << level -1 << std::endl;
81 
82  // gbc->zero(F_thin);
83 
84  }
85 
86  END_CODE();
87  }
88 
89  /* This recurses the force and slaps on the gauge piece at the end.
90  I am coming around to realising that the gauge stuff ought not
91  be slapped on here but maybe somewhere in the MC. Consider a SLIC
92  force. There the operator would appply the fatForceToThin to
93  the fat force and just do the normal deriv for the thin liks
94  and this thing can be pulled out into the dsdq methods.
95  For now, the default behaviour is to recurse the force down
96  here but I am planning ahead to a refactor. */
97  void deriv(P& F) const
98  {
99  START_CODE();
100 
101  QDPIO::cout << "WARNING: StoutGaugeState::deriv() is never called in current scheme of things -- the gauge monomial doesn't know about it" << std::endl;
102 
103  P F_tmp(Nd);
104 
105  // Function resizes F_tmp
106  fatForceToThin(F,F_tmp);
107 
108 
109  // Multiply in by the final U term to close off the links
110  for(int mu=0; mu < Nd; mu++) {
111  F[mu] = (smeared_links[0])[mu]*F_tmp[mu];
112  }
113 
114  END_CODE();
115  }
116 
117 
118  void create(Handle< GaugeBC<P,Q> > gbc_,
119  const StoutFermStateParams& p_,
120  const Q& u_)
121  {
122  START_CODE();
123 
124  gbc = gbc_;
125  params = p_;
126 
127  // Allocate smeared and thin links
128  smeared_links.resize(params.n_smear + 1);
129  for(int i=0; i <= params.n_smear; i++) {
130  smeared_links[i].resize(Nd);
131  }
132 
133 
134  // Copy thin links into smeared_links[0]
135  for(int mu=0; mu < Nd; mu++) {
136  (smeared_links[0])[mu] = u_[mu];
137  }
138 
139  // This is different from fermions.
140  // I apply the BC-s to the gauge fields
141  // at the bottom.
142  gbc->modify( smeared_links[0] );
143 
144  // Iterate up the smearings
145  for(int i=1; i <= params.n_smear; i++) {
147 
148  // If the gauge BC's are nontrivial
149  // apply at every level - eg SF BC's
150  if( gbc->nontrivialP() ) {
151  gbc->modify( smeared_links[i] );
152  }
153 
154  }
155 
156  END_CODE();
157  }
158 
159  private:
160  StoutGaugeState() {} // hide default constructur
161  void operator=(const StoutGaugeState&) {} // hide =
162 
163  private:
165  multi1d<Q> smeared_links;
167  };
168 
169 
170 
171  //! Create a stout gauge connection state
172  /*! @ingroup gaugestates
173  *
174  * This is a factory class for producing a connection state
175  */
176  template<typename P, typename Q>
178  {
179  public:
180  //! Full constructor
182  const StoutFermStateParams& p_) : gbc(gbc_), params(p_) {}
183 
184  //! Destructor
186 
187  //! Construct a ConnectState
189  {
190  return new StoutGaugeState<P,Q>(gbc, params, q);
191  }
192 
193  //! Return the gauge BC object for this state
194  const GaugeBC<P,Q>& getBC() const {return *gbc;}
195 
196  private:
197  CreateStoutGaugeState() {} // hide default constructur
198  void operator=(const CreateStoutGaugeState&) {} // hide =
199 
200  private:
203  };
204 
205 
206 
207 }
208 
209 
210 #endif
Create a gauge connection state.
Definition: create_state.h:47
Create a stout gauge connection state.
StoutGaugeState< P, Q > * operator()(const Q &q) const
Construct a ConnectState.
CreateStoutGaugeState(Handle< GaugeBC< P, Q > > gbc_, const StoutFermStateParams &p_)
Full constructor.
Handle< GaugeBC< P, Q > > gbc
const GaugeBC< P, Q > & getBC() const
Return the gauge BC object for this state.
void operator=(const CreateStoutGaugeState &)
Base class for all gauge action boundary conditions.
Definition: gaugebc.h:30
Support class for fermion actions and linear operators.
Definition: state.h:74
Class for counted reference semantics.
Definition: handle.h:33
Stout version of GaugeState.
const Q & getThinLinks() const
void create(Handle< GaugeBC< P, Q > > gbc_, const StoutFermStateParams &p_, const Q &u_)
StoutFermStateParams params
void deriv(P &F) const
void operator=(const StoutGaugeState &)
Handle< GaugeBC< P, Q > > gbc
const Q & getLinks() const
Return the link fields needed in constructing linear operators.
void fatForceToThin(const P &F_fat, P &F_thin) const
StoutGaugeState(Handle< GaugeBC< P, Q > > gbc_, const StoutFermStateParams &p_, const Q &q_)
Full constructor.
virtual ~StoutGaugeState()
Destructor.
const GaugeBC< P, Q > & getBC() const
Return the gauge BC object for this state.
int mu
Definition: cool.cc:24
Create a connection state.
void smear_links(const multi1d< LatticeColorMatrix > &current, multi1d< LatticeColorMatrix > &next, const multi1d< bool > &smear_in_this_dirP, const multi2d< Real > &rho)
Do the smearing from level i to level i+1.
Definition: stout_utils.cc:936
void deriv_recurse(multi1d< LatticeColorMatrix > &F, const multi1d< bool > &smear_in_this_dirP, const multi2d< Real > &rho, const multi1d< LatticeColorMatrix > &u)
Do the force recursion from level i+1, to level i.
Definition: stout_utils.cc:186
Class for counted reference semantics.
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
int i
Definition: pbg5p_w.cc:55
START_CODE()
::std::string string
Definition: gtest.h:1979
Support class for fermion actions and linear operators.
Stout utilities.
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13
static INTERNAL_PRECISION F