wallPointDataI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 namespace Foam
29 {
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 // Update this with w2 if w2 nearer to pt.
34 template<class Type>
35 template<class TrackingData>
36 inline bool wallPointData<Type>::update
37 (
38  const point& pt,
39  const wallPointData<Type>& w2,
40  const scalar tol,
41  TrackingData& td
42 )
43 {
44  scalar dist2 = magSqr(pt - w2.origin());
45 
46  if (valid(td))
47  {
48  scalar diff = distSqr() - dist2;
49 
50  if (diff < 0)
51  {
52  // already nearer to pt
53  return false;
54  }
55 
56  if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol)))
57  {
58  // don't propagate small changes
59  return false;
60  }
61  }
62 
63  // Either *this is not yet valid or w2 is closer
64  {
65  // current not yet set so use any value
66  distSqr() = dist2;
67  origin() = w2.origin();
68  data_ = w2.data();
69 
70  return true;
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
77 // Null constructor
78 template<class Type>
80 :
81  wallPoint(),
82  data_()
83 {}
84 
85 
86 // Construct from components
87 template<class Type>
89 (
90  const point& origin,
91  const Type& data,
92  const scalar distSqr
93 )
94 :
95  wallPoint(origin, distSqr),
96  data_(data)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 template<class Type>
103 inline const Type& wallPointData<Type>::data() const
104 {
105  return data_;
106 }
107 
108 
109 template<class Type>
111 {
112  return data_;
113 }
114 
115 
116 // Update this with w2 if w2 nearer to pt.
117 template<class Type>
118 template<class TrackingData>
120 (
121  const polyMesh& mesh,
122  const label thisCelli,
123  const label,
124  const wallPointData<Type>& neighbourWallInfo,
125  const scalar tol,
126  TrackingData& td
127 )
128 {
129  const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
130 
131  return update
132  (
133  cellCentres[thisCelli],
134  neighbourWallInfo,
135  tol,
136  td
137  );
138 }
139 
140 
141 // Update this with w2 if w2 nearer to pt.
142 template<class Type>
143 template<class TrackingData>
145 (
146  const polyMesh& mesh,
147  const label thisFacei,
148  const label,
149  const wallPointData<Type>& neighbourWallInfo,
150  const scalar tol,
151  TrackingData& td
152 )
153 {
154  const vectorField& faceCentres = mesh.faceCentres();
155 
156  return update
157  (
158  faceCentres[thisFacei],
159  neighbourWallInfo,
160  tol,
161  td
162  );
163 }
164 
165 
166 // Update this with w2 if w2 nearer to pt.
167 template<class Type>
168 template<class TrackingData>
170 (
171  const polyMesh& mesh,
172  const label thisFacei,
173  const wallPointData<Type>& neighbourWallInfo,
174  const scalar tol,
175  TrackingData& td
176 )
177 {
178  const vectorField& faceCentres = mesh.faceCentres();
179 
180  return update
181  (
182  faceCentres[thisFacei],
183  neighbourWallInfo,
184  tol,
185  td
186  );
187 }
188 
189 
190 // ************************************************************************* //
191 
192 } // End namespace Foam
193 
194 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Holds information regarding nearest wall point. Used in wall distance calculation.
Definition: wallPoint.H:63
const vectorField & faceCentres() const
Holds information (coordinate and normal) regarding nearest wall point.
Definition: wallPointData.H:48
vector point
Point is a vector.
Definition: point.H:41
wallPointData()
Construct null.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.