OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BoxCornerDomain.h
Go to the documentation of this file.
1 #ifndef BOXCORNER_DOMAIN_H
2 #define BOXCORNER_DOMAIN_H
3 #ifdef HAVE_SAAMG_SOLVER
4 
5 //#include <vector>
6 #include <map>
7 //#include <multimap>
8 #include <string>
9 #include <cmath>
10 #include <iostream> // Neeeded for stream I/O
11 #include <fstream> // Needed for file I/O
12 //#include <iomanip> // Needed for I/O manipulators
13 
14 //#include "Ippl.h"
15 #include "IrregularDomain.h"
16 
17 
18 /*
19 
20  A_m and B_m are the half apperture of the box
21 
22 
23  / (A_m,B_m)
24  /
25  /
26  /
27  L1_m /
28 ------------ --------------+ (-A_m,B_m)
29  | L2_m | |
30  C_m| | |
31  |------| | /
32  ..... | /
33 (0,0)---.......-----------------+ /
34  ..... | /
35  z | /
36  | | /
37 --------------------------------+/ (-A_m,-B_m)
38 
39  Length_m
40 
41 Test in which of the 3 parts of the geometry we are in.
42 
43  if((z < L1_m) || (z > (L1_m + L2_m)))
44  b = B_m;
45  else
46  b = B_m-C_m;
47 
48 */
49 
50 class BoxCornerDomain : public IrregularDomain {
51 
52 public:
53 
54  BoxCornerDomain(Vector_t nr, Vector_t hr);
55  BoxCornerDomain(double A, double B, double C, double Length, double L1, double L2, Vector_t nr, Vector_t hr,
56  std::string interpl);
57  ~BoxCornerDomain();
58 
60  void getBoundaryStencil(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B,
61  double &C, double &scaleFactor);
62 
64  void getBoundaryStencil(int idx, double &W, double &E, double &S, double &N, double &F, double &B, double &C,
65  double &scaleFactor);
66 
68  void getNeighbours(int x, int y, int z, int &W, int &E, int &S, int &N, int &F, int &B);
69 
71  void getNeighbours(int idx, int &W, int &E, int &S, int &N, int &F, int &B);
72 
74  std::string getType() {return "BoxCorner";}
75 
76 
78  int getNumXY(int z) { return -1;}
79 
80 
82  inline double getB(double z) {
83  if((z < L1_m) || (z > (L1_m + L2_m)))
84  return B_m;
85  else
86  return B_m - C_m;
87  }
88 
90  inline bool isInside(int x, int y, int z) {
91  const double xx = (x - (nr[0] - 1) / 2.0) * hr[0];
92  const double yy = (y - (nr[1] - 1) / 2.0) * hr[1];
93  const double b = getB(z * hr[2]);
94  return (xx < A_m && yy < b && z != 0 && z != nr[2] - 1);
95  }
96 
98  //void setSemiMinor(double sm) {SemiMinor = sm;}
100  //void setSemiMajor(double sm) {SemiMajor = sm;}
101 
102  void compute(Vector_t hr);
103  void compute(Vector_t hr, NDIndex<3> localId);
104 
105  double getXRangeMin() { return -A_m; }
106  double getXRangeMax() { return A_m; }
107  double getYRangeMin() { return -B_m;} // actBMin_m; }
108  double getYRangeMax() { return B_m; } // actBMax_m; }
109  double getZRangeMin() { return L1_m;}
110  double getZRangeMax() { return L1_m+L2_m; }
111 
112 
113  //TODO: ?
114  int getStartIdx() {return 0;}
115 
116  bool hasGeometryChanged() { return hasGeometryChanged_m; }
117 
118 private:
119 
120  //XXX: since the Y coorindate is dependent on the Z value we need (int,
121  //int) -> intersection. To simplify things (for now) we use the same
122  //structure for X...
125  typedef std::multimap< std::pair<int, int>, double > BoxCornerPointList;
126 
128  BoxCornerPointList IntersectXDir;
129 
131  BoxCornerPointList IntersectYDir;
132 
134  std::map<int, int> IdxMap;
135 
137  std::map<int, int> CoordMap;
138 
140  double A_m;
141 
143  double B_m;
144 
145 
147  double actBMin_m;
148 
149  double actBMax_m;
150 
152  double C_m;
153 
155  double Length_m;
156 
158  double L1_m;
159 
161  double L2_m;
162 
164  // :FIXME: unused
165  //double SemiMajor;
167  // :FIXME: unused
168  //double SemiMinor;
169 
171  int interpolationMethod;
173  bool hasGeometryChanged_m;
174 
176  std::ofstream os_m;
177 
178 
179 
180 
181 
182  inline double getXIntersection(double cx, int z) {
183  if(cx < 0)
184  return -A_m;
185  else
186  return A_m;
187  }
188 
189  inline double getYIntersection(double cy, int z) {
190  if(cy < 0)
191  return -B_m;
192  else
193  return getB(z * hr[2]);
194  }
195 
197  inline int toCoordIdx(int x, int y, int z) {
198  return (z * nr[1] + y) * nr[0] + x;
199  }
200 
202  /*inline*/
203  inline int getIdx(int x, int y, int z) {
204  if(isInside(x, y, z) && x >= 0 && y >= 0 && z >= 0)
205  return IdxMap[toCoordIdx(x, y, z)];
206  else
207  return -1;
208  }
209 
211  inline void getCoord(int idx, int &x, int &y, int &z) {
212 
213  int idxx = CoordMap[idx];
214 
215  x = idxx % (int)nr[0];
216  idxx /= nr[0];
217  y = idxx % (int)nr[1];
218  idxx /= nr[1];
219  z = idxx;
220 
221  }
222 
224  void constantInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
225  void linearInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
226  void quadraticInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
227 
228 };
229 
230 #endif //#ifdef HAVE_SAAMG_SOLVER
231 #endif //#ifdef BOXCORNER_DOMAIN_H
Definition: TSVMeta.h:24
const int nr
Definition: ClassicRandom.h:24