OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
EllipticDomain.h
Go to the documentation of this file.
1 #ifndef ELLIPTICAL_DOMAIN_H
2 #define ELLIPTICAL_DOMAIN_H
3 #ifdef HAVE_SAAMG_SOLVER
4 
5 #include <vector>
6 #include <map>
7 #include <string>
8 #include <cmath>
9 #include "IrregularDomain.h"
11 
12 class EllipticDomain : public IrregularDomain {
13 
14 public:
15 
16  EllipticDomain(Vector_t nr, Vector_t hr);
17  EllipticDomain(double semimajor, double semiminor, Vector_t nr, Vector_t hr, std::string interpl);
18  EllipticDomain(BoundaryGeometry *bgeom, Vector_t nr, Vector_t hr, std::string interpl);
19  EllipticDomain(BoundaryGeometry *bgeom, Vector_t nr, std::string interpl);
20 
21  ~EllipticDomain();
22 
24  void getBoundaryStencil(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
26  void getBoundaryStencil(int idx, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
28  void getNeighbours(int x, int y, int z, int &W, int &E, int &S, int &N, int &F, int &B);
30  void getNeighbours(int idx, int &W, int &E, int &S, int &N, int &F, int &B);
32  std::string getType() {return "Elliptic";}
34  inline bool isInside(int x, int y, int z) {
35  double xx = (x - (nr[0] - 1) / 2.0) * hr[0];
36  double yy = (y - (nr[1] - 1) / 2.0) * hr[1];
37  return ((xx * xx / (SemiMajor * SemiMajor) + yy * yy / (SemiMinor * SemiMinor) < 1) && z != 0 && z != nr[2] - 1);
38  }
39 
40  int getNumXY(int z) { return nxy_m; }
42  void setSemiMinor(double sm) {SemiMinor = sm;}
44  void setSemiMajor(double sm) {SemiMajor = sm;}
45 
47  void compute(Vector_t hr);
48  void compute(Vector_t hr, NDIndex<3> localId);
49 
50  double getXRangeMin() { return -SemiMajor; }
51  double getXRangeMax() { return SemiMajor; }
52  double getYRangeMin() { return -SemiMinor; }
53  double getYRangeMax() { return SemiMinor; }
54  double getZRangeMin() { return zMin_m; }
55  double getZRangeMax() { return zMax_m; }
56 
57 
58  //TODO: ?
59  int getStartIdx() {return 0;}
60 
61  bool hasGeometryChanged() { return hasGeometryChanged_m; }
62 
63 private:
64 
67  typedef std::multimap<int, double> EllipticPointList;
68 
70  EllipticPointList IntersectXDir;
71 
73  EllipticPointList IntersectYDir;
74 
76  std::map<int, int> IdxMap;
77 
79  std::map<int, int> CoordMap;
80 
82  double SemiMajor;
84  double SemiMinor;
86  int nxy_m;
88  int interpolationMethod;
90  bool hasGeometryChanged_m;
91 
93  inline int toCoordIdx(int x, int y) { return y * nr[0] + x; }
95  inline int getIdx(int x, int y, int z) {
96  if(isInside(x, y, z) && x >= 0 && y >= 0 && z >= 0)
97  return IdxMap[toCoordIdx(x, y)] + (z - 1) * nxy_m;
98  else
99  return -1;
100  }
102  inline void getCoord(int idx, int &x, int &y, int &z) {
103  int ixy = idx % nxy_m;
104  int xy = CoordMap[ixy];
105  int inr = (int)nr[0];
106  x = xy % inr;
107  y = (xy - x) / nr[0];
108  z = (idx - ixy) / nxy_m + 1;
109  }
110 
112  void constantInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
113  void linearInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
114  void quadraticInterpolation(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
115 
116 };
117 
118 #endif //#ifdef HAVE_SAAMG_SOLVER
119 #endif //#ifdef ELLIPTICAL_DOMAIN_H
Definition: TSVMeta.h:24
const int nr
Definition: ClassicRandom.h:24