externalPointEdgePointI.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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
34template<class TrackingData>
36(
37 const point& pt,
38 const externalPointEdgePoint& w2,
39 const scalar tol,
40 TrackingData& td
41)
42{
43 const scalar dist2 = magSqr(pt - w2.origin());
44
45 if (!valid(td))
46 {
47 // current not yet set so use any value
48 distSqr_ = dist2;
49 origin_ = w2.origin();
50
51 return true;
52 }
53
54 const scalar diff = distSqr_ - dist2;
55
56 if (diff < 0)
57 {
58 // already nearer to pt
59 return false;
60 }
61
62 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
63 {
64 // don't propagate small changes
65 return false;
66 }
67 else
68 {
69 // update with new values
70 distSqr_ = dist2;
71 origin_ = w2.origin();
72
73 return true;
74 }
75}
76
77
78template<class TrackingData>
80(
81 const externalPointEdgePoint& w2,
82 const scalar tol,
83 TrackingData& td
84)
85{
86 if (!valid(td))
87 {
88 // current not yet set so use any value
89 distSqr_ = w2.distSqr();
90 origin_ = w2.origin();
91
92 return true;
93 }
94
95 const scalar diff = distSqr_ - w2.distSqr();
96
97 if (diff < 0)
98 {
99 // already nearer to pt
100 return false;
101 }
102
103 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
104 {
105 // don't propagate small changes
106 return false;
107 }
108 else
109 {
110 // update with new values
111 distSqr_ = w2.distSqr();
112 origin_ = w2.origin();
113
114 return true;
115 }
116}
117
118
119// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
120
122:
123 origin_(point::max),
124 distSqr_(GREAT)
125{}
126
127
129(
130 const point& origin,
131 const scalar distSqr
132)
133:
134 origin_(origin),
135 distSqr_(distSqr)
136{}
137
138
139// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140
141template<class TrackingData>
142inline bool Foam::externalPointEdgePoint::valid(TrackingData& td) const
143{
144 return origin_ != point::max;
145}
146
147
148// Checks for cyclic points
149template<class TrackingData>
151(
153 const scalar tol,
154 TrackingData& td
155) const
156{
157 const scalar diff = Foam::mag(distSqr() - w2.distSqr());
158
159 if (diff < SMALL)
160 {
161 return true;
162 }
163 else
164 {
165 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
166 {
167 return true;
168 }
169 else
170 {
171 return false;
172 }
173 }
174}
175
176
177template<class TrackingData>
179(
180 const polyPatch& patch,
181 const label patchPointi,
182 const point& coord,
183 TrackingData& td
184)
185{
186 origin_ -= coord;
187}
188
189
190template<class TrackingData>
192(
193 const tensor& rotTensor,
194 TrackingData& td
195)
196{
197 origin_ = Foam::transform(rotTensor, origin_);
198}
199
200
201template<class TrackingData>
203(
204 const polyPatch& patch,
205 const label patchPointi,
206 const point& coord,
207 TrackingData& td
208)
209{
210 // back to absolute form
211 origin_ += coord;
212}
213
214
215template<class TrackingData>
217(
218 const polyMesh& mesh,
219 const label pointi,
220 const label edgeI,
221 const externalPointEdgePoint& edgeInfo,
222 const scalar tol,
223 TrackingData& td
224)
225{
226 return update(td.points_[pointi], edgeInfo, tol, td);
227}
228
229
230template<class TrackingData>
232(
233 const polyMesh& mesh,
234 const label pointi,
235 const externalPointEdgePoint& newPointInfo,
236 const scalar tol,
237 TrackingData& td
238)
239{
240 return update(td.points_[pointi], newPointInfo, tol, td);
241}
242
243
244template<class TrackingData>
246(
247 const externalPointEdgePoint& newPointInfo,
248 const scalar tol,
249 TrackingData& td
250)
251{
252 return update(newPointInfo, tol, td);
253}
254
255
256template<class TrackingData>
258(
259 const polyMesh& mesh,
260 const label edgeI,
261 const label pointi,
262 const externalPointEdgePoint& pointInfo,
263 const scalar tol,
264 TrackingData& td
265)
266{
267 const edge& e = mesh.edges()[edgeI];
268 return update(e.centre(td.points_), pointInfo, tol, td);
269}
270
271
272template<class TrackingData>
274(
275 const externalPointEdgePoint& rhs,
276 TrackingData& td
277) const
278{
279 return operator==(rhs);
280}
281
282
283// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
284
286(
287 const externalPointEdgePoint& rhs
288) const
289{
290 return origin_ == rhs.origin_ && distSqr_ == rhs.distSqr_;
291}
292
293
295(
296 const externalPointEdgePoint& rhs
297) const
298{
299 return !(*this == rhs);
300}
301
302
303// ************************************************************************* //
#define w2
Definition: blockCreate.C:35
bool valid() const
True if all internal ids are non-negative.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
externalPointEdgePoint()
Default construct.
bool equal(const externalPointEdgePoint &, TrackingData &td) const
Test for equality, with TrackingData.
bool sameGeometry(const externalPointEdgePoint &, const scalar tol, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgeI, const externalPointEdgePoint &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
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 leaveDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
void enterDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert relative origin to absolute by adding entering point.
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
virtual bool update()
Update the mesh for both mesh motion and topology change.
Default transformation behaviour.
static const complex max
complex (VGREAT,VGREAT)
Definition: complex.H:293
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
mesh update()
dynamicFvMesh & mesh
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
volScalarField & e
Definition: createFields.H:11
3D tensor transformation operations.