Loading...
Searching...
No Matches
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 Copyright (C) 2020,2025 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
34// Update this with w2 if w2 nearer to pt.
35template<class TrackingData>
36inline bool Foam::wallPoint::update
37(
38 const wallPoint& w2,
39 const scalar dist2,
40 const scalar tol,
41 TrackingData& td
42)
43{
44 if (!valid(td))
45 {
46 // current not yet set so use any value
47 distSqr_ = dist2;
48 origin_ = w2.origin();
49
50 return true;
51 }
52
53 const scalar diff = distSqr_ - dist2;
54
55 if (diff < 0)
56 {
57 // already nearer to pt
58 return false;
59 }
60
61 if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
62 {
63 // don't propagate small changes
64 return false;
65 }
66 else
67 {
68 // update with new values
69 distSqr_ = dist2;
70 origin_ = w2.origin();
71
72 return true;
73 }
74}
75
76
77// Update this with w2 if w2 nearer to pt.
78template<class TrackingData>
79inline bool Foam::wallPoint::update
80(
81 const point& pt,
82 const wallPoint& w2,
83 const scalar tol,
84 TrackingData& td
85)
86{
87 return update
88 (
89 w2,
90 magSqr(pt - w2.origin()),
91 tol,
93 );
94}
95
96
97// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98
100:
101 origin_(point::max),
102 distSqr_(-GREAT)
103{}
104
105
106inline Foam::wallPoint::wallPoint(const point& origin, const scalar distSqr)
107:
108 origin_(origin),
109 distSqr_(distSqr)
110{}
111
112
113// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114
115template<class TrackingData>
116inline bool Foam::wallPoint::valid(TrackingData& td) const
118 return distSqr_ > -SMALL;
119}
120
121
122// Checks for cyclic faces
123template<class TrackingData>
125(
126 const polyMesh&,
127 const wallPoint& w2,
128 const scalar tol,
129 TrackingData& td
130) const
131{
132 const scalar diff = mag(distSqr() - w2.distSqr());
133
134 if (diff < SMALL)
135 {
136 return true;
137 }
138 else
139 {
140 if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
141 {
142 return true;
143 }
144 else
145 {
146 return false;
147 }
148 }
149}
150
151
152template<class TrackingData>
154(
155 const polyMesh&,
156 const polyPatch&,
157 const label,
158 const point& faceCentre,
159 TrackingData& td
161{
162 origin_ -= faceCentre;
163}
164
165
166template<class TrackingData>
168(
169 const polyMesh&,
170 const tensor& rotTensor,
171 TrackingData& td
172)
173{
174 origin_ = Foam::transform(rotTensor, origin_);
175}
176
177
178// Update absolute geometric quantities. Note that distance (distSqr_)
179// is not affected by leaving/entering domain.
180template<class TrackingData>
182(
183 const polyMesh&,
184 const polyPatch&,
185 const label,
186 const point& faceCentre,
187 TrackingData& td
188)
189{
190 // back to absolute form
191 origin_ += faceCentre;
192}
193
194
195// Update this with w2 if w2 nearer to pt.
196template<class TrackingData>
198(
199 const polyMesh& mesh,
200 const label thisCelli,
201 const label neighbourFacei,
202 const wallPoint& neighbourWallInfo,
203 const scalar tol,
204 TrackingData& td
205)
206{
207 return
208 update
209 (
210 mesh.cellCentres()[thisCelli],
211 neighbourWallInfo,
212 tol,
214 );
215}
216
217
218// Update this with w2 if w2 nearer to pt.
219template<class TrackingData>
221(
222 const polyMesh& mesh,
223 const label thisFacei,
224 const label neighbourCelli,
225 const wallPoint& neighbourWallInfo,
226 const scalar tol,
227 TrackingData& td
228)
229{
230 return
231 update
232 (
233 mesh.faceCentres()[thisFacei],
234 neighbourWallInfo,
235 tol,
237 );
238}
239
240
241// Update this with w2 if w2 nearer to pt.
242template<class TrackingData>
244(
245 const polyMesh& mesh,
246 const label thisFacei,
247 const wallPoint& neighbourWallInfo,
248 const scalar tol,
249 TrackingData& td
250)
251{
252 return
253 update
254 (
255 mesh.faceCentres()[thisFacei],
256 neighbourWallInfo,
257 tol,
258 td
259 );
260}
261
262
263template<class TrackingData>
264inline bool Foam::wallPoint::equal
265(
266 const wallPoint& rhs,
267 TrackingData& td
268) const
269{
270 return operator==(rhs);
271}
272
273
274template<class TrackingData>
276(
277 const polyMesh&,
278 const point& pt,
279 const label i0,
280 const wallPoint& f0,
281 const label i1,
282 const wallPoint& f1,
283 const scalar weight,
284 const scalar tol,
285 TrackingData& td
286)
287{
288 if (f0.valid(td))
289 {
290 if (f1.valid(td))
291 {
292 // What do we do about the origin? Should be consistent with the
293 // distance? But then interpolating between a point 'on the left'
294 // and a point 'on the right' the interpolate might just be on
295 // top of us so suddenly setting the distance to be zero...
296
297 const scalar dist2 =
298 sqr(lerp(sqrt(f0.distSqr()), sqrt(f1.distSqr()), weight));
299
300 if (f0.distSqr() < f1.distSqr())
301 {
302 // Update with interpolated distance and f0 origin
303 return update(f0, dist2, tol, td);
304 }
305 else
306 {
307 return update(f1, dist2, tol, td);
308 }
309 }
310 else
311 {
312 return update(f0, f0.distSqr(), tol, td);
313 }
314 }
315 else if (f1.valid(td))
316 {
317 return update(f1, f1.distSqr(), tol, td);
318 }
319 else
320 {
321 return false;
322 }
323}
324
325
326// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
327
328inline bool Foam::wallPoint::operator==
329(
331) const
332{
333 return origin_ == rhs.origin_;
334}
335
336
337inline bool Foam::wallPoint::operator!=
338(
339 const wallPoint& rhs
340) const
341{
342 return !(*this == rhs);
343}
344
345
346// ************************************************************************* //
#define w2
Definition blockCreate.C:28
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
Holds information regarding nearest wall point. Used in wall distance calculation.
Definition wallPoint.H:62
const point & origin() const
Definition wallPoint.H:123
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition wallPointI.H:161
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition wallPointI.H:175
bool equal(const wallPoint &, TrackingData &td) const
Test for equality, with TrackingData.
Definition wallPointI.H:258
scalar distSqr() const
Definition wallPoint.H:132
bool interpolate(const polyMesh &, const point &pt, const label i0, const wallPoint &f0, const label i1, const wallPoint &f1, const scalar weight, const scalar tol, TrackingData &td)
Interpolate between two values (lerp). Returns true if causes changes. Not sure if needs to be specia...
Definition wallPointI.H:269
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:191
bool sameGeometry(const polyMesh &, const wallPoint &, const scalar, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking).
Definition wallPointI.H:118
wallPoint()
Default construct.
Definition wallPointI.H:92
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition wallPointI.H:109
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:214
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face centre.
Definition wallPointI.H:147
mesh update()
dynamicFvMesh & mesh
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensionedScalar sqrt(const dimensionedScalar &ds)
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:373
vector point
Point is a vector.
Definition point.H:37
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
3D tensor transformation operations.