1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 13:40:46 +01:00

Hadrons: free scalar buffer fix and output

This commit is contained in:
Antonin Portelli 2017-01-05 14:58:55 +00:00
parent 82b3f54697
commit 97843e2b58
2 changed files with 32 additions and 7 deletions

View File

@ -1,11 +1,13 @@
#include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp> #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp>
#define KERNAME "_" + getName() + "_momKernel"
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MScalar; using namespace MScalar;
/****************************************************************************** /******************************************************************************
* TFreeProp implementation * * TFreeProp implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
TFreeProp::TFreeProp(const std::string name) TFreeProp::TFreeProp(const std::string name)
@ -30,6 +32,12 @@ std::vector<std::string> TFreeProp::getOutput(void)
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void TFreeProp::setup(void) void TFreeProp::setup(void)
{ {
std::string kerName = KERNAME;
if (!env().hasRegisteredObject(kerName))
{
env().registerLattice<ScalarField>(kerName);
}
env().registerLattice<ScalarField>(getName()); env().registerLattice<ScalarField>(getName());
} }
@ -39,13 +47,13 @@ void TFreeProp::execute(void)
ScalarField &prop = *env().createLattice<ScalarField>(getName()); ScalarField &prop = *env().createLattice<ScalarField>(getName());
ScalarField &source = *env().getObject<ScalarField>(par().source); ScalarField &source = *env().getObject<ScalarField>(par().source);
ScalarField *momKernel; ScalarField *momKernel;
std::string kerName = "_" + getName() + "_momKernel"; std::string kerName = KERNAME;
if (!env().hasCreatedObject(kerName)) if (!env().hasCreatedObject(kerName))
{ {
LOG(Message) << "Caching momentum space free scalar propagator" LOG(Message) << "Caching momentum space free scalar propagator"
<< "(mass= " << par().mass << ")..." << std::endl; << " (mass= " << par().mass << ")..." << std::endl;
momKernel = env().template createLattice<ScalarField>(kerName); momKernel = env().createLattice<ScalarField>(kerName);
Scalar<SIMPL>::MomentumSpacePropagator(*momKernel, par().mass); Scalar<SIMPL>::MomentumSpacePropagator(*momKernel, par().mass);
} }
else else
@ -54,4 +62,20 @@ void TFreeProp::execute(void)
} }
LOG(Message) << "Computing free scalar propagator..." << std::endl; LOG(Message) << "Computing free scalar propagator..." << std::endl;
Scalar<SIMPL>::FreePropagator(source, prop, *momKernel); Scalar<SIMPL>::FreePropagator(source, prop, *momKernel);
if (!par().output.empty())
{
TextWriter writer(par().output + "." +
std::to_string(env().getTrajectory()));
std::vector<TComplex> buf;
std::vector<Complex> result;
sliceSum(prop, buf, Tp);
result.resize(buf.size());
for (unsigned int t = 0; t < buf.size(); ++t)
{
result[t] = TensorRemove(buf[t]);
}
write(writer, "prop", result);
}
} }

View File

@ -8,7 +8,7 @@
BEGIN_HADRONS_NAMESPACE BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* FreeProp * * FreeProp *
******************************************************************************/ ******************************************************************************/
BEGIN_MODULE_NAMESPACE(MScalar) BEGIN_MODULE_NAMESPACE(MScalar)
@ -17,7 +17,8 @@ class FreePropPar: Serializable
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(FreePropPar, GRID_SERIALIZABLE_CLASS_MEMBERS(FreePropPar,
std::string, source, std::string, source,
double, mass); double, mass,
std::string, output);
}; };
class TFreeProp: public Module<FreePropPar> class TFreeProp: public Module<FreePropPar>