-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathLATfield2_Site_decl.hpp
282 lines (203 loc) · 7.66 KB
/
LATfield2_Site_decl.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#ifndef LATFIELD2_SITE_DECL_HPP
#define LATFIELD2_SITE_DECL_HPP
/*! \class Site
\brief A class for referencing values of an instance of the field class at a given point on a lattice.
A class which simplify the map of the field data array index. This class allow to get coordinate on the lattice, loop over each site of the lattice and perform displacment on the lattice.
The site class encapsulates the mapping between the coordinate on the lattice and the index of the Field::data_ array which store the value of an instance of the Field class. It also contain method to loop over each site of the lattice, and to perform spacial displacement on the lattice.
*/
class Site
{
public:
//CONSTRUCTORS=================
//! Constructor.
Site();
/*!
Constructor with initialization.
\param lattice : the lattice on which the Site is defined.
\sa initialize(Lattice& lattice)
*/
Site(Lattice& lattice);
/*!
Constructor with initialization.
\param lattice : the lattice on which the Site is defined.
\param index : set the current index of the field.
\sa initialize(Lattice& lattice, long index)
*/
Site(Lattice& lattice, long index);
//INITIALIZATION=================
/*!
Initialization.
\param lattice : the lattice on which the Site is defined.
*/
void initialize(Lattice& lattice);
/*!
Constructor with initialization.
\param lattice : the lattice on which the Site is defined.
\param index : set the current index of the field.
*/
void initialize(Lattice& lattice, long index);
//LOOPING OPERATIONS==============
/*!
Method to set the Site to the first site which is not within the halo. This method is used for loopping over the all lattice sites:
for(site.first();site.test();site.next());
\sa test()
\sa next()
*/
void first();
/*!
Method to test if the Site have a smaller or equal index than the last index not within the halo. This method is used for loopping over the all lattice sites:
for(site.first();site.test();site.next());
\sa first()
\sa next()
*/
bool test();
/*!
Method to jump to the next index which is not in the halo. This method is used for loopping over the all lattice sites:
for(site.first();site.test();site.next());
\sa first()
\sa test()
*/
void next();
void nextInSlice(int offset,int thickness);
//HALO OPERATIONS==============
/*!
Method to set the Site to the first site which is within the halo. This method is used for loopping over the all halo sites:
for(site.haloFirst();site.haloTest();site.haloNext());
\sa haloTest()
\sa haloNext()
*/
void haloFirst();
/*!
Method to test if the Site have a smaller or equal index than the last index within the halo. This method is used for loopping over the all halo sites:
for(site.haloFirst();site.haloTest();site.haloNext());
\sa haloFirst()
\sa haloNext()
*/
bool haloTest();
/*!
Method to jump to the next index which is in the halo. This method is used for loopping over the all halo sites:
for(site.haloFirst();site.haloTest();site.haloNext());
\sa haloFirst()
\sa haloTest()
*/
void haloNext();
//NEIGHBOURING SITE OPERATORS==
/*!
Overloaded operator +
The + operator is used to make a displacement of +1 site the the asked direction.
\param direction : direction of the displacement
*/
Site operator+(int direction);
/*!
Overloaded operator -
The - operator is used to make a displacement of -1 site the the asked direction.
\param direction : direction of the displacement
*/
Site operator-(int direction);
Site move(int direction);
Site move(int direction, int step);
Site move(int * steps);
Site move3d(int sx, int sy, int sz);
//SITE INDEX ADVANCE===========
/*!
Method which add "number" to the current index.
*/
void indexAdvance(long number);
//MISCELLANEOUS================
/*!
\return this method return the current index pointed by the site.
*/
long index() const;
/*!
Method to set the current index of the site.
\param new_index: the site index is set to new_index.
*/
void setIndex(long new_index);
/*!
Method which return the site coordinate of a give dimension
\param direction : label of the coordinate.
\return site coordinate of the "direction" dimension
*/
int coord(int direction);
/*!
Method which return the local site coordinate of a give dimension
\param direction : label of the coordinate.
\return site local coordinate of the "direction" dimension
*/
int coordLocal(int direction);
/*!
Method to set the site to a given coordinate.
\param r : array which contain the coordinate. The array size must be equal to the number of dimension of the lattice
\return True: if the coordinate is local.
False: if the local part of the lattice does not have this coordinate.
*/
bool setCoord(int* r);
/*!
Method to set the site to a given coordinate for 3d lattices.
\param x : coordinate of the 0 dimension.
\param y : coordinate of the 1 dimension.
\param z : coordinate of the 2 dimension.
\return True: if the coordinate is local.
False: if the local part of the lattice does not have this coordinate.
*/
bool setCoord(int x, int y, int z);
bool setCoordLocal(int *r);
/*!
\return Returns the pointer to the lattice on which the site is defined.
*/
Lattice& lattice();
protected:
Lattice* lattice_;
long index_;
};
#ifdef FFT3D
/*! \class cKSite
\brief A child of Site, built to work with the Fourier space Lattice for complex to complex transforms.
A class which simplify the map of the field data array index. This class allow to get coordinate on the lattice, loop over each site of the lattice and perform displacment on the lattice.
WARNING: this site class must be used only on lattice initialized using initializeComplexFFT() method of the Lattice class.
This class have same binding that the Site class, so one can refer to the Site class for the documentation.
*/
class cKSite:public Site{
public:
cKSite(){;}
cKSite(Lattice& lattice){initialize(lattice);}
cKSite(Lattice& lattice, long index){initialize(lattice, index);}
void initialize(Lattice& lattice);
void initialize(Lattice& lattice, long index);
cKSite operator+(int asked_direction);
cKSite operator-(int asked_direction);
int coordLocal(int asked_direction);
int coord(int asked_direction) ;
int latCoord(int direction);
int latCoordLocal(int direction);
bool setCoord(int* r_asked);
bool setCoord(int x, int y, int z);
private:
int directions_[3];
};
/*! \class rKSite
\brief A child of Site, built to work with the Fourier space Lattice for real to complex transforms.
A class which simplifies the map of the field data array index. This class allow to get coordinate on the Lattice, loop over each site of the Lattice and access neighboring lattices sites
WARNING: the rKSite class must be used only on Lattice initialized using initializeRealFFT() method of the Lattice class.
This class has same binding as the Site class, please refer to the Site class for the documentation.
*/
class rKSite:public Site{
public:
rKSite(){;}
rKSite(Lattice& lattice){initialize(lattice);}
rKSite(Lattice& lattice, long index){initialize(lattice, index);}
void initialize(Lattice& lattice);
void initialize(Lattice& lattice, long index);
rKSite operator+(int asked_direction);
rKSite operator-(int asked_direction);
int coordLocal(int asked_direction);
int coord(int asked_direction) ;
int latCoord(int direction);
int latCoordLocal(int direction);
bool setCoord(int* r_asked);
bool setCoord(int x, int y, int z);
private:
int directions_[3];
};
#endif
#endif