1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "transform.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 // Update this with w2 if w2 nearer to pt.
33 inline bool Foam::pointEdgePoint::update
36 const pointEdgePoint& w2,
40 scalar dist2 = magSqr(pt - w2.origin());
44 // current not yet set so use any value
46 origin_ = w2.origin();
51 scalar diff = distSqr_ - dist2;
55 // already nearer to pt
59 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
61 // don't propagate small changes
66 // update with new values
68 origin_ = w2.origin();
75 // Update this with w2 (information on same point)
76 inline bool Foam::pointEdgePoint::update
78 const pointEdgePoint& w2,
84 // current not yet set so use any value
85 distSqr_ = w2.distSqr();
86 origin_ = w2.origin();
91 scalar diff = distSqr_ - w2.distSqr();
95 // already nearer to pt
99 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
101 // don't propagate small changes
106 // update with new values
107 distSqr_ = w2.distSqr();
108 origin_ = w2.origin();
114 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 inline Foam::pointEdgePoint::pointEdgePoint()
124 // Construct from origin, distance
125 inline Foam::pointEdgePoint::pointEdgePoint
137 inline Foam::pointEdgePoint::pointEdgePoint(const pointEdgePoint& wpt)
139 origin_(wpt.origin()),
140 distSqr_(wpt.distSqr())
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 inline const Foam::point& Foam::pointEdgePoint::origin() const
152 inline Foam::scalar Foam::pointEdgePoint::distSqr() const
158 inline bool Foam::pointEdgePoint::valid() const
160 return origin_ != greatPoint;
164 // Checks for cyclic points
165 inline bool Foam::pointEdgePoint::sameGeometry
167 const pointEdgePoint& w2,
171 scalar diff = Foam::mag(distSqr() - w2.distSqr());
179 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
191 inline void Foam::pointEdgePoint::leaveDomain
193 const polyPatch& patch,
194 const label patchPointI,
202 inline void Foam::pointEdgePoint::transform(const tensor& rotTensor)
204 origin_ = Foam::transform(rotTensor, origin_);
208 // Update absolute geometric quantities. Note that distance (distSqr_)
209 // is not affected by leaving/entering domain.
210 inline void Foam::pointEdgePoint::enterDomain
212 const polyPatch& patch,
213 const label patchPointI,
217 // back to absolute form
222 // Update this with information from connected edge
223 inline bool Foam::pointEdgePoint::updatePoint
225 const polyMesh& mesh,
228 const pointEdgePoint& edgeInfo,
235 mesh.points()[pointI],
242 // Update this with new information on same point
243 inline bool Foam::pointEdgePoint::updatePoint
245 const polyMesh& mesh,
247 const pointEdgePoint& newPointInfo,
254 mesh.points()[pointI],
261 // Update this with new information on same point. No extra information.
262 inline bool Foam::pointEdgePoint::updatePoint
264 const pointEdgePoint& newPointInfo,
268 return update(newPointInfo, tol);
272 // Update this with information from connected point
273 inline bool Foam::pointEdgePoint::updateEdge
275 const polyMesh& mesh,
278 const pointEdgePoint& pointInfo,
282 const pointField& points = mesh.points();
284 const edge& e = mesh.edges()[edgeI];
286 const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
298 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
300 inline bool Foam::pointEdgePoint::operator==(const Foam::pointEdgePoint& rhs)
303 return origin() == rhs.origin();
307 inline bool Foam::pointEdgePoint::operator!=(const Foam::pointEdgePoint& rhs)
310 return !(*this == rhs);
314 // ************************************************************************* //