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"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 // Update this with w2 if w2 nearer to pt.
33 inline bool Foam::wallPoint::update
40 //Already done in calling algorithm
41 //if (w2.origin() == origin_)
43 // // Shortcut. Same input so same distance.
47 scalar dist2 = magSqr(pt - w2.origin());
51 // current not yet set so use any value
53 origin_ = w2.origin();
58 scalar diff = distSqr_ - dist2;
62 // already nearer to pt
66 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
68 // don't propagate small changes
73 // update with new values
75 origin_ = w2.origin();
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85 inline Foam::wallPoint::wallPoint()
92 // Construct from origin, distance
93 inline Foam::wallPoint::wallPoint(const point& origin, const scalar distSqr)
95 origin_(origin), distSqr_(distSqr)
100 inline Foam::wallPoint::wallPoint(const wallPoint& wpt)
102 origin_(wpt.origin()), distSqr_(wpt.distSqr())
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 inline const Foam::point& Foam::wallPoint::origin() const
114 inline Foam::point& Foam::wallPoint::origin()
120 inline Foam::scalar Foam::wallPoint::distSqr() const
126 inline Foam::scalar& Foam::wallPoint::distSqr()
132 inline bool Foam::wallPoint::valid() const
134 return origin_ != greatPoint;
138 // Checks for cyclic faces
139 inline bool Foam::wallPoint::sameGeometry
147 scalar diff = mag(distSqr() - w2.distSqr());
155 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
167 inline void Foam::wallPoint::leaveDomain
172 const point& faceCentre
175 origin_ -= faceCentre;
179 inline void Foam::wallPoint::transform
182 const tensor& rotTensor
185 origin_ = Foam::transform(rotTensor, origin_);
189 // Update absolute geometric quantities. Note that distance (distSqr_)
190 // is not affected by leaving/entering domain.
191 inline void Foam::wallPoint::enterDomain
196 const point& faceCentre
199 // back to absolute form
200 origin_ += faceCentre;
204 // Update this with w2 if w2 nearer to pt.
205 inline bool Foam::wallPoint::updateCell
207 const polyMesh& mesh,
208 const label thisCellI,
209 const label neighbourFaceI,
210 const wallPoint& neighbourWallInfo,
217 mesh.cellCentres()[thisCellI],
224 // Update this with w2 if w2 nearer to pt.
225 inline bool Foam::wallPoint::updateFace
227 const polyMesh& mesh,
228 const label thisFaceI,
229 const label neighbourCellI,
230 const wallPoint& neighbourWallInfo,
237 mesh.faceCentres()[thisFaceI],
243 // Update this with w2 if w2 nearer to pt.
244 inline bool Foam::wallPoint::updateFace
246 const polyMesh& mesh,
247 const label thisFaceI,
248 const wallPoint& neighbourWallInfo,
255 mesh.faceCentres()[thisFaceI],
262 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
264 inline bool Foam::wallPoint::operator==(const Foam::wallPoint& rhs) const
266 return origin() == rhs.origin();
270 inline bool Foam::wallPoint::operator!=(const Foam::wallPoint& rhs) const
272 return !(*this == rhs);
276 // ************************************************************************* //