initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / cellDist / wallPoint / wallPointDataI.H
blob87c29f6ddee01dc05b328c3a12c23bb391870a82
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 Description
27 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 // Update this with w2 if w2 nearer to pt.
38 template <class Type>
39 inline bool wallPointData<Type>::update
41     const point& pt,
42     const wallPointData<Type>& w2,
43     const scalar tol
46     scalar dist2 = magSqr(pt - w2.origin());
48     if (!valid())
49     {
50         // current not yet set so use any value
51         distSqr() = dist2;
52         origin() = w2.origin();
53         data_ = w2.data();
55         return true;
56     }        
58     scalar diff = distSqr() - dist2;
60     if (diff < 0)
61     {
62         // already nearer to pt
63         return false;
64     }
66     if ((diff < SMALL) || ((distSqr() > SMALL) && (diff/distSqr() < tol)))
67     {
68         // don't propagate small changes
69         return false;
70     }
71     else
72     {
73         // update with new values
74         distSqr() = dist2;
75         origin() = w2.origin();
76         data_ = w2.data();
78         return true;
79     }
81     
83 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
85 // Null constructor
86 template <class Type>
87 inline wallPointData<Type>::wallPointData()
89     wallPoint(),
90     data_()
94 // Construct from components
95 template <class Type>
96 inline wallPointData<Type>::wallPointData
98     const point& origin,
99     const Type& data,
100     const scalar distSqr
103     wallPoint(origin, distSqr),
104     data_(data)
108 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
110 template <class Type>
111 inline const Type& wallPointData<Type>::data() const
113     return data_;
117 template <class Type>
118 inline Type& wallPointData<Type>::data()
120     return data_;
124 // Update this with w2 if w2 nearer to pt.
125 template <class Type>
126 inline bool wallPointData<Type>::updateCell
128     const polyMesh& mesh,
129     const label thisCellI,
130     const label,
131     const wallPointData<Type>& neighbourWallInfo,
132     const scalar tol
135     const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
137     return update
138     (
139         cellCentres[thisCellI],
140         neighbourWallInfo,
141         tol
142     );
143 }    
146 // Update this with w2 if w2 nearer to pt.
147 template <class Type>
148 inline bool wallPointData<Type>::updateFace
150     const polyMesh& mesh,
151     const label thisFaceI,
152     const label,
153     const wallPointData<Type>& neighbourWallInfo,
154     const scalar tol
157     const vectorField& faceCentres = mesh.faceCentres();
159     return update
160     (
161         faceCentres[thisFaceI],
162         neighbourWallInfo,
163         tol
164     );
165 }    
168 // Update this with w2 if w2 nearer to pt.
169 template <class Type>
170 inline bool wallPointData<Type>::updateFace
172     const polyMesh& mesh,
173     const label thisFaceI,
174     const wallPointData<Type>& neighbourWallInfo,
175     const scalar tol
178     const vectorField& faceCentres = mesh.faceCentres();
180     return update
181     (
182         faceCentres[thisFaceI],
183         neighbourWallInfo,
184         tol
185     );
186 }    
189 // ************************************************************************* //
191 } // End namespace Foam
193 // ************************************************************************* //