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