1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "transform.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 // Update this with w2 if w2 nearer to pt.
32 template<class TrackingData>
33 inline bool Foam::pointEdgePoint::update
36 const pointEdgePoint& w2,
41 scalar dist2 = magSqr(pt - w2.origin());
45 // current not yet set so use any value
47 origin_ = w2.origin();
52 scalar diff = distSqr_ - dist2;
56 // already nearer to pt
60 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
62 // don't propagate small changes
67 // update with new values
69 origin_ = w2.origin();
76 // Update this with w2 (information on same point)
77 template<class TrackingData>
78 inline bool Foam::pointEdgePoint::update
80 const pointEdgePoint& w2,
87 // current not yet set so use any value
88 distSqr_ = w2.distSqr();
89 origin_ = w2.origin();
94 scalar diff = distSqr_ - w2.distSqr();
98 // already nearer to pt
102 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
104 // don't propagate small changes
109 // update with new values
110 distSqr_ = w2.distSqr();
111 origin_ = w2.origin();
118 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
121 inline Foam::pointEdgePoint::pointEdgePoint()
128 // Construct from origin, distance
129 inline Foam::pointEdgePoint::pointEdgePoint
141 inline Foam::pointEdgePoint::pointEdgePoint(const pointEdgePoint& wpt)
143 origin_(wpt.origin()),
144 distSqr_(wpt.distSqr())
148 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 inline const Foam::point& Foam::pointEdgePoint::origin() const
156 inline Foam::scalar Foam::pointEdgePoint::distSqr() const
162 template<class TrackingData>
163 inline bool Foam::pointEdgePoint::valid(TrackingData& td) const
165 return origin_ != point::max;
169 // Checks for cyclic points
170 template<class TrackingData>
171 inline bool Foam::pointEdgePoint::sameGeometry
173 const pointEdgePoint& w2,
178 scalar diff = Foam::mag(distSqr() - w2.distSqr());
186 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
198 template<class TrackingData>
199 inline void Foam::pointEdgePoint::leaveDomain
201 const polyPatch& patch,
202 const label patchPointI,
211 template<class TrackingData>
212 inline void Foam::pointEdgePoint::transform
214 const tensor& rotTensor,
218 origin_ = Foam::transform(rotTensor, origin_);
222 // Update absolute geometric quantities. Note that distance (distSqr_)
223 // is not affected by leaving/entering domain.
224 template<class TrackingData>
225 inline void Foam::pointEdgePoint::enterDomain
227 const polyPatch& patch,
228 const label patchPointI,
233 // back to absolute form
238 // Update this with information from connected edge
239 template<class TrackingData>
240 inline bool Foam::pointEdgePoint::updatePoint
242 const polyMesh& mesh,
245 const pointEdgePoint& edgeInfo,
250 return update(mesh.points()[pointI], edgeInfo, tol, td);
254 // Update this with new information on same point
255 template<class TrackingData>
256 inline bool Foam::pointEdgePoint::updatePoint
258 const polyMesh& mesh,
260 const pointEdgePoint& newPointInfo,
265 return update(mesh.points()[pointI], newPointInfo, tol, td);
269 // Update this with new information on same point. No extra information.
270 template<class TrackingData>
271 inline bool Foam::pointEdgePoint::updatePoint
273 const pointEdgePoint& newPointInfo,
278 return update(newPointInfo, tol, td);
282 // Update this with information from connected point
283 template<class TrackingData>
284 inline bool Foam::pointEdgePoint::updateEdge
286 const polyMesh& mesh,
289 const pointEdgePoint& pointInfo,
294 const edge& e = mesh.edges()[edgeI];
295 return update(e.centre(mesh.points()), pointInfo, tol, td);
299 template <class TrackingData>
300 inline bool Foam::pointEdgePoint::equal
302 const pointEdgePoint& rhs,
306 return operator==(rhs);
310 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
312 inline bool Foam::pointEdgePoint::operator==(const Foam::pointEdgePoint& rhs)
315 return origin() == rhs.origin();
319 inline bool Foam::pointEdgePoint::operator!=(const Foam::pointEdgePoint& rhs)
322 return !(*this == rhs);
326 // ************************************************************************* //