CHROMA
avp_inverter_interface.cc
Go to the documentation of this file.
2 using namespace QDP;
3 
4 namespace Chroma {
5 
6  namespace AVPSolverFunctions {
7  // Gauge Reader function - user supplied
8  double gaugeReader(const void *OuterGauge,
9  void *env,
10  const int latt_coord[4],
11  int mu,
12  int row,
13  int col,
14  int reim)
15  {
16  /* Translate arg */
17  multi1d<LatticeColorMatrix>& u = *(multi1d<LatticeColorMatrix>*)OuterGauge;
18 
19  // Get node and index
20  multi1d<int> coord(Nd);
21  coord = latt_coord;
22  int node = Layout::nodeNumber(coord);
23  int linear = Layout::linearSiteIndex(coord);
24 
25  if (node != Layout::nodeNumber()) {
26 
27  QDPIO::cerr << __func__ << ": wrong coordinates for this node" << std::endl;
28  QDP_abort(1);
29  }
30 
31  // Get the value
32  // NOTE: it would be nice to use the "peek" functions, but they will
33  // broadcast to all nodes the value since they are platform independent.
34  // We don't want that, so we poke into the on-node data
35  double val = (reim == 0) ?
36  toDouble(u[mu].elem(linear).elem().elem(row,col).real()) :
37  toDouble(u[mu].elem(linear).elem().elem(row,col).imag());
38 
39  return val;
40  }
41 
42 
43  // Fermion Reader function - user supplied
44  double fermionReaderRHS(const void *OuterFermion,
45  void *env,
46  const int latt_coord[5],
47  int color,
48  int spin,
49  int reim)
50  {
51  /* Translate arg */
52  multi1d<LatticeFermion>& psi = *(multi1d<LatticeFermion>*)OuterFermion;
53  int Ls1 = psi.size() - 1;
54 
55  // Get node and index
56  int s = latt_coord[Nd];
57  multi1d<int> coord(Nd);
58  coord = latt_coord;
59  int node = Layout::nodeNumber(coord);
60  int linear = Layout::linearSiteIndex(coord);
61 
62  if (node != Layout::nodeNumber()) {
63 
64  QDPIO::cerr << __func__ << ": wrong coordinates for this node" << std::endl;
65  QDP_abort(1);
66  }
67 
68  // Get the value
69  // NOTE: it would be nice to use the "peek" functions, but they will
70  // broadcast to all nodes the value since they are platform independent.
71  // We don't want that, so we poke into the on-node data
72  double val = (reim == 0) ?
73  double(psi[Ls1-s].elem(linear).elem(spin).elem(color).real()) :
74  double(psi[Ls1-s].elem(linear).elem(spin).elem(color).imag());
75 
76  if (spin >= Ns/2)
77  val *= -1;
78 
79  return val;
80  }
81 
82 
83  // Fermion Reader function - user supplied
84  double fermionReaderGuess(const void *OuterFermion,
85  void *env,
86  const int latt_coord[5],
87  int color,
88  int spin,
89  int reim)
90  {
91  /* Translate arg */
92  multi1d<LatticeFermion>& psi = *(multi1d<LatticeFermion>*)OuterFermion;
93  int Ls1 = psi.size() - 1;
94 
95  // Get node and index
96  int s = latt_coord[Nd];
97  multi1d<int> coord(Nd);
98  coord = latt_coord;
99  int node = Layout::nodeNumber(coord);
100  int linear = Layout::linearSiteIndex(coord);
101 
102  if (node != Layout::nodeNumber()) {
103  QDPIO::cerr << __func__ << ": wrong coordinates for this node" << std::endl;
104  QDP_abort(1);
105  }
106 
107  // Get the value
108  // NOTE: it would be nice to use the "peek" functions, but they will
109  // broadcast to all nodes the value since they are platform independent.
110  // We don't want that, so we poke into the on-node data
111  double val = (reim == 0) ?
112  double(psi[Ls1-s].elem(linear).elem(spin).elem(color).real()) :
113  double(psi[Ls1-s].elem(linear).elem(spin).elem(color).imag());
114 
115  if (spin >= Ns/2)
116  val *= -1;
117 
118  val *= -0.5;
119 
120  return val;
121  }
122 
123 
124  // Fermion Writer function - user supplied
125  void fermionWriterSolver( void *OuterFermion,
126  void *env,
127  const int latt_coord[5],
128  int color,
129  int spin,
130  int reim,
131  double val)
132 
133  {
134  /* Translate arg */
135  multi1d<LatticeFermion>& psi = *(multi1d<LatticeFermion>*)OuterFermion;
136  int Ls1 = psi.size() - 1;
137 
138  // Get node and index
139  int s = latt_coord[Nd];
140  multi1d<int> coord(Nd);
141  coord = latt_coord;
142  int node = Layout::nodeNumber(coord);
143  int linear = Layout::linearSiteIndex(coord);
144 
145  if (node != Layout::nodeNumber()) {
146  QDPIO::cerr << __func__ << ": wrong coordinates for this node" << std::endl;
147  QDP_abort(1);
148  }
149 
150  // Rescale
151  if (spin >= Ns/2)
152  val *= -1;
153 
154  val *= -2.0;
155 
156  // Set the value
157  // NOTE: it would be nice to use the "peek" functions, but they will
158  // broadcast to all nodes the value since they are platform independent.
159  // We don't want that, so we poke into the on-node data
160  if (reim == 0)
161  psi[Ls1-s].elem(linear).elem(spin).elem(color).real() = val;
162  else
163  psi[Ls1-s].elem(linear).elem(spin).elem(color).imag() = val;
164 
165  return;
166  }
167 
168  // Fermion Writer function - user supplied
169  void fermionWriterOperator( void *OuterFermion,
170  void *env,
171  const int latt_coord[5],
172  int color,
173  int spin,
174  int reim,
175  double val)
176  {
177  /* Translate arg */
178  multi1d<LatticeFermion>& psi = *(multi1d<LatticeFermion>*)OuterFermion;
179  int Ls1 = psi.size() - 1;
180 
181  // Get node and index
182  int s = latt_coord[Nd];
183  multi1d<int> coord(Nd);
184  coord = latt_coord;
185  int node = Layout::nodeNumber(coord);
186  int linear = Layout::linearSiteIndex(coord);
187 
188  if (node != Layout::nodeNumber()) {
189  QDPIO::cerr << __func__ << ": wrong coordinates for this node" << std::endl;
190  QDP_abort(1);
191  }
192 
193  // Rescale
194  if (spin >= Ns/2)
195  val *= -1;
196 
197  val *= -0.5;
198 
199  // Set the value
200  // NOTE: it would be nice to use the "peek" functions, but they will
201  // broadcast to all nodes the value since they are platform independent.
202  // We don't want that, so we poke into the on-node data
203  if (reim == 0)
204  psi[Ls1-s].elem(linear).elem(spin).elem(color).real() = val;
205  else
206  psi[Ls1-s].elem(linear).elem(spin).elem(color).imag() = val;
207 
208  return;
209  }
210  };
211 
212 };
Base class for AVP's DWF solver interface.
int mu
Definition: cool.cc:24
unsigned s
Definition: ldumul_w.cc:37
multi1d< int > coord(Nd)
Nd
Definition: meslate.cc:74
void fermionWriterOperator(void *OuterFermion, void *env, const int latt_coord[5], int color, int spin, int reim, double val)
double fermionReaderGuess(const void *OuterFermion, void *env, const int latt_coord[5], int color, int spin, int reim)
double gaugeReader(const void *OuterGauge, void *env, const int latt_coord[4], int mu, int row, int col, int reim)
double fermionReaderRHS(const void *OuterFermion, void *env, const int latt_coord[5], int color, int spin, int reim)
void fermionWriterSolver(void *OuterFermion, void *env, const int latt_coord[5], int color, int spin, int reim, double val)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
psi
Definition: pade_trln_w.cc:191