pointEdgeStructuredWalkI.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  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyMesh.H"
30 #include "transform.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 template<class TrackingData>
35 inline bool Foam::pointEdgeStructuredWalk::update
36 (
37  const pointEdgeStructuredWalk& w2,
38  const scalar tol,
39  TrackingData& td
40 )
41 {
42  if (!valid(td))
43  {
44  // current not yet set. Walked from w2 to here (=point0)
45  dist_ = w2.dist_ + mag(point0_-w2.previousPoint_);
46  previousPoint_ = point0_;
47  data_ = w2.data_;
48  index_ = w2.index_;
49 
50  return true;
51  }
52 
53  return false;
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60 :
61  point0_(point::max),
62  previousPoint_(point::max),
63  dist_(0),
64  data_(Zero),
65  index_(-1)
66 {}
67 
68 
70 (
71  const point& point0,
72  const point& previousPoint,
73  const scalar dist,
74  const vector& data,
75  const label index
76 )
77 :
78  point0_(point0),
79  previousPoint_(previousPoint),
80  dist_(dist),
81  data_(data),
82  index_(index)
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  return point0_ != point::max;
91 }
92 
93 
94 inline Foam::scalar Foam::pointEdgeStructuredWalk::dist() const
95 {
96  return dist_;
97 }
98 
99 
101 {
102  return data_;
103 }
104 
105 
107 {
108  return index_;
109 }
110 
111 
112 template<class TrackingData>
113 inline bool Foam::pointEdgeStructuredWalk::valid(TrackingData& td) const
114 {
115  return previousPoint_ != point::max;
116 }
117 
118 
119 // Checks for cyclic points
120 template<class TrackingData>
122 (
124  const scalar tol,
125  TrackingData& td
126 ) const
127 {
128  scalar diff = Foam::mag(dist() - w2.dist());
129 
130  if (diff < SMALL)
131  {
132  return true;
133  }
134  else
135  {
136  if ((dist() > SMALL) && ((diff/dist()) < tol))
137  {
138  return true;
139  }
140  else
141  {
142  return false;
143  }
144  }
145 }
146 
147 
148 template<class TrackingData>
150 (
151  const polyPatch& patch,
152  const label patchPointi,
153  const point& coord,
154  TrackingData& td
155 )
156 {
157  previousPoint_ -= coord;
158 }
159 
160 
161 template<class TrackingData>
163 (
164  const tensor& rotTensor,
165  TrackingData& td
166 )
167 {
168  previousPoint_ = Foam::transform(rotTensor, previousPoint_);
169 }
170 
171 
172 // Update absolute geometric quantities. Note that distance (dist_)
173 // is not affected by leaving/entering domain.
174 template<class TrackingData>
176 (
177  const polyPatch& patch,
178  const label patchPointi,
179  const point& coord,
180  TrackingData& td
181 )
182 {
183  // back to absolute form
184  previousPoint_ += coord;
185 }
186 
187 
188 // Update this with information from connected edge
189 template<class TrackingData>
191 (
192  const polyMesh& mesh,
193  const label pointi,
194  const label edgeI,
195  const pointEdgeStructuredWalk& edgeInfo,
196  const scalar tol,
197  TrackingData& td
198 )
199 {
200  if (inZone())
201  {
202  return update(edgeInfo, tol, td);
203  }
204 
205  return false;
206 }
207 
208 
209 // Update this with new information on same point
210 template<class TrackingData>
212 (
213  const polyMesh& mesh,
214  const label pointi,
215  const pointEdgeStructuredWalk& newPointInfo,
216  const scalar tol,
217  TrackingData& td
218 )
219 {
220  if (inZone())
221  {
222  return update(newPointInfo, tol, td);
223  }
224 
225  return false;
226 }
227 
228 
229 // Update this with new information on same point. No extra information.
230 template<class TrackingData>
232 (
233  const pointEdgeStructuredWalk& newPointInfo,
234  const scalar tol,
235  TrackingData& td
236 )
237 {
238  return update(newPointInfo, tol, td);
239 }
240 
241 
242 // Update this with information from connected point
243 template<class TrackingData>
245 (
246  const polyMesh& mesh,
247  const label edgeI,
248  const label pointi,
249  const pointEdgeStructuredWalk& pointInfo,
250  const scalar tol,
251  TrackingData& td
252 )
253 {
254  if (inZone())
255  {
256  return update(pointInfo, tol, td);
257  }
258 
259  return false;
260 }
261 
262 
263 template<class TrackingData>
265 (
266  const pointEdgeStructuredWalk& rhs,
267  TrackingData& td
268 ) const
269 {
270  return operator==(rhs);
271 }
272 
273 
274 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
275 
276 inline bool Foam::pointEdgeStructuredWalk::operator==
277 (
279 ) const
280 {
281  return previousPoint_ == rhs.previousPoint_;
282 }
283 
284 
285 inline bool Foam::pointEdgeStructuredWalk::operator!=
286 (
288 ) const
289 {
290  return !(*this == rhs);
291 }
292 
293 
294 // ************************************************************************* //
Foam::pointEdgeStructuredWalk::updateEdge
bool updateEdge(const polyMesh &mesh, const label edgeI, const label pointi, const pointEdgeStructuredWalk &pointInfo, const scalar tol, TrackingData &td)
Influence of point on edge.
Definition: pointEdgeStructuredWalkI.H:245
Foam::Tensor< scalar >
Foam::pointEdgeStructuredWalk::dist
scalar dist() const
The distance information.
Definition: pointEdgeStructuredWalkI.H:94
Foam::pointEdgeStructuredWalk::enterDomain
void enterDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert relative origin to absolute by adding entering point.
Definition: pointEdgeStructuredWalkI.H:176
Foam::pointEdgeStructuredWalk
Determines length of string of edges walked to point.
Definition: pointEdgeStructuredWalk.H:62
update
mesh update()
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::pointEdgeStructuredWalk::index
label index() const
Index (if any) associated with data.
Definition: pointEdgeStructuredWalkI.H:106
Foam::pointEdgeStructuredWalk::transform
void transform(const tensor &rotTensor, TrackingData &td)
Apply rotation matrix to origin.
Definition: pointEdgeStructuredWalkI.H:163
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
polyMesh.H
Foam::pointEdgeStructuredWalk::data
const vector & data() const
Tracking data.
Definition: pointEdgeStructuredWalkI.H:100
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
Foam::pointEdgeStructuredWalk::equal
bool equal(const pointEdgeStructuredWalk &, TrackingData &) const
Same (like operator==)
Definition: pointEdgeStructuredWalkI.H:265
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::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::pointEdgeStructuredWalk::valid
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: pointEdgeStructuredWalkI.H:113
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::pointEdgeStructuredWalk::updatePoint
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgeI, const pointEdgeStructuredWalk &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
Definition: pointEdgeStructuredWalkI.H:191
w2
#define w2
Definition: blockCreate.C:35
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::pointEdgeStructuredWalk::leaveDomain
void leaveDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert origin to relative vector to leaving point.
Definition: pointEdgeStructuredWalkI.H:150
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::max
static const Vector< scalar > max
Definition: VectorSpace.H:117
Foam::pointEdgeStructuredWalk::inZone
bool inZone() const
True if starting point is valid (ie, not point::max)
Definition: pointEdgeStructuredWalkI.H:88
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::pointEdgeStructuredWalk::pointEdgeStructuredWalk
pointEdgeStructuredWalk()
Construct null.
Definition: pointEdgeStructuredWalkI.H:59
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
transform.H
3D tensor transformation operations.
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:54
Foam::pointEdgeStructuredWalk::sameGeometry
bool sameGeometry(const pointEdgeStructuredWalk &, const scalar tol, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
Definition: pointEdgeStructuredWalkI.H:122