Grid 0.7.0
ObservableModules.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/modules/ObservableModules.h
6
7Copyright (C) 2016
8
9Author: Guido Cossu <guido.cossu@ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#ifndef HMC_OBSERVABLE_MODULES_H
30#define HMC_OBSERVABLE_MODULES_H
31
33
35// Observables
37template <class ObservableType, class OPar>
39 : public Parametrized<OPar>,
40 public HMCModuleBase< HmcObservable<typename ObservableType::Field> > {
41public:
43 typedef typename Base::Product Product;
44 typedef OPar Parameters;
45
46 std::unique_ptr<ObservableType> ObservablePtr;
47
48 ObservableModule(OPar Par) : Parametrized<OPar>(Par) {}
49
53
54 template <class ReaderClass>
55 ObservableModule(Reader<ReaderClass>& Reader) : Parametrized<OPar>(Reader){};
56
59
60 return ObservablePtr.get();
61 }
62
63private:
64 virtual void initialize() = 0;
65};
66
67
68
70// Modules
72
74class PlaquetteObsParameters : Serializable {
75public:
77 std::string, output_prefix);
78};
79
80template < class Impl >
81class PlaquetteMod: public ObservableModule<PlaquetteLogger<Impl>, NoParameters>{
83 using ObsBase::ObsBase; // for constructors
84
85 // acquire resource
86 virtual void initialize(){
87 this->ObservablePtr.reset(new PlaquetteLogger<Impl>());
88 }
89public:
91};
92
93template < class Impl >
94class PolyakovMod: public ObservableModule<PolyakovLogger<Impl>, NoParameters>{
96 using ObsBase::ObsBase; // for constructors
97
98 // acquire resource
99 virtual void initialize(){
100 this->ObservablePtr.reset(new PolyakovLogger<Impl>());
101 }
102 public:
104};
105
106template < class Impl >
107class SpatialPolyakovMod: public ObservableModule<SpatialPolyakovLogger<Impl>, NoParameters>{
109 using ObsBase::ObsBase; // for constructors
110
111 // acquire resource
112 virtual void initialize(){
114 }
115 public:
117};
118
119template < class Impl >
120class TopologicalChargeMod: public ObservableModule<TopologicalCharge<Impl>, TopologyObsParameters>{
122 using ObsBase::ObsBase; // for constructors
123
124 // acquire resource
125 virtual void initialize(){
126 this->ObservablePtr.reset(new TopologicalCharge<Impl>(this->Par_));
127 }
128public:
131};
132
134// Factories specialisations
136// explicit ref to LatticeGaugeField must be changed or put in the factory
137//typedef HMCModuleBase< HmcObservable<LatticeGaugeField> > HMC_ObsModBase;
138
139template <char const *str, class Field, class ReaderClass >
141 : public Factory < HMCModuleBase< HmcObservable<Field> >, Reader<ReaderClass> > {
142public:
143 typedef Reader<ReaderClass> TheReader;
144 // use SINGLETON FUNCTOR MACRO HERE
149 return e;
150 }
151
152private:
154 std::string obj_type() const {
155 return std::string(str);
156 }
157};
158
159extern char observable_string[];
160
162
163#endif //HMC_OBSERVABLE_MODULES_H
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
char observable_string[]
HmcObservable< typename ObservableType::Field > Product
Definition Modules.h:97
Reader< ReaderClass > TheReader
HMC_ObservablesModuleFactory(const HMC_ObservablesModuleFactory &e)=delete
static HMC_ObservablesModuleFactory & getInstance(void)
HMC_ObservablesModuleFactory(void)=default
void operator=(const HMC_ObservablesModuleFactory &e)=delete
Base::Product Product
virtual void initialize()=0
std::unique_ptr< PlaquetteLogger< Impl > > ObservablePtr
virtual void print_parameters()
ObservableModule(Reader< ReaderClass > &Reader)
HMCModuleBase< HmcObservable< typename ObservableType::Field > > Base
Parametrized(Parameters Par)
Definition Modules.h:78
void print_parameters()
Definition Modules.h:62
Parametrized(Parameters Par)
Definition Modules.h:51
ObservableModule< PlaquetteLogger< Impl >, NoParameters > ObsBase
virtual void initialize()
GRID_SERIALIZABLE_CLASS_MEMBERS(PlaquetteObsParameters, std::string, output_prefix)
virtual void initialize()
ObservableModule< PolyakovLogger< Impl >, NoParameters > ObsBase
ObservableModule< SpatialPolyakovLogger< Impl >, NoParameters > ObsBase
virtual void initialize()
TopologicalChargeMod(TopologyObsParameters Par)
ObservableModule< TopologicalCharge< Impl >, TopologyObsParameters > ObsBase