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-2018 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 "transform.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class TrackingData>
31 inline bool Foam::sweepData::update
32 (
33  const sweepData& svf,
34  const point& position,
35  const scalar tol,
36  TrackingData& td
37 )
38 {
39  if (!valid(td))
40  {
41  operator=(svf);
42  return true;
43  }
44 
45  scalar myDist2 = magSqr(position - origin());
46 
47  if (myDist2 < small)
48  {
49  if (svf.value() > value())
50  {
51  operator=(svf);
52  return true;
53  }
54  else
55  {
56  return false;
57  }
58  }
59 
60  scalar dist2 = magSqr(position - svf.origin());
61 
62  if (dist2 < myDist2)
63  {
64  operator=(svf);
65  return true;
66  }
67 
68  return false;
69 }
70 
71 
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 
75 :
76  value_(-great),
77  origin_(vector::max)
78 {}
79 
80 
81 inline Foam::sweepData::sweepData(const scalar value, const point& origin)
82 :
83  value_(value),
84  origin_(origin)
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
90 template<class TrackingData>
91 inline bool Foam::sweepData::valid(TrackingData& td) const
92 {
93  return value_ > -small;
94 }
95 
96 
97 template<class TrackingData>
99 (
100  const polyMesh&,
101  const sweepData&,
102  const scalar,
103  TrackingData& td
104 ) const
105 {
106  return true;
107 }
108 
109 
110 template<class TrackingData>
112 (
113  const polyMesh&,
114  const polyPatch&,
115  const label,
116  const point& faceCentre,
117  TrackingData& td
118 )
119 {
120  origin_ -= faceCentre;
121 }
122 
123 
124 template<class TrackingData>
125 inline void Foam::sweepData::transform
126 (
127  const polyMesh&,
128  const tensor& rotTensor,
129  TrackingData& td
130 )
131 {
132  origin_ = Foam::transform(rotTensor, origin_);
133 }
134 
135 
136 template<class TrackingData>
138 (
139  const polyMesh&,
140  const polyPatch&,
141  const label,
142  const point& faceCentre,
143  TrackingData& td
144 )
145 {
146  // back to absolute form
147  origin_ += faceCentre;
148 }
149 
150 
151 template<class TrackingData>
152 inline bool Foam::sweepData::updateCell
153 (
154  const polyMesh& mesh,
155  const label thisCelli,
156  const label,
157  const sweepData& svf,
158  const scalar tol,
159  TrackingData& td
160 )
161 {
162  return update(svf, mesh.cellCentres()[thisCelli], tol, td);
163 }
164 
165 
166 template<class TrackingData>
167 inline bool Foam::sweepData::updateFace
168 (
169  const polyMesh& mesh,
170  const label thisFacei,
171  const label,
172  const sweepData& svf,
173  const scalar tol,
174  TrackingData& td
175 )
176 {
177  return update(svf, mesh.faceCentres()[thisFacei], tol, td);
178 }
179 
180 
181 // Update this (face) with coupled face information.
182 template<class TrackingData>
183 inline bool Foam::sweepData::updateFace
184 (
185  const polyMesh& mesh,
186  const label thisFacei,
187  const sweepData& svf,
188  const scalar tol,
189  TrackingData& td
190 )
191 {
192  return update(svf, mesh.faceCentres()[thisFacei], tol, td);
193 }
194 
195 
196 template<class TrackingData>
197 inline bool Foam::sweepData::equal
198 (
199  const sweepData& rhs,
200  TrackingData& td
201 ) const
202 {
203  return operator==(rhs);
204 }
205 
206 
207 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
208 
209 inline void Foam::sweepData::operator=
210 (
211  const scalar value
212 )
213 {
214  value_ = value;
215 }
216 
217 
218 inline bool Foam::sweepData::operator==
219 (
220  const sweepData& rhs
221 ) const
222 {
223  return origin() == rhs.origin();
224 }
225 
226 
227 inline bool Foam::sweepData::operator!=
228 (
229  const sweepData& rhs
230 ) const
231 {
232  return !(*this == rhs);
233 }
234 
235 
236 // ************************************************************************* //
bool operator==(const sweepData &) const
Definition: sweepDataI.H:219
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
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: sweepDataI.H:91
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const sweepData &svf, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: sweepDataI.H:153
bool sameGeometry(const polyMesh &, const sweepData &, const scalar, TrackingData &td) const
Check for identical geometrical data.
Definition: sweepDataI.H:99
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
scalar value() const
Return value.
Definition: sweepData.H:82
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to.
Definition: sweepDataI.H:112
sweepData()
Construct null.
Definition: sweepDataI.H:74
Helper class used by fvc::sweep function.
Definition: sweepData.H:47
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: sweepDataI.H:138
const point & origin() const
Return origin.
Definition: sweepData.H:88
bool equal(const sweepData &, TrackingData &td) const
Same (like operator==)
Definition: sweepDataI.H:198
3D tensor transformation operations.
const vectorField & cellCentres() const
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const sweepData &svf, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: sweepDataI.H:168
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition: sweepDataI.H:126
const vectorField & faceCentres() const
void operator=(const scalar value)
Definition: sweepDataI.H:210
vector point
Point is a vector.
Definition: point.H:41
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477