1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00
Grid/lib/qcd/hmc/NerscCheckpointer.h
paboyle 5a80930dd2 Charge conjugation boundary conditions for gauge fields implemented as a policy
class, changing the nature of covariant Cshifts used in
plaquettes, rectangles and staples.

As a result same code is used for the plaq and rect action independent of the BC type.

Should probably isolate the BC in a separate class that Gimpl takes as a template param.
Do the same with smearing policies.

This would then allow composition of BC with smearing etc....
2016-01-02 13:37:25 +00:00

54 lines
1.5 KiB
C++

#ifndef NERSC_CHECKPOINTER
#define NERSC_CHECKPOINTER
#include <string>
#include <iostream>
#include <sstream>
namespace Grid{
namespace QCD{
template<class Gimpl>
class NerscHmcCheckpointer : public HmcObservable<typename Gimpl::GaugeField> {
private:
std::string configStem;
std::string rngStem;
int SaveInterval;
public:
INHERIT_GIMPL_TYPES(Gimpl);
NerscHmcCheckpointer(std::string cf, std::string rn,int savemodulo) {
configStem = cf;
rngStem = rn;
SaveInterval= savemodulo;
};
void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG )
{
if ( (traj % SaveInterval)== 0 ) {
std::string rng; { std::ostringstream os; os << rngStem <<"."<< traj; rng = os.str(); }
std::string config;{ std::ostringstream os; os << configStem <<"."<< traj; config = os.str();}
int precision32=1;
int tworow =0;
NerscIO::writeRNGState(sRNG,pRNG,rng);
NerscIO::writeConfiguration(U,config,tworow,precision32);
}
};
void CheckpointRestore(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG ){
std::string rng; { std::ostringstream os; os << rngStem <<"."<< traj; rng = os.str(); }
std::string config;{ std::ostringstream os; os << configStem <<"."<< traj; config = os.str();}
NerscField header;
NerscIO::readRNGState(sRNG,pRNG,header,rng);
NerscIO::readConfiguration(U,header,config);
};
};
}}
#endif