externalPointEdgePointI.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) 2013-2019 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 #include "polyMesh.H"
27 #include "transform.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class TrackingData>
32 inline bool Foam::externalPointEdgePoint::update
33 (
34  const point& pt,
35  const externalPointEdgePoint& w2,
36  const scalar tol,
37  TrackingData& td
38 )
39 {
40  scalar dist2 = magSqr(pt - w2.origin());
41 
42  if (!valid(td))
43  {
44  // current not yet set so use any value
45  distSqr_ = dist2;
46  origin_ = w2.origin();
47 
48  return true;
49  }
50 
51  scalar diff = distSqr_ - dist2;
52 
53  if (diff < 0)
54  {
55  // already nearer to pt
56  return false;
57  }
58 
59  if ((diff < small) || ((distSqr_ > small) && (diff/distSqr_ < tol)))
60  {
61  // don't propagate small changes
62  return false;
63  }
64  else
65  {
66  // update with new values
67  distSqr_ = dist2;
68  origin_ = w2.origin();
69 
70  return true;
71  }
72 }
73 
74 
75 template<class TrackingData>
76 inline bool Foam::externalPointEdgePoint::update
77 (
78  const externalPointEdgePoint& w2,
79  const scalar tol,
80  TrackingData& td
81 )
82 {
83  if (!valid(td))
84  {
85  // current not yet set so use any value
86  distSqr_ = w2.distSqr();
87  origin_ = w2.origin();
88 
89  return true;
90  }
91 
92  scalar diff = distSqr_ - w2.distSqr();
93 
94  if (diff < 0)
95  {
96  // already nearer to pt
97  return false;
98  }
99 
100  if ((diff < small) || ((distSqr_ > small) && (diff/distSqr_ < tol)))
101  {
102  // don't propagate small changes
103  return false;
104  }
105  else
106  {
107  // update with new values
108  distSqr_ = w2.distSqr();
109  origin_ = w2.origin();
110 
111  return true;
112  }
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 :
120  origin_(point::max),
121  distSqr_(great)
122 {}
123 
124 
126 (
127  const point& origin,
128  const scalar distSqr
129 )
130 :
131  origin_(origin),
132  distSqr_(distSqr)
133 {}
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
139 {
140  return origin_;
141 }
142 
143 
144 inline Foam::scalar Foam::externalPointEdgePoint::distSqr() const
145 {
146  return distSqr_;
147 }
148 
149 
150 template<class TrackingData>
151 inline bool Foam::externalPointEdgePoint::valid(TrackingData& td) const
152 {
153  return origin_ != point::max;
154 }
155 
156 
157 // Checks for cyclic points
158 template<class TrackingData>
160 (
161  const externalPointEdgePoint& w2,
162  const scalar tol,
163  TrackingData& td
164 ) const
165 {
166  scalar diff = Foam::mag(distSqr() - w2.distSqr());
167 
168  if (diff < small)
169  {
170  return true;
171  }
172  else
173  {
174  if ((distSqr() > small) && ((diff/distSqr()) < tol))
175  {
176  return true;
177  }
178  else
179  {
180  return false;
181  }
182  }
183 }
184 
185 
186 template<class TrackingData>
188 (
189  const polyPatch& patch,
190  const label patchPointi,
191  const point& coord,
192  TrackingData& td
193 )
194 {
195  origin_ -= coord;
196 }
197 
198 
199 template<class TrackingData>
201 (
202  const tensor& rotTensor,
203  TrackingData& td
204 )
205 {
206  origin_ = Foam::transform(rotTensor, origin_);
207 }
208 
209 
210 template<class TrackingData>
212 (
213  const polyPatch& patch,
214  const label patchPointi,
215  const point& coord,
216  TrackingData& td
217 )
218 {
219  // back to absolute form
220  origin_ += coord;
221 }
222 
223 
224 template<class TrackingData>
226 (
227  const polyMesh& mesh,
228  const label pointi,
229  const label edgeI,
230  const externalPointEdgePoint& edgeInfo,
231  const scalar tol,
232  TrackingData& td
233 )
234 {
235  return update(td.points_[pointi], edgeInfo, tol, td);
236 }
237 
238 
239 template<class TrackingData>
241 (
242  const polyMesh& mesh,
243  const label pointi,
244  const externalPointEdgePoint& newPointInfo,
245  const scalar tol,
246  TrackingData& td
247 )
248 {
249  return update(td.points_[pointi], newPointInfo, tol, td);
250 }
251 
252 
253 template<class TrackingData>
255 (
256  const externalPointEdgePoint& newPointInfo,
257  const scalar tol,
258  TrackingData& td
259 )
260 {
261  return update(newPointInfo, tol, td);
262 }
263 
264 
265 template<class TrackingData>
267 (
268  const polyMesh& mesh,
269  const label edgeI,
270  const label pointi,
271  const externalPointEdgePoint& pointInfo,
272  const scalar tol,
273  TrackingData& td
274 )
275 {
276  const edge& e = mesh.edges()[edgeI];
277  return update(e.centre(td.points_), pointInfo, tol, td);
278 }
279 
280 
281 template<class TrackingData>
283 (
284  const externalPointEdgePoint& rhs,
285  TrackingData& td
286 ) const
287 {
288  return operator==(rhs);
289 }
290 
291 
292 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
293 
294 inline bool Foam::externalPointEdgePoint::operator==
295 (
297 )
298 const
299 {
300  return (origin() == rhs.origin()) && (distSqr() == rhs.distSqr());
301 }
302 
303 
304 inline bool Foam::externalPointEdgePoint::operator!=
305 (
307 )
308 const
309 {
310  return !(*this == rhs);
311 }
312 
313 
314 // ************************************************************************* //
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< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgeI, const externalPointEdgePoint &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
point centre(const pointField &) const
Return centre (centroid)
Definition: edgeI.H:169
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
3D tensor transformation operations.
void transform(const tensor &rotTensor, TrackingData &td)
Apply rotation matrix to origin.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
bool sameGeometry(const externalPointEdgePoint &, const scalar tol, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
vector point
Point is a vector.
Definition: point.H:41
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
bool equal(const externalPointEdgePoint &, TrackingData &td) const
Equivalent to operator== with TrackingData.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
void leaveDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert origin to relative vector to leaving point.
bool operator==(const externalPointEdgePoint &) const
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
bool updateEdge(const polyMesh &mesh, const label edgeI, const label pointi, const externalPointEdgePoint &pointInfo, const scalar tol, TrackingData &td)
Influence of point on edge.
void enterDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert relative origin to absolute by adding entering point.