1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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
27 \*---------------------------------------------------------------------------*/
30 #include "transform.H"
31 #include "wallPoint.H"
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 // Update this with w2 if w2 nearer to pt.
36 inline bool Foam::pointData::update
43 scalar dist2 = magSqr(pt - w2.origin());
48 origin_ = w2.origin();
62 scalar diff = distSqr_ - dist2;
66 // already nearer to pt
70 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
72 // don't propagate small changes
77 // update with new values
79 origin_ = w2.origin();
88 // Update this with w2 (information on same point)
89 inline bool Foam::pointData::update
97 // current not yet set so use any value
98 distSqr_ = w2.distSqr();
99 origin_ = w2.origin();
112 scalar diff = distSqr_ - w2.distSqr();
116 // already nearer to pt
120 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
122 // don't propagate small changes
127 // update with new values
128 distSqr_ = w2.distSqr();
129 origin_ = w2.origin();
138 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
141 inline Foam::pointData::pointData()
143 origin_(wallPoint::greatPoint),
146 v_(wallPoint::greatPoint)
150 // Construct from origin, distance
151 inline Foam::pointData::pointData
154 const scalar distSqr,
167 inline Foam::pointData::pointData(const pointData& wpt)
169 origin_(wpt.origin()),
170 distSqr_(wpt.distSqr()),
176 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
178 inline const Foam::point& Foam::pointData::origin() const
184 inline Foam::scalar Foam::pointData::distSqr() const
190 inline Foam::scalar Foam::pointData::s() const
196 inline const Foam::vector& Foam::pointData::v() const
202 inline bool Foam::pointData::valid() const
204 return origin_ != wallPoint::greatPoint;
208 // Checks for cyclic points
209 inline bool Foam::pointData::sameGeometry
215 scalar diff = Foam::mag(distSqr() - w2.distSqr());
223 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
235 inline void Foam::pointData::leaveDomain
237 const polyPatch& patch,
238 const label patchPointI,
246 inline void Foam::pointData::transform(const tensor& rotTensor)
248 origin_ = Foam::transform(rotTensor, origin_);
252 // Update absolute geometric quantities. Note that distance (distSqr_)
253 // is not affected by leaving/entering domain.
254 inline void Foam::pointData::enterDomain
256 const polyPatch& patch,
257 const label patchPointI,
261 // back to absolute form
266 // Update this with information from connected edge
267 inline bool Foam::pointData::updatePoint
269 const polyMesh& mesh,
272 const pointData& edgeInfo,
279 mesh.points()[pointI],
286 // Update this with new information on same point
287 inline bool Foam::pointData::updatePoint
289 const polyMesh& mesh,
291 const pointData& newPointInfo,
298 mesh.points()[pointI],
305 // Update this with new information on same point. No extra information.
306 inline bool Foam::pointData::updatePoint
308 const pointData& newPointInfo,
312 return update(newPointInfo, tol);
316 // Update this with information from connected point
317 inline bool Foam::pointData::updateEdge
319 const polyMesh& mesh,
322 const pointData& pointInfo,
326 const pointField& points = mesh.points();
328 const edge& e = mesh.edges()[edgeI];
330 const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
342 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
344 inline bool Foam::pointData::operator==(const pointData& rhs) const
346 return origin() == rhs.origin();
350 inline bool Foam::pointData::operator!=(const pointData& rhs) const
352 return !(*this == rhs);
356 // ************************************************************************* //