From febe41cc1d5832869fbc71fd97beb6e3a46a5065 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 23 Oct 2018 12:48:15 +0100 Subject: [PATCH] Hadrons: improvement on PR #176 --- Hadrons/DilutedNoise.hpp | 29 ++++--------------- .../MNoise/FullVolumeSpinColorDiagonal.hpp | 2 +- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/Hadrons/DilutedNoise.hpp b/Hadrons/DilutedNoise.hpp index 9440eb74..1eb7ff40 100644 --- a/Hadrons/DilutedNoise.hpp +++ b/Hadrons/DilutedNoise.hpp @@ -56,7 +56,6 @@ public: GridCartesian *getGrid(void) const; // generate noise (pure virtual) virtual void generateNoise(GridParallelRNG &rng) = 0; - virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src) = 0; private: std::vector noise_; GridCartesian *grid_; @@ -74,7 +73,6 @@ public: virtual ~TimeDilutedSpinColorDiagonalNoise(void) = default; // generate noise virtual void generateNoise(GridParallelRNG &rng); - virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src); private: unsigned int nt_; }; @@ -90,9 +88,8 @@ public: virtual ~FullVolumeSpinColorDiagonalNoise(void) = default; // generate noise virtual void generateNoise(GridParallelRNG &rng); - virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src); -public: - unsigned int n_src; +private: + unsigned int nSrc_; }; @@ -206,31 +203,17 @@ void TimeDilutedSpinColorDiagonalNoise::generateNoise(GridParallelRNG &rn } } -template -void TimeDilutedSpinColorDiagonalNoise::generateNoise(GridParallelRNG &rng, unsigned int n_src) -{ - assert(0); -} - /****************************************************************************** * FullVolumeSpinColorDiagonalNoise template implementation * ******************************************************************************/ template FullVolumeSpinColorDiagonalNoise:: -FullVolumeSpinColorDiagonalNoise(GridCartesian *g, unsigned int n_src) -: DilutedNoise(g) -{ - this->resize(n_src*Ns*FImpl::Dimension); -} +FullVolumeSpinColorDiagonalNoise(GridCartesian *g, unsigned int nSrc) +: DilutedNoise(g, nSrc*Ns*FImpl::Dimension), nSrc_(nSrc) +{} template void FullVolumeSpinColorDiagonalNoise::generateNoise(GridParallelRNG &rng) -{ - assert(0); -} - -template -void FullVolumeSpinColorDiagonalNoise::generateNoise(GridParallelRNG &rng,unsigned int n_src) { typedef decltype(peekColour((*this)[0], 0)) SpinField; @@ -245,7 +228,7 @@ void FullVolumeSpinColorDiagonalNoise::generateNoise(GridParallelRNG &rng bernoulli(rng, eta); eta = (2.*eta - shift)*(1./::sqrt(2.)); - for (unsigned int n = 0; n < n_src; ++n) + for (unsigned int n = 0; n < nSrc_; ++n) { for (unsigned int s = 0; s < Ns; ++s) { diff --git a/Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp b/Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp index 3a4cc639..93990882 100644 --- a/Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp +++ b/Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp @@ -111,7 +111,7 @@ void TFullVolumeSpinColorDiagonal::execute(void) { auto &noise = envGet(DilutedNoise, getName()); LOG(Message) << "Generating full volume, spin-color diagonal noise" << std::endl; - noise.generateNoise(rng4d(),par().nsrc); + noise.generateNoise(rng4d()); } END_MODULE_NAMESPACE