mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
New modules for loading in MFs as diskvectors and producing propagaotrs from 4 quark contractions
This commit is contained in:
7
Hadrons/Modules/MContraction/A2AFourQuarkContraction.cc
Normal file
7
Hadrons/Modules/MContraction/A2AFourQuarkContraction.cc
Normal file
@ -0,0 +1,7 @@
|
||||
#include <Hadrons/Modules/MContraction/A2AFourQuarkContraction.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TA2AFourQuarkContraction<FIMPL>;
|
105
Hadrons/Modules/MContraction/A2AFourQuarkContraction.hpp
Normal file
105
Hadrons/Modules/MContraction/A2AFourQuarkContraction.hpp
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef Hadrons_MContraction_A2AFourQuarkContraction_hpp_
|
||||
#define Hadrons_MContraction_A2AFourQuarkContraction_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
#include <Hadrons/DiskVector.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* A2AFourQuarkContraction *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class A2AFourQuarkContractionPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AFourQuarkContractionPar,
|
||||
std::string, v1,
|
||||
std::string, v2,
|
||||
std::string, mf12);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TA2AFourQuarkContraction: public Module<A2AFourQuarkContractionPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl, );
|
||||
// constructor
|
||||
TA2AFourQuarkContraction(const std::string name);
|
||||
// destructor
|
||||
virtual ~TA2AFourQuarkContraction(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(A2AFourQuarkContraction, TA2AFourQuarkContraction<FIMPL>, MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TA2AFourQuarkContraction implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TA2AFourQuarkContraction<FImpl>::TA2AFourQuarkContraction(const std::string name)
|
||||
: Module<A2AFourQuarkContractionPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TA2AFourQuarkContraction<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().v1, par().v2, par().mf12};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TA2AFourQuarkContraction<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TA2AFourQuarkContraction<FImpl>::setup(void)
|
||||
{
|
||||
int nt = env().getDim(Tp);
|
||||
|
||||
envCreate(std::vector<PropagatorField>, getName(), 1, nt, envGetGrid(PropagatorField));
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TA2AFourQuarkContraction<FImpl>::execute(void)
|
||||
{
|
||||
int nt = env().getDim(Tp);
|
||||
|
||||
auto &v1 = envGet(std::vector<FermionField>, par().v1);
|
||||
auto &v2 = envGet(std::vector<FermionField>, par().v2);
|
||||
auto &mf12 = envGet(EigenDiskVector<Complex>, par().mf12);
|
||||
|
||||
auto &wwvv = envGet(std::vector<PropagatorField>, getName());
|
||||
|
||||
for (int t = 0; t < nt; t++)
|
||||
{
|
||||
wwvv[t] = zero;
|
||||
}
|
||||
|
||||
LOG(Message) << "Computing 4 quark contraction for: " << getName() << std::endl;
|
||||
A2Autils<FImpl>::ContractWWVV(wwvv, mf12, &v1[0], &v2[0]);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_A2AFourQuarkContraction_hpp_
|
7
Hadrons/Modules/MIO/LoadA2AMatrixDiskVector.cc
Normal file
7
Hadrons/Modules/MIO/LoadA2AMatrixDiskVector.cc
Normal file
@ -0,0 +1,7 @@
|
||||
#include <Hadrons/Modules/MIO/LoadA2AMatrixDiskVector.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MIO;
|
||||
|
||||
template class Grid::Hadrons::MIO::TLoadA2AMatrixDiskVector<FIMPL>;
|
115
Hadrons/Modules/MIO/LoadA2AMatrixDiskVector.hpp
Normal file
115
Hadrons/Modules/MIO/LoadA2AMatrixDiskVector.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
#ifndef Hadrons_MIO_LoadA2AMatrixDiskVector_hpp_
|
||||
#define Hadrons_MIO_LoadA2AMatrixDiskVector_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
#include <Hadrons/A2AMatrix.hpp>
|
||||
#include <Hadrons/DiskVector.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* LoadA2AMatrixDiskVector *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MIO)
|
||||
|
||||
class LoadA2AMatrixDiskVectorPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LoadA2AMatrixDiskVectorPar,
|
||||
std::string, file,
|
||||
std::string, dataset,
|
||||
std::string, diskVectorDir,
|
||||
int, cacheSize);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TLoadA2AMatrixDiskVector: public Module<LoadA2AMatrixDiskVectorPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl, );
|
||||
// constructor
|
||||
TLoadA2AMatrixDiskVector(const std::string name);
|
||||
// destructor
|
||||
virtual ~TLoadA2AMatrixDiskVector(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(LoadA2AMatrixDiskVector, TLoadA2AMatrixDiskVector<FIMPL>, MIO);
|
||||
|
||||
/******************************************************************************
|
||||
* TLoadA2AMatrixDiskVector implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TLoadA2AMatrixDiskVector<FImpl>::TLoadA2AMatrixDiskVector(const std::string name)
|
||||
: Module<LoadA2AMatrixDiskVectorPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TLoadA2AMatrixDiskVector<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TLoadA2AMatrixDiskVector<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TLoadA2AMatrixDiskVector<FImpl>::setup(void)
|
||||
{
|
||||
int Ls = 1;
|
||||
|
||||
std::string dvDir = par().diskVectorDir;
|
||||
std::string dataset = par().dataset;
|
||||
std::string dvFile = dvDir + "/" + getName() + "." + std::to_string(vm().getTrajectory());
|
||||
|
||||
int nt = env().getDim(Tp);
|
||||
int cacheSize = par().cacheSize;
|
||||
bool clean = true;
|
||||
GridBase *grid = envGetGrid(FermionField);
|
||||
|
||||
envCreate(EigenDiskVector<ComplexD>, getName(), Ls, dvFile, nt, cacheSize, clean, grid);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TLoadA2AMatrixDiskVector<FImpl>::execute(void)
|
||||
{
|
||||
int nt = env().getDim(Tp);
|
||||
std::string file = par().file;
|
||||
std::string dataset = par().dataset;
|
||||
GridBase *grid = envGetGrid(FermionField);
|
||||
|
||||
auto &mesonFieldDV = envGet(EigenDiskVector<ComplexD>, getName());
|
||||
|
||||
int traj = vm().getTrajectory();
|
||||
tokenReplace(file, "traj", traj);
|
||||
LOG(Message) << "-- Loading '" << file << "'-- " << std::endl;
|
||||
double t;
|
||||
A2AMatrixIo<HADRONS_A2AM_IO_TYPE> mfIO(file, dataset, nt);
|
||||
mfIO.load(mesonFieldDV, &t, grid);
|
||||
LOG(Message) << "Read " << mfIO.getSize() << " bytes in " << t << " usec, " << mfIO.getSize() / t * 1.0e6 / 1024 / 1024 << " MB/s" << std::endl;
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MIO_LoadA2AMatrixDiskVector_hpp_
|
Reference in New Issue
Block a user