1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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
25 \*---------------------------------------------------------------------------*/
28 #include "transform.H"
29 #include "wallPoint.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 // Update this with w2 if w2 nearer to pt.
34 inline bool Foam::pointData::update
41 scalar dist2 = magSqr(pt - w2.origin());
46 origin_ = w2.origin();
60 scalar diff = distSqr_ - dist2;
64 // already nearer to pt
68 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
70 // don't propagate small changes
75 // update with new values
77 origin_ = w2.origin();
86 // Update this with w2 (information on same point)
87 inline bool Foam::pointData::update
95 // current not yet set so use any value
96 distSqr_ = w2.distSqr();
97 origin_ = w2.origin();
110 scalar diff = distSqr_ - w2.distSqr();
114 // already nearer to pt
118 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
120 // don't propagate small changes
125 // update with new values
126 distSqr_ = w2.distSqr();
127 origin_ = w2.origin();
136 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
139 inline Foam::pointData::pointData()
141 origin_(wallPoint::greatPoint),
144 v_(wallPoint::greatPoint)
148 // Construct from origin, distance
149 inline Foam::pointData::pointData
152 const scalar distSqr,
165 inline Foam::pointData::pointData(const pointData& wpt)
167 origin_(wpt.origin()),
168 distSqr_(wpt.distSqr()),
174 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
176 inline const Foam::point& Foam::pointData::origin() const
182 inline Foam::scalar Foam::pointData::distSqr() const
188 inline Foam::scalar Foam::pointData::s() const
194 inline const Foam::vector& Foam::pointData::v() const
200 inline bool Foam::pointData::valid() const
202 return origin_ != wallPoint::greatPoint;
206 // Checks for cyclic points
207 inline bool Foam::pointData::sameGeometry
213 scalar diff = Foam::mag(distSqr() - w2.distSqr());
221 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
233 inline void Foam::pointData::leaveDomain
235 const polyPatch& patch,
236 const label patchPointI,
244 inline void Foam::pointData::transform(const tensor& rotTensor)
246 origin_ = Foam::transform(rotTensor, origin_);
250 // Update absolute geometric quantities. Note that distance (distSqr_)
251 // is not affected by leaving/entering domain.
252 inline void Foam::pointData::enterDomain
254 const polyPatch& patch,
255 const label patchPointI,
259 // back to absolute form
264 // Update this with information from connected edge
265 inline bool Foam::pointData::updatePoint
267 const polyMesh& mesh,
270 const pointData& edgeInfo,
277 mesh.points()[pointI],
284 // Update this with new information on same point
285 inline bool Foam::pointData::updatePoint
287 const polyMesh& mesh,
289 const pointData& newPointInfo,
296 mesh.points()[pointI],
303 // Update this with new information on same point. No extra information.
304 inline bool Foam::pointData::updatePoint
306 const pointData& newPointInfo,
310 return update(newPointInfo, tol);
314 // Update this with information from connected point
315 inline bool Foam::pointData::updateEdge
317 const polyMesh& mesh,
320 const pointData& pointInfo,
324 const pointField& points = mesh.points();
326 const edge& e = mesh.edges()[edgeI];
328 const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
340 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
342 inline bool Foam::pointData::operator==(const pointData& rhs) const
344 return origin() == rhs.origin();
348 inline bool Foam::pointData::operator!=(const pointData& rhs) const
350 return !(*this == rhs);
354 // ************************************************************************* //