initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / autoMesh / autoHexMesh / autoHexMeshDriver / pointData / pointDataI.H
blob9832bbf877d0fe53c81b2f679a21aecd091dfbc9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "polyMesh.H"
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
36     const point& pt,
37     const pointData& w2,
38     const scalar tol
41     scalar dist2 = magSqr(pt - w2.origin());
43     if (!valid())
44     {
45         distSqr_ = dist2;
46         origin_ = w2.origin();
47         s_ = w2.s();
48         v_ = w2.v();
50         return true;
51     }       
54 //    if (v_ != w2.v())
55 //    {
56 //        return false;
57 //    }
60     scalar diff = distSqr_ - dist2;
62     if (diff < 0)
63     {
64         // already nearer to pt
65         return false;
66     }
68     if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
69     {
70         // don't propagate small changes
71         return false;
72     }
73     else
74     {
75         // update with new values
76         distSqr_ = dist2;
77         origin_ = w2.origin();
78         s_ = w2.s();
79         v_ = w2.v();
81         return true;
82     }
85     
86 // Update this with w2 (information on same point)
87 inline bool Foam::pointData::update
89     const pointData& w2,
90     const scalar tol
93     if (!valid())
94     {
95         // current not yet set so use any value
96         distSqr_ = w2.distSqr();
97         origin_ = w2.origin();
98         s_ = w2.s();
99         v_ = w2.v();
100         return true;
101     }        
104 //    if (v_ != w2.v())
105 //    {
106 //        return false;
107 //    }
110     scalar diff = distSqr_ - w2.distSqr();
112     if (diff < 0)
113     {
114         // already nearer to pt
115         return false;
116     }
118     if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
119     {
120         // don't propagate small changes
121         return false;
122     }
123     else
124     {
125         // update with new values
126         distSqr_ =  w2.distSqr();
127         origin_ = w2.origin();
128         s_ = w2.s();
129         v_ = w2.v();
131         return true;
132     }
136 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
138 // Null constructor
139 inline Foam::pointData::pointData()
141     origin_(wallPoint::greatPoint),
142     distSqr_(GREAT),
143     s_(GREAT),
144     v_(wallPoint::greatPoint)
148 // Construct from origin, distance
149 inline Foam::pointData::pointData
151     const point& origin, 
152     const scalar distSqr,
153     const scalar s,
154     const vector& v
157     origin_(origin),
158     distSqr_(distSqr),
159     s_(s),
160     v_(v)
164 // Construct as copy
165 inline Foam::pointData::pointData(const pointData& wpt)
167     origin_(wpt.origin()),
168     distSqr_(wpt.distSqr()),
169     s_(wpt.s()),
170     v_(wpt.v())
174 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
176 inline const Foam::point& Foam::pointData::origin() const
178     return origin_;
182 inline Foam::scalar Foam::pointData::distSqr() const
184     return distSqr_;
188 inline Foam::scalar Foam::pointData::s() const
190     return s_;
194 inline const Foam::vector& Foam::pointData::v() const
196     return v_;
200 inline bool Foam::pointData::valid() const
202     return origin_ != wallPoint::greatPoint;
206 // Checks for cyclic points
207 inline bool Foam::pointData::sameGeometry
209     const pointData& w2,
210     const scalar tol
211 ) const
213     scalar diff = Foam::mag(distSqr() - w2.distSqr());
215     if (diff < SMALL)
216     {
217         return true;
218     }
219     else
220     {
221         if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
222         {
223             return true;
224         }
225         else
226         {
227             return false;
228         }
229     }
233 inline void Foam::pointData::leaveDomain
235     const polyPatch& patch,
236     const label patchPointI,
237     const point& coord
240     origin_ -= coord;
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,
256     const point& coord
259     // back to absolute form
260     origin_ += coord;
264 // Update this with information from connected edge
265 inline bool Foam::pointData::updatePoint
267     const polyMesh& mesh,
268     const label pointI,
269     const label edgeI,
270     const pointData& edgeInfo,
271     const scalar tol
274     return 
275         update
276         (
277             mesh.points()[pointI],
278             edgeInfo,
279             tol
280         );
281     }    
284 // Update this with new information on same point
285 inline bool Foam::pointData::updatePoint
287     const polyMesh& mesh,
288     const label pointI,
289     const pointData& newPointInfo,
290     const scalar tol
293     return
294         update
295         (
296             mesh.points()[pointI],
297             newPointInfo,
298             tol
299         );
300 }    
303 // Update this with new information on same point. No extra information.
304 inline bool Foam::pointData::updatePoint
306     const pointData& newPointInfo,
307     const scalar tol
310     return update(newPointInfo, tol);
311 }    
314 // Update this with information from connected point
315 inline bool Foam::pointData::updateEdge
317     const polyMesh& mesh,
318     const label edgeI,
319     const label pointI,
320     const pointData& pointInfo,
321     const scalar tol
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]]));
330     return
331         update
332         (
333             edgeMid,
334             pointInfo,
335             tol
336         );
337 }    
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 // ************************************************************************* //