00001 #include "wellinfo.h"
00002 #include "numericmethods.h"
00003 WellInfo::WellInfo(Point3D p1,Point3D p2,double value,ConditionType bcType)
00004 :P(p1),Q(p2),m_bcType(bcType),m_value(value)
00005 {
00006 assert(p1[0] < p2[0] &&
00007 p1[1] < p2[1] &&
00008 p1[2] < p2[2]);
00009 }
00010
00011 bool WellInfo::isPointInWell(const Point3D &p1) const
00012 {
00013 return (p1[0] >= P[0] && p1[0] <= Q[0] &&
00014 p1[1] >= P[1] && p1[1] <= Q[1] &&
00015 p1[2] >= P[2] && p1[2] <= Q[2]);
00016
00017 }
00018 bool WellInfo::isPointInWell(const VecDouble &p1) const
00019 {
00020 assert(p1.size() ==3);
00021 return (p1(0) >= P[0] && p1(0) <= Q[0] &&
00022 p1(1) >= P[1] && p1(1) <= Q[1] &&
00023 p1(2) >= P[2] && p1(2) <= Q[2]);
00024
00025 }
00026
00027
00028 double WellInfo::volume()
00029 {
00030 return fabs( (Q[0]-P[0])*(Q[1]-P[1])*(Q[2]-P[2]) );
00031 }
00032
00033
00034
00035
00036 double WellInfo::area()
00037 {
00038 Point3D DX = Q;
00039 DX -=P;
00040
00041 return 2*(DX[0]*DX[1] + DX[0]*DX[2] + DX[1]*DX[2]);
00042
00043 }
00044
00045
00046 void WellInfo::adjustBoundaryWithGrid(const Point3D &DX)
00047 {
00048 double tol = NumericMethods::min(DX[0],DX[1],DX[2])/10.0;
00049 P[0] = floor(P[0]/DX[0])*DX[0];
00050 P[1] = floor(P[1]/DX[1])*DX[1];
00051 P[2] = floor(P[2]/DX[2])*DX[2];
00052
00053 Q[0] = ceil(Q[0]/DX[0])*DX[0];
00054 Q[1] = ceil(Q[1]/DX[1])*DX[1];
00055 Q[2] = ceil(Q[2]/DX[2])*DX[2];
00056
00057
00058
00059
00060
00061
00062 if (NumericMethods::a_equal(P[0],Q[0],tol))
00063 Q[0] = P[0]+DX[0];
00064 if (NumericMethods::a_equal(P[1],Q[1],tol))
00065 Q[1] = P[1]+DX[1];
00066 if (NumericMethods::a_equal(P[2],Q[2],tol))
00067 Q[2] = P[2]+DX[2];
00068
00069 }
00070
00071
00072 bool WellInfo::isInnerCell(Point3D &cellCenter,Point3D &DX)
00073 {
00074 if (!isPointInWell(cellCenter))
00075 return false;
00076
00077 Point3D p = P;
00078 p+=DX;
00079
00080 Point3D q = Q;
00081 q-=DX;
00082
00083 if (p[0] >= q[0] || p[1] >= q[1] ||p[2] >= q[2])
00084 {
00085 return false;
00086 }
00087
00088
00089 return NumericMethods::isInCube(p,q,cellCenter);
00090 }