1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-21 01:25:48 +01:00
Grid/lib/qcd/hmc/HMCModules.h

112 lines
3.0 KiB
C
Raw Normal View History

2016-12-22 12:41:56 +00:00
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/qcd/hmc/GenericHmcRunner.h
Copyright (C) 2015
Copyright (C) 2016
Author: Guido Cossu <guido.cossu@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution
directory
*************************************************************************************/
/* END LEGAL */
#ifndef GRID_HMC_MODULES
#define GRID_HMC_MODULES
2017-01-16 10:18:09 +00:00
2017-01-25 18:09:46 +00:00
#include "HMC_GridModules.h"
2016-12-22 12:41:56 +00:00
2017-01-25 18:09:46 +00:00
namespace Grid {
namespace QCD {
2017-01-09 11:06:18 +00:00
////////////////////////////////////////////////////////////////////
struct RNGModuleParameters: Serializable {
2017-01-16 10:18:09 +00:00
GRID_SERIALIZABLE_CLASS_MEMBERS(RNGModuleParameters,
std::string, serial_seeds,
std::string, parallel_seeds,);
2017-01-09 11:06:18 +00:00
std::vector<int> getSerialSeeds(){return strToVec<int>(serial_seeds);}
std::vector<int> getParallelSeeds(){return strToVec<int>(parallel_seeds);}
2017-01-09 11:06:18 +00:00
RNGModuleParameters(): serial_seeds("1"), parallel_seeds("1"){}
2017-01-09 11:06:18 +00:00
2017-01-16 10:18:09 +00:00
template <class ReaderClass >
RNGModuleParameters(Reader<ReaderClass>& Reader){
read(Reader, "RandomNumberGenerator", *this);
2017-01-09 11:06:18 +00:00
}
2017-01-16 10:18:09 +00:00
2017-01-09 11:06:18 +00:00
};
2017-01-16 10:18:09 +00:00
// Random number generators module
2016-12-22 12:41:56 +00:00
class RNGModule{
GridSerialRNG sRNG_;
std::unique_ptr<GridParallelRNG> pRNG_;
2017-01-09 11:06:18 +00:00
RNGModuleParameters Params_;
2016-12-22 12:41:56 +00:00
public:
2017-01-09 11:06:18 +00:00
RNGModule(){};
void set_pRNG(GridParallelRNG* pRNG){
pRNG_.reset(pRNG);
}
2017-01-16 10:18:09 +00:00
void set_RNGSeeds(RNGModuleParameters& Params) {
Params_ = Params;
2017-01-09 11:06:18 +00:00
}
2017-01-16 10:18:09 +00:00
GridSerialRNG& get_sRNG() { return sRNG_; }
GridParallelRNG& get_pRNG() { return *pRNG_.get(); }
2017-01-09 11:06:18 +00:00
2017-01-16 10:18:09 +00:00
void seed() {
auto SerialSeeds = Params_.getSerialSeeds();
auto ParallelSeeds = Params_.getParallelSeeds();
if (SerialSeeds.size() == 0 && ParallelSeeds.size() == 0) {
std::cout << GridLogError << "Seeds not initialized" << std::endl;
2017-01-09 11:06:18 +00:00
exit(1);
}
sRNG_.SeedFixedIntegers(SerialSeeds);
pRNG_->SeedFixedIntegers(ParallelSeeds);
2016-12-22 12:41:56 +00:00
}
};
/*
2017-01-09 11:06:18 +00:00
///////////////////////////////////////////////////////////////////
2017-01-05 13:09:32 +00:00
/// Smearing module
template <class ImplementationPolicy>
class SmearingModule{
virtual void get_smearing();
};
template <class ImplementationPolicy>
class StoutSmearingModule: public SmearingModule<ImplementationPolicy>{
SmearedConfiguration<ImplementationPolicy> SmearingPolicy;
};
*/
2017-01-09 11:06:18 +00:00
2016-12-22 12:41:56 +00:00
} // namespace QCD
} // namespace Grid
#endif // GRID_HMC_MODULES