pointEdgeStructuredWalkI.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-2022 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 "transformer.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 // Update this with w2.
32 template<class TrackingData>
33 inline bool Foam::pointEdgeStructuredWalk::update
34 (
35  const pointEdgeStructuredWalk& w2,
36  const scalar tol,
37  TrackingData& td
38 )
39 {
40  if (!valid(td))
41  {
42  // current not yet set. Walked from w2 to here (=point0)
43  dist_ = w2.dist_ + mag(point0_-w2.previousPoint_);
44  previousPoint_ = point0_;
45  data_ = w2.data_;
46 
47  return true;
48  }
49  else
50  {
51  return false;
52  }
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
58 // Null constructor
60 :
61  point0_(vector::max),
62  previousPoint_(vector::max),
63  dist_(0),
64  data_(Zero)
65 {}
66 
67 
68 // Construct from origin, distance
70 (
71  const point& point0,
72  const point& previousPoint,
73  const scalar dist,
74  const vector& data
75 )
76 :
77  point0_(point0),
78  previousPoint_(previousPoint),
79  dist_(dist),
80  data_(data)
81 {}
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 {
88  return point0_ != vector::max;
89 }
90 
91 
92 //inline const Foam::point& Foam::pointEdgeStructuredWalk::previousPoint() const
93 //{
94 // return previousPoint_;
95 //}
96 
97 
98 inline Foam::scalar Foam::pointEdgeStructuredWalk::dist() const
99 {
100  return dist_;
101 }
102 
103 
105 {
106  return data_;
107 }
108 
109 
110 template<class TrackingData>
111 inline bool Foam::pointEdgeStructuredWalk::valid(TrackingData& td) const
112 {
113  return previousPoint_ != vector::max;
114 }
115 
116 
117 // Checks for cyclic points
118 template<class TrackingData>
120 (
122  const scalar tol,
123  TrackingData& td
124 ) const
125 {
126  scalar diff = Foam::mag(dist() - w2.dist());
127 
128  if (diff < small)
129  {
130  return true;
131  }
132  else
133  {
134  if ((dist() > small) && ((diff/dist()) < tol))
135  {
136  return true;
137  }
138  else
139  {
140  return false;
141  }
142  }
143 }
144 
145 
146 template<class TrackingData>
148 (
149  const polyPatch& patch,
150  const label patchFacei,
151  const transformer& transform,
152  TrackingData& td
153 )
154 {
155  // Note that dist_ is not affected by crossing an interface
156  previousPoint_ = transform.transformPosition(previousPoint_);
157 }
158 
159 
160 // Update this with information from connected edge
161 template<class TrackingData>
163 (
164  const polyMesh& mesh,
165  const label pointi,
166  const label edgeI,
167  const pointEdgeStructuredWalk& edgeInfo,
168  const scalar tol,
169  TrackingData& td
170 )
171 {
172  if (inZone())
173  {
174  return update(edgeInfo, tol, td);
175  }
176  else
177  {
178  return false;
179  }
180 }
181 
182 
183 // Update this with new information on same point
184 template<class TrackingData>
186 (
187  const polyMesh& mesh,
188  const label pointi,
189  const pointEdgeStructuredWalk& newPointInfo,
190  const scalar tol,
191  TrackingData& td
192 )
193 {
194  if (inZone())
195  {
196  return update(newPointInfo, tol, td);
197  }
198  else
199  {
200  return false;
201  }
202 }
203 
204 
205 // Update this with new information on same point. No extra information.
206 template<class TrackingData>
208 (
209  const pointEdgeStructuredWalk& newPointInfo,
210  const scalar tol,
211  TrackingData& td
212 )
213 {
214  return update(newPointInfo, tol, td);
215 }
216 
217 
218 // Update this with information from connected point
219 template<class TrackingData>
221 (
222  const polyMesh& mesh,
223  const label edgeI,
224  const label pointi,
225  const pointEdgeStructuredWalk& pointInfo,
226  const scalar tol,
227  TrackingData& td
228 )
229 {
230  if (inZone())
231  {
232  return update(pointInfo, tol, td);
233  }
234  else
235  {
236  return false;
237  }
238 }
239 
240 
241 template<class TrackingData>
243 (
244  const pointEdgeStructuredWalk& rhs,
245  TrackingData& td
246 ) const
247 {
248  return operator==(rhs);
249 }
250 
251 
252 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
253 
254 inline bool Foam::pointEdgeStructuredWalk::operator==
255 (
257 ) const
258 {
259  return previousPoint_ == rhs.previousPoint_;
260 }
261 
262 
263 inline bool Foam::pointEdgeStructuredWalk::operator!=
264 (
266 ) const
267 {
268  return !(*this == rhs);
269 }
270 
271 
272 // ************************************************************************* //
#define w2
Definition: blockCreate.C:32
static const Form max
Definition: VectorSpace.H:115
Database for solution and other reduced data.
Definition: data.H:54
Determines length of string of edges walked to point.
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgeI, const pointEdgeStructuredWalk &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
bool sameGeometry(const pointEdgeStructuredWalk &, const scalar tol, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
bool equal(const pointEdgeStructuredWalk &, TrackingData &) const
Same (like operator==)
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
bool updateEdge(const polyMesh &mesh, const label edgeI, const label pointi, const pointEdgeStructuredWalk &pointInfo, const scalar tol, TrackingData &td)
Influence of point on edge.
void transform(const polyPatch &patch, const label patchFacei, const transformer &transform, TrackingData &td)
Transform across an interface.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
static const zero Zero
Definition: zero.H:97
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
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:403
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)