FreeFOAM The Cross-Platform CFD Toolkit
wallPointDataI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 
36 // Update this with w2 if w2 nearer to pt.
37 template <class Type>
38 inline bool wallPointData<Type>::update
39 (
40  const point& pt,
41  const wallPointData<Type>& w2,
42  const scalar tol
43 )
44 {
45  scalar dist2 = magSqr(pt - w2.origin());
46 
47  if (!valid())
48  {
49  // current not yet set so use any value
50  distSqr() = dist2;
51  origin() = w2.origin();
52  data_ = w2.data();
53 
54  return true;
55  }
56 
57  scalar diff = distSqr() - dist2;
58 
59  if (diff < 0)
60  {
61  // already nearer to pt
62  return false;
63  }
64 
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();
76 
77  return true;
78  }
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 
84 // Null constructor
85 template <class Type>
87 :
88  wallPoint(),
89  data_()
90 {}
91 
92 
93 // Construct from components
94 template <class Type>
96 (
97  const point& origin,
98  const Type& data,
99  const scalar distSqr
100 )
101 :
102  wallPoint(origin, distSqr),
103  data_(data)
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template <class Type>
110 inline const Type& wallPointData<Type>::data() const
111 {
112  return data_;
113 }
114 
115 
116 template <class Type>
118 {
119  return data_;
120 }
121 
122 
123 // Update this with w2 if w2 nearer to pt.
124 template <class Type>
126 (
127  const polyMesh& mesh,
128  const label thisCellI,
129  const label,
130  const wallPointData<Type>& neighbourWallInfo,
131  const scalar tol
132 )
133 {
134  const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
135 
136  return update
137  (
138  cellCentres[thisCellI],
139  neighbourWallInfo,
140  tol
141  );
142 }
143 
144 
145 // Update this with w2 if w2 nearer to pt.
146 template <class Type>
148 (
149  const polyMesh& mesh,
150  const label thisFaceI,
151  const label,
152  const wallPointData<Type>& neighbourWallInfo,
153  const scalar tol
154 )
155 {
156  const vectorField& faceCentres = mesh.faceCentres();
157 
158  return update
159  (
160  faceCentres[thisFaceI],
161  neighbourWallInfo,
162  tol
163  );
164 }
165 
166 
167 // Update this with w2 if w2 nearer to pt.
168 template <class Type>
170 (
171  const polyMesh& mesh,
172  const label thisFaceI,
173  const wallPointData<Type>& neighbourWallInfo,
174  const scalar tol
175 )
176 {
177  const vectorField& faceCentres = mesh.faceCentres();
178 
179  return update
180  (
181  faceCentres[thisFaceI],
182  neighbourWallInfo,
183  tol
184  );
185 }
186 
187 } // End namespace Foam
188 
189 // ************************ vim: set sw=4 sts=4 et: ************************ //