Forward compatibility: flex
[foam-extend-3.2.git] / src / meshTools / cellDist / wallPoint / wallPointDataI.H
blob7d064686b8d0b36eb6857ab44df6b1ba636a38a7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
36 // Update this with w2 if w2 nearer to pt.
37 template <class Type>
38 inline bool wallPointData<Type>::update
40     const point& pt,
41     const wallPointData<Type>& w2,
42     const scalar tol
45     scalar dist2 = magSqr(pt - w2.origin());
47     if (!valid())
48     {
49         // current not yet set so use any value
50         distSqr() = dist2;
51         origin() = w2.origin();
52         data_ = w2.data();
54         return true;
55     }
57     scalar diff = distSqr() - dist2;
59     if (diff < 0)
60     {
61         // already nearer to pt
62         return false;
63     }
65     if ((diff < SMALL) || ((distSqr() > SMALL) && (diff/distSqr() < tol)))
66     {
67         // don't propagate small changes
68         return false;
69     }
70     else
71     {
72         // update with new values
73         distSqr() = dist2;
74         origin() = w2.origin();
75         data_ = w2.data();
77         return true;
78     }
82 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
84 // Null constructor
85 template <class Type>
86 inline wallPointData<Type>::wallPointData()
88     wallPoint(),
89     data_()
93 // Construct from components
94 template <class Type>
95 inline wallPointData<Type>::wallPointData
97     const point& origin,
98     const Type& data,
99     const scalar distSqr
102     wallPoint(origin, distSqr),
103     data_(data)
107 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
109 template <class Type>
110 inline const Type& wallPointData<Type>::data() const
112     return data_;
116 template <class Type>
117 inline Type& wallPointData<Type>::data()
119     return data_;
123 // Update this with w2 if w2 nearer to pt.
124 template <class Type>
125 inline bool wallPointData<Type>::updateCell
127     const polyMesh& mesh,
128     const label thisCellI,
129     const label,
130     const wallPointData<Type>& neighbourWallInfo,
131     const scalar tol
134     const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
136     return update
137     (
138         cellCentres[thisCellI],
139         neighbourWallInfo,
140         tol
141     );
145 // Update this with w2 if w2 nearer to pt.
146 template <class Type>
147 inline bool wallPointData<Type>::updateFace
149     const polyMesh& mesh,
150     const label thisFaceI,
151     const label,
152     const wallPointData<Type>& neighbourWallInfo,
153     const scalar tol
156     const vectorField& faceCentres = mesh.faceCentres();
158     return update
159     (
160         faceCentres[thisFaceI],
161         neighbourWallInfo,
162         tol
163     );
167 // Update this with w2 if w2 nearer to pt.
168 template <class Type>
169 inline bool wallPointData<Type>::updateFace
171     const polyMesh& mesh,
172     const label thisFaceI,
173     const wallPointData<Type>& neighbourWallInfo,
174     const scalar tol
177     const vectorField& faceCentres = mesh.faceCentres();
179     return update
180     (
181         faceCentres[thisFaceI],
182         neighbourWallInfo,
183         tol
184     );
188 // ************************************************************************* //
190 } // End namespace Foam
192 // ************************************************************************* //