Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr.h
Go to the documentation of this file.
1 
14 #ifndef FOPR_INCLUDED
15 #define FOPR_INCLUDED
16 
17 #include "Field/field_F.h"
18 #include "Parameters/parameters.h"
19 
20 #include "IO/bridgeIO.h"
21 using Bridge::vout;
22 
23 #ifdef USE_FACTORY
24 #include "Tools/factory.h"
25 #include "Tools/director.h"
26 #endif
27 
28 
30 
46 class Fopr
47 {
48  public:
49  Fopr()
50  : m_vl(CommonParameters::Vlevel()) {}
51 
52  virtual ~Fopr() {}
53 
54  private:
55  // non-copyable
56  Fopr(const Fopr&);
57  Fopr& operator=(const Fopr&);
58 
59  public:
60  virtual void set_parameters(const Parameters&) = 0;
61 
63 
65  virtual void set_config(Field *) = 0;
66  virtual void set_config(unique_ptr<Field_G>&) = 0;
67 
69  // and set the resultant field to the 1st argument.
70  virtual void mult(Field&, const Field&) = 0;
71 
73  virtual void mult_dag(Field&, const Field&) {}
74 
76  virtual void mult_gm5(Field&, const Field&)
77  {
78  vout.crucial(m_vl, "Fopr: mult_gm5 not implemented.\n");
79  exit(EXIT_FAILURE);
80  }
81 
83  virtual void mult(Field&, const Field&, const std::string mode) {}
84 
86  virtual void mult_dag(Field&, const Field&, const std::string mode) {}
87 
89  virtual void mult_up(const int mu, Field&, const Field&) {}
90  virtual void mult_dn(const int mu, Field&, const Field&) {}
91 
94  virtual void set_mode(const std::string mode)
95  {
96  vout.general(m_vl, "Fopr: set_mode not implemented.\n");
97  exit(EXIT_FAILURE);
98  }
99 
101  // virtual void set_lowmodes(int Nsbt, std::vector<double> *ev,
102  // std::vector<Field> *vk);
103 
104  virtual std::string get_mode() const
105  {
106  vout.general(m_vl, "Fopr: get_mode not implemented.\n");
107  return std::string();
108  }
109 
111  virtual int field_nvol() = 0;
112 
114  virtual int field_nin() = 0;
115 
117  virtual int field_nex() = 0;
118 
120  virtual double flop_count() { return 0.0; }
121 
123  virtual double flop_count(const std::string mode)
124  { return 0; }
125 
126  protected:
128 
129 
130 #ifdef USE_FACTORY
131  public:
132  typedef Fopr *(*ProductCreator_noarg)();
133  typedef Fopr *(*ProductCreator_fopr)(Fopr *fopr);
134  typedef Fopr *(*ProductCreator_fopr_director)(Fopr *fopr, Director *director);
135  typedef Fopr *(*ProductCreator_string)(const std::string& arg);
136 
137  typedef FactoryTemplate<Fopr, ProductCreator_noarg> Factory_noarg;
138  typedef FactoryTemplate<Fopr, ProductCreator_fopr> Factory_fopr;
139  typedef FactoryTemplate<Fopr, ProductCreator_fopr_director> Factory_fopr_director;
140  typedef FactoryTemplate<Fopr, ProductCreator_string> Factory_string;
141 
142  static Fopr *New(const IdentifierType& subtype)
143  {
144  ProductCreator_noarg p = Factory_noarg::Find(subtype);
145 
146  return p ? (*p)() : 0;
147  }
148 
149  static Fopr *New(const IdentifierType& subtype, Fopr *fopr)
150  {
151  ProductCreator_fopr p = Factory_fopr::Find(subtype);
152 
153  return p ? (*p)(fopr) : 0;
154  }
155 
156  static Fopr *New(const IdentifierType& subtype, unique_ptr<Fopr>& fopr)
157  {
158  ProductCreator_fopr p = Factory_fopr::Find(subtype);
159 
160  return p ? (*p)(fopr.get()) : 0;
161  }
162 
163  static Fopr *New(const IdentifierType& subtype, Fopr *fopr, Director *director)
164  {
165  ProductCreator_fopr_director p = Factory_fopr_director::Find(subtype);
166 
167  return p ? (*p)(fopr, director) : 0;
168  }
169 
170  static Fopr *New(const IdentifierType& subtype, unique_ptr<Fopr>& fopr, unique_ptr<Director>& director)
171  {
172  ProductCreator_fopr_director p = Factory_fopr_director::Find(subtype);
173 
174  return p ? (*p)(fopr.get(), director.get()) : 0;
175  }
176 
177  static Fopr *New(const IdentifierType& subtype, const std::string& arg)
178  {
179  ProductCreator_string p = Factory_string::Find(subtype);
180 
181  return p ? (*p)(arg) : 0;
182  }
183 
184 #ifdef USE_FACTORY_AUTOREGISTER
185 #else
186  static bool init_factory();
187 #endif
188 #endif
189 };
190 #endif
BridgeIO vout
Definition: bridgeIO.cpp:503
void general(const char *format,...)
Definition: bridgeIO.cpp:197
virtual void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr.h:94
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Container of Field-type object.
Definition: field.h:45
virtual void mult_gm5(Field &, const Field &)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Definition: fopr.h:76
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
Definition: fopr.h:62
Class for parameters.
Definition: parameters.h:46
virtual void mult_dag(Field &, const Field &, const std::string mode)
execute mult_dag with specified mode (unchanging internal mode). [23 May 2016 H.Matsufuru].
Definition: fopr.h:86
virtual int field_nin()=0
returns the on-site d.o.f. for which the fermion operator is defined.
Manager of commonly used data object in HMC.
Definition: director.h:37
Fopr()
Definition: fopr.h:49
virtual void mult(Field &, const Field &, const std::string mode)
execute mult with specified mode (unchanging internal mode). [23 May 2016 H.Matsufuru].
Definition: fopr.h:83
Bridge::VerboseLevel m_vl
Definition: fopr.h:127
virtual double flop_count()
returns the flop in giga unit
Definition: fopr.h:120
virtual std::string get_mode() const
only for Fopr_Overlap
Definition: fopr.h:104
pointer get() const
virtual int field_nex()=0
returns the external d.o.f. for which the fermion operator is defined.
virtual void mult_dn(const int mu, Field &, const Field &)
Definition: fopr.h:90
Common parameter class: provides parameters as singleton.
virtual void set_parameters(const Parameters &)=0
virtual void mult_up(const int mu, Field &, const Field &)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
Definition: fopr.h:89
virtual double flop_count(const std::string mode)
returns the flop in giga unit for a specified mode. [23 May 2016 H.Matsufuru]
Definition: fopr.h:123
Fopr & operator=(const Fopr &)
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
virtual ~Fopr()
Definition: fopr.h:52
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
std::string IdentifierType
Factory template class.
Definition: factory.h:39
virtual void mult_dag(Field &, const Field &)
hermitian conjugate of mult(Field&, const Field&).
Definition: fopr.h:73
Base class of fermion operator family.
Definition: fopr.h:46
virtual int field_nvol()=0
returns the volume for which the fermion operator is defined.