00001
00002
00003
00004
00005
00006 #include "chromabase.h"
00007
00008 #include "meas/smear/link_smearing_factory.h"
00009 #include "meas/smear/ape_link_smearing.h"
00010 #include "meas/smear/ape_smear.h"
00011
00012 namespace Chroma
00013 {
00014
00015 void read(XMLReader& xml, const string& path, APELinkSmearingEnv::Params& param)
00016 {
00017 APELinkSmearingEnv::Params tmp(xml, path);
00018 param = tmp;
00019 }
00020
00021
00022 void write(XMLWriter& xml, const string& path, const APELinkSmearingEnv::Params& param)
00023 {
00024 param.writeXML(xml, path);
00025 }
00026
00027
00028
00029
00030 namespace APELinkSmearingEnv
00031 {
00032 namespace
00033 {
00034
00035 LinkSmearing* createSource(XMLReader& xml_in,
00036 const std::string& path)
00037 {
00038 return new LinkSmear(Params(xml_in, path));
00039 }
00040
00041
00042 bool registered = false;
00043
00044
00045 const std::string name = "APE_SMEAR";
00046 }
00047
00048
00049 std::string getName() {return name;}
00050
00051
00052 bool registerAll()
00053 {
00054 bool success = true;
00055 if (! registered)
00056 {
00057 success &= Chroma::TheLinkSmearingFactory::Instance().registerObject(name, createSource);
00058 registered = true;
00059 }
00060 return success;
00061 }
00062
00063
00064
00065 Params::Params(XMLReader& xml, const string& path)
00066 {
00067 XMLReader paramtop(xml, path);
00068
00069 int version = 1;
00070 if (paramtop.count("version") != 0)
00071 read(paramtop, "version", version);
00072
00073 BlkMax = 100;
00074 BlkAccu = 1.0e-5;
00075
00076 switch (version)
00077 {
00078 case 1:
00079 break;
00080
00081 case 2:
00082 read(paramtop, "BlkMax", BlkMax);
00083 read(paramtop, "BlkAccu", BlkAccu);
00084 break;
00085
00086 default :
00087 QDPIO::cerr << "Input parameter version " << version << " unsupported." << endl;
00088 QDP_abort(1);
00089 }
00090
00091 read(paramtop, "link_smear_num", link_smear_num);
00092 read(paramtop, "link_smear_fact", link_smear_fact);
00093 read(paramtop, "no_smear_dir", no_smear_dir);
00094 }
00095
00096
00097 void Params::writeXML(XMLWriter& xml, const string& path) const
00098 {
00099 push(xml, path);
00100
00101 int version = 2;
00102 write(xml, "version", version);
00103 write(xml, "LinkSmearingType", name);
00104 write(xml, "link_smear_num", link_smear_num);
00105 write(xml, "link_smear_fact", link_smear_fact);
00106 write(xml, "no_smear_dir", no_smear_dir);
00107 write(xml, "BlkMax", BlkMax);
00108 write(xml, "BlkAccu", BlkAccu);
00109
00110 pop(xml);
00111 }
00112
00113
00114
00115 void
00116 LinkSmear::operator()(multi1d<LatticeColorMatrix>& u) const
00117 {
00118
00119 multi1d<LatticeColorMatrix> u_ape = u;
00120
00121 if (params.link_smear_num > 0)
00122 {
00123 QDPIO::cout << "APE Smear gauge field" << endl;
00124
00125 for(int i=0; i < params.link_smear_num; ++i)
00126 {
00127 multi1d<LatticeColorMatrix> u_tmp(Nd);
00128
00129 for(int mu = 0; mu < Nd; ++mu)
00130 if ( mu != params.no_smear_dir )
00131 APE_Smear(u_ape, u_tmp[mu], mu, 0,
00132 params.link_smear_fact, params.BlkAccu, params.BlkMax,
00133 params.no_smear_dir);
00134 else
00135 u_tmp[mu] = u_ape[mu];
00136
00137 u_ape = u_tmp;
00138 }
00139 QDPIO::cout << "Gauge field APE-smeared!" << endl;
00140 }
00141
00142 u = u_ape;
00143 }
00144
00145 }
00146 }