wallPointI.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMesh.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 // Update this with w2 if w2 nearer to pt.
34 template<class TrackingData>
35 inline bool Foam::wallPoint::update
36 (
37  const point& pt,
38  const wallPoint& w2,
39  const scalar tol,
40  TrackingData& td
41 )
42 {
43  //Already done in calling algorithm
44  //if (w2.origin() == origin_)
45  //{
46  // // Shortcut. Same input so same distance.
47  // return false;
48  //}
49 
50  scalar dist2 = magSqr(pt - w2.origin());
51 
52  if (!valid(td))
53  {
54  // current not yet set so use any value
55  distSqr_ = dist2;
56  origin_ = w2.origin();
57 
58  return true;
59  }
60 
61  scalar diff = distSqr_ - dist2;
62 
63  if (diff < 0)
64  {
65  // already nearer to pt
66  return false;
67  }
68 
69  if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
70  {
71  // don't propagate small changes
72  return false;
73  }
74  else
75  {
76  // update with new values
77  distSqr_ = dist2;
78  origin_ = w2.origin();
79 
80  return true;
81  }
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86 
88 :
89  origin_(point::max),
90  distSqr_(-GREAT)
91 {}
92 
93 
94 inline Foam::wallPoint::wallPoint(const point& origin, const scalar distSqr)
95 :
96  origin_(origin),
97  distSqr_(distSqr)
98 {}
99 
100 
102 :
103  origin_(wpt.origin()),
104  distSqr_(wpt.distSqr())
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  return origin_;
113 }
114 
115 
117 {
118  return origin_;
119 }
120 
121 
122 inline Foam::scalar Foam::wallPoint::distSqr() const
123 {
124  return distSqr_;
125 }
126 
127 
128 inline Foam::scalar& Foam::wallPoint::distSqr()
129 {
130  return distSqr_;
131 }
132 
133 
134 template<class TrackingData>
135 inline bool Foam::wallPoint::valid(TrackingData& td) const
136 {
137  return distSqr_ > -SMALL;
138 }
139 
140 
141 // Checks for cyclic faces
142 template<class TrackingData>
144 (
145  const polyMesh&,
146  const wallPoint& w2,
147  const scalar tol,
148  TrackingData& td
149 ) const
150 {
151  scalar diff = mag(distSqr() - w2.distSqr());
152 
153  if (diff < SMALL)
154  {
155  return true;
156  }
157  else
158  {
159  if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
160  {
161  return true;
162  }
163  else
164  {
165  return false;
166  }
167  }
168 }
169 
170 
171 template<class TrackingData>
173 (
174  const polyMesh&,
175  const polyPatch&,
176  const label,
177  const point& faceCentre,
178  TrackingData& td
179 )
180 {
181  origin_ -= faceCentre;
182 }
183 
184 
185 template<class TrackingData>
186 inline void Foam::wallPoint::transform
187 (
188  const polyMesh&,
189  const tensor& rotTensor,
190  TrackingData& td
191 )
192 {
193  origin_ = Foam::transform(rotTensor, origin_);
194 }
195 
196 
197 // Update absolute geometric quantities. Note that distance (distSqr_)
198 // is not affected by leaving/entering domain.
199 template<class TrackingData>
201 (
202  const polyMesh&,
203  const polyPatch&,
204  const label,
205  const point& faceCentre,
206  TrackingData& td
207 )
208 {
209  // back to absolute form
210  origin_ += faceCentre;
211 }
212 
213 
214 // Update this with w2 if w2 nearer to pt.
215 template<class TrackingData>
216 inline bool Foam::wallPoint::updateCell
217 (
218  const polyMesh& mesh,
219  const label thisCelli,
220  const label neighbourFacei,
221  const wallPoint& neighbourWallInfo,
222  const scalar tol,
223  TrackingData& td
224 )
225 {
226  return
227  update
228  (
229  mesh.cellCentres()[thisCelli],
230  neighbourWallInfo,
231  tol,
232  td
233  );
234  }
235 
236 
237 // Update this with w2 if w2 nearer to pt.
238 template<class TrackingData>
239 inline bool Foam::wallPoint::updateFace
240 (
241  const polyMesh& mesh,
242  const label thisFacei,
243  const label neighbourCelli,
244  const wallPoint& neighbourWallInfo,
245  const scalar tol,
246  TrackingData& td
247 )
248 {
249  return
250  update
251  (
252  mesh.faceCentres()[thisFacei],
253  neighbourWallInfo,
254  tol,
255  td
256  );
257 }
258 
259 // Update this with w2 if w2 nearer to pt.
260 template<class TrackingData>
261 inline bool Foam::wallPoint::updateFace
262 (
263  const polyMesh& mesh,
264  const label thisFacei,
265  const wallPoint& neighbourWallInfo,
266  const scalar tol,
267  TrackingData& td
268 )
269 {
270  return
271  update
272  (
273  mesh.faceCentres()[thisFacei],
274  neighbourWallInfo,
275  tol,
276  td
277  );
278 }
279 
280 
281 template<class TrackingData>
282 inline bool Foam::wallPoint::equal
283 (
284  const wallPoint& rhs,
285  TrackingData& td
286 ) const
287 {
288  return operator==(rhs);
289 }
290 
291 
292 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
293 
294 inline bool Foam::wallPoint::operator==(const Foam::wallPoint& rhs) const
295 {
296  return origin() == rhs.origin();
297 }
298 
299 
300 inline bool Foam::wallPoint::operator!=(const Foam::wallPoint& rhs) const
301 {
302  return !(*this == rhs);
303 }
304 
305 
306 // ************************************************************************* //
Foam::wallPoint::sameGeometry
bool sameGeometry(const polyMesh &, const wallPoint &, const scalar, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
Definition: wallPointI.H:144
Foam::wallPoint
Holds information regarding nearest wall point. Used in wall distance calculation.
Definition: wallPoint.H:65
Foam::Tensor< scalar >
Foam::wallPoint::valid
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: wallPointI.H:135
Foam::wallPoint::operator!=
bool operator!=(const wallPoint &) const
Definition: wallPointI.H:300
update
mesh update()
Foam::wallPoint::operator==
bool operator==(const wallPoint &) const
Definition: wallPointI.H:294
Foam::wallPoint::updateFace
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const wallPoint &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: wallPointI.H:240
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
polyMesh.H
Foam::wallPoint::wallPoint
wallPoint()
Construct null.
Definition: wallPointI.H:87
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
Foam::label
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:62
Foam::wallPoint::enterDomain
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: wallPointI.H:201
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::wallPoint::distSqr
scalar distSqr() const
Definition: wallPointI.H:122
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::wallPoint::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face.
Definition: wallPointI.H:173
Foam::wallPoint::updateCell
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const wallPoint &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: wallPointI.H:217
w2
#define w2
Definition: blockCreate.C:35
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::wallPoint::origin
const point & origin() const
Definition: wallPointI.H:110
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:176
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:145
Foam::wallPoint::equal
bool equal(const wallPoint &, TrackingData &td) const
Same (like operator==)
Definition: wallPointI.H:283
transform.H
3D tensor transformation operations.
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::wallPoint::transform
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition: wallPointI.H:187