sweepDataI.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) 2011-2022 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 "sweepData.H"
27 #include "transformer.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template<class TrackingData>
34 inline bool Foam::sweepData::update
35 (
36  const sweepData& svf,
37  const point& position,
38  const scalar tol,
39  TrackingData& td
40 )
41 {
42  if (!valid(td))
43  {
44  operator=(svf);
45  return true;
46  }
47 
48  scalar myDist2 = magSqr(position - origin());
49 
50  if (myDist2 < small)
51  {
52  if (svf.value() > value())
53  {
54  operator=(svf);
55  return true;
56  }
57  else
58  {
59  return false;
60  }
61  }
62 
63  scalar dist2 = magSqr(position - svf.origin());
64 
65  if (dist2 < myDist2)
66  {
67  operator=(svf);
68  return true;
69  }
70 
71  return false;
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 :
79  value_(-great),
80  origin_(vector::max)
81 {}
82 
83 
84 inline Foam::sweepData::sweepData(const scalar value, const point& origin)
85 :
86  value_(value),
87  origin_(origin)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 template<class TrackingData>
94 inline bool Foam::sweepData::valid(TrackingData& td) const
95 {
96  return value_ > -small;
97 }
98 
99 
100 template<class TrackingData>
102 (
103  const fvMesh&,
104  const sweepData&,
105  const scalar,
106  TrackingData& td
107 ) const
108 {
109  return true;
110 }
111 
112 
113 template<class TrackingData>
115 (
116  const fvPatch& patch,
117  const label patchFacei,
118  const transformer& transform,
119  TrackingData& td
120 )
121 {
122  origin_ = transform.transformPosition(origin_);
123 }
124 
125 
126 template<class TrackingData>
128 (
129  const fvMesh& mesh,
130  const label thisCelli,
131  const labelPair&,
132  const sweepData& svf,
133  const scalar tol,
134  TrackingData& td
135 )
136 {
137  return update(svf, mesh.C()[thisCelli], tol, td);
138 }
139 
140 
141 template<class TrackingData>
143 (
144  const fvMesh& mesh,
145  const labelPair& thisPatchAndFacei,
146  const label,
147  const sweepData& svf,
148  const scalar tol,
149  TrackingData& td
150 )
151 {
152  const label thisPatchi = thisPatchAndFacei.first();
153  const label thisFacei = thisPatchAndFacei.second();
154 
155  return
156  update
157  (
158  svf,
159  thisPatchi == -1
160  ? mesh.Cf()[thisFacei]
161  : mesh.Cf().boundaryField()[thisPatchi][thisFacei],
162  tol,
163  td
164  );
165 }
166 
167 
168 // Update this (face) with coupled face information.
169 template<class TrackingData>
171 (
172  const fvMesh& mesh,
173  const labelPair& thisPatchAndFacei,
174  const sweepData& svf,
175  const scalar tol,
176  TrackingData& td
177 )
178 {
179  const label thisPatchi = thisPatchAndFacei.first();
180  const label thisFacei = thisPatchAndFacei.second();
181 
182  return
183  update
184  (
185  svf,
186  thisPatchi == -1
187  ? mesh.Cf()[thisFacei]
188  : mesh.Cf().boundaryField()[thisPatchi][thisFacei],
189  tol,
190  td
191  );
192 }
193 
194 
195 template<class TrackingData>
197 (
198  const sweepData& rhs,
199  TrackingData& td
200 ) const
201 {
202  return operator==(rhs);
203 }
204 
205 
206 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
207 
208 inline void Foam::sweepData::operator=
209 (
210  const scalar value
211 )
212 {
213  value_ = value;
214 }
215 
216 
217 inline bool Foam::sweepData::operator==
218 (
219  const sweepData& rhs
220 ) const
221 {
222  return origin() == rhs.origin();
223 }
224 
225 
226 inline bool Foam::sweepData::operator!=
227 (
228  const sweepData& rhs
229 ) const
230 {
231  return !(*this == rhs);
232 }
233 
234 
235 // ************************************************************************* //
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const Type & second() const
Return second.
Definition: Pair.H:110
const Type & first() const
Return first.
Definition: Pair.H:98
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const volVectorField & C() const
Return cell centres.
const surfaceVectorField & Cf() const
Return face centres.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Helper class used by fvc::sweep function.
Definition: sweepData.H:57
sweepData()
Construct null.
Definition: sweepDataI.H:77
bool updateCell(const fvMesh &, const label thisCelli, const labelPair &neighbourPatchAndFacei, const sweepData &svf, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: sweepDataI.H:128
scalar value() const
Return value.
Definition: sweepData.H:97
void operator=(const scalar value)
Definition: sweepDataI.H:209
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: sweepDataI.H:94
bool updateFace(const fvMesh &, const labelPair &thisPatchAndFacei, const label neighbourCelli, const sweepData &svf, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: sweepDataI.H:143
bool sameGeometry(const fvMesh &, const sweepData &, const scalar, TrackingData &td) const
Check for identical geometrical data.
Definition: sweepDataI.H:102
const point & origin() const
Return origin.
Definition: sweepData.H:103
bool equal(const sweepData &, TrackingData &td) const
Same (like operator==)
Definition: sweepDataI.H:197
void transform(const fvPatch &patch, const label patchFacei, const transformer &transform, TrackingData &td)
Transform across an interface.
Definition: sweepDataI.H:115
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
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
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::surfaceFields.