diff --git a/extras/Hadrons/Application.cc b/extras/Hadrons/Application.cc index 7ba98ade..39c898bc 100644 --- a/extras/Hadrons/Application.cc +++ b/extras/Hadrons/Application.cc @@ -43,12 +43,6 @@ using namespace Hadrons; Application::Application(void) { initLogger(); - LOG(Message) << "Modules available:" << std::endl; - auto list = ModuleFactory::getInstance().getBuilderList(); - for (auto &m: list) - { - LOG(Message) << " " << m << std::endl; - } auto dim = GridDefaultLatt(), mpi = GridDefaultMpi(), loc(dim); locVol_ = 1; for (unsigned int d = 0; d < dim.size(); ++d) diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index c42e5e88..135934fb 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -57,6 +57,7 @@ See the full license in the file "LICENSE" in the top level distribution directo #include #include #include +#include #include #include #include diff --git a/extras/Hadrons/Modules/MContraction/Meson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp index b0988a5c..0197534d 100644 --- a/extras/Hadrons/Modules/MContraction/Meson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -171,7 +171,7 @@ void TMeson::execute(void) LOG(Message) << "Computing meson contractions '" << getName() << "' using" << " quarks '" << par().q1 << "' and '" << par().q2 << "'" << std::endl; - + ResultWriter writer(RESULT_FILE_NAME(par().output)); std::vector buf; std::vector result; diff --git a/extras/Hadrons/Modules/MScalarSUN/Div.hpp b/extras/Hadrons/Modules/MScalarSUN/Div.hpp new file mode 100644 index 00000000..6680cd79 --- /dev/null +++ b/extras/Hadrons/Modules/MScalarSUN/Div.hpp @@ -0,0 +1,166 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MScalarSUN/Div.hpp + +Copyright (C) 2015-2018 + +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 */ +#ifndef Hadrons_MScalarSUN_Div_hpp_ +#define Hadrons_MScalarSUN_Div_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Div * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MScalarSUN) + +class DivPar: Serializable +{ +public: + GRID_SERIALIZABLE_ENUM(DiffType, undef, forward, 1, backward, 2, central, 3); + GRID_SERIALIZABLE_CLASS_MEMBERS(DivPar, + std::vector, op, + DiffType, type, + std::string, output); +}; + +template +class TDiv: public Module +{ +public: + typedef typename SImpl::Field Field; + typedef typename SImpl::ComplexField ComplexField; + class Result: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, + DivPar::DiffType, type, + Complex, value); + }; +public: + // constructor + TDiv(const std::string name); + // destructor + virtual ~TDiv(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(DivSU2, TDiv>, MScalarSUN); +MODULE_REGISTER_NS(DivSU3, TDiv>, MScalarSUN); +MODULE_REGISTER_NS(DivSU4, TDiv>, MScalarSUN); +MODULE_REGISTER_NS(DivSU5, TDiv>, MScalarSUN); +MODULE_REGISTER_NS(DivSU6, TDiv>, MScalarSUN); + +/****************************************************************************** + * TDiv implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TDiv::TDiv(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TDiv::getInput(void) +{ + return par().op; +} + +template +std::vector TDiv::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TDiv::setup(void) +{ + if (par().op.size() != env().getNd()) + { + HADRON_ERROR(Size, "the number of components differs from number of dimensions"); + } + envCreateLat(ComplexField, getName()); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TDiv::execute(void) +{ + const auto nd = env().getNd(); + + LOG(Message) << "Computing the " << par().type << " divergence of ["; + for (unsigned int mu = 0; mu < nd; ++mu) + { + std::cout << par().op[mu] << ((mu == nd - 1) ? "]" : ", "); + } + std::cout << std::endl; + + auto &div = envGet(ComplexField, getName()); + div = zero; + for (unsigned int mu = 0; mu < nd; ++mu) + { + auto &op = envGet(ComplexField, par().op[mu]); + switch(par().type) + { + case DivPar::DiffType::backward: + div += op - Cshift(op, mu, -1); + break; + case DivPar::DiffType::forward: + div += Cshift(op, mu, 1) - op; + break; + case DivPar::DiffType::central: + div += 0.5*(Cshift(op, mu, 1) - Cshift(op, mu, -1)); + break; + } + } + if (!par().output.empty()) + { + Result r; + ResultWriter writer(RESULT_FILE_NAME(par().output)); + + r.type = par().type; + r.value = TensorRemove(sum(div)); + write(writer, "div", r); + } +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MScalarSUN_Div_hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 3e62c91f..90602275 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -44,6 +44,7 @@ modules_hpp =\ Modules/MAction/DWF.hpp \ Modules/MAction/Wilson.hpp \ Modules/MAction/WilsonClover.hpp \ + Modules/MScalarSUN/Div.hpp \ Modules/MScalarSUN/TrMag.hpp \ Modules/MScalarSUN/TwoPoint.hpp \ Modules/MScalarSUN/TrPhi.hpp \