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/MFermion/GaugeProp.hpp
|
2017-07-31 12:26:34 +01:00
|
|
|
|
2019-02-05 18:55:24 +00:00
|
|
|
Copyright (C) 2015-2019
|
2017-07-31 12:26:34 +01:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2018-02-26 19:24:19 +00:00
|
|
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
2017-12-26 13:16:47 +00:00
|
|
|
Author: Lanny91 <andrew.lawson@gmail.com>
|
2018-02-26 19:24:19 +00:00
|
|
|
Author: pretidav <david.preti@csic.es>
|
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-08 02:10:48 +01:00
|
|
|
#ifndef Hadrons_MFermion_GaugeProp_hpp_
|
|
|
|
#define Hadrons_MFermion_GaugeProp_hpp_
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Hadrons/Solver.hpp>
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* GaugeProp *
|
2016-12-05 07:47:29 +00:00
|
|
|
******************************************************************************/
|
2017-06-08 02:10:48 +01:00
|
|
|
BEGIN_MODULE_NAMESPACE(MFermion)
|
|
|
|
|
|
|
|
class GaugePropPar: Serializable
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-08 02:10:48 +01:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(GaugePropPar,
|
2016-12-05 07:47:29 +00:00
|
|
|
std::string, source,
|
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
class TGaugeProp: public Module<GaugePropPar>
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-09-21 18:15:18 +01:00
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
2018-06-22 11:14:37 +01:00
|
|
|
SOLVER_TYPE_ALIASES(FImpl,);
|
2016-12-05 07:47:29 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp(const std::string name);
|
2016-12-05 07:47:29 +00:00
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TGaugeProp(void) {};
|
2017-06-08 02:10:48 +01:00
|
|
|
// dependency relation
|
2016-12-05 07:47:29 +00:00
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
2017-12-03 18:46:18 +00:00
|
|
|
protected:
|
2016-12-05 07:47:29 +00:00
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
private:
|
|
|
|
unsigned int Ls_;
|
2018-06-22 11:14:37 +01:00
|
|
|
Solver *solver_{nullptr};
|
2016-12-05 07:47:29 +00:00
|
|
|
};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2018-04-23 17:35:01 +01:00
|
|
|
MODULE_REGISTER_TMP(GaugeProp, TGaugeProp<FIMPL>, MFermion);
|
2018-06-22 14:53:22 +01:00
|
|
|
MODULE_REGISTER_TMP(ZGaugeProp, TGaugeProp<ZFIMPL>, MFermion);
|
2016-12-14 17:59:45 +00:00
|
|
|
|
2015-12-23 14:21:35 +00:00
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* TGaugeProp implementation *
|
2015-12-23 14:21:35 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp<FImpl>::TGaugeProp(const std::string name)
|
|
|
|
: Module<GaugePropPar>(name)
|
2015-12-23 14:21:35 +00:00
|
|
|
{}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getInput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
std::vector<std::string> in = {par().source, par().solver};
|
2016-04-30 08:17:04 +01:00
|
|
|
|
|
|
|
return in;
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getOutput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2015-12-23 14:30:33 +00:00
|
|
|
std::vector<std::string> out = {getName(), getName() + "_5d"};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2016-04-30 08:17:04 +01:00
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::setup(void)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
Ls_ = env().getObjectLs(par().solver);
|
2017-12-01 19:38:23 +00:00
|
|
|
envCreateLat(PropagatorField, getName());
|
|
|
|
envTmpLat(FermionField, "tmp");
|
2016-04-30 08:17:04 +01:00
|
|
|
if (Ls_ > 1)
|
2016-01-14 04:23:51 +00:00
|
|
|
{
|
2019-03-29 16:36:56 +00:00
|
|
|
envTmpLat(FermionField, "source", Ls_);
|
|
|
|
envTmpLat(FermionField, "sol", Ls_);
|
2017-12-01 19:38:23 +00:00
|
|
|
envCreateLat(PropagatorField, getName() + "_5d", Ls_);
|
2016-01-14 04:23:51 +00:00
|
|
|
}
|
2019-03-29 16:36:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
envTmpLat(FermionField, "source");
|
|
|
|
envTmpLat(FermionField, "sol");
|
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::execute(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-04 20:17:27 +01:00
|
|
|
LOG(Message) << "Computing quark propagator '" << getName() << "'"
|
2017-12-01 19:38:23 +00:00
|
|
|
<< std::endl;
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
|
|
|
|
auto &prop = envGet(PropagatorField, propName);
|
|
|
|
auto &fullSrc = envGet(PropagatorField, par().source);
|
2018-06-22 11:14:37 +01:00
|
|
|
auto &solver = envGet(Solver, par().solver);
|
|
|
|
auto &mat = solver.getFMat();
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
envGetTmp(FermionField, source);
|
|
|
|
envGetTmp(FermionField, sol);
|
|
|
|
envGetTmp(FermionField, tmp);
|
2016-05-12 11:59:28 +01:00
|
|
|
LOG(Message) << "Inverting using solver '" << par().solver
|
2017-12-01 19:38:23 +00:00
|
|
|
<< "' on source '" << par().source << "'" << std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
for (unsigned int s = 0; s < Ns; ++s)
|
2018-06-22 11:14:37 +01:00
|
|
|
for (unsigned int c = 0; c < FImpl::Dimension; ++c)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
LOG(Message) << "Inversion for spin= " << s << ", color= " << c
|
2017-12-13 19:41:41 +00:00
|
|
|
<< std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 4D sources
|
2018-06-22 11:14:37 +01:00
|
|
|
LOG(Message) << "Import source" << std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
if (!env().isObject5d(par().source))
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ == 1)
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(source, fullSrc, s, c);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(tmp, fullSrc, s, c);
|
2018-06-22 11:14:37 +01:00
|
|
|
mat.ImportPhysicalFermionSource(tmp, source);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 5D sources
|
2016-04-30 08:17:04 +01:00
|
|
|
else
|
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ != env().getObjectLs(par().source))
|
|
|
|
{
|
2018-04-25 16:49:14 +01:00
|
|
|
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(source, fullSrc, s, c);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2018-01-27 23:50:43 +00:00
|
|
|
sol = Zero();
|
2018-06-22 11:14:37 +01:00
|
|
|
LOG(Message) << "Solve" << std::endl;
|
2016-06-06 17:45:37 +01:00
|
|
|
solver(sol, source);
|
2018-06-22 11:14:37 +01:00
|
|
|
LOG(Message) << "Export solution" << std::endl;
|
2017-12-22 18:02:07 +00:00
|
|
|
FermToProp<FImpl>(prop, sol, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
// create 4D propagators from 5D one if necessary
|
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
PropagatorField &p4d = envGet(PropagatorField, getName());
|
2018-06-22 11:14:37 +01:00
|
|
|
mat.ExportPhysicalFermionSolution(sol, tmp);
|
2017-12-22 18:02:07 +00:00
|
|
|
FermToProp<FImpl>(p4d, tmp, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
#endif // Hadrons_MFermion_GaugeProp_hpp_
|