Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
field_F.h
Go to the documentation of this file.
1 
14 #ifndef FIELD_F_INCLUDED
15 #define FIELD_F_INCLUDED
16 
17 #include "field_G.h"
18 #include "Tools/vec_SU_N.h"
19 #include "Tools/gammaMatrix.h"
21 
22 #include "IO/bridgeIO.h"
23 using Bridge::vout;
24 
26 
37 class Field_F : public Field
38 {
39  private:
40  int m_Nc; // num of the color elements
41  int m_Nc2; // num of the double color elements
42  int m_Nd; // num of the spinor elements
43 
44  inline
45  int myindex(const int c2, const int s, const int site, const int ex)
46  const
47  {
48  return Field::myindex(c2 + m_Nc2 * s, site, ex);
49  }
50 
51  public:
52 
53  explicit
54  Field_F(const int Nvol = CommonParameters::Nvol(), const int Nex = 1) :
55  Field(2 * CommonParameters::Nc() * CommonParameters::Nd(),
56  Nvol, Nex, Element_type::COMPLEX),
57  m_Nc(CommonParameters::Nc()),
58  m_Nc2(2 * CommonParameters::Nc()),
59  m_Nd(CommonParameters::Nd())
60  {
61  check();
62  }
63 
64  Field_F clone() const
65  {
66  return Field_F(nvol(), nex());
67  }
68 
69  // conversion from Field type
70 
71  Field_F(const Field& x) :
72  Field(x),
73  m_Nc(CommonParameters::Nc()),
74  m_Nc2(2 * CommonParameters::Nc()),
75  m_Nd(CommonParameters::Nd())
76  {
77  check();
78  }
79 
80  void reset(int Nvol, int Nex)
81  {
82  Field::reset(m_Nc2 * m_Nd, Nvol, Nex);
83  }
84 
85  // assignment
86  //Field_F& operator=(const double a) { field = a; return *this; }
87  Field_F& operator=(const Field_F& v) { copy(*this, v); return *this; }
88 
89  int nc() const { return m_Nc; }
90  int nc2() const { return m_Nc2; }
91  int nd() const { return m_Nd; }
92 
93  // accessors
94  double cmp_r(const int cc, const int s, const int site, const int e = 0)
95  const
96  {
97  return field[myindex(2 * cc, s, site, e)];
98  }
99 
100  double cmp_i(const int cc, const int s, const int site, const int e = 0)
101  const
102  {
103  return field[myindex(2 * cc + 1, s, site, e)];
104  }
105 
106  void set_r(const int cc, const int s, const int site, const int e, const double re)
107  {
108  field[myindex(2 * cc, s, site, e)] = re;
109  }
110 
111  void set_i(const int cc, const int s, const int site, const int e, const double im)
112  {
113  field[myindex(2 * cc + 1, s, site, e)] = im;
114  }
115 
116  void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
117  {
118  field[myindex(2 * cc, s, site, e)] = re;
119  field[myindex(2 * cc + 1, s, site, e)] = im;
120  }
121 
122  Vec_SU_N vec(const int s, const int site, const int e = 0) const
123  {
124  Vec_SU_N Tmp;
125 
126  for (int cc = 0; cc < m_Nc; ++cc) {
127  Tmp.set(cc,
128  field[myindex(2 * cc, s, site, e)],
129  field[myindex(2 * cc + 1, s, site, e)]);
130  }
131  return Tmp;
132  }
133 
134  void set_vec(const int s, const int site, const int e, const Vec_SU_N& F)
135  {
136  for (int cc = 0; cc < m_Nc; ++cc) {
137  field[myindex(2 * cc, s, site, e)] = F.r(cc);
138  field[myindex(2 * cc + 1, s, site, e)] = F.i(cc);
139  }
140  }
141 
142  void add_vec(const int s, const int site, const int e, const Vec_SU_N& F)
143  {
144  for (int cc = 0; cc < m_Nc; ++cc) {
145  field[myindex(2 * cc, s, site, e)] += F.r(cc);
146  field[myindex(2 * cc + 1, s, site, e)] += F.i(cc);
147  }
148  }
149 
150  void clear_vec(const int s, const int site, const int e)
151  {
152  for (int cc = 0; cc < m_Nc2; ++cc) {
153  field[myindex(cc, s, site, e)] = 0.0;
154  }
155  }
156 
157  void xI()
158  {
160 
161  // // assume that components of complex are stored in pair: (real, imag), ...
162  // for (int i = 0, n = ntot(); i < n; i += 2) {
163  // double r = field[i];
164  // field[i] = -field[i + 1];
165  // field[i + 1] = r;
166  // }
167 
168  int size = ntot();
169 // int i_thread, Nthread, is, ns;
170 // set_threadtask(i_thread, Nthread, is, ns, ntot());
172  int i_thread = ThreadManager_OpenMP::get_thread_id();
173 
174  int is = size * i_thread / Nthread;
175  int ns = size * (i_thread + 1) / Nthread;
176 
177  double *p = this->ptr(0);
178 
179  for (int k = is; k < ns; k += 2) {
180  double r = p[k];
181  p[k] = -p[k + 1];
182  p[k + 1] = r;
183  }
184  }
185 
186  void Ix(const Field_F& w)
187  {
188  // assert(m_Nin = w.m_Nin);
189  // assert(m_Nvol = w.m_Nvol);
190  // assert(m_Nex = w.m_Nex);
191 
192  // // assume that components of complex are stored in pair: (real, imag), ...
193  // for (int i = 0, n = ntot(); i < n; i += 2) {
194  // double r = w.field[i]; // it should be safe if w = this.
195  // field[i] = -w.field[i + 1];
196  // field[i + 1] = r;
197  // }
198 
199  int size = ntot();
200 // int i_thread, Nthread, is, ns;
201 // set_threadtask(i_thread, Nthread, is, ns, ntot());
203  int i_thread = ThreadManager_OpenMP::get_thread_id();
204 
205  int is = size * i_thread / Nthread;
206  int ns = size * (i_thread + 1) / Nthread;
207 
208  double *yp = this->ptr(0);
209  const double *xp = w.ptr(0);
210 
211  for (int k = is; k < ns; k += 2) {
212  double r = xp[k];
213  yp[k] = -xp[k + 1];
214  yp[k + 1] = r;
215  }
216  }
217 
218  private:
219 
221  void check();
222 };
223 
224 
225 //- function style
226 void mult_Field_Gn(Field_F& y, const int ex,
227  const Field_G& u, int ex1,
228  const Field_F& x, int ex2);
229 
230 void mult_Field_Gd(Field_F& y, const int ex,
231  const Field_G& u, int ex1,
232  const Field_F& x, int ex2);
233 
234 void multadd_Field_Gn(Field_F& y, const int ex,
235  const Field_G& u, int ex1,
236  const Field_F& x, int ex2,
237  const double a);
238 
239 void multadd_Field_Gd(Field_F& y, const int ex,
240  const Field_G& u, int ex1,
241  const Field_F& x, int ex2,
242  const double a);
243 
245 void mult_GM(Field_F& y,
246  const GammaMatrix& gm,
247  const Field_F& x);
248 
250 void mult_iGM(Field_F& y,
251  const GammaMatrix& gm,
252  const Field_F& x);
253 
255 void mult_GMproj(Field_F& y,
256  const int pm, const GammaMatrix& gm,
257  const Field_F& x);
258 
260 void mult_GMproj2(Field_F& y,
261  const int pm, const GammaMatrix& gm,
262  const Field_F& x);
263 
265 void mult_GMproj2(Field_F& y,
266  const double nu_s,
267  const int pm,
268  const double r_s,
269  const GammaMatrix& gm,
270  const Field_F& x);
271 
272 #endif
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:79
BridgeIO vout
Definition: bridgeIO.cpp:503
double cmp_i(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:100
static int get_num_threads()
returns available number of threads.
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
double r(const int c) const
Definition: vec_SU_N.h:65
size_t myindex(const int jin, const int site, const int jex) const
Definition: field.h:64
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:134
void set_i(const int cc, const int s, const int site, const int e, const double im)
Definition: field_F.h:111
Container of Field-type object.
Definition: field.h:45
void check()
check several assumptions for performance implementation.
Definition: field_F_imp.cpp:25
friend void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:532
Field_F clone() const
Definition: field_F.h:64
int nvol() const
Definition: field.h:127
void clear_vec(const int s, const int site, const int e)
Definition: field_F.h:150
int m_Nc
Definition: field_F.h:40
int myindex(const int c2, const int s, const int site, const int ex) const
Definition: field_F.h:45
void multadd_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2, const double a)
static int get_thread_id()
returns thread id.
Wilson-type fermion field.
Definition: field_F.h:37
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
void set(const int c, const double re, const double im)
Definition: vec_SU_N.h:74
Gamma Matrix class.
Definition: gammaMatrix.h:44
SU(N) gauge field.
Definition: field_G.h:38
void reset(int Nvol, int Nex)
Definition: field_F.h:80
void set_r(const int cc, const int s, const int site, const int e, const double re)
Definition: field_F.h:106
void Ix(const Field_F &w)
Definition: field_F.h:186
void mult_iGM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication (i is multiplied)
double i(const int c) const
Definition: vec_SU_N.h:67
void multadd_Field_Gd(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2, const double a)
void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
Definition: field_F.h:116
void xI()
Definition: field_F.h:157
int nex() const
Definition: field.h:128
Common parameter class: provides parameters as singleton.
int m_Nd
Definition: field_F.h:42
std::valarray< double > field
Definition: field.h:60
void mult_Field_Gn(Field_F &y, const int ex, const Field_G &u, int ex1, const Field_F &x, int ex2)
Definition: field_F_imp.cpp:35
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
Field_F & operator=(const Field_F &v)
Definition: field_F.h:87
int nc() const
Definition: field_F.h:89
int ntot() const
Definition: field.h:131
element_type field_element_type() const
Definition: field.h:129
int nc2() const
Definition: field_F.h:90
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:122
Field_F(const int Nvol=CommonParameters::Nvol(), const int Nex=1)
Definition: field_F.h:54
void add_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:142
void mult_GMproj(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)/2
int nd() const
Definition: field_F.h:91
Field_F(const Field &x)
Definition: field_F.h:71
int size() const
Definition: field.h:132
int m_Nc2
Definition: field_F.h:41
double cmp_r(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:94