OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
CornerGrid.hpp
Go to the documentation of this file.
1 
12 #ifndef __CORNERGRID_HEADER__
13 #define __CORNERGRID_HEADER__
14 
15 // Standard header files
16 #include <math.h>
17 #include <stdlib.h>
18 #include <vector>
19 
20 // OpenCAEPoro header files
21 #include "OCPConst.hpp"
22 
23 using namespace std;
24 
25 // Constants used by corner-point grid code
26 const OCP_DBL SMALL_REAL = 1E-10;
27 const OCP_DBL TEENY = 1E-3;
28 const OCP_DBL SMALL = 1E-3;
29 const USI MAX_NEIGHBOR = 80;
30 
32 class Point2D
33 {
34 public:
35  OCP_DBL x;
36  OCP_DBL y;
37 
38 public:
39  Point2D() = default;
40  Point2D(OCP_DBL x0, OCP_DBL y0)
41  : x(x0)
42  , y(y0){};
43 };
44 
46 class Point3D
47 {
48 public:
49  OCP_DBL x;
50  OCP_DBL y;
51  OCP_DBL z;
52 
53 public:
54  Point3D() = default;
55  Point3D(OCP_DBL x0, OCP_DBL y0, OCP_DBL z0)
56  : x(x0)
57  , y(y0)
58  , z(z0){};
59 
60  Point3D& operator=(const Point3D& other);
61  Point3D operator+(const Point3D& other) const;
62  Point3D operator-(const Point3D& other) const;
63  OCP_DBL operator*(const Point3D& other) const;
64  Point3D& operator+=(const Point3D& other);
65  Point3D& operator*=(const OCP_DBL& a);
66  Point3D& operator/=(const OCP_DBL& a);
67  void Reset()
68  {
69  x = 0;
70  y = 0;
71  z = 0;
72  };
73 };
74 
75 Point3D operator*(const Point3D& p, const OCP_DBL& a);
76 Point3D operator*(const OCP_DBL& a, const Point3D& p);
77 Point3D CrossProduct(const Point3D& p1, const Point3D& p2);
78 
81 {
82 public:
83  Point3D p0, p1, p2, p3, p4, p5, p6, p7;
84 };
85 
88 {
89 public:
90  Point3D p0, p1, p2, p3;
91 };
92 
94 class Matrix3
95 {
96 public:
97  OCP_DBL M[3][3];
98  Point3D operator*(const Point3D& v) const;
99 };
100 
103 
106 
109 
112 
114 Point2D CalCrossingPoint(const Point2D Line1[2], const Point2D Line2[2]);
115 
117 OCP_DBL CalAreaNotQuadr(const HexahedronFace& FACE1, const HexahedronFace& FACE2);
118 
120 class HalfConn
121 {
122 public:
123  OCP_DBL Ad_dd;
124  Point3D d;
125  OCP_USI neigh;
126  USI directionType; // 1 - x, 2 - y, 3 - z, 4 - extension
127 };
128 
130 class ConnGrid
131 {
132 public:
133  USI nConn, maxConn;
134  vector<HalfConn> halfConn;
135  void Allocate(const USI& max_neighbor);
136  void AddHalfConn(const OCP_USI& n,
137  const Point3D& area,
138  const Point3D& d,
139  const USI& direction,
140  const OCP_DBL& flag = 1);
141 };
142 
145 {
146 public:
147  OCP_USI begin, end;
148  USI directionType; // 1 - x, 2 - y, 3 - z, 4 - extension
149  OCP_DBL Ad_dd_begin;
150  OCP_DBL Ad_dd_end;
151 };
152 
155 {
156  friend class Grid;
157 
158 public:
159  void Allocate(const USI& Nx, const USI& Ny, const USI& Nz);
160  void InputData(const vector<OCP_DBL>& coord, const vector<OCP_DBL>& zcorn);
161  OCP_BOOL InputCOORDDATA(const vector<OCP_DBL>& coord);
162  OCP_BOOL InputZCORNDATA(const vector<OCP_DBL>& zcorn);
163  // New version
164  void SetupCornerPoints();
165  void SetAllFlags(const HexahedronFace& oFace, const HexahedronFace& Face);
166  // functions
167  OCP_DBL OCP_SIGN(const OCP_DBL& x) { return x >= 0 ? 1 : -1; }
168 
169 private:
170  USI nx;
171  USI ny;
172  USI nz;
173  OCP_DBL*** COORDDATA;
174  OCP_DBL**** ZCORNDATA;
175  Hexahedron*** cornerPoints;
176 
178  OCP_USI numConn;
179  OCP_USI numConnMax;
180  vector<OCP_DBL> v;
181  vector<OCP_DBL> depth;
182  vector<OCP_DBL> dx;
183  vector<OCP_DBL> dy;
184  vector<OCP_DBL> dz;
185  vector<Point3D> center;
186 
187  vector<GeneralConnect> connect;
188 
189  // Auxiliary variables
190  // if the i th point of oFace is deeper than the one of Face, then flagpi = 1;
191  // if the i th point of oFace is higher than the one of Face, then flagpi = -1;
192  // if the i th point of oFace is very close to the one of Face, then flagpi = 0;
193  OCP_INT flagp0, flagp1, flagp2, flagp3;
194  OCP_BOOL flagQuad;
195  OCP_BOOL upNNC, downNNC;
196  OCP_BOOL flagJump;
197  HexahedronFace tmpFace;
198  // after the Axes are determined, blocks will be placed along the y+, or along the
199  // y- if y+, then flagForward equals 1.0, else -1.0, this relates to calculation of
200  // area normal vector
201  OCP_DBL flagForward;
202 };
203 
204 #endif
205 
206 /*----------------------------------------------------------------------------*/
207 /* Brief Change History of This File */
208 /*----------------------------------------------------------------------------*/
209 /* Author Date Actions */
210 /*----------------------------------------------------------------------------*/
211 /* Shizhe Li Nov/16/2021 Create file */
212 /* Chensong Zhang Jan/16/2022 Update Doxygen */
213 /*----------------------------------------------------------------------------*/
OCP_DBL CalAreaNotQuadr(const HexahedronFace &FACE1, const HexahedronFace &FACE2)
???
Definition: CornerGrid.cpp:198
const OCP_DBL TEENY
Used for checking distance b/w center to face.
Definition: CornerGrid.hpp:27
Point3D VectorFace(const HexahedronFace &f)
Find the normal vector of a face.
Definition: CornerGrid.cpp:145
const OCP_DBL SMALL_REAL
Used for checking determinate of a small matrix.
Definition: CornerGrid.hpp:26
const OCP_DBL SMALL
Small number as tolerance.
Definition: CornerGrid.hpp:28
Point3D CrossProduct(const Point3D &p1, const Point3D &p2)
Cross product.
Definition: CornerGrid.cpp:71
Point2D CalCrossingPoint(const Point2D Line1[2], const Point2D Line2[2])
???
Definition: CornerGrid.cpp:163
Point3D CenterHexahedron(const Hexahedron &h)
Find the center of a hexahedron.
Definition: CornerGrid.cpp:138
Point3D CenterFace(const HexahedronFace &f)
Find the center of a face.
Definition: CornerGrid.cpp:156
Point3D operator*(const Point3D &p, const OCP_DBL &a)
Point * a.
Definition: CornerGrid.cpp:61
OCP_DBL VolumHexahedron(const Hexahedron &h)
Get the volume of a hexahedron.
Definition: CornerGrid.cpp:89
const USI MAX_NEIGHBOR
Max number of neighbors allowed.
Definition: CornerGrid.hpp:29
Definition of build-in datatypes and consts.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
unsigned int OCP_BOOL
OCP_BOOL in OCP.
Definition: OCPConst.hpp:29
Definition: Grid.hpp:89
vector< OCP_DBL > v
Volume of cells: numGrid.
Definition: Grid.hpp:165
USI nx
Number of cells in x-direction.
Definition: Grid.hpp:145
vector< OCP_DBL > depth
Depth of center of grid cells: numGrid.
Definition: Grid.hpp:166
vector< OCP_DBL > dz
Size of cell in z-direction: numGrid.
Definition: Grid.hpp:164
USI nz
Number of cells in z-direction.
Definition: Grid.hpp:147
vector< OCP_DBL > zcorn
ZValues of a corner-point grid.
Definition: Grid.hpp:151
vector< OCP_DBL > coord
Lines of a corner-point grid.
Definition: Grid.hpp:150
USI ny
Number of cells in y-direction.
Definition: Grid.hpp:146
vector< OCP_DBL > dy
Size of cell in y-direction: numGrid.
Definition: Grid.hpp:163
vector< OCP_DBL > dx
Size of cell in x-direction: numGrid.
Definition: Grid.hpp:162
OCP_USI numGrid
Number of all cells.
Definition: Grid.hpp:142
A face of a hexahedron cell.
Definition: CornerGrid.hpp:88
A hexahedron cell.
Definition: CornerGrid.hpp:81
3 by 3 matrix.
Definition: CornerGrid.hpp:95
A point in 2D.
Definition: CornerGrid.hpp:33
A point in 3D.
Definition: CornerGrid.hpp:47