/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: Hadrons/Modules/MDistil/LoadPerambulator.hpp Copyright (C) 2019 Author: Felix Erben Author: Michael Marshall 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_MIO_LoadPerambulator_hpp_ #define Hadrons_MIO_LoadPerambulator_hpp_ #include BEGIN_HADRONS_NAMESPACE BEGIN_MODULE_NAMESPACE(MIO) /****************************************************************************** * LoadPerambulator * ******************************************************************************/ class LoadPerambulatorPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(LoadPerambulatorPar, std::string, PerambFileName, std::string, DistilPar); }; template class TLoadPerambulator: public Module { public: // constructor TLoadPerambulator(const std::string name); // destructor virtual ~TLoadPerambulator(void) {}; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); // setup virtual void setup(void); // execution virtual void execute(void); protected: std::string DParName; }; MODULE_REGISTER_TMP(LoadPerambulator, TLoadPerambulator, MIO); /****************************************************************************** * TLoadPerambulator implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TLoadPerambulator::TLoadPerambulator(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TLoadPerambulator::getInput(void) { DParName = par().DistilPar; return { par().PerambFileName, DParName }; } template std::vector TLoadPerambulator::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TLoadPerambulator::setup(void) { auto &DPar = envGet(MDistil::DistilParameters, DParName); const int Nt{env().getDim(Tdir)}; const int nvec{DPar.nvec}; const int nnoise{DPar.nnoise}; const int tsrc{DPar.tsrc}; const int TI{DPar.TI}; const int LI{DPar.LI}; const int SI{DPar.SI}; const bool full_tdil{ TI == Nt }; const bool exact_distillation{ full_tdil && LI == nvec }; const int Nt_inv{ full_tdil ? 1 : TI }; envCreate(MDistil::PerambTensor, getName(), 1, Nt,nvec,LI,nnoise,Nt_inv,SI); } // execution /////////////////////////////////////////////////////////////////// template void TLoadPerambulator::execute(void) { auto &perambulator = envGet(MDistil::PerambTensor, getName()); std::string sPerambName{ par().PerambFileName }; sPerambName.append( 1, '.' ); sPerambName.append( std::to_string( vm().getTrajectory() ) ); perambulator.read(sPerambName.c_str()); } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MIO_LoadPerambulator_hpp_