Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <OpenFOAM/polyMesh.H>
00027 #include <OpenFOAM/transform.H>
00028
00029
00030
00031
00032 inline bool Foam::pointEdgePoint::update
00033 (
00034 const point& pt,
00035 const pointEdgePoint& w2,
00036 const scalar tol
00037 )
00038 {
00039 scalar dist2 = magSqr(pt - w2.origin());
00040
00041 if (!valid())
00042 {
00043
00044 distSqr_ = dist2;
00045 origin_ = w2.origin();
00046
00047 return true;
00048 }
00049
00050 scalar diff = distSqr_ - dist2;
00051
00052 if (diff < 0)
00053 {
00054
00055 return false;
00056 }
00057
00058 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
00059 {
00060
00061 return false;
00062 }
00063 else
00064 {
00065
00066 distSqr_ = dist2;
00067 origin_ = w2.origin();
00068
00069 return true;
00070 }
00071 }
00072
00073
00074
00075 inline bool Foam::pointEdgePoint::update
00076 (
00077 const pointEdgePoint& w2,
00078 const scalar tol
00079 )
00080 {
00081 if (!valid())
00082 {
00083
00084 distSqr_ = w2.distSqr();
00085 origin_ = w2.origin();
00086
00087 return true;
00088 }
00089
00090 scalar diff = distSqr_ - w2.distSqr();
00091
00092 if (diff < 0)
00093 {
00094
00095 return false;
00096 }
00097
00098 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
00099 {
00100
00101 return false;
00102 }
00103 else
00104 {
00105
00106 distSqr_ = w2.distSqr();
00107 origin_ = w2.origin();
00108
00109 return true;
00110 }
00111 }
00112
00113
00114
00115
00116 inline Foam::pointEdgePoint::pointEdgePoint()
00117 :
00118 origin_(greatPoint),
00119 distSqr_(GREAT)
00120 {}
00121
00122
00123
00124 inline Foam::pointEdgePoint::pointEdgePoint
00125 (
00126 const point& origin,
00127 const scalar distSqr
00128 )
00129 :
00130 origin_(origin),
00131 distSqr_(distSqr)
00132 {}
00133
00134
00135
00136 inline Foam::pointEdgePoint::pointEdgePoint(const pointEdgePoint& wpt)
00137 :
00138 origin_(wpt.origin()),
00139 distSqr_(wpt.distSqr())
00140 {}
00141
00142
00143
00144
00145 inline const Foam::point& Foam::pointEdgePoint::origin() const
00146 {
00147 return origin_;
00148 }
00149
00150
00151 inline Foam::scalar Foam::pointEdgePoint::distSqr() const
00152 {
00153 return distSqr_;
00154 }
00155
00156
00157 inline bool Foam::pointEdgePoint::valid() const
00158 {
00159 return origin_ != greatPoint;
00160 }
00161
00162
00163
00164 inline bool Foam::pointEdgePoint::sameGeometry
00165 (
00166 const pointEdgePoint& w2,
00167 const scalar tol
00168 ) const
00169 {
00170 scalar diff = Foam::mag(distSqr() - w2.distSqr());
00171
00172 if (diff < SMALL)
00173 {
00174 return true;
00175 }
00176 else
00177 {
00178 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
00179 {
00180 return true;
00181 }
00182 else
00183 {
00184 return false;
00185 }
00186 }
00187 }
00188
00189
00190 inline void Foam::pointEdgePoint::leaveDomain
00191 (
00192 const polyPatch& patch,
00193 const label patchPointI,
00194 const point& coord
00195 )
00196 {
00197 origin_ -= coord;
00198 }
00199
00200
00201 inline void Foam::pointEdgePoint::transform(const tensor& rotTensor)
00202 {
00203 origin_ = Foam::transform(rotTensor, origin_);
00204 }
00205
00206
00207
00208
00209 inline void Foam::pointEdgePoint::enterDomain
00210 (
00211 const polyPatch& patch,
00212 const label patchPointI,
00213 const point& coord
00214 )
00215 {
00216
00217 origin_ += coord;
00218 }
00219
00220
00221
00222 inline bool Foam::pointEdgePoint::updatePoint
00223 (
00224 const polyMesh& mesh,
00225 const label pointI,
00226 const label edgeI,
00227 const pointEdgePoint& edgeInfo,
00228 const scalar tol
00229 )
00230 {
00231 return
00232 update
00233 (
00234 mesh.points()[pointI],
00235 edgeInfo,
00236 tol
00237 );
00238 }
00239
00240
00241
00242 inline bool Foam::pointEdgePoint::updatePoint
00243 (
00244 const polyMesh& mesh,
00245 const label pointI,
00246 const pointEdgePoint& newPointInfo,
00247 const scalar tol
00248 )
00249 {
00250 return
00251 update
00252 (
00253 mesh.points()[pointI],
00254 newPointInfo,
00255 tol
00256 );
00257 }
00258
00259
00260
00261 inline bool Foam::pointEdgePoint::updatePoint
00262 (
00263 const pointEdgePoint& newPointInfo,
00264 const scalar tol
00265 )
00266 {
00267 return update(newPointInfo, tol);
00268 }
00269
00270
00271
00272 inline bool Foam::pointEdgePoint::updateEdge
00273 (
00274 const polyMesh& mesh,
00275 const label edgeI,
00276 const label pointI,
00277 const pointEdgePoint& pointInfo,
00278 const scalar tol
00279 )
00280 {
00281 const pointField& points = mesh.points();
00282
00283 const edge& e = mesh.edges()[edgeI];
00284
00285 const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
00286
00287 return
00288 update
00289 (
00290 edgeMid,
00291 pointInfo,
00292 tol
00293 );
00294 }
00295
00296
00297
00298
00299 inline bool Foam::pointEdgePoint::operator==(const Foam::pointEdgePoint& rhs)
00300 const
00301 {
00302 return origin() == rhs.origin();
00303 }
00304
00305
00306 inline bool Foam::pointEdgePoint::operator!=(const Foam::pointEdgePoint& rhs)
00307 const
00308 {
00309 return !(*this == rhs);
00310 }
00311
00312
00313