CHROMA
inline_building_blocks_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline construction of BuildingBlocks
3  *
4  * Building Blocks on forward and sequential props
5  */
6 
9 #include "meas/glue/mesplq.h"
10 #include "util/ft/sftmom.h"
12 #include "util/info/proginfo.h"
14 
16 
19 
20 namespace Chroma
21 {
22  namespace InlineBuildingBlocksEnv
23  {
24  namespace
25  {
26  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
27  const std::string& path)
28  {
29  return new InlineBuildingBlocks(InlineBuildingBlocksParams(xml_in, path));
30  }
31 
32  //! Local registration flag
33  bool registered = false;
34  }
35 
36  const std::string name = "BUILDING_BLOCKS";
37 
38  //! Register all the factories
39  bool registerAll()
40  {
41  bool success = true;
42  if (! registered)
43  {
45  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
46  registered = true;
47  }
48  return success;
49  }
50  }
51 
52 
53  //! Param input
54  void read(XMLReader& xml, const std::string& path, InlineBuildingBlocksParams::Param_t& input)
55  {
56  XMLReader paramtop(xml, path);
57 
58  int version;
59  read(paramtop, "version", version);
60  input.use_sink_offset = false;
61  input.canonical = false;
62  input.time_reverse = false;
63  input.translate = false;
64 
66 
67  switch (version)
68  {
69  case 1:
70  break;
71 
72  case 2:
73  read(paramtop, "use_sink_offset", input.use_sink_offset);
74  break;
75 
76  case 3:
77  read(paramtop, "use_sink_offset", input.use_sink_offset);
78  read(paramtop, "canonical", input.canonical);
79  break;
80 
81  case 4:
82  read(paramtop, "use_sink_offset", input.use_sink_offset);
83  read(paramtop, "canonical", input.canonical);
84 
85  if (paramtop.count("FermState") != 0)
86  input.cfs = readXMLGroup(paramtop, "FermState", "Name");
87  break;
88 
89  case 5:
90  read(paramtop, "use_sink_offset", input.use_sink_offset);
91  read(paramtop, "canonical", input.canonical);
92  read(paramtop, "time_reverse", input.time_reverse);
93  read(paramtop, "translate", input.translate);
94 
95  if (paramtop.count("FermState") != 0)
96  input.cfs = readXMLGroup(paramtop, "FermState", "Name");
97  break;
98 
99  default :
100  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": input parameter version "
101  << version << " unsupported." << std::endl;
102  QDP_abort(1);
103  }
104 
105  read(paramtop, "links_max", input.links_max);
106  read(paramtop, "mom2_max", input.mom2_max);
107  }
108 
109 
110  //! Param write
111  void write(XMLWriter& xml, const std::string& path, const InlineBuildingBlocksParams::Param_t& input)
112  {
113  push(xml, path);
114 
115  int version = 5;
116  write(xml, "version", version);
117  write(xml, "links_max", input.links_max);
118  write(xml, "mom2_max", input.mom2_max);
119  write(xml, "canonical", input.canonical);
120  write(xml, "time_reverse", input.time_reverse);
121  write(xml, "translate", input.translate);
122  xml << input.cfs.xml;
123 
124  pop(xml);
125  }
126 
127  //! Propagator input
128  void read(XMLReader& xml, const std::string& path, InlineBuildingBlocksParams::NamedObject_t& input)
129  {
130  XMLReader inputtop(xml, path);
131 
132  read(inputtop, "BkwdPropId", input.BkwdPropId);
133  read(inputtop, "BkwdPropG5Format", input.BkwdPropG5Format);
134  read(inputtop, "GammaInsertion", input.GammaInsertion);
135  read(inputtop, "Flavor", input.Flavor);
136  read(inputtop, "BBFileNamePattern", input.BBFileNamePattern);
137  }
138 
139  //! Propagator output
140  void write(XMLWriter& xml, const std::string& path, const InlineBuildingBlocksParams::NamedObject_t& input)
141  {
142  push(xml, path);
143 
144  write(xml, "BkwdPropId", input.BkwdPropId);
145  write(xml, "BkwdPropG5Format", input.BkwdPropG5Format);
146  write(xml, "GammaInsertion", input.GammaInsertion);
147  write(xml, "Flavor", input.Flavor);
148  write(xml, "BBFileNamePattern", input.BBFileNamePattern);
149 
150  pop(xml);
151  }
152 
153  //! BB parameters
154  void read(XMLReader& xml, const std::string& path, InlineBuildingBlocksParams::BB_out_t& input)
155  {
156  XMLReader inputtop(xml, path);
157 
158  read(inputtop, "OutFileName", input.OutFileName);
159  read(inputtop, "GaugeId", input.GaugeId);
160  read(inputtop, "FrwdPropId", input.FrwdPropId);
161  read(inputtop, "BkwdProps", input.BkwdProps);
162  }
163 
164  //! BB parameters
165  void write(XMLWriter& xml, const std::string& path, const InlineBuildingBlocksParams::BB_out_t& input)
166  {
167  push(xml, path);
168 
169  write(xml, "OutFileName", input.OutFileName);
170  write(xml, "GaugeId", input.GaugeId);
171  write(xml, "FrwdPropId", input.FrwdPropId);
172  write(xml, "BkwdProps", input.BkwdProps);
173 
174  pop(xml);
175  }
176 
177 
178  // Param stuff
180 
182  {
183  try
184  {
185  XMLReader paramtop(xml_in, path);
186 
187  if (paramtop.count("Frequency") == 1)
188  read(paramtop, "Frequency", frequency);
189  else
190  frequency = 1;
191 
192  // Read program parameters
193  read(paramtop, "Param", param);
194 
195  // Read in the building block setup
196  read(paramtop, "BuildingBlocks", bb);
197 
198  // Possible alternate XML file pattern
199  if (paramtop.count("xml_file") != 0)
200  {
201  read(paramtop, "xml_file", xml_file);
202  }
203  }
204  catch(const std::string& e)
205  {
206  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
207  QDP_abort(1);
208  }
209  }
210 
211 
212  void
213  InlineBuildingBlocksParams::write(XMLWriter& xml_out, const std::string& path)
214  {
215  push(xml_out, path);
216 
217  Chroma::write(xml_out, "Param", param);
218  Chroma::write(xml_out, "BuildingBlocks", bb);
219  QDP::write(xml_out, "xml_file", xml_file);
220 
221  pop(xml_out);
222  }
223 
224 
225  //###################################################################################//
226  // Accept All Link Patterns //
227  //###################################################################################//
228 
229  void AllLinkPatterns( bool & DoThisPattern,
230  bool & DoFurtherPatterns,
231  multi1d< unsigned short int > & LinkPattern )
232  {
233  DoThisPattern = true;
234  DoFurtherPatterns = true;
235 
236  return;
237  }
238 
239 
240  // Function call
241  void
242  InlineBuildingBlocks::operator()(unsigned long update_no,
243  XMLWriter& xml_out)
244  {
245  // If xml file not empty, then use alternate
246  if (params.xml_file != "")
247  {
248  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
249 
250  push(xml_out, "ExampleBuildingBlocks");
251  write(xml_out, "update_no", update_no);
252  write(xml_out, "xml_file", xml_file);
253  pop(xml_out);
254 
255  XMLFileWriter xml(xml_file);
256  func(update_no, xml);
257  }
258  else
259  {
260  func(update_no, xml_out);
261  }
262  }
263 
264 
265  // Function call
266  void
267  InlineBuildingBlocks::func(unsigned long update_no,
268  XMLWriter& XmlOut)
269  {
270  START_CODE();
271 
272  StopWatch snoop;
273  snoop.reset();
274  snoop.start();
275 
276  push(XmlOut, "ExampleBuildingBlocks");
277  write(XmlOut, "update_no", update_no);
278 
279  QDPIO::cout << " ExampleBuildingBlocks" << std::endl;
280  QDPIO::cout << " volume: " << QDP::Layout::lattSize()[0];
281  for (int i=1; i<Nd; ++i) {
282  QDPIO::cout << " x " << QDP::Layout::lattSize()[i];
283  }
284  QDPIO::cout << std::endl;
285 
286  //#################################################################################//
287  // Echo Arguments //
288  //#################################################################################//
289 
290  // will capture all would-be standard output
291  TextFileWriter Out( params.bb.OutFileName );
292 
293  Out << "\n";
294  Out << " NX = " << QDP::Layout::lattSize()[0] << "\n";
295  Out << " NY = " << QDP::Layout::lattSize()[1] << "\n";
296  Out << " NZ = " << QDP::Layout::lattSize()[2] << "\n";
297  Out << " NT = " << QDP::Layout::lattSize()[3] << "\n";
298  Out << " Forward Propagator = " << params.bb.FrwdPropId << "\n";
299  Out << "\n";
300  for(int loop=0; loop < params.bb.BkwdProps.size(); ++loop)
301  {
303  Out << " Backward Propagator = " << prop.BkwdPropId << "\n";
304  Out << " Backward Propagator Gamma5 Format = " << prop.BkwdPropG5Format << "\n";
305  Out << " Gamma Insertion = " << prop.GammaInsertion << "\n";
306  Out << " Flavor = " << prop.Flavor << "\n";
307  Out << " Building Blocks = " << prop.BBFileNamePattern << "\n";
308  Out << "\n";
309  }
310 
311  Out << " Maximum Number of Links = " << params.param.links_max << "\n";
312  Out << " Maximum Spatial Momentum Squared = " << params.param.mom2_max << "\n";
313  Out << " Filename Canonicalization = " << params.param.canonical << "\n";
314  Out << " Time reverse building blocks = " << params.param.time_reverse << "\n";
315  Out << " Translate building blocks = " << params.param.translate << "\n";
316 
317  Out << " Text Output File Name = " << params.bb.OutFileName << "\n";
318  Out << "\n";
319  Out.flush();
320 
321  //#################################################################################//
322  // Record the CVS Info for BuildingBlocks //
323  //#################################################################################//
324 
325  CVSBuildingBlocks( Out );
326  Out << "CVSBuildingBlocks_hh = " << CVSBuildingBlocks_hh << "\n";
327  Out << "\n";
328 
329  //#################################################################################//
330  // XML output
331  //#################################################################################//
332 
333  proginfo(XmlOut); // Print out basic program info
334 
335  push(XmlOut, "Output_version");
336  write(XmlOut, "out_version", 2);
337  pop(XmlOut);
338 
339  //###############################################################################//
340  // Read Gauge Field //
341  //###############################################################################//
342 
343  Out << "Attempt to initialize the gauge field" << "\n"; Out.flush();
344 
345  // Grab the gauge field
346  multi1d<LatticeColorMatrix> U;
347  XMLBufferWriter gauge_xml;
348 
349  try
350  {
351  U = TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.bb.GaugeId);
352  TheNamedObjMap::Instance().get(params.bb.GaugeId).getRecordXML(gauge_xml);
353 
354  // Set the construct state and modify the fields
355  {
356 QDPIO::cout << "cfs=XX" << params.param.cfs.xml << "XX" << std::endl;
357  std::istringstream xml_s(params.param.cfs.xml);
358  XMLReader fermtop(xml_s);
359 
362  fermtop,
363  params.param.cfs.path));
364 
365  Handle<FermState< LatticeFermion, multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
366  state((*cfs)(U));
367 
368  // Pull the u fields back out from the state since they might have been
369  // munged with fermBC's
370  U = state->getLinks();
371  }
372 
373  }
374  catch( std::bad_cast )
375  {
376  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": caught dynamic cast error"
377  << std::endl;
378  QDP_abort(1);
379  }
380  catch (const std::string& e)
381  {
382  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": std::map call failed: " << e
383  << std::endl;
384  QDP_abort(1);
385  }
386  catch( ... )
387  {
388  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": caught generic exception "
389  << std::endl;
390  QDP_abort(1);
391  }
392 
393  // Write out the input
394  params.write(XmlOut, "Input");
395 
396  // Write out the config info
397  write(XmlOut, "Config_info", gauge_xml);
398 
399  // check that the gauge field seems normal
400  Double ave_plaq, ave_spacelike_plaq, ave_timelike_plaq, ave_link_trace;
401  MesPlq( U, ave_plaq, ave_spacelike_plaq, ave_timelike_plaq, ave_link_trace );
402  Out << "basic gauge field observables" << "\n";
403  Out << "average plaquette = " << ave_plaq << "\n";
404  Out << "average space-like plaquette = " << ave_spacelike_plaq << "\n";
405  Out << "average time-like plaquette = " << ave_timelike_plaq << "\n";
406  Out << "average link trace = " << ave_link_trace << "\n";
407 
408  push(XmlOut, "Observables");
409  write(XmlOut, "ave_plaq", ave_plaq);
410  write(XmlOut, "ave_spacelike_plaq", ave_spacelike_plaq);
411  write(XmlOut, "ave_timelike_plaq", ave_timelike_plaq);
412  write(XmlOut, "ave_link_trace", ave_link_trace);
413  pop(XmlOut);
414 
415  //#################################################################################//
416  // Read Forward Propagator //
417  //#################################################################################//
418 
419  SftMom phases_nomom( 0, true, Nd-1 ); // used to check props. Fix to Nd-1 direction.
420 
421  LatticePropagator F;
423  PropSourceConst_t source_header;
424  QDPIO::cout << "Attempt to parse forward propagator" << std::endl;
425  Out << "parsing forward propagator " << params.bb.FrwdPropId << " ... " << "\n"; Out.flush();
426 
427  try
428  {
429  // Snarf a copy
430  F = TheNamedObjMap::Instance().getData<LatticePropagator>(params.bb.FrwdPropId);
431 
432  // Snarf the frwd prop info. This is will throw if the frwd prop id is not there
433  XMLReader FrwdPropXML, FrwdPropRecordXML;
434  TheNamedObjMap::Instance().get(params.bb.FrwdPropId).getFileXML(FrwdPropXML);
435  TheNamedObjMap::Instance().get(params.bb.FrwdPropId).getRecordXML(FrwdPropRecordXML);
436 
437  // Try to invert this record XML into a ChromaProp struct
438  {
439  read(FrwdPropRecordXML, "/Propagator/ForwardProp", prop_header);
440  read(FrwdPropRecordXML, "/Propagator/PropSource", source_header);
441  }
442 
443  // Sanity check - write out the norm2 of the forward prop in the j_decay direction
444  // Use this for any possible verification
445  {
446  multi1d<Double> FrwdPropCheck =
447  sumMulti( localNorm2( F ), phases_nomom.getSet() );
448 
449  Out << "forward propagator check = " << FrwdPropCheck[0] << "\n"; Out.flush();
450 
451  // Write out the forward propagator header
452  push(XmlOut, "ForwardProp");
453  write(XmlOut, "FrwdPropId", params.bb.FrwdPropId);
454  write(XmlOut, "FrwdPropXML", FrwdPropXML);
455  write(XmlOut, "FrwdPropRecordXML", FrwdPropRecordXML);
456  write(XmlOut, "FrwdPropCheck", FrwdPropCheck);
457  pop(XmlOut);
458  }
459  }
460  catch( std::bad_cast )
461  {
462  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": caught dynamic cast error"
463  << std::endl;
464  QDP_abort(1);
465  }
466  catch (const std::string& e)
467  {
468  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": forward prop: error message: " << e
469  << std::endl;
470  QDP_abort(1);
471  }
472 
473  QDPIO::cout << "Forward propagator successfully parsed" << std::endl;
474  Out << "finished parsing forward propagator " << params.bb.FrwdPropId << "\n"; Out.flush();
475 
476 
477  // Derived from input prop
478  int j_decay = source_header.j_decay;
479  multi1d<int> t_srce = source_header.getTSrce() ;
480 
481  //#################################################################################//
482  // Read Backward (or Sequential) Propagators //
483  //#################################################################################//
484 
485  StopWatch swatch;
486  const int NF = params.bb.BkwdProps.size();
487 
488  push(XmlOut, "SequentialSource");
489 
490  for(int loop = 0; loop < NF; ++loop)
491  {
492  push(XmlOut, "elem");
493  write(XmlOut, "loop_ctr", loop);
494 
495  Out << "Loop = " << loop << "\n"; Out.flush();
496  QDPIO::cout << "Loop = " << loop << std::endl;
497 
498  multi1d< LatticePropagator > B( 1 );
499  SeqSource_t seqsource_header;
500  QDPIO::cout << "Attempt to parse backward propagator" << std::endl;
501  Out << "parsing backward u propagator " << params.bb.BkwdProps[loop].BkwdPropId << " ... " << "\n"; Out.flush();
502  try
503  {
504  // Extract the backward prop
505  B[0] = TheNamedObjMap::Instance().getData<LatticePropagator>(params.bb.BkwdProps[loop].BkwdPropId);
506 
507  // Snarf the bkwd prop info. This is will throw if the bkwd prop id is not there
508  XMLReader BkwdPropXML, BkwdPropRecordXML;
509  TheNamedObjMap::Instance().get(params.bb.BkwdProps[loop].BkwdPropId).getFileXML(BkwdPropXML);
510  TheNamedObjMap::Instance().get(params.bb.BkwdProps[loop].BkwdPropId).getRecordXML(BkwdPropRecordXML);
511 
512  // Try to invert this record XML into a ChromaProp struct
513  // Also pull out the id of this source
514  // NEED SECURITY HERE - need a way to cross check props. Use the ID.
515  {
516  read(BkwdPropRecordXML, "/SequentialProp/SeqSource", seqsource_header);
517  }
518 
519  // Sanity check - write out the norm2 of the forward prop in the j_decay direction
520  // Use this for any possible verification
521  {
522  multi1d<Double> BkwdPropCheck = sumMulti( localNorm2( B[0] ), phases_nomom.getSet() );
523 
524  Out << "backward u propagator check = " << BkwdPropCheck[0] << "\n"; Out.flush();
525 
526  // Write out the forward propagator header
527  push(XmlOut, "BackwardProp");
528  write(XmlOut, "BkwdPropId", params.bb.BkwdProps[loop].BkwdPropId);
529  write(XmlOut, "BkwdPropG5Format", params.bb.BkwdProps[loop].BkwdPropG5Format);
530  write(XmlOut, "SequentialSourceType", seqsource_header.seqsrc.id);
531  write(XmlOut, "BkwdPropXML", BkwdPropXML);
532  write(XmlOut, "BkwdPropRecordXML", BkwdPropRecordXML);
533  write(XmlOut, "BkwdPropCheck", BkwdPropCheck);
534  pop(XmlOut);
535  }
536  }
537  catch( std::bad_cast )
538  {
539  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": forward prop: caught dynamic cast error"
540  << std::endl;
541  QDP_abort(1);
542  }
543  catch (const std::string& e)
544  {
545  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": forward prop: error message: " << e
546  << std::endl;
547  QDP_abort(1);
548  }
549 
550  QDPIO::cout << "Backward propagator successfully parse" << std::endl;
551  Out << "finished reading backward u propagator " << params.bb.BkwdProps[loop].BkwdPropId << " ... " << "\n"; Out.flush();
552 
553  //#################################################################################//
554  // Additional Gamma Matrix Insertions //
555  //#################################################################################//
556 
557  multi1d<int> GammaInsertions(1);
558  GammaInsertions[0] = params.bb.BkwdProps[loop].GammaInsertion;
559 
560  if (GammaInsertions[0] < 0 || GammaInsertions[0] >= Ns*Ns)
561  {
562  QDPIO::cerr << "InlineBuildingBlocks: Gamma insertion out of bounds: " << GammaInsertions[0] << std::endl;
563  QDP_abort(1);
564  }
565 
566  //#################################################################################//
567  // Some output //
568  //#################################################################################//
569 
570  QDPIO::cout << "Seqsource name = " << seqsource_header.seqsrc.id << std::endl;
571  QDPIO::cout << "Gamma insertion = " << params.bb.BkwdProps[loop].GammaInsertion << std::endl;
572  QDPIO::cout << "Flavor = " << params.bb.BkwdProps[loop].Flavor << std::endl;
573 
574  write(XmlOut, "seq_src", seqsource_header.seqsrc.id);
575  write(XmlOut, "gamma_insertion", GammaInsertions[0]);
576  write(XmlOut, "flavor", params.bb.BkwdProps[loop].Flavor);
577  write(XmlOut, "t_source", source_header.t_source);
578  write(XmlOut, "t_sink", seqsource_header.t_sink);
579  write(XmlOut, "sink_mom", seqsource_header.sink_mom);
580 
581  //#################################################################################//
582  // Convert Backward Propagator Format //
583  //#################################################################################//
584 
585  if( params.bb.BkwdProps[loop].BkwdPropG5Format == "G5_B" )
586  {
587  LatticePropagator Bu = B[0];
588  B[0] = Gamma( 15 ) * Bu;
589  }
590  else if( params.bb.BkwdProps[loop].BkwdPropG5Format == "B_G5" )
591  {
592  LatticePropagator Bu = B[0];
593  B[0] = Bu * Gamma( 15 );
594  }
595  else if( params.bb.BkwdProps[loop].BkwdPropG5Format == "G5_B_G5" )
596  {
597  LatticePropagator Bu = B[0];
598  B[0] = Gamma( 15 ) * Bu * Gamma( 15 );
599  }
600 
601  //#################################################################################//
602  // Set Momenta //
603  //#################################################################################//
604 
605  multi1d< int > SnkMom( Nd - 1 );
607  SnkMom = seqsource_header.sink_mom;
608  else
609  SnkMom = 0;
610 
611  SftMom Phases( params.param.mom2_max, t_srce, SnkMom, false, j_decay );
612  SftMom PhasesCanonical( params.param.mom2_max, t_srce, SnkMom,
614 
615  //#################################################################################//
616  // Construct File Names //
617  //#################################################################################//
618 
619  int NumO = PhasesCanonical.numMom();
620 
621  multi2d< std::string > Files( 1, NumO );
622 
623  const int BBFileNameLength = params.bb.BkwdProps[loop].BBFileNamePattern.length() + 3 * 3 + 1;
624 
625  for( int o = 0; o < NumO; o ++ )
626  {
627  multi1d< int > Q = PhasesCanonical.numToMom( o );
628 
629  char XSign = '+';
630  char YSign = '+';
631  char ZSign = '+';
632 
633  if( Q[0] < 0 )
634  {
635  XSign = '-';
636  }
637  if( Q[1] < 0 )
638  {
639  YSign = '-';
640  }
641  if( Q[2] < 0 )
642  {
643  ZSign = '-';
644  }
645 
646  char* bbf = new char[BBFileNameLength + 1];
647  sprintf( bbf, params.bb.BkwdProps[loop].BBFileNamePattern.c_str(), ZSign, abs(Q[2]), YSign, abs(Q[1]), XSign, abs(Q[0]) );
648 
649  Files(0,o) = bbf;
650 
651  delete[] bbf;
652  }
653 
654  //#################################################################################//
655  // Flavor-ology //
656  //#################################################################################//
657 
658  multi1d< int > Flavors( 1 );
659 
660  //
661  // Dru puts a Flavor into the BB
662  // Telephone book std::map of flavor name to a number
663  //
664  if (params.bb.BkwdProps[loop].Flavor == "U")
665  Flavors[0] = 0;
666  else if (params.bb.BkwdProps[loop].Flavor == "D")
667  Flavors[0] = 1;
668  else if (params.bb.BkwdProps[loop].Flavor == "S")
669  Flavors[0] = 2;
670  else if (params.bb.BkwdProps[loop].Flavor == "C")
671  Flavors[0] = 3;
672  else if (params.bb.BkwdProps[loop].Flavor == "B")
673  Flavors[0] = 4;
674  else if (params.bb.BkwdProps[loop].Flavor == "T")
675  Flavors[0] = 5;
676  else
677  {
678  QDPIO::cerr << InlineBuildingBlocksEnv::name << ": invalid flavor tag = "
679  << params.bb.BkwdProps[loop].Flavor
680  << ", should be one of U,D,S,C,T,B" << std::endl;
681  QDP_abort(1);
682  }
683 
684  //#################################################################################//
685  // Loop-back tests //
686  //#################################################################################//
687  {
688  //! Test a meson sequential source.
689  /*!
690  * For the case of a meson, we have evaluated as the sequential source
691  *
692  * H(y, 0; tx, p) = \sum exp{ip.x} U(y,x) \gamma_5\Gamma_f^\dag\gamma_5 D(x,0)
693  *
694  * H^\dag(y, 0; tx, p) = \sum_x exp{-ip.x} \gamma_5 D(0,x) \Gamma_f U(x,y) \gamma_5
695  *
696  * Thus we can see that
697  *
698  * Tr[ \gamma_5 H^\dag(0,0; tx, p)\gamma_5 \Gamma_i] =
699  * \sum_x exp{-ip.x} Tr[ D(0,x)\Gamma_f U(x,0) \Gamma_i ]
700  *
701  * which is the desired meson correlator at momentum p and timslice tx
702  */
703 
704  // assumes any Gamma5 matrices have already been absorbed
705  push(XmlOut, "LoopBackTest");
706  write(XmlOut, "seq_src", seqsource_header.seqsrc.id);
707  write(XmlOut, "gamma_insertion", GammaInsertions[0]);
708  write(XmlOut, "flavor", params.bb.BkwdProps[loop].Flavor);
709  write(XmlOut, "t_srce", t_srce);
710  write(XmlOut, "t_source", source_header.t_source);
711  write(XmlOut, "t_sink", seqsource_header.t_sink);
712  write(XmlOut, "sink_mom", seqsource_header.sink_mom);
713  LatticeComplex tr = trace(adj(B[0]) * Gamma(GammaInsertions[0]));
714  Complex seq_src_value = peekSite(tr, t_srce);
715  write(XmlOut, "source_value", seq_src_value);
716  pop(XmlOut);
717  }
718 
719  //#################################################################################//
720  // Diagnostic tests //
721  //#################################################################################//
722  {
723  // assumes any Gamma5 matrices have already been absorbed
724  int GammaInsertion = GammaInsertions[0];
725 
726  push(XmlOut, "DiagnosticTest");
727  write(XmlOut, "GammaInsertion", GammaInsertion);
728 
729  {
730  LatticePropagator GFG = Gamma(0) * F * Gamma( GammaInsertion );
731  LatticeComplex tr = localInnerProduct( B[0], GFG );
732  multi1d< DComplex > pr = sumMulti(tr, Phases.getSet());
733  write(XmlOut, "formFactor_G0", pr);
734  }
735  {
736  LatticePropagator GFG = Gamma(8) * F * Gamma( GammaInsertion );
737  LatticeComplex tr = localInnerProduct( B[0], GFG );
738  multi1d< DComplex > pr = sumMulti(tr, Phases.getSet());
739  write(XmlOut, "formFactor_G8", pr);
740  }
741  {
742  LatticePropagator GFG = Gamma(Ns*Ns-1) * F * Gamma( GammaInsertion );
743  LatticeComplex tr = localInnerProduct( B[0], GFG );
744  multi1d< DComplex > pr = sumMulti(tr, Phases.getSet());
745  write(XmlOut, "formFactor_G15", pr);
746  }
747 
748  pop(XmlOut);
749  }
750 
751  //#################################################################################//
752  // Construct Building Blocks //
753  //#################################################################################//
754 
755  swatch.reset();
756  Out << "calculating building blocks" << "\n"; Out.flush();
757  QDPIO::cout << "calculating building blocks" << std::endl;
758 
759  const signed short int T1 = 0;
760  const signed short int T2 = QDP::Layout::lattSize()[j_decay] - 1;
761  const signed short int DecayDir = j_decay;
762  const signed short int Tsrc = source_header.t_source;
763  const signed short int Tsnk = seqsource_header.t_sink;
764 
765  swatch.start();
766  BuildingBlocks(B, F, U,
767  GammaInsertions, Flavors,
769  Phases, PhasesCanonical,
770  Files, T1, T2,
771  Tsrc, Tsnk,
772  seqsource_header.seqsrc.id, seqsource_header.sink_mom, DecayDir,
775  swatch.stop();
776 
777  Out << "finished calculating building blocks for loop = " << loop << "\n"; Out.flush();
778  QDPIO::cout << "finished calculating building blocks for loop = " << loop
779  << " time= "
780  << swatch.getTimeInSeconds()
781  << " secs" << std::endl;
782 
783  pop(XmlOut); // elem
784  } // end loop over sequential sources
785 
786  pop(XmlOut); // SequentialSource
787 
788  pop(XmlOut); // ExampleBuildingBlocks
789 
790  Out << "\n" << "FINISHED" << "\n" << "\n";
791  Out.close();
792 
793  snoop.stop();
794  QDPIO::cout << InlineBuildingBlocksEnv::name << ": total time = "
795  << snoop.getTimeInSeconds()
796  << " secs" << std::endl;
797 
798  QDPIO::cout << InlineBuildingBlocksEnv::name << ": ran successfully" << std::endl;
799 
800  END_CODE();
801  }
802 
803 }
Inline measurement factory.
Class for counted reference semantics.
Definition: handle.h:33
Inline measurement of 3-pt functions writing building-blocks.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
InlineBuildingBlocksParams params
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
Definition: sftmom.h:35
multi1d< int > numToMom(int mom_num) const
Convert momenta id to actual array of momenta.
Definition: sftmom.h:78
int numMom() const
Number of momenta.
Definition: sftmom.h:60
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
All ferm create-state method.
Fermion create state factory.
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.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
std::map< std::string, SinkPropContainer_t > prop
multi1d< int > t_srce
ForwardProp_t prop_header
Inline construction of BuildingBlocks.
Make xml file writer.
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Named object function std::map.
static bool registered
Local registration flag.
GroupXML_t nullXMLGroup()
Returns a periodic createstate group.
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
void write(XMLWriter &xml, const std::string &path, const InlineBuildingBlocksParams::BB_out_t &input)
BB parameters.
static const char *const CVSBuildingBlocks_hh
void AllLinkPatterns(bool &DoThisPattern, bool &DoFurtherPatterns, multi1d< unsigned short int > &LinkPattern)
void BuildingBlocks(const multi1d< LatticePropagator > &B, const LatticePropagator &F, const multi1d< LatticeColorMatrix > &U, const multi1d< int > &GammaInsertions, const multi1d< int > &Flavors, const unsigned short int MaxNLinks, const BBLinkPattern LinkPattern, const SftMom &Phases, const SftMom &PhasesCanonical, const multi2d< std::string > &BinaryDataFileNames, const signed short int T1, const signed short int T2, const signed short int Tsrc, const signed short int Tsnk, const std::string &SeqSourceType, const multi1d< int > &SnkMom, const signed short int DecayDir, const bool TimeReverse, const bool ShiftFlag)
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
START_CODE()
void CVSBuildingBlocks(TextWriter &Out)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Print out basic info about this program.
Fourier transform phase factor support.
Propagator parameters.
Definition: qprop_io.h:75
void write(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineBuildingBlocksParams::BB_out_t bb
struct Chroma::InlineBuildingBlocksParams::Param_t param
Propagator source construction parameters.
Definition: qprop_io.h:27
multi1d< int > getTSrce() const
Definition: qprop_io.cc:120
Sequential source parameters.
Definition: qprop_io.h:90
multi1d< int > sink_mom
Definition: qprop_io.h:95
GroupXML_t seqsrc
Definition: qprop_io.h:93
multi1d< LatticeColorMatrix > U
static INTERNAL_PRECISION F