1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-07 20:50: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>
#define KERNAME "_" + getName() + "_momKernel"
using namespace Grid;
using namespace Hadrons;
using namespace MScalar;
/******************************************************************************
* TFreeProp implementation *
* TFreeProp implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
TFreeProp::TFreeProp(const std::string name)
@ -30,6 +32,12 @@ std::vector<std::string> TFreeProp::getOutput(void)
// setup ///////////////////////////////////////////////////////////////////////
void TFreeProp::setup(void)
{
std::string kerName = KERNAME;
if (!env().hasRegisteredObject(kerName))
{
env().registerLattice<ScalarField>(kerName);
}
env().registerLattice<ScalarField>(getName());
}
@ -39,13 +47,13 @@ void TFreeProp::execute(void)
ScalarField &prop = *env().createLattice<ScalarField>(getName());
ScalarField &source = *env().getObject<ScalarField>(par().source);
ScalarField *momKernel;
std::string kerName = "_" + getName() + "_momKernel";
std::string kerName = KERNAME;
if (!env().hasCreatedObject(kerName))
{
LOG(Message) << "Caching momentum space free scalar propagator"
<< "(mass= " << par().mass << ")..." << std::endl;
momKernel = env().template createLattice<ScalarField>(kerName);
<< " (mass= " << par().mass << ")..." << std::endl;
momKernel = env().createLattice<ScalarField>(kerName);
Scalar<SIMPL>::MomentumSpacePropagator(*momKernel, par().mass);
}
else
@ -54,4 +62,20 @@ void TFreeProp::execute(void)
}
LOG(Message) << "Computing free scalar propagator..." << std::endl;
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
/******************************************************************************
* FreeProp *
* FreeProp *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MScalar)
@ -17,7 +17,8 @@ class FreePropPar: Serializable
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(FreePropPar,
std::string, source,
double, mass);
double, mass,
std::string, output);
};
class TFreeProp: public Module<FreePropPar>