#ifndef Hadrons_MContraction_A2AFourQuarkContraction_hpp_ #define Hadrons_MContraction_A2AFourQuarkContraction_hpp_ #include #include #include #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * A2AFourQuarkContraction * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MContraction) class A2AFourQuarkContractionPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(A2AFourQuarkContractionPar, std::string, v1, std::string, v2, std::string, mf12, bool, allContr, unsigned int, dt); }; template class TA2AFourQuarkContraction: public Module { public: FERM_TYPE_ALIASES(FImpl, ); // constructor TA2AFourQuarkContraction(const std::string name); // destructor virtual ~TA2AFourQuarkContraction(void) {}; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); // setup virtual void setup(void); // execution virtual void execute(void); private: unsigned int nt_; }; MODULE_REGISTER_TMP(A2AFourQuarkContraction, TA2AFourQuarkContraction, MContraction); /****************************************************************************** * TA2AFourQuarkContraction implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TA2AFourQuarkContraction::TA2AFourQuarkContraction(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TA2AFourQuarkContraction::getInput(void) { std::vector in = {par().v1, par().v2, par().mf12}; return in; } template std::vector TA2AFourQuarkContraction::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TA2AFourQuarkContraction::setup(void) { if (par().allContr) { nt_ = env().getDim(Tp); envTmp(std::vector, "tmpWWVV", 1, nt_, envGetGrid(PropagatorField)); envCreate(std::vector, getName(), 1, nt_, envGetGrid(PropagatorField)); } else { envTmp(std::vector, "tmpWWVV", 1, 1, envGetGrid(PropagatorField)); envCreate(PropagatorField, getName(), 1, envGetGrid(PropagatorField)); } } // execution /////////////////////////////////////////////////////////////////// template void TA2AFourQuarkContraction::execute(void) { auto &v1 = envGet(std::vector, par().v1); auto &v2 = envGet(std::vector, par().v2); auto &mf12 = envGet(EigenDiskVector, par().mf12); envGetTmp(std::vector, tmpWWVV); unsigned int dt = par().dt; unsigned int nt = env().getDim(Tp); if (par().allContr) { LOG(Message) << "Computing 4 quark contraction for " << getName() << " for all t0 time translations " << "with nt = " << nt_ << " and dt = " << dt << std::endl; auto &WWVV = envGet(std::vector, getName()); A2Autils::ContractWWVV(tmpWWVV, mf12, &v1[0], &v2[0]); for(unsigned int t = 0; t < nt_; t++){ unsigned int t0 = (t + dt) % nt_; WWVV[t] = tmpWWVV[t0]; } } else { LOG(Message) << "Computing 4 quark contraction for: " << getName() << " for time dt = " << dt << std::endl; auto &WWVV = envGet(PropagatorField, getName()); int ni = v1.size(); int nj = v2.size(); Eigen::Matrix mf; mf = mf12[dt]; Eigen::TensorMap> mfT(mf.data(), 1, ni, nj); A2Autils::ContractWWVV(tmpWWVV, mfT, &v1[0], &v2[0]); WWVV = tmpWWVV[0]; } } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MContraction_A2AFourQuarkContraction_hpp_