OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
RectangularDomain.h
Go to the documentation of this file.
1 #ifndef RECTANGULAR_DOMAIN_H
2 #define RECTANGULAR_DOMAIN_H
3 #ifdef HAVE_SAAMG_SOLVER
4 
5 #include <vector>
6 #include <string>
7 #include "IrregularDomain.h"
8 
9 class RectangularDomain : public IrregularDomain {
10 
11 public:
12 
14  RectangularDomain(Vector_t nr, Vector_t hr);
16  RectangularDomain(double a, double b, Vector_t nr, Vector_t hr);
17 
19  void compute(Vector_t hr);
20 
22  int getNumXY(int z);
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  using IrregularDomain::getNeighbours;
29  void getNeighbours(int x, int y, int z, double &W, double &E, double &S, double &N, double &F, double &B);
31  void getNeighbours(int idx, double &W, double &E, double &S, double &N, double &F, double &B);
33  std::string getType() {return "Rectangular";}
35  inline bool isInside(int x, int y, int z) {
36  double xx = (x - (nr[0] - 1) / 2.0) * hr[0];
37  double yy = (y - (nr[1] - 1) / 2.0) * hr[1];
38  return (xx <= a_m && yy < b_m);
39  }
40 
41  void setB_m(double b) {b_m = b;}
42  void setA_m(double a) {a_m = a;}
43 
44  double getXRangeMin() { return -a_m; }
45  double getXRangeMax() { return a_m; }
46  double getYRangeMin() { return -b_m; }
47  double getYRangeMax() { return b_m; }
48  double getZRangeMin() { return getMinZ(); }
49  double getZRangeMax() { return getMaxZ(); }
50 
51 
52  int getStartIdx() {return 0;}
53 
54 private:
55 
57  double a_m;
59  double b_m;
61  int nxy_m;
62 
64  inline int getIdx(int x, int y, int z) {
65  if(isInside(x, y, z) && x >= 0 && y >= 0 && z >= 0)
66  return y * nr[0] + x + z * nxy_m;
67  else
68  return -1;
69  }
71  inline void getCoord(int idx, int &x, int &y, int &z) {
72  int ixy = idx % nxy_m;
73  int inr = nr[0];
74  x = ixy % inr;
75  y = (ixy - x) / nr[0];
76  z = (idx - ixy) / nxy_m;
77  }
78 
79 };
80 
81 #endif //#ifdef HAVE_SAAMG_SOLVER
82 #endif //#ifdef RECTANGULAR_DOMAIN_H
Definition: TSVMeta.h:24
const int nr
Definition: ClassicRandom.h:24