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-2024 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& w2,
35  const scalar tol,
36  data& td
37 )
38 {
39  const scalar dist2 = magSqr(pt - w2.origin());
40 
41  if (!valid(td))
42  {
43  // current not yet set so use any value
44  distSqr_ = dist2;
45  origin_ = w2.origin();
46 
47  if (distSqr_ > td.maxDistSqr)
48  {
49  return false;
50  }
51  else
52  {
53  return true;
54  }
55  }
56 
57  scalar diff = distSqr_ - dist2;
58 
59  if (diff < 0)
60  {
61  // already nearer to pt
62  return false;
63  }
64 
65  if ((diff < small) || ((distSqr_ > small) && (diff/distSqr_ < tol)))
66  {
67  // don't propagate small changes
68  return false;
69  }
70  else
71  {
72  // update with new values
73  distSqr_ = dist2;
74  origin_ = w2.origin();
75 
76  if (distSqr_ > td.maxDistSqr)
77  {
78  return false;
79  }
80  else
81  {
82  return true;
83  }
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 
91 :
92  origin_(point::max),
93  distSqr_(great)
94 {}
95 
96 
98 (
99  const point& origin,
100  const scalar distSqr
101 )
102 :
103  origin_(origin),
104  distSqr_(distSqr)
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  return origin_;
113 }
114 
115 
116 inline Foam::scalar Foam::pointEdgeDist::distSqr() const
117 {
118  return distSqr_;
119 }
120 
121 
122 inline bool Foam::pointEdgeDist::valid(data& td) const
123 {
124  return origin_ != point::max;
125 }
126 
127 
129 (
130  const polyPatch& patch,
131  const label patchFacei,
132  const transformer& transform,
133  data& td
134 )
135 {
136  origin_ = transform.transformPosition(origin_);
137 }
138 
139 
141 (
142  const polyMesh& mesh,
143  const label pointi,
144  const label edgei,
145  const pointEdgeDist& edgeInfo,
146  const scalar tol,
147  data& td
148 )
149 {
150  return update(td.points[pointi], edgeInfo, tol, td);
151 }
152 
153 
155 (
156  const polyMesh& mesh,
157  const label pointi,
158  const pointEdgeDist& newPointInfo,
159  const scalar tol,
160  data& td
161 )
162 {
163  return update(td.points[pointi], newPointInfo, tol, td);
164 }
165 
166 
168 (
169  const polyMesh& mesh,
170  const label edgei,
171  const label pointi,
172  const pointEdgeDist& pointInfo,
173  const scalar tol,
174  data& td
175 )
176 {
177  const edge& e = mesh.edges()[edgei];
178  return update(e.centre(td.points), pointInfo, tol, td);
179 }
180 
181 
183 (
184  const pointEdgeDist& rhs,
185  data& td
186 ) const
187 {
188  return operator==(rhs);
189 }
190 
191 
192 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
193 
194 inline bool Foam::pointEdgeDist::operator==
195 (
196  const Foam::pointEdgeDist& rhs
197 )
198 const
199 {
200  return (origin() == rhs.origin()) && (distSqr() == rhs.distSqr());
201 }
202 
203 
204 inline bool Foam::pointEdgeDist::operator!=
205 (
206  const Foam::pointEdgeDist& rhs
207 )
208 const
209 {
210  return !(*this == rhs);
211 }
212 
213 
214 // ************************************************************************* //
#define w2
Definition: blockCreate.C:32
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
scalar distSqr() const
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
bool valid(data &td) const
Check whether origin has been changed at all or.
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
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
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 > &)
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
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > magSqr(const dimensioned< Type > &)