Grid 0.7.0
HMCRunnerModule.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/hmc/GenericHmcRunner.h
6
7Copyright (C) 2015
8Copyright (C) 2016
9
10Author: Guido Cossu <guido.cossu@ed.ac.uk>
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2 of the License, or
15(at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along
23with this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26See the full license in the file "LICENSE" in the top level distribution
27directory
28*************************************************************************************/
29 /* END LEGAL */
30#ifndef HMC_RUNNER_MODULE
31#define HMC_RUNNER_MODULE
32
34
35// the reader class is necessary here for the automatic initialization of the resources
36// if we had a virtual reader would have been unecessary
37template <class HMCType, class ReaderClass >
39 : public Parametrized< HMCparameters >,
40 public HMCModuleBase< HMCRunnerBase<ReaderClass> > {
41public:
43 typedef typename Base::Product Product;
44
45 std::unique_ptr<HMCType> HMCPtr;
46
48
49 template <class ReaderCl>
50 HMCModule(Reader<ReaderCl>& R) : Parametrized<HMCparameters>(R, "HMC"){};
51
53 if (!HMCPtr) initialize();
54
55 return HMCPtr.get();
56 }
57
58private:
59 virtual void initialize() = 0;
60};
61
62// Factory
63template <char const *str, class ReaderClass >
65 : public Factory < HMCModuleBase< HMCRunnerBase<ReaderClass> > , Reader<ReaderClass> > {
66public:
67 typedef Reader<ReaderClass> TheReader;
68 // use SINGLETON FUNCTOR MACRO HERE
70 void operator=(const HMCRunnerModuleFactory& e) = delete;
73 return e;
74 }
75
76private:
77 HMCRunnerModuleFactory(void) = default;
78 std::string obj_type() const {
79 return std::string(str);
80 }
81};
82
83
84
85
86
88// macro for these
89
90template < class ImplementationPolicy, class RepresentationPolicy, class ReaderClass >
91class HMCLeapFrog: public HMCModule< GenericHMCRunnerTemplate<ImplementationPolicy, RepresentationPolicy, LeapFrog>, ReaderClass >{
93 using HMCBaseMod::HMCBaseMod;
94
95 // aquire resource
99};
100
101template < class ImplementationPolicy, class RepresentationPolicy, class ReaderClass >
102class HMCMinimumNorm2: public HMCModule< GenericHMCRunnerTemplate<ImplementationPolicy, RepresentationPolicy, MinimumNorm2>, ReaderClass >{
104 using HMCBaseMod::HMCBaseMod;
105
106 // aquire resource
110};
111
112
113template < class ImplementationPolicy, class RepresentationPolicy, class ReaderClass >
114class HMCForceGradient: public HMCModule< GenericHMCRunnerTemplate<ImplementationPolicy, RepresentationPolicy, ForceGradient>, ReaderClass >{
116 using HMCBaseMod::HMCBaseMod;
117
118 // aquire resource
122};
123
124extern char hmc_string[];
125
127
129
130#endif
HMCWrapperTemplate< Implementation, Integrator, RepresentationsPolicy > GenericHMCRunnerTemplate
char hmc_string[]
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
HMCModule< GenericHMCRunnerTemplate< ImplementationPolicy, RepresentationPolicy, ForceGradient >, ReaderClass > HMCBaseMod
virtual void initialize()
HMCModule< GenericHMCRunnerTemplate< ImplementationPolicy, RepresentationPolicy, LeapFrog >, ReaderClass > HMCBaseMod
virtual void initialize()
HMCModule< GenericHMCRunnerTemplate< ImplementationPolicy, RepresentationPolicy, MinimumNorm2 >, ReaderClass > HMCBaseMod
virtual void initialize()
HMCRunnerBase< ReaderClass > Product
Definition Modules.h:97
HMCModule(Reader< ReaderCl > &R)
std::unique_ptr< GenericHMCRunnerTemplate< ImplementationPolicy, RepresentationPolicy, LeapFrog > > HMCPtr
HMCModule(HMCparameters Par)
Product * getPtr()
virtual void initialize()=0
HMCModuleBase< HMCRunnerBase< ReaderClass > > Base
Base::Product Product
Reader< ReaderClass > TheReader
HMCRunnerModuleFactory(const HMCRunnerModuleFactory &e)=delete
static HMCRunnerModuleFactory & getInstance(void)
void operator=(const HMCRunnerModuleFactory &e)=delete
HMCRunnerModuleFactory(void)=default
std::string obj_type() const
Parametrized(Parameters Par)
Definition Modules.h:51