pointEdgeDistI.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) 2013-2026 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 inline bool Foam::pointEdgeDist::update
32 (
33  const point& pt,
34  const pointEdgeDist& ped2,
35  const scalar tol,
36  data& td
37 )
38 {
39  // Don't propagate into or past the end points
40  if (distSqr_ < 0 || ped2.distSqr_ < 0)
41  {
42  return false;
43  }
44 
45  const scalar dist2 = magSqr(pt - ped2.origin());
46 
47  if (!valid(td))
48  {
49  // current not yet set so use any value
50  distSqr_ = dist2;
51  origin_ = ped2.origin();
52 
53  if (distSqr_ > td.maxDistSqr)
54  {
55  return false;
56  }
57  else
58  {
59  return true;
60  }
61  }
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  else
77  {
78  // update with new values
79  distSqr_ = dist2;
80  origin_ = ped2.origin();
81 
82  if (distSqr_ > td.maxDistSqr)
83  {
84  return false;
85  }
86  else
87  {
88  return true;
89  }
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
95 
97 :
98  origin_(point::max),
99  distSqr_(great)
100 {}
101 
102 
104 (
105  const point& origin,
106  const scalar distSqr
107 )
108 :
109  origin_(origin),
110  distSqr_(distSqr)
111 {}
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 {
118  return origin_;
119 }
120 
121 
122 inline Foam::scalar Foam::pointEdgeDist::distSqr() const
123 {
124  return distSqr_;
125 }
126 
127 
128 inline bool Foam::pointEdgeDist::valid(const data& td) const
129 {
130  return origin_ != point::max;
131 }
132 
133 
134 inline bool Foam::pointEdgeDist::set(const data& td) const
135 {
136  return distSqr_ >= 0 && valid(td);
137 }
138 
139 
141 (
142  const polyPatch& patch,
143  const label patchFacei,
144  const transformer& transform,
145  data& td
146 )
147 {
148  origin_ = transform.transformPosition(origin_);
149 }
150 
151 
153 (
154  const polyMesh& mesh,
155  const label pointi,
156  const label edgei,
157  const pointEdgeDist& edgeInfo,
158  const scalar tol,
159  data& td
160 )
161 {
162  return update(td.points[pointi], edgeInfo, tol, td);
163 }
164 
165 
167 (
168  const polyMesh& mesh,
169  const label pointi,
170  const pointEdgeDist& newPointInfo,
171  const scalar tol,
172  data& td
173 )
174 {
175  return update(td.points[pointi], newPointInfo, tol, td);
176 }
177 
178 
180 (
181  const polyMesh& mesh,
182  const label edgei,
183  const label pointi,
184  const pointEdgeDist& pointInfo,
185  const scalar tol,
186  data& td
187 )
188 {
189  const edge& e = mesh.edges()[edgei];
190  return update(e.centre(td.points), pointInfo, tol, td);
191 }
192 
193 
195 (
196  const pointEdgeDist& rhs,
197  data& td
198 ) const
199 {
200  return operator==(rhs);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
205 
206 inline bool Foam::pointEdgeDist::operator==
207 (
208  const Foam::pointEdgeDist& rhs
209 )
210 const
211 {
212  return (origin() == rhs.origin()) && (distSqr() == rhs.distSqr());
213 }
214 
215 
216 inline bool Foam::pointEdgeDist::operator!=
217 (
218  const Foam::pointEdgeDist& rhs
219 )
220 const
221 {
222  return !(*this == rhs);
223 }
224 
225 
226 // ************************************************************************* //
static const Form max
Definition: VectorSpace.H:120
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:61
Class used to pass data into container.
Definition: pointEdgeDist.H:80
const pointField & points
Definition: pointEdgeDist.H:82
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
Definition: pointEdgeDist.H:66
bool valid(const data &td) const
Check whether origin has been changed at all or.
scalar distSqr() const
bool set(const data &td) const
Check whether origin and distSqr have been set.
pointEdgeDist()
Construct null.
bool equal(const pointEdgeDist &, data &td) const
Equivalent to operator== with data.
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgei, const pointEdgeDist &edgeinfo, const scalar tol, data &td)
Influence of edge on point.
void transform(const polyPatch &patch, const label patchFacei, const transformer &transform, data &td)
Transform across an interface.
bool updateEdge(const polyMesh &mesh, const label edgei, const label pointi, const pointEdgeDist &pointInfo, const scalar tol, data &td)
Influence of point on edge.
const point & origin() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
bool valid(const PtrList< ModelType > &l)
const doubleScalar e
Definition: doubleScalar.H:106
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 > &)
void transform(GeometricField< Type, GeoMesh > &rtf, const GeometricField< tensor, GeoMesh > &trf, const GeometricField< Type, GeoMesh > &tf)
vector point
Point is a vector.
Definition: point.H:41
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:409
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)