CHROMA
wilson_coarse_fine_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wilson gauge action supporting 2+2 anisotropy
3  */
4 
5 #include "chromabase.h"
9 
10 namespace Chroma
11 {
12 
13  namespace WilsonCoarseFineGaugeActEnv
14  {
16  multi1d<LatticeColorMatrix> >* createGaugeAct(XMLReader& xml,
17  const std::string& path)
18  {
21  }
22 
23  const std::string name = "WILSON_COARSE_FINE_GAUGEACT";
24 
25  //! Local registration flag
26  static bool registered = false;
27 
28  //! Register all the factories
29  bool registerAll()
30  {
31  bool success = true;
32  if (! registered)
33  {
34  success &= TheGaugeActFactory::Instance().registerObject(name, createGaugeAct);
35  registered = true;
36  }
37  return success;
38  }
39  }
40 
41 
43  {
44  XMLReader paramtop(xml_in, path);
45 
46  try
47  {
48  read(paramtop, "coarse_dirs", coarse_dirs);
49  read(paramtop, "coeff_ff", coeff_ff);
50  read(paramtop, "coeff_cf", coeff_cf);
51  read(paramtop, "coeff_cc", coeff_cc);
52  }
53  catch( const std::string& e )
54  {
55  QDPIO::cerr << __func__ << ": Error reading XML: " << e << std::endl;
56  QDP_abort(1);
57  }
58  }
59 
60  void read(XMLReader& xml, const std::string& path, WilsonCoarseFineGaugeActParams& p)
61  {
63  p = tmp;
64  }
65 
66  void write(XMLWriter& xml, const std::string& path, const WilsonCoarseFineGaugeActParams& p)
67  {
68  push(xml, path);
69 
70  int version = 1;
71 
72  write(xml, "version", version);
73  write(xml, "coarse_dirs", p.coarse_dirs);
74  write(xml, "coeff_ff", p.coeff_ff);
75  write(xml, "coeff_cf", p.coeff_cf);
76  write(xml, "coeff_cc", p.coeff_cc);
77 
78  pop(xml);
79  }
80 
81 
82 
83  //! Read beta from a param struct
86  : param(p)
87  {
88  init(cgs);
89  }
90 
91 
92  // Private initializer
93  void
95  {
96  START_CODE();
97 
98  // Sanity check. Insist there are 2 coarse and 2 fine directions
99  if (param.coarse_dirs.size() != 4 || Nd != 4)
100  {
101  QDPIO::cerr << WilsonCoarseFineGaugeActEnv::name << ": coarse_dirs and Nd must be size=4" << std::endl;
102  QDP_abort(1);
103  }
104 
105  int cnt = 0;
106  for(int i=0; i < param.coarse_dirs.size(); ++i)
107  {
108  if (param.coarse_dirs[i]) ++cnt;
109  }
110 
111  if (cnt != 2)
112  {
113  QDPIO::cerr << WilsonCoarseFineGaugeActEnv::name << ": not 2 coarse dirs" << std::endl;
114  QDP_abort(1);
115  }
116 
117 
118  // Fold in normalizations
119  PlaqGaugeActParams plaq_param;
120  plaq_param.coeffs.resize(Nd,Nd);
121  plaq_param.coeffs = zero;
122 
123  for(int mu = 0; mu < Nd; ++mu)
124  {
125  for(int nu = mu+1; nu < Nd; ++nu)
126  {
127  if( (! param.coarse_dirs[mu]) && (! param.coarse_dirs[nu]) )
128  {
129  // Fine-fine Plaquette in either mu or nu direction
130  plaq_param.coeffs[mu][nu] = param.coeff_ff;
131  }
132  else if( param.coarse_dirs[mu] && param.coarse_dirs[nu] )
133  {
134  // Coarse-coarse Plaquette in either mu or nu direction
135  plaq_param.coeffs[mu][nu] = param.coeff_cc;
136  }
137  else
138  {
139  // Coarse-fine or fine-coarse Plaquette
140  plaq_param.coeffs[mu][nu] = param.coeff_cf;
141  }
142 
143  plaq_param.coeffs[nu][mu] = plaq_param.coeffs[mu][nu];
144  }
145  }
146 
147  // Create gauge action
148  plaq = new PlaqGaugeAct(cgs,plaq_param);
149 
150  END_CODE();
151  }
152 
153 }
154 
Primary include file for CHROMA library code.
Create a gauge connection state.
Definition: create_state.h:47
Abstract base class for gauge actions.
Definition: gaugeact.h:25
Class for counted reference semantics.
Definition: handle.h:33
static T & Instance()
Definition: singleton.h:432
void init(Handle< CreateGaugeState< P, Q > > cgs)
Private initializer.
WilsonCoarseFineGaugeActParams param
int mu
Definition: cool.cc:24
int nu
Definition: cool.cc:25
All gauge create-state method.
Fermion action factories.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Nd
Definition: meslate.cc:74
Handle< CreateGaugeState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the CreateGaugeState readers.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
GaugeAction< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createGaugeAct(XMLReader &xml, const std::string &path)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
START_CODE()
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
Parameter structure.
Definition: plaq_gaugeact.h:26
Wilson gauge action supporting 2+2 anisotropy.