1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 inline bool Foam::pointEdgePoint::update
35 const pointEdgePoint& w2,
39 scalar dist2 = magSqr(pt - w2.origin());
43 // current not yet set so use any value
45 origin_ = w2.origin();
50 scalar diff = distSqr_ - dist2;
54 // already nearer to pt
58 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
60 // don't propagate small changes
65 // update with new values
67 origin_ = w2.origin();
74 // Update this with w2 (information on same point)
75 inline bool Foam::pointEdgePoint::update
77 const pointEdgePoint& w2,
83 // current not yet set so use any value
84 distSqr_ = w2.distSqr();
85 origin_ = w2.origin();
90 scalar diff = distSqr_ - w2.distSqr();
94 // already nearer to pt
98 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
100 // don't propagate small changes
105 // update with new values
106 distSqr_ = w2.distSqr();
107 origin_ = w2.origin();
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
116 inline Foam::pointEdgePoint::pointEdgePoint()
123 // Construct from origin, distance
124 inline Foam::pointEdgePoint::pointEdgePoint
136 inline Foam::pointEdgePoint::pointEdgePoint(const pointEdgePoint& wpt)
138 origin_(wpt.origin()),
139 distSqr_(wpt.distSqr())
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 inline const Foam::point& Foam::pointEdgePoint::origin() const
151 inline Foam::scalar Foam::pointEdgePoint::distSqr() const
157 inline bool Foam::pointEdgePoint::valid() const
159 return origin_ != greatPoint;
163 // Checks for cyclic points
164 inline bool Foam::pointEdgePoint::sameGeometry
166 const pointEdgePoint& w2,
170 scalar diff = Foam::mag(distSqr() - w2.distSqr());
178 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
190 inline void Foam::pointEdgePoint::leaveDomain
192 const polyPatch& patch,
193 const label patchPointI,
201 inline void Foam::pointEdgePoint::transform(const tensor& rotTensor)
203 origin_ = Foam::transform(rotTensor, origin_);
207 // Update absolute geometric quantities. Note that distance (distSqr_)
208 // is not affected by leaving/entering domain.
209 inline void Foam::pointEdgePoint::enterDomain
211 const polyPatch& patch,
212 const label patchPointI,
216 // back to absolute form
221 // Update this with information from connected edge
222 inline bool Foam::pointEdgePoint::updatePoint
224 const polyMesh& mesh,
227 const pointEdgePoint& edgeInfo,
234 mesh.allPoints()[pointI],
241 // Update this with new information on same point
242 inline bool Foam::pointEdgePoint::updatePoint
244 const polyMesh& mesh,
246 const pointEdgePoint& newPointInfo,
253 mesh.allPoints()[pointI],
260 // Update this with new information on same point. No extra information.
261 inline bool Foam::pointEdgePoint::updatePoint
263 const pointEdgePoint& newPointInfo,
267 return update(newPointInfo, tol);
271 // Update this with information from connected point
272 inline bool Foam::pointEdgePoint::updateEdge
274 const polyMesh& mesh,
277 const pointEdgePoint& pointInfo,
281 const pointField& points = mesh.points();
283 const edge& e = mesh.edges()[edgeI];
285 const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
297 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
299 inline bool Foam::pointEdgePoint::operator==(const Foam::pointEdgePoint& rhs)
302 return origin() == rhs.origin();
306 inline bool Foam::pointEdgePoint::operator!=(const Foam::pointEdgePoint& rhs)
309 return !(*this == rhs);
313 // ************************************************************************* //