CHROMA
stout_fermstate_w.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Stout field state for stout links and a creator
5  *
6  * Holds gauge fields at various smearing levels and caches some
7  * auxiliary things
8  */
9 
10 #ifndef _stout_fermstate_h
11 #define _stout_fermstate_h
12 
13 #include "state.h"
14 #include "create_state.h"
16 #include "util/gauge/stout_utils.h"
17 
18 namespace Chroma
19 {
20  /*! @ingroup fermstates */
21  namespace CreateStoutFermStateEnv
22  {
23  extern const std::string name;
24  bool registerAll();
25  }
26 
27 
28  //! Stout field state
29  /*! @ingroup fermstates
30  *
31  * Holds a stout smeared state
32  */
33  template< typename T, typename P, typename Q>
34  class StoutFermState : public FermState<T,P,Q>
35  {
36  public:
37  // Typedefs to save typing
38  //! Constructor only from a parameter structure
39  // Constructor only from a parameter structure
41  const StoutFermStateParams& p_,
42  const Q& u_)
43  {
44  START_CODE();
45  create(fbc_, p_, u_);
46  END_CODE();
47  }
48 
49  //! Return the ferm BC object for this state
50  const FermBC<T,P,Q>& getBC() const {return *fbc;}
51 
52  //! Return the ferm BC object for this state
53  Handle< FermBC<T,P,Q> > getFermBC() const {return fbc;}
54 
55  //! Destructor is automagic
56  virtual ~StoutFermState() {}
57 
58  //! Return FAT Linke
59  const Q& getLinks() const
60  {
61  // This has BC-s applied already in the construction
62  return fat_links_with_bc;
63  }
64 
65  const Q& getThinLinks() const
66  {
67  return smeared_links[0];
68  }
69 
70  /* Recurse the thick force to compute the thin force. */
71  /* I pull this out because SLIC like actions may want to do
72  this without slapping on the final list of thin U's
73  F_thin is resize internally */
74  void fatForceToThin(const P& F_fat, P& F_thin) const
75  {
76  START_CODE();
77 
78  F_thin.resize(Nd);
79  F_thin = F_fat;
80 
81  // Undo antiperiodic BC-s / force fixed BCs - this should really be unmodify
82  // but essentially it works OK for everything except maybe twisted bc-s
83  fbc->modify(F_thin);
84 
85  // Zero out fixed BCs
86  fbc->zero(F_thin);
87 
88  // Now if the state is smeared recurse down.
89 
90  for(int level=params.n_smear; level > 0; level--) {
91 
93 
94  fbc->zero(F_thin);
95 
96  }
97 
98  END_CODE();
99  }
100 
101 
102  /* This recurses the force and slaps on the gauge piece at the end.
103  I am coming around to realising that the gauge stuff ought not
104  be slapped on here but maybe somewhere in the MC. Consider a SLIC
105  force. There the operator would appply the fatForceToThin to
106  the fat force and just do the normal deriv for the thin liks
107  and this thing can be pulled out into the dsdq methods.
108  For now, the default behaviour is to recurse the force down
109  here but I am planning ahead to a refactor. */
110  virtual void deriv(P& F) const
111  {
112  START_CODE();
113 
114  P F_tmp(Nd);
115 
116 
117  // Function resizes F_tmp
118  fatForceToThin(F,F_tmp);
119 
120 
121  // Multiply in by the final U term to close off the links
122  for(int mu=0; mu < Nd; mu++) {
123  F[mu] = (smeared_links[0])[mu]*F_tmp[mu];
124  }
125 
126  END_CODE();
127  }
128 
129 
130  private:
131 
132  // Hide default constructor
134 
135 
136  // create function
138  const StoutFermStateParams& p_,
139  const Q& u_)
140  {
141  START_CODE();
142 
143  fbc = fbc_;
144  params = p_;
145 
146  // Allocate smeared and thin links
147  smeared_links.resize(params.n_smear + 1);
148  for(int i=0; i <= params.n_smear; i++) {
149  smeared_links[i].resize(Nd);
150  }
151 
152 
153  // Copy thin links into smeared_links[0]
154  for(int mu=0; mu < Nd; mu++) {
155  (smeared_links[0])[mu] = u_[mu];
156  }
157 
158  if( fbc->nontrivialP() ) {
159  fbc->modify( smeared_links[0] );
160  }
161 
162  // Iterate up the smearings
163  for(int i=1; i <= params.n_smear; i++) {
164 
166  if( fbc->nontrivialP() ) {
167  fbc->modify( smeared_links[i] );
168  }
169 
170  }
171 
172  // ANTIPERIODIC BCs only -- modify only top level smeared thing
173  fat_links_with_bc.resize(Nd);
175  fbc->modify(fat_links_with_bc);
176 
177 
178  END_CODE();
179  }
180 
181 
182  private:
184 
185  // smeared_links[0] are the thin links smeared_links[params.n_smear]
186  // are the smeared links.
187  multi1d< Q > smeared_links;
189 
190 
192  }; // End class
193 
194 
195  //! Create a stout ferm connection state
196  /*! @ingroup fermstates
197  *
198  * This is a factory class for producing a connection state
199  */
200  template<typename T, typename P, typename Q >
201  class CreateStoutFermState : public CreateFermState<T, P, Q>
202  {
203  public:
204  // Typedefs to save typing
205 
206  //! Full constructor
208  const StoutFermStateParams& p_) :
209  fbc(fbc_), params(p_) {}
210 
211  //! Destructor
213 
214  //! Construct a ConnectState
216  {
217  return new StoutFermState<T,P,Q>(fbc, params, q);
218  }
219 
220  //! Return the ferm BC object for this state
221  const FermBC<T,P,Q>& getBC() const {return *fbc;}
222 
223  //! Return the ferm BC object for this state
224  Handle< FermBC<T,P,Q> > getFermBC() const {return fbc;}
225 
226  private:
227  CreateStoutFermState() {} // hide default constructur
228  void operator=(const CreateStoutFermState&) {} // hide =
229 
230  private:
233  };
234 
235 
236  /* SLIC Fermions */
237 
238  /*! @ingroup fermstates */
239  namespace CreateSLICFermStateEnv
240  {
241  extern const std::string name;
242  bool registerAll();
243  }
244 
245  //! SLIC (Stout Link Irrelevant Clover ferm connection state
246  /*! @ingroup fermstates
247  *
248  * This ferm state is for use in SLIC Fermions ONLY (or their ilk)
249  * It inherits directly from stout ferm state and overrides the
250  * deriv function. In the SLIC case it is the duty of the linop
251  * to thin the fat links, so here the deriv() only multiplies by
252  * the thin links. CAVEAT: The way stout links currently work
253  * The fermion force for the stout part must remove the fermionic
254  * boundaries - as the thin links don't have these applied. THe
255  * thin links do have gauge boundaries (a la schroedinger) applied
256  *
257  * - NB This state inherits data from its super. This is not necessarily
258  * a good thing. However we don't have private data of our own that is
259  * not in the superclass and I only access this read only in deriv()
260  * using a public function.
261  */
262  template< typename T, typename P, typename Q >
263  class SLICFermState : public StoutFermState<T,P,Q> {
264  public:
265  // Initialise the super
267  const StoutFermStateParams& p_,
268  const Q& u_) : StoutFermState<T,P,Q>(fbc_,p_, u_) {
269  }
270 
272 
273  void deriv(P& F) const {
274  P F_tmp = F;
275  Q thin_links = StoutFermState<T,P,Q>::getThinLinks();
276  // StoutFermState<T,P,Q>::getBC().modify(thin_links);
277 
278  // Multiply in by the final U term to close off the links
279  for(int mu=0; mu < Nd; mu++) {
280  F[mu] = thin_links[mu]*F_tmp[mu];
281  }
282  }
283  private:
284  };
285 
286  //! Create a SLIC ferm connection state
287  /*! @ingroup fermstates
288  *
289  * This is a factory class for producing a connection state
290  */
291  template<typename T, typename P, typename Q>
292  class CreateSLICFermState : public CreateFermState<T, P, Q>
293  {
294  public:
295 
296  //! Full constructor
298  const StoutFermStateParams& p_) :
299  fbc(fbc_), params(p_) {}
300 
301  //! Destructor
303 
304  //! Construct a ConnectState
306  {
307  return new SLICFermState<T,P,Q>(fbc, params, q);
308  }
309 
310  //! Return the ferm BC object for this state
311  const FermBC<T,P,Q>& getBC() const {return *fbc;}
312 
313  //! Return the ferm BC object for this state
314  Handle< FermBC<T,P,Q> > getFermBC() const {return fbc;}
315 
316  private:
317  CreateSLICFermState() {} // hide default constructur
318  void operator=(const CreateSLICFermState&) {} // hide =
319 
320  private:
323  };
324 
325 } // end namespace
326 
327 #endif
Create a fermion connection state.
Definition: create_state.h:69
Create a SLIC ferm connection state.
const FermBC< T, P, Q > & getBC() const
Return the ferm BC object for this state.
CreateSLICFermState(Handle< FermBC< T, P, Q > > fbc_, const StoutFermStateParams &p_)
Full constructor.
void operator=(const CreateSLICFermState &)
StoutFermStateParams params
Handle< FermBC< T, P, Q > > getFermBC() const
Return the ferm BC object for this state.
StoutFermState< T, P, Q > * operator()(const Q &q) const
Construct a ConnectState.
Handle< FermBC< T, P, Q > > fbc
Create a stout ferm connection state.
void operator=(const CreateStoutFermState &)
CreateStoutFermState(Handle< FermBC< T, P, Q > > fbc_, const StoutFermStateParams &p_)
Full constructor.
StoutFermState< T, P, Q > * operator()(const Q &q) const
Construct a ConnectState.
const FermBC< T, P, Q > & getBC() const
Return the ferm BC object for this state.
Handle< FermBC< T, P, Q > > fbc
Handle< FermBC< T, P, Q > > getFermBC() const
Return the ferm BC object for this state.
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
SLIC (Stout Link Irrelevant Clover ferm connection state.
SLICFermState(Handle< FermBC< T, P, Q > > fbc_, const StoutFermStateParams &p_, const Q &u_)
void deriv(P &F) const
Stout field state.
StoutFermState(Handle< FermBC< T, P, Q > > fbc_, const StoutFermStateParams &p_, const Q &u_)
Constructor only from a parameter structure.
const Q & getThinLinks() const
virtual void deriv(P &F) const
const FermBC< T, P, Q > & getBC() const
Return the ferm BC object for this state.
StoutFermStateParams params
Handle< FermBC< T, P, Q > > fbc
const Q & getLinks() const
Return FAT Linke.
void create(Handle< FermBC< T, P, Q > > fbc_, const StoutFermStateParams &p_, const Q &u_)
Handle< FermBC< T, P, Q > > getFermBC() const
Return the ferm BC object for this state.
void fatForceToThin(const P &F_fat, P &F_thin) const
virtual ~StoutFermState()
Destructor is automagic.
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
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
LinOpSysSolverMGProtoClover::T T
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