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::patchEdgeFaceInfo::update
36 const patchEdgeFaceInfo& 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 edge)
77 template<class TrackingData>
78 inline bool Foam::patchEdgeFaceInfo::update
80 const patchEdgeFaceInfo& 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::patchEdgeFaceInfo::patchEdgeFaceInfo()
128 // Construct from origin, distance
129 inline Foam::patchEdgeFaceInfo::patchEdgeFaceInfo
141 inline Foam::patchEdgeFaceInfo::patchEdgeFaceInfo(const patchEdgeFaceInfo& wpt)
143 origin_(wpt.origin()),
144 distSqr_(wpt.distSqr())
148 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 inline const Foam::point& Foam::patchEdgeFaceInfo::origin() const
156 inline Foam::scalar Foam::patchEdgeFaceInfo::distSqr() const
162 template<class TrackingData>
163 inline bool Foam::patchEdgeFaceInfo::valid(TrackingData& td) const
165 return origin_ != point::max;
169 template<class TrackingData>
170 inline void Foam::patchEdgeFaceInfo::transform
172 const polyMesh& mesh,
173 const primitivePatch& patch,
174 const tensor& rotTensor,
179 origin_ = Foam::transform(rotTensor, origin_);
183 template<class TrackingData>
184 inline bool Foam::patchEdgeFaceInfo::updateEdge
186 const polyMesh& mesh,
187 const primitivePatch& patch,
190 const patchEdgeFaceInfo& faceInfo,
195 const edge& e = patch.edges()[edgeI];
199 patch.points()[patch.meshPoints()[e[0]]]
200 + patch.points()[patch.meshPoints()[e[1]]]
202 return update(eMid, faceInfo, tol, td);
206 template<class TrackingData>
207 inline bool Foam::patchEdgeFaceInfo::updateEdge
209 const polyMesh& mesh,
210 const primitivePatch& patch,
211 const patchEdgeFaceInfo& edgeInfo,
212 const bool sameOrientation,
217 return update(edgeInfo, tol, td);
221 template<class TrackingData>
222 inline bool Foam::patchEdgeFaceInfo::updateFace
224 const polyMesh& mesh,
225 const primitivePatch& patch,
228 const patchEdgeFaceInfo& edgeInfo,
233 return update(patch.faceCentres()[faceI], edgeInfo, tol, td);
237 template <class TrackingData>
238 inline bool Foam::patchEdgeFaceInfo::equal
240 const patchEdgeFaceInfo& rhs,
244 return operator==(rhs);
248 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
250 inline bool Foam::patchEdgeFaceInfo::operator==
252 const Foam::patchEdgeFaceInfo& rhs
255 return origin() == rhs.origin();
259 inline bool Foam::patchEdgeFaceInfo::operator!=
261 const Foam::patchEdgeFaceInfo& rhs
264 return !(*this == rhs);
268 // ************************************************************************* //