2017-07-31 12:26:34 +01:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-09-01 21:30:30 +01:00
|
|
|
Source file: Hadrons/Modules/MSink/Point.hpp
|
2017-07-31 12:26:34 +01:00
|
|
|
|
2017-12-26 13:16:47 +00:00
|
|
|
Copyright (C) 2015-2018
|
2017-07-31 12:26:34 +01:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2018-04-23 17:36:20 +01:00
|
|
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
2017-12-26 13:16:47 +00:00
|
|
|
Author: Lanny91 <andrew.lawson@gmail.com>
|
2017-07-31 12:26:34 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
|
|
|
|
2017-06-06 17:45:30 +01:00
|
|
|
#ifndef Hadrons_MSink_Point_hpp_
|
|
|
|
#define Hadrons_MSink_Point_hpp_
|
|
|
|
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
2017-06-06 17:45:30 +01:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Point *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MSink)
|
|
|
|
|
|
|
|
class PointPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar,
|
|
|
|
std::string, mom);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
|
|
|
class TPoint: public Module<PointPar>
|
|
|
|
{
|
|
|
|
public:
|
2018-09-21 18:15:18 +01:00
|
|
|
BASIC_TYPE_ALIASES(FImpl,);
|
2017-06-06 17:45:30 +01:00
|
|
|
SINK_TYPE_ALIASES();
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TPoint(const std::string name);
|
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TPoint(void) {};
|
2017-06-06 17:45:30 +01:00
|
|
|
// dependency relation
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
2017-12-03 18:46:18 +00:00
|
|
|
protected:
|
2017-06-06 17:45:30 +01:00
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
2017-12-01 19:38:23 +00:00
|
|
|
private:
|
|
|
|
bool hasPhase_{false};
|
|
|
|
std::string momphName_;
|
2017-06-06 17:45:30 +01:00
|
|
|
};
|
|
|
|
|
2018-04-23 17:35:01 +01:00
|
|
|
MODULE_REGISTER_TMP(Point, TPoint<FIMPL>, MSink);
|
|
|
|
MODULE_REGISTER_TMP(ScalarPoint, TPoint<ScalarImplCR>, MSink);
|
2017-06-06 17:45:30 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TPoint implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
TPoint<FImpl>::TPoint(const std::string name)
|
|
|
|
: Module<PointPar>(name)
|
2017-12-01 19:38:23 +00:00
|
|
|
, momphName_ (name + "_momph")
|
2017-06-06 17:45:30 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
std::vector<std::string> TPoint<FImpl>::getInput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> in;
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FImpl>
|
|
|
|
std::vector<std::string> TPoint<FImpl>::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out = {getName()};
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
void TPoint<FImpl>::setup(void)
|
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
envTmpLat(LatticeComplex, "coor");
|
|
|
|
envCacheLat(LatticeComplex, momphName_);
|
|
|
|
envCreate(SinkFn, getName(), 1, nullptr);
|
2017-06-06 17:45:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
void TPoint<FImpl>::execute(void)
|
2017-12-13 19:41:41 +00:00
|
|
|
{
|
2017-06-06 17:45:30 +01:00
|
|
|
LOG(Message) << "Setting up point sink function for momentum ["
|
|
|
|
<< par().mom << "]" << std::endl;
|
2017-12-01 19:38:23 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
auto &ph = envGet(LatticeComplex, momphName_);
|
|
|
|
|
2017-12-01 19:38:23 +00:00
|
|
|
if (!hasPhase_)
|
2017-06-06 17:45:30 +01:00
|
|
|
{
|
2017-12-13 19:41:41 +00:00
|
|
|
Complex i(0.0,1.0);
|
|
|
|
std::vector<Real> p;
|
2017-12-01 19:38:23 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
envGetTmp(LatticeComplex, coor);
|
|
|
|
p = strToVec<Real>(par().mom);
|
2017-12-01 19:38:23 +00:00
|
|
|
ph = zero;
|
2018-03-19 17:56:53 +00:00
|
|
|
for(unsigned int mu = 0; mu < p.size(); mu++)
|
2017-12-01 19:38:23 +00:00
|
|
|
{
|
|
|
|
LatticeCoordinate(coor, mu);
|
2018-09-29 17:55:19 +01:00
|
|
|
ph = ph + (p[mu]/env().getDim(mu))*coor;
|
2017-12-01 19:38:23 +00:00
|
|
|
}
|
|
|
|
ph = exp((Real)(2*M_PI)*i*ph);
|
|
|
|
hasPhase_ = true;
|
2017-06-06 17:45:30 +01:00
|
|
|
}
|
2017-12-01 19:38:23 +00:00
|
|
|
auto sink = [&ph](const PropagatorField &field)
|
2017-06-06 17:45:30 +01:00
|
|
|
{
|
|
|
|
SlicedPropagator res;
|
|
|
|
PropagatorField tmp = ph*field;
|
|
|
|
|
|
|
|
sliceSum(tmp, res, Tp);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
2017-12-01 19:38:23 +00:00
|
|
|
envGet(SinkFn, getName()) = sink;
|
2017-06-06 17:45:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MSink_Point_hpp_
|