OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ArbitraryDomain.h
Go to the documentation of this file.
1 #ifndef ARBITRARY_DOMAIN_H
2 #define ARBITRARY_DOMAIN_H
3 
4 #ifdef HAVE_SAAMG_SOLVER
5 
6 #include <mpi.h>
7 #include <hdf5.h>
8 #include "H5hut.h"
9 
10 #include <map>
11 #include <string>
12 #include <tuple>
13 #include <vector>
14 #include "IrregularDomain.h"
15 
16 class BoundaryGeometry;
17 
18 class ArbitraryDomain : public IrregularDomain {
19 
20 public:
21 
22  ArbitraryDomain(BoundaryGeometry *bgeom, Vector_t nr, Vector_t hr, std::string interpl);
23  ArbitraryDomain(BoundaryGeometry *bgeom, Vector_t nr, Vector_t hr, Vector_t globalMeanR, Quaternion_t globalToLocalQuaternion, std::string interpl);
24 
25  ~ArbitraryDomain();
26 
28  void getBoundaryStencil(int idx, int idy, int idz, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
30  void getBoundaryStencil(int idxyz, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
32  void getNeighbours(int idx, int idy, int idz, int &W, int &E, int &S, int &N, int &F, int &B);
34  void getNeighbours(int idxyz, int &W, int &E, int &S, int &N, int &F, int &B);
36  std::string getType() {return "Geometric";}
38  bool isInside(int idx, int idy, int idz);
40  int getNumXY(int idz);
41  // calculates intersection
42  void compute(Vector_t hr);
43  // calculates intersection with rotated and shifted geometry
44  void compute(Vector_t hr, NDIndex<3> localId);
45 
46  int getStartId() {return startId;}
47 
48  double getXRangeMin(){ return minCoords_m(0); }
49  double getYRangeMin(){ return minCoords_m(1); }
50  double getZRangeMin(){ return minCoords_m(2); }
51 
52  double getXRangeMax(){ return maxCoords_m(0); }
53  double getYRangeMax(){ return maxCoords_m(1); }
54  double getZRangeMax(){ return maxCoords_m(2); }
55 
56  void setXRangeMin(double xmin){ minCoords_m(0) = xmin; }
57  void setYRangeMin(double ymin){ minCoords_m(1) = ymin; }
58  void setZRangeMin(double zmin){ minCoords_m(2) = zmin; }
59 
60  void setXRangeMax(double xmax){ maxCoords_m(0) = xmax; }
61  void setYRangeMax(double ymax){ maxCoords_m(1) = ymax; }
62  void setZRangeMax(double zmax){ maxCoords_m(2) = zmax; }
63 
64 
65  bool hasGeometryChanged() { return hasGeometryChanged_m; }
66 
67 private:
68  BoundaryGeometry *bgeom_m;
69 
71  typedef std::multimap< std::tuple<int, int, int>, double > PointList;
72 
74  PointList IntersectHiX, IntersectLoX;
75 
77  PointList IntersectHiY, IntersectLoY;
78 
80  PointList IntersectHiZ, IntersectLoZ;
81 
82  // meanR to shift from global to local frame
83  Vector_t globalMeanR_m;
84  // Quaternion_t globalToLocalQuaternion_m; because defined in parent class
85  Quaternion_t localToGlobalQuaternion_m;
86 
87  int startId;
88 
89  // Here we store the number of nodes in a xy layer for a given z coordinate
90  std::map<int, int> numXY;
91  std::map<int, int> numYZ;
92  std::map<int, int> numXZ;
93 
94  // Number of nodes in the xy plane (for this case: independent of the z coordinate)
95  int nxy_m[1000];
96  // mapping (x,y,z) -> idxyz
97  std::map<int, int> IdxMap;
98  // Mapping idxyz -> (x,y,z)
99  std::map<int, int> CoordMap;
100 
101  // Mapping all cells that are inside the geometry
102  std::map<int, bool> IsInsideMap;
103 
104  // Interpolation type
105  int interpolationMethod;
106 
107  // Flag indicating if geometry has changed for the current time-step
108  bool hasGeometryChanged_m;
109 
110  Vector_t Geo_nr_m;
111  Vector_t Geo_hr_m;
112  Vector_t geomCentroid_m;
113  Vector_t minCoords_m;
114  Vector_t maxCoords_m;
115  Vector_t globalInsideP0_m;
116 
117  // Conversion from (x,y,z) to index in xyz plane
118  inline int toCoordIdx(int idx, int idy, int idz);
119  // Conversion from (x,y,z) to index on the 3D grid
120  int getIdx(int idx, int idy, int idz);
121  // Conversion from a 3D index to (x,y,z)
122  inline void getCoord(int idxyz, int &x, int &y, int &z);
123 
124  inline void crossProduct(double A[], double B[], double C[]);
125  inline double dotProduct(double v1[], double v2[]) { return (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]); }
126 
127  // Different interpolation methods for boundary points
128  void constantInterpolation(int idx, int idy, int idz, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
129  void linearInterpolation(int idx, int idy, int idz, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
130  void quadraticInterpolation(int idx, int idy, int idz, double &W, double &E, double &S, double &N, double &F, double &B, double &C, double &scaleFactor);
131 
132  // Rotate positive axes with quaternion -DW
133  inline void rotateWithQuaternion(Vector_t &v, Quaternion_t const quaternion);
134 
135  inline void rotateXAxisWithQuaternion(Vector_t &v, Quaternion_t const quaternion);
136  inline void rotateYAxisWithQuaternion(Vector_t &v, Quaternion_t const quaternion);
137  inline void rotateZAxisWithQuaternion(Vector_t &v, Quaternion_t const quaternion);
138 };
139 
140 #endif //#ifdef HAVE_SAAMG_SOLVER
141 #endif //#ifdef ARBITRARY_DOMAIN
Definition: TSVMeta.h:24
const int nr
Definition: ClassicRandom.h:24
double dotProduct(const Vector_t &a, const Vector_t &b)
Definition: Mesher.cpp:133