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-------------------------------------------------------------------------------
10License
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
32template<class TrackingData>
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
96template<class TrackingData>
97inline bool Foam::sweepData::valid(TrackingData& td) const
98{
99 return value_ > -SMALL;
100}
101
102
103template<class TrackingData>
105(
106 const polyMesh&,
107 const sweepData&,
108 const scalar,
109 TrackingData& td
110) const
111{
112 return true;
113}
114
115
116template<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
130template<class TrackingData>
132(
133 const polyMesh&,
134 const tensor& rotTensor,
135 TrackingData& td
136)
137{
138 origin_ = Foam::transform(rotTensor, origin_);
139}
140
141
142template<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
157template<class TrackingData>
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
172template<class TrackingData>
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.
188template<class TrackingData>
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
202template<class TrackingData>
204(
205 const sweepData& rhs,
206 TrackingData& td
207) const
208{
209 return operator==(rhs);
210}
211
212
213// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
214
216(
217 const sweepData& rhs
218) const
219{
220 return origin_ == rhs.origin_;
221}
222
223
225(
226 const sweepData& rhs
227) const
228{
229 return !(*this == rhs);
230}
231
232
233// ************************************************************************* //
bool valid() const
True if all internal ids are non-negative.
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
virtual bool update()
Update the mesh for both mesh motion and topology change.
Default transformation behaviour.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
const vectorField & faceCentres() const
const vectorField & cellCentres() const
Helper class used by fvc::sweep function.
Definition: sweepData.H:57
const point & origin() const
Return origin.
Definition: sweepData.H:116
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
sweepData()
Default construct.
Definition: sweepDataI.H:76
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: sweepDataI.H:144
scalar value() const
Return value.
Definition: sweepData.H:104
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition: sweepDataI.H:97
sweepData & operator=(const sweepData &)=default
Copy assignment.
bool sameGeometry(const polyMesh &, const sweepData &, const scalar, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
Definition: sweepDataI.H:105
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
bool equal(const sweepData &, TrackingData &td) const
Test for equality, with TrackingData.
Definition: sweepDataI.H:204
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
mesh update()
dynamicFvMesh & mesh
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
3D tensor transformation operations.