Loading...
Searching...
No Matches
wallPointAddressingI.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) 2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
29#include "globalMeshData.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33inline void Foam::wallPointAddressing::setNull
34(
35 const globalIndexAndTransform& gt
36)
37{
38 if (data_ == labelPair(-1, -1))
39 {
40 const label proci = 0;
41 const label index = -1;
42
43 // Add sending side transform
44 data_ = gt.encode(proci, index, gt.nullTransformIndex());
45 }
46}
47
48
49// Update this with w2 if w2 nearer to pt.
50template<class TrackingData>
51inline bool Foam::wallPointAddressing::update
52(
53 const point& pt,
55 const scalar tol,
56 TrackingData& td
57)
58{
59 const scalar dist2 = magSqr(pt - w2.origin());
60
61 if (valid(td))
62 {
63 const scalar diff = distSqr() - dist2;
64
65 if (diff < 0)
66 {
67 // already nearer to pt
68 return false;
69 }
70
71 if ((diff < SMALL) || ((distSqr() > SMALL) && (diff/distSqr() < tol)))
72 {
73 // don't propagate small changes
74 return false;
75 }
76 }
77
78 // Either *this is not yet valid or w2 is closer
79 {
80 // current not yet set so use any value
81 distSqr() = dist2;
82 origin() = w2.origin();
83 data_ = w2.data();
84
85 return true;
86 }
87}
88
89
90// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91
93:
94 wallPoint(),
95 data_(labelPair(-1, -1))
96{}
97
98
100(
101 const point& origin,
102 const labelPair& data,
103 const scalar distSqr
104)
105:
106 wallPoint(origin, distSqr),
107 data_(data)
108{}
109
110
111// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112
113template<class TrackingData>
115(
116 const polyMesh& mesh,
117 const polyPatch& pp,
118 const label patchFacei,
119 const point& faceCentre,
120 TrackingData& td
121)
122{
123 const auto& gt = mesh.globalData().globalTransforms();
124
125 setNull(gt);
126
127 // Convert to relative form
128 wallPoint::leaveDomain(mesh, pp, patchFacei, faceCentre, td);
129
130 // Add to transformation
131 const label transformi = gt.transformIndex(data_);
132 const label proci = gt.processor(data_);
133 const label index = gt.index(data_);
134
135 // Add sending side transform
136 const label newTransformi = gt.addToTransformIndex
137 (
138 transformi,
139 pp.index()
140 );
141 data_ = gt.encode(proci, index, newTransformi);
142}
143
144
147//template<class TrackingData>
148//inline void Foam::wallPointAddressing::enterDomain
149//(
150// const polyMesh& mesh,
151// const polyPatch& pp,
152// const label patchFacei,
153// const point& faceCentre,
154// TrackingData& td
155//)
156//{
157// // back to absolute form
158// wallPoint::enterDomain(mesh, pp, patchFacei, faceCentre, td);
159//}
160
161
162// Update this with w2 if w2 nearer to pt.
163template<class TrackingData>
165(
166 const polyMesh& mesh,
167 const label thisCelli,
168 const label neighbourFacei,
169 const wallPointAddressing& neighbourWallInfo,
170 const scalar tol,
171 TrackingData& td
172)
173{
174 setNull(mesh.globalData().globalTransforms());
175
176 const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
177
178 return update
179 (
180 cellCentres[thisCelli],
181 neighbourWallInfo,
182 tol,
184 );
185}
186
187
188// Update this with w2 if w2 nearer to pt.
189template<class TrackingData>
191(
192 const polyMesh& mesh,
193 const label thisFacei,
194 const label,
195 const wallPointAddressing& neighbourWallInfo,
196 const scalar tol,
197 TrackingData& td
198)
199{
200 setNull(mesh.globalData().globalTransforms());
201
202 const vectorField& faceCentres = mesh.faceCentres();
203
204 return update
205 (
206 faceCentres[thisFacei],
207 neighbourWallInfo,
208 tol,
210 );
211}
212
213
214// Update this with w2 if w2 nearer to pt.
215template<class TrackingData>
217(
218 const polyMesh& mesh,
219 const label thisFacei,
220 const wallPointAddressing& neighbourWallInfo,
221 const scalar tol,
222 TrackingData& td
223)
224{
225 setNull(mesh.globalData().globalTransforms());
226
227 const vectorField& faceCentres = mesh.faceCentres();
228
229 return update
230 (
231 faceCentres[thisFacei],
232 neighbourWallInfo,
233 tol,
234 td
235 );
236}
237
238
239// ************************************************************************* //
#define w2
Definition blockCreate.C:28
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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 (coordinate and origin) regarding nearest wall point.
bool updateCell(const polyMesh &mesh, const label thisCelli, const label neighbourFacei, const wallPointAddressing &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
bool updateFace(const polyMesh &mesh, const label thisFacei, const label neighbourCelli, const wallPointAddressing &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
const labelPair & data() const
wallPointAddressing()
Default construct.
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face centre.
Holds information regarding nearest wall point. Used in wall distance calculation.
Definition wallPoint.H:62
const point & origin() const
Definition wallPoint.H:123
scalar distSqr() const
Definition wallPoint.H:132
wallPoint()
Default construct.
Definition wallPointI.H:92
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)
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition triad.C:373
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)