From 673994b281e6c464b4021c62c80a9976e0035176 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Thu, 29 Dec 2016 22:44:58 +0100 Subject: [PATCH] Hadrons: modules for scalar propagators --- extras/Hadrons/Global.hpp | 25 ++++++-- extras/Hadrons/Modules.hpp | 30 +--------- extras/Hadrons/Modules/MScalar/ChargedProp.cc | 40 +++++++++++++ .../Hadrons/Modules/MScalar/ChargedProp.hpp | 44 ++++++++++++++ extras/Hadrons/Modules/MScalar/FreeProp.cc | 57 +++++++++++++++++++ extras/Hadrons/Modules/MScalar/FreeProp.hpp | 47 +++++++++++++++ extras/Hadrons/modules.inc | 6 +- 7 files changed, 215 insertions(+), 34 deletions(-) create mode 100644 extras/Hadrons/Modules/MScalar/ChargedProp.cc create mode 100644 extras/Hadrons/Modules/MScalar/ChargedProp.hpp create mode 100644 extras/Hadrons/Modules/MScalar/FreeProp.cc create mode 100644 extras/Hadrons/Modules/MScalar/FreeProp.hpp diff --git a/extras/Hadrons/Global.hpp b/extras/Hadrons/Global.hpp index 81afab13..bcb282fc 100644 --- a/extras/Hadrons/Global.hpp +++ b/extras/Hadrons/Global.hpp @@ -51,23 +51,38 @@ using Grid::operator<<; * error with GCC 5 (clang & GCC 6 compile fine without it). */ -// FIXME: find a way to do that in a more general fashion #ifndef FIMPL #define FIMPL WilsonImplR #endif +#ifndef SIMPL +#define SIMPL ScalarImplR +#endif BEGIN_HADRONS_NAMESPACE // type aliases -#define TYPE_ALIASES(FImpl, suffix)\ +#define FERM_TYPE_ALIASES(FImpl, suffix)\ typedef FermionOperator FMat##suffix; \ typedef typename FImpl::FermionField FermionField##suffix; \ typedef typename FImpl::PropagatorField PropagatorField##suffix; \ -typedef typename FImpl::SitePropagator SitePropagator##suffix; \ -typedef typename FImpl::DoubledGaugeField DoubledGaugeField##suffix;\ -typedef std::function SolverFn##suffix; +#define TYPE_ALIASES(FImpl, suffix)\ +FERM_TYPE_ALIASES(FImpl, suffix)\ +GAUGE_TYPE_ALIASES(FImpl, suffix)\ +SOLVER_TYPE_ALIASES(FImpl, suffix) + // logger class HadronsLogger: public Logger { diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index 5d1a456c..ad31d2a7 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -1,31 +1,3 @@ -/************************************************************************************* - -Grid physics library, www.github.com/paboyle/Grid - -Source file: extras/Hadrons/Modules.hpp - -Copyright (C) 2015 -Copyright (C) 2016 - -Author: Antonin Portelli - -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 */ #include #include #include @@ -34,6 +6,8 @@ See the full license in the file "LICENSE" in the top level distribution directo #include #include #include +#include +#include #include #include #include diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.cc b/extras/Hadrons/Modules/MScalar/ChargedProp.cc new file mode 100644 index 00000000..1137c6f0 --- /dev/null +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.cc @@ -0,0 +1,40 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MScalar; + +/****************************************************************************** +* TChargedProp implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +TChargedProp::TChargedProp(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +std::vector TChargedProp::getInput(void) +{ + std::vector in; + + return in; +} + +std::vector TChargedProp::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +void TChargedProp::setup(void) +{ + +} + +// execution /////////////////////////////////////////////////////////////////// +void TChargedProp::execute(void) +{ + +} diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.hpp b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp new file mode 100644 index 00000000..7a60c2ad --- /dev/null +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp @@ -0,0 +1,44 @@ +#ifndef Hadrons_ChargedProp_hpp_ +#define Hadrons_ChargedProp_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * ChargedProp * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MScalar) + +class ChargedPropPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(ChargedPropPar, + unsigned int, i); +}; + +class TChargedProp: public Module +{ +public: + // constructor + TChargedProp(const std::string name); + // destructor + virtual ~TChargedProp(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_NS(ChargedProp, TChargedProp, MScalar); + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_ChargedProp_hpp_ diff --git a/extras/Hadrons/Modules/MScalar/FreeProp.cc b/extras/Hadrons/Modules/MScalar/FreeProp.cc new file mode 100644 index 00000000..7419a954 --- /dev/null +++ b/extras/Hadrons/Modules/MScalar/FreeProp.cc @@ -0,0 +1,57 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MScalar; + +/****************************************************************************** +* TFreeProp implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +TFreeProp::TFreeProp(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +std::vector TFreeProp::getInput(void) +{ + std::vector in = {par().source}; + + return in; +} + +std::vector TFreeProp::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +void TFreeProp::setup(void) +{ + env().registerLattice(getName()); +} + +// execution /////////////////////////////////////////////////////////////////// +void TFreeProp::execute(void) +{ + ScalarField &prop = *env().createLattice(getName()); + ScalarField &source = *env().getObject(par().source); + ScalarField *momKernel; + std::string kerName = "_" + getName() + "_momKernel"; + + if (!env().hasCreatedObject(kerName)) + { + LOG(Message) << "Caching momentum space free scalar propagator" + << "(mass= " << par().mass << ")..." << std::endl; + momKernel = env().template createLattice(kerName); + Scalar::MomentumSpacePropagator(*momKernel, par().mass); + } + else + { + momKernel = env().getObject(kerName); + } + LOG(Message) << "Computing free scalar propagator..." << std::endl; + Scalar::FreePropagator(source, prop, *momKernel); +} diff --git a/extras/Hadrons/Modules/MScalar/FreeProp.hpp b/extras/Hadrons/Modules/MScalar/FreeProp.hpp new file mode 100644 index 00000000..6a0cd930 --- /dev/null +++ b/extras/Hadrons/Modules/MScalar/FreeProp.hpp @@ -0,0 +1,47 @@ +#ifndef Hadrons_FreeProp_hpp_ +#define Hadrons_FreeProp_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * FreeProp * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MScalar) + +class FreePropPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(FreePropPar, + std::string, source, + double, mass); +}; + +class TFreeProp: public Module +{ +public: + SCALAR_TYPE_ALIASES(SIMPL,); +public: + // constructor + TFreeProp(const std::string name); + // destructor + virtual ~TFreeProp(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_NS(FreeProp, TFreeProp, MScalar); + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_FreeProp_hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 8b559024..b091c38b 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -2,7 +2,9 @@ modules_cc =\ Modules/MGauge/Load.cc \ Modules/MGauge/Random.cc \ Modules/MGauge/StochEm.cc \ - Modules/MGauge/Unit.cc + Modules/MGauge/Unit.cc \ + Modules/MScalar/ChargedProp.cc \ + Modules/MScalar/FreeProp.cc modules_hpp =\ Modules/MAction/DWF.hpp \ @@ -13,6 +15,8 @@ modules_hpp =\ Modules/MGauge/Random.hpp \ Modules/MGauge/StochEm.hpp \ Modules/MGauge/Unit.hpp \ + Modules/MScalar/ChargedProp.hpp \ + Modules/MScalar/FreeProp.hpp \ Modules/MSolver/RBPrecCG.hpp \ Modules/MSource/Point.hpp \ Modules/MSource/SeqGamma.hpp \