diff --git a/programs/Hadrons/Application.cc b/programs/Hadrons/Application.cc index 5eb43363..00ca8f61 100644 --- a/programs/Hadrons/Application.cc +++ b/programs/Hadrons/Application.cc @@ -156,6 +156,7 @@ void Application::configLoop(void) { LOG(Message) << "Starting measurement for trajectory " << t << std::endl; + env_.loadUnitGauge(); execute(program_); env_.freeAll(); } diff --git a/programs/Hadrons/Environment.cc b/programs/Hadrons/Environment.cc index fb9052f0..ac7c81fa 100644 --- a/programs/Hadrons/Environment.cc +++ b/programs/Hadrons/Environment.cc @@ -29,9 +29,15 @@ using namespace Hadrons; // constructor ///////////////////////////////////////////////////////////////// Environment::Environment(void) { + std::vector seed4d({1,2,3,4}); + grid4d_.reset(SpaceTimeGrid::makeFourDimGrid( GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), GridDefaultMpi())); + gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get())); + rng4d_.reset(new GridParallelRNG(grid4d_.get())); + rng4d_->SeedFixedIntegers(seed4d); + gauge_.reset(new LatticeGaugeField(grid4d_.get())); } // dry run ///////////////////////////////////////////////////////////////////// @@ -45,30 +51,67 @@ bool Environment::isDryRun(void) return dryRun_; } +// grids /////////////////////////////////////////////////////////////////////// +GridCartesian * Environment::get4dGrid(void) +{ + return grid4d_.get(); +} + +GridRedBlackCartesian * Environment::getRb4dGrid(void) +{ + return gridRb4d_.get(); +} + +GridCartesian * Environment::get5dGrid(const unsigned int Ls) +{ + try + { + return grid5d_.at(Ls).get(); + } + catch(std::out_of_range &) + { + HADRON_ERROR("no 5D grid with Ls= " << Ls); + } +} + +GridRedBlackCartesian * Environment::getRb5dGrid(const unsigned int Ls) +{ + try + { + return gridRb5d_.at(Ls).get(); + } + catch(std::out_of_range &) + { + HADRON_ERROR("no red-black 5D grid with Ls= " << Ls); + } +} + // quark propagators /////////////////////////////////////////////////////////// void Environment::addProp(const std::string name, const unsigned int Ls) { + GridCartesian *p4 = grid4d_.get(); + if (propExists(name)) { HADRON_ERROR("propagator '" + name + "' already exists"); } if (Ls > 1) { - GridCartesian *pt; + GridCartesian *p; try { - pt = grid5d_.at(Ls).get(); + p = grid5d_.at(Ls).get(); } catch(std::out_of_range &) { - grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, - grid4d_.get())); - pt = grid5d_[Ls].get(); + grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, p4)); + gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, p4)); + p = grid5d_[Ls].get(); } if (!isDryRun()) { - prop_[name].reset(new LatticePropagator(pt)); + prop_[name].reset(new LatticePropagator(p)); } else { @@ -80,7 +123,7 @@ void Environment::addProp(const std::string name, const unsigned int Ls) { if (!isDryRun()) { - prop_[name].reset(new LatticePropagator(grid4d_.get())); + prop_[name].reset(new LatticePropagator(p4)); } else { @@ -143,6 +186,22 @@ unsigned int Environment::nProp(void) return size; } +// gauge configuration ///////////////////////////////////////////////////////// +LatticeGaugeField * Environment::getGauge(void) +{ + return gauge_.get(); +} + +void Environment::loadUnitGauge(void) +{ + SU3::ColdConfiguration(*rng4d_, *gauge_); +} + +void Environment::loadRandomGauge(void) +{ + SU3::HotConfiguration(*rng4d_, *gauge_); +} + // general free //////////////////////////////////////////////////////////////// void Environment::free(const std::string name) { diff --git a/programs/Hadrons/Environment.hpp b/programs/Hadrons/Environment.hpp index 66576658..17ca462d 100644 --- a/programs/Hadrons/Environment.hpp +++ b/programs/Hadrons/Environment.hpp @@ -31,28 +31,45 @@ class Environment { SINGLETON(Environment); public: - typedef std::unique_ptr GridPt; - typedef std::unique_ptr PropPt; + typedef std::unique_ptr GridPt; + typedef std::unique_ptr GridRbPt; + typedef std::unique_ptr RngPt; + typedef std::unique_ptr PropPt; + typedef std::unique_ptr GaugePt; public: // dry run - void dryRun(const bool isDry); - bool isDryRun(void); + void dryRun(const bool isDry); + bool isDryRun(void); + // grids + GridCartesian * get4dGrid(void); + GridRedBlackCartesian * getRb4dGrid(void); + GridCartesian * get5dGrid(const unsigned int Ls); + GridRedBlackCartesian * getRb5dGrid(const unsigned int Ls); // quark propagators - void addProp(const std::string name, - const unsigned int Ls = 1); - void freeProp(const std::string name); - LatticePropagator * getProp(const std::string name); - bool propExists(const std::string name); - unsigned int nProp(void); + void addProp(const std::string name, + const unsigned int Ls = 1); + void freeProp(const std::string name); + LatticePropagator * getProp(const std::string name); + bool propExists(const std::string name); + unsigned int nProp(void); + // gauge configuration + LatticeGaugeField * getGauge(void); + void loadUnitGauge(void); + void loadRandomGauge(void); // general free - void free(const std::string name); - void freeAll(void); + void free(const std::string name); + void freeAll(void); private: bool dryRun_{false}; GridPt grid4d_; std::map grid5d_; + GridRbPt gridRb4d_; + std::map gridRb5d_; + RngPt rng4d_; std::map prop_; std::map propSize_; + GaugePt gauge_; + }; END_HADRONS_NAMESPACE diff --git a/programs/Hadrons/MQuark.cc b/programs/Hadrons/MQuark.cc index f2ae3ee9..c328e3a8 100644 --- a/programs/Hadrons/MQuark.cc +++ b/programs/Hadrons/MQuark.cc @@ -66,4 +66,20 @@ void MQuark::execute(Environment &env) { LOG(Message) << "computing quark propagator '" << getName() << "'" << std::endl; + + GridCartesian *g4d = env.get4dGrid(), + *g5d = env.get5dGrid(par_.Ls); + GridRedBlackCartesian *gRb4d = env.getRb4dGrid(), + *gRb5d = env.getRb5dGrid(par_.Ls); + LatticeGaugeField &Umu = *env.getGauge(); + LatticeFermion src(g5d); src=zero; + LatticeFermion result(g5d); result=zero; + + RealD mass=0.1; + RealD M5=1.8; + DomainWallFermionR Ddwf(Umu, *g5d, *gRb5d, *g4d, *gRb4d, mass, M5); + + ConjugateGradient CG(1.0e-8,10000); + SchurRedBlackDiagMooeeSolve SchurSolver(CG); + SchurSolver(Ddwf,src,result); }