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  const 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_(point::max)
80 {}
81 
82 
84 (
85  const scalar value,
86  const point& origin
87 )
88 :
89  value_(value),
90  origin_(origin)
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class TrackingData>
97 inline bool Foam::sweepData::valid(TrackingData& td) const
98 {
99  return value_ > -SMALL;
100 }
101 
102 
103 template<class TrackingData>
105 (
106  const polyMesh&,
107  const sweepData&,
108  const scalar,
109  TrackingData& td
110 ) const
111 {
112  return true;
113 }
114 
115 
116 template<class TrackingData>
118 (
119  const polyMesh&,
120  const polyPatch&,
121  const label,
122  const point& faceCentre,
123  TrackingData& td
124 )
125 {
126  origin_ -= faceCentre;
127 }
128 
129 
130 template<class TrackingData>
131 inline void Foam::sweepData::transform
132 (
133  const polyMesh&,
134  const tensor& rotTensor,
135  TrackingData& td
136 )
137 {
138  origin_ = Foam::transform(rotTensor, origin_);
139 }
140 
141 
142 template<class TrackingData>
144 (
145  const polyMesh&,
146  const polyPatch&,
147  const label,
148  const point& faceCentre,
149  TrackingData& td
150 )
151 {
152  // back to absolute form
153  origin_ += faceCentre;
154 }
155 
156 
157 template<class TrackingData>
158 inline bool Foam::sweepData::updateCell
159 (
160  const polyMesh& mesh,
161  const label thisCelli,
162  const label,
163  const sweepData& svf,
164  const scalar tol,
165  TrackingData& td
166 )
167 {
168  return update(svf, mesh.cellCentres()[thisCelli], tol, td);
169 }
170 
171 
172 template<class TrackingData>
173 inline bool Foam::sweepData::updateFace
174 (
175  const polyMesh& mesh,
176  const label thisFacei,
177  const label,
178  const sweepData& svf,
179  const scalar tol,
180  TrackingData& td
181 )
182 {
183  return update(svf, mesh.faceCentres()[thisFacei], tol, td);
184 }
185 
186 
187 // Update this (face) with coupled face information.
188 template<class TrackingData>
189 inline bool Foam::sweepData::updateFace
190 (
191  const polyMesh& mesh,
192  const label thisFacei,
193  const sweepData& svf,
194  const scalar tol,
195  TrackingData& td
196 )
197 {
198  return update(svf, mesh.faceCentres()[thisFacei], tol, td);
199 }
200 
201 
202 template<class TrackingData>
203 inline bool Foam::sweepData::equal
204 (
205  const sweepData& rhs,
206  TrackingData& td
207 ) const
208 {
209  return operator==(rhs);
210 }
211 
212 
213 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
214 
215 inline bool Foam::sweepData::operator==
216 (
217  const sweepData& rhs
218 ) const
219 {
220  return origin_ == rhs.origin_;
221 }
222 
223 
224 inline bool Foam::sweepData::operator!=
225 (
226  const sweepData& rhs
227 ) const
228 {
229  return !(*this == rhs);
230 }
231 
232 
233 // ************************************************************************* //
Foam::sweepData::value
scalar value() const
Return value.
Definition: sweepData.H:104
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:118
Foam::sweepData::sweepData
sweepData()
Default construct.
Definition: sweepDataI.H:76
Foam::sweepData
Helper class used by fvc::sweep function.
Definition: sweepData.H:56
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:144
Foam::sweepData::valid
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition: sweepDataI.H:97
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
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::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:68
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
Test for equality, with TrackingData.
Definition: sweepDataI.H:204
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::sweepData::operator=
sweepData & operator=(const sweepData &)=default
Copy assignment.
Foam::sweepData::origin
const point & origin() const
Return origin.
Definition: sweepData.H:116
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:84
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:174
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:77
Foam::sweepData::sameGeometry
bool sameGeometry(const polyMesh &, const sweepData &, const scalar, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
Definition: sweepDataI.H:105
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:132
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:159