OpenCAEPoro  0.2.0 Sep/22/2022
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 };
65 
66 Point3D operator*(const Point3D& p, const OCP_DBL& a);
67 Point3D operator*(const OCP_DBL& a, const Point3D& p);
68 Point3D CrossProduct(const Point3D& p1, const Point3D& p2);
69 
72 {
73 public:
74  Point3D p0, p1, p2, p3, p4, p5, p6, p7;
75 };
76 
79 {
80 public:
81  Point3D p0, p1, p2, p3;
82 };
83 
85 class Matrix3
86 {
87 public:
88  OCP_DBL M[3][3];
89  Point3D operator*(const Point3D& v) const;
90 };
91 
94 
97 
100 
103 
105 Point2D CalCrossingPoint(const Point2D Line1[2], const Point2D Line2[2]);
106 
108 OCP_DBL CalAreaNotQuadr(const HexahedronFace& FACE1, const HexahedronFace& FACE2);
109 
110 
111 
113 class HalfConn
114 {
115 public:
116  OCP_DBL Ad_dd;
117  Point3D d;
118  OCP_USI neigh;
119  USI directionType; // 1 - x, 2 - y, 3 - z, 4 - extension
120 };
121 
123 class ConnGrid
124 {
125 public:
126  USI nConn, maxConn;
127  vector<HalfConn> halfConn;
128  void Allocate(const USI& max_neighbor);
129  void AddHalfConn(const OCP_USI& n, const Point3D& area, const Point3D& d,
130  const USI& direction, const OCP_DBL& flag = 1);
131 };
132 
135 {
136 public:
137  OCP_USI begin, end;
138  USI directionType; // 1 - x, 2 - y, 3 - z, 4 - extension
139  OCP_DBL Ad_dd_begin;
140  OCP_DBL Ad_dd_end;
141 };
142 
144 class COORD
145 {
146  friend class Grid;
147 
148 public:
149  void Allocate(const USI& Nx, const USI& Ny, const USI& Nz);
150  void InputData(const vector<OCP_DBL>& coord, const vector<OCP_DBL>& zcorn);
151  bool InputCOORDDATA(const vector<OCP_DBL>& coord);
152  bool InputZCORNDATA(const vector<OCP_DBL>& zcorn);
153  // New version
154  void SetupCornerPoints();
155  void SetAllFlags(const HexahedronFace& oFace, const HexahedronFace& Face);
156  // functions
157  OCP_DBL OCP_SIGN(const OCP_DBL& x) { return x >= 0 ? 1 : -1; }
158 
159 private:
160  USI nx;
161  USI ny;
162  USI nz;
163  OCP_DBL*** COORDDATA;
164  OCP_DBL**** ZCORNDATA;
165  Hexahedron*** cornerPoints;
166 
167  OCP_USI numGrid;
168  OCP_USI numConn;
169  OCP_USI numConnMax;
170  vector<OCP_DBL> v;
171  vector<OCP_DBL> depth;
172  vector<OCP_DBL> dx;
173  vector<OCP_DBL> dy;
174  vector<OCP_DBL> dz;
175  vector<Point3D> center;
176 
177  vector<GeneralConnect> connect;
178 
179  // Auxiliary variables
180  // if the i th point of oFace is deeper than the one of Face, then flagpi = 1;
181  // if the i th point of oFace is higher than the one of Face, then flagpi = -1;
182  // if the i th point of oFace is very close to the one of Face, then flagpi = 0;
183  OCP_INT flagp0, flagp1, flagp2, flagp3;
184  bool flagQuad;
185  bool upNNC, downNNC;
186  bool flagJump;
187  HexahedronFace tmpFace;
188  // after the Axes are determined, blocks will be placed along the y+, or along the y-
189  // if y+, then flagForward equals 1.0, else -1.0, this relates to calculation of
190  // area normal vector
191  OCP_DBL flagForward;
192 };
193 
194 #endif
195 
196 /*----------------------------------------------------------------------------*/
197 /* Brief Change History of This File */
198 /*----------------------------------------------------------------------------*/
199 /* Author Date Actions */
200 /*----------------------------------------------------------------------------*/
201 /* Shizhe Li Nov/16/2021 Create file */
202 /* Chensong Zhang Jan/16/2022 Update Doxygen */
203 /*----------------------------------------------------------------------------*/
OCP_DBL CalAreaNotQuadr(const HexahedronFace &FACE1, const HexahedronFace &FACE2)
???
Definition: CornerGrid.cpp:175
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:122
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:48
Point2D CalCrossingPoint(const Point2D Line1[2], const Point2D Line2[2])
???
Definition: CornerGrid.cpp:140
Point3D CenterHexahedron(const Hexahedron &h)
Find the center of a hexahedron.
Definition: CornerGrid.cpp:115
Point3D CenterFace(const HexahedronFace &f)
Find the center of a face.
Definition: CornerGrid.cpp:133
Point3D operator*(const Point3D &p, const OCP_DBL &a)
Point * a.
Definition: CornerGrid.cpp:38
OCP_DBL VolumHexahedron(const Hexahedron &h)
Get the volume of a hexahedron.
Definition: CornerGrid.cpp:66
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:22
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:24
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
Basic information of computational grid, including the rock properties.
Definition: Grid.hpp:76
A face of a hexahedron cell.
Definition: CornerGrid.hpp:79
A hexahedron cell.
Definition: CornerGrid.hpp:72
3 by 3 matrix.
Definition: CornerGrid.hpp:86
A point in 2D.
Definition: CornerGrid.hpp:33
A point in 3D.
Definition: CornerGrid.hpp:47