CHROMA
npr_vertex_w.cc
Go to the documentation of this file.
1 // $Id: npr_vertex_w.cc,v 1.8 2008-12-21 21:22:37 edwards Exp $
2 /*! \file
3  * \brief NPR vertex calculations
4  */
5 
6 #include "util/ft/sftmom.h"
8 
9 namespace Chroma
10 {
11 
12  QDP::StandardOutputStream& operator<<(QDP::StandardOutputStream& s, const multi1d<int>& d)
13  {
14  if (d.size() > 0)
15  {
16  s << d[0];
17  for(int i=1; i < d.size(); ++i)
18  s << " " << d[i];
19  }
20 
21  return s;
22  }
23 
24 
25  void BkwdFrwd(const LatticePropagator& B,
26  const LatticePropagator& F,
27  QDPFileWriter& qio_file,
28  int& GBB_NLinkPatterns,
29  const multi1d< int > & LinkDirs)
30  {
31  StopWatch TotalTime;
32  TotalTime.reset();
33  TotalTime.start();
34 
35  for( int i = 0; i < Ns * Ns; i ++ )
36  {
37  XMLBufferWriter record_xml;
38  push(record_xml, "Vertex");
39 
40  QDPIO::cout << __func__ << ": LinkDirs = " << LinkDirs
41  << " gamma = " << i << std::endl;
42 
43  write(record_xml, "linkDirs", LinkDirs); // link pattern
44  write(record_xml, "gamma", i);
45 
46  // counts number of link patterns
47  GBB_NLinkPatterns++;
48 
49  // assumes any Gamma5 matrices have already been absorbed
50  int G5 = Ns*Ns-1;
51 
52  // Compute the single site propagator and write it
53  DPropagator prop;
54  {
55  // assumes any Gamma5 matrices have already been absorbed into B
56  LatticePropagator tmp = B * Gamma(i) * F;
57  // The site's worth of data of interest
58  prop = sum(tmp)/Double(Layout::vol()); // and normalize by the volume
59  //QDPIO::cout<<" The 1/12*trace is: "<<trace(Gamma(i)*prop)/12.0;
60  //QDPIO::cout<<std::endl ;
61  }
62 
63  pop(record_xml);
64 
65  write(qio_file, record_xml, prop);
66  }
67 
68  TotalTime.stop();
69  QDPIO::cout << __func__ << ": total time = " << TotalTime.getTimeInSeconds() << " seconds" << std::endl;
70 
71  return;
72  }
73 
74 //###################################################################################//
75 // accumulate link operators //
76 //###################################################################################//
77 
78  void AddLinks(const LatticePropagator& B,
79  const LatticePropagator& F,
80  const multi1d< LatticeColorMatrix > & U,
81  multi1d< int >& LinkDirs,
82  const int MaxNLinks,
83  BBLinkPattern LinkPattern,
84  const int PreviousDir,
85  const int PreviousMu,
86  QDPFileWriter& qio_file,
87  int& GBB_NLinkPatterns)
88  {
89  StopWatch Timer;
90  Timer.reset();
91  Timer.start();
92 
93  const int NLinks = LinkDirs.size();
94 
95  if( NLinks == MaxNLinks )
96  {
97  return;
98  }
99 
100  LatticePropagator F_mu;
101  multi1d< int > NextLinkDirs( NLinks + 1 );
102 
103  for(int Link = 0; Link < NLinks; Link ++)
104  {
105  NextLinkDirs[ Link ] = LinkDirs[ Link ];
106  }
107 
108  // add link in forward mu direction
109  for( int mu = 0; mu < Nd; mu ++ )
110  {
111  // skip the double back
112  if( ( PreviousDir != -1 ) || ( PreviousMu != mu ) )
113  {
114  bool DoThisPattern = true;
115  bool DoFurtherPatterns = true;
116 
117  NextLinkDirs[ NLinks ] = mu;
118 
119  LinkPattern( DoThisPattern, DoFurtherPatterns, NextLinkDirs );
120 
121  if( DoFurtherPatterns == true )
122  {
123  // accumulate product of link fields
124  F_mu = shift( adj( U[ mu ] ) * F, BACKWARD, mu );
125  }
126 
127  if( DoThisPattern == true )
128  {
129  BkwdFrwd(B, F_mu, qio_file, GBB_NLinkPatterns, NextLinkDirs);
130  }
131 
132  if( DoFurtherPatterns == true )
133  {
134  // add another link
135  AddLinks(B, F_mu, U,
136  NextLinkDirs, MaxNLinks, LinkPattern, 1, mu,
137  qio_file, GBB_NLinkPatterns);
138  }
139  }
140  }
141 
142  // add link in backward mu direction
143  for( int mu = 0; mu < Nd; mu ++ )
144  {
145  // skip the double back
146  if( ( PreviousDir != 1 ) || ( PreviousMu != mu ) )
147  {
148  bool DoThisPattern = true;
149  bool DoFurtherPatterns = true;
150 
151  NextLinkDirs[ NLinks ] = mu + Nd;
152 
153  LinkPattern( DoThisPattern, DoFurtherPatterns, NextLinkDirs );
154 
155  if( DoFurtherPatterns == true )
156  {
157  // accumulate product of link fields
158  F_mu = U[ mu ] * shift( F, FORWARD, mu );
159  }
160 
161  if( DoThisPattern == true )
162  {
163  BkwdFrwd(B, F_mu, qio_file, GBB_NLinkPatterns, NextLinkDirs);
164  }
165 
166  if( DoFurtherPatterns == true )
167  {
168  // add another link
169  AddLinks(B, F_mu, U,
170  NextLinkDirs, MaxNLinks, LinkPattern, -1, mu,
171  qio_file, GBB_NLinkPatterns);
172  }
173  }
174  }
175 
176  Timer.stop();
177  QDPIO::cout << __func__ << ": total time = " << Timer.getTimeInSeconds() << " seconds" << std::endl;
178 
179  return;
180  }
181 
182 
183  //! NPR vertices
184  void NprVertex(const LatticePropagator & F,
185  const multi1d< LatticeColorMatrix > & U,
186  const unsigned short int MaxNLinks,
187  const BBLinkPattern LinkPattern,
188  QDPFileWriter& qio_file)
189  {
190  StopWatch TotalTime;
191  TotalTime.reset();
192  TotalTime.start();
193 
194  StopWatch Timer;
195 
196  int GBB_NLinkPatterns;
197 
198  //#################################################################################//
199  // open building blocks data files //
200  //#################################################################################//
201 
202  Timer.reset();
203  Timer.start();
204 
205  //#################################################################################//
206  // calculate building blocks //
207  //#################################################################################//
208 
209  QDPIO::cout << __func__ << ": start BkwdFrwd" << std::endl;
210 
211  const int NLinks = 0;
212  multi1d< int > LinkDirs( 0 );
213 
214  LatticePropagator B = Gamma(15)*adj(F)*Gamma(15);
215  BkwdFrwd(B, F, qio_file, GBB_NLinkPatterns, LinkDirs);
216 
217 
218  Timer.stop();
219  QDPIO::cout << __func__ << ": total time for 0 links (single BkwdFrwdTr call) = "
220  << Timer.getTimeInSeconds()
221  << " seconds" << std::endl;
222 
223  Timer.reset();
224  Timer.start();
225 
226  QDPIO::cout << __func__ << ": start AddLinks" << std::endl;
227 
228  AddLinks(B, F, U,
229  LinkDirs, MaxNLinks, LinkPattern, 0, -1,
230  qio_file, GBB_NLinkPatterns);
231 
232  Timer.stop();
233  QDPIO::cout << __func__ << ": total time for remaining links (outermost AddLinks call) = "
234  << Timer.getTimeInSeconds()
235  << " seconds" << std::endl;
236 
237  TotalTime.stop();
238  QDPIO::cout << __func__ << ": total time = "
239  << TotalTime.getTimeInSeconds()
240  << " seconds" << std::endl;
241 
242  return;
243  }
244 
245 } // end namespace Chroma
int mu
Definition: cool.cc:24
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void(* BBLinkPattern)(bool &DoThisPattern, bool &DoFurtherPatterns, multi1d< unsigned short int > &LinkPattern)
Used to Set Requested Link Patterns.
void NprVertex(const LatticePropagator &F, const multi1d< LatticeColorMatrix > &U, const unsigned short int MaxNLinks, const BBLinkPattern LinkPattern, QDPFileWriter &qio_file)
NPR vertices.
std::map< std::string, SinkPropContainer_t > prop
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP::StandardOutputStream & operator<<(QDP::StandardOutputStream &s, const multi1d< int > &d)
Definition: npr_vertex_w.cc:12
int G5
Definition: pbg5p_w.cc:57
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
DComplex d
Definition: invbicg.cc:99
void AddLinks(const multi1d< LatticePropagator > &B, const LatticePropagator &F, const multi1d< LatticeColorMatrix > &U, const multi1d< int > &GammaInsertions, const SftMom &Phases, const SftMom &PhasesCanonical, multi1d< unsigned short int > &LinkDirs, const unsigned short int MaxNLinks, BBLinkPattern LinkPattern, const short int PreviousDir, const short int PreviousMu, multi2d< BinaryFileWriter > &BinaryWriters, multi1d< int > &GBB_NLinkPatterns, multi2d< int > &GBB_NMomPerms, const signed short int T1, const signed short int T2, const signed short int Tsrc, const signed short int Tsnk, const bool TimeReverse, const bool ShiftFlag)
void BkwdFrwd(const LatticePropagator &B, const LatticePropagator &F, QDPFileWriter &qio_file, int &GBB_NLinkPatterns, const multi1d< int > &LinkDirs)
Definition: npr_vertex_w.cc:25
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
NPR vertex calculations.
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37
Fourier transform phase factor support.
multi1d< LatticeColorMatrix > U
static INTERNAL_PRECISION F