topoDistanceDataI.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  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyMesh.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  data_(-1),
36  distance_(-1)
37 {}
38 
39 
41 (
42  const label data,
43  const label distance
44 )
45 :
46  data_(data),
47  distance_(distance)
48 {}
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 template<class TrackingData>
54 inline bool Foam::topoDistanceData::valid(TrackingData& td) const
55 {
56  return distance_ != -1;
57 }
58 
59 
60 // No geometric data so never any problem on cyclics
61 template<class TrackingData>
63 (
64  const polyMesh&,
65  const topoDistanceData&,
66  const scalar,
67  TrackingData&
68 ) const
69 {
70  return true;
71 }
72 
73 
74 // No geometric data.
75 template<class TrackingData>
77 (
78  const polyMesh&,
79  const polyPatch& patch,
80  const label patchFacei,
81  const point& faceCentre,
82  TrackingData&
83 )
84 {}
85 
86 
87 // No geometric data.
88 template<class TrackingData>
90 (
91  const polyMesh&,
92  const tensor& rotTensor,
93  TrackingData&
94 )
95 {}
96 
97 
98 // No geometric data.
99 template<class TrackingData>
101 (
102  const polyMesh&,
103  const polyPatch& patch,
104  const label patchFacei,
105  const point& faceCentre,
106  TrackingData&
107 )
108 {}
109 
110 
111 // Update cell with neighbouring face information
112 template<class TrackingData>
114 (
115  const polyMesh&,
116  const label thisCelli,
117  const label neighbourFacei,
118  const topoDistanceData& neighbourInfo,
119  const scalar tol,
120  TrackingData&
121 )
122 {
123  if (distance_ == -1)
124  {
125  operator=(neighbourInfo);
126  return true;
127  }
128 
129  return false;
130 }
131 
132 
133 // Update face with neighbouring cell information
134 template<class TrackingData>
136 (
137  const polyMesh& mesh,
138  const label thisFacei,
139  const label neighbourCelli,
140  const topoDistanceData& neighbourInfo,
141  const scalar tol,
142  TrackingData&
143 )
144 {
145  // From cell to its faces.
146 
147  if (distance_ == -1)
148  {
149  data_ = neighbourInfo.data_;
150  distance_ = neighbourInfo.distance_ + 1;
151  return true;
152  }
153 
154  return false;
155 }
156 
157 
158 // Update face with coupled face information
159 template<class TrackingData>
161 (
162  const polyMesh&,
163  const label thisFacei,
164  const topoDistanceData& neighbourInfo,
165  const scalar tol,
166  TrackingData&
167 )
168 {
169  // From face to face (e.g. coupled faces)
170  if (distance_ == -1)
171  {
172  operator=(neighbourInfo);
173  return true;
174  }
175 
176  return false;
177 }
178 
179 
180 template<class TrackingData>
182 (
183  const topoDistanceData& rhs,
184  TrackingData& td
185 ) const
186 {
187  return operator==(rhs);
188 }
189 
190 
191 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
192 
193 inline bool Foam::topoDistanceData::operator==
194 (
195  const Foam::topoDistanceData& rhs
196 ) const
197 {
198  return data() == rhs.data() && distance() == rhs.distance();
199 }
200 
201 
202 inline bool Foam::topoDistanceData::operator!=
203 (
204  const Foam::topoDistanceData& rhs
205 ) const
206 {
207  return !(*this == rhs);
208 }
209 
210 
211 // ************************************************************************* //
Foam::topoDistanceData::updateFace
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const topoDistanceData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: topoDistanceDataI.H:136
Foam::Tensor< scalar >
Foam::topoDistanceData::transform
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition: topoDistanceDataI.H:90
Foam::topoDistanceData
For use with FaceCellWave. Determines topological distance to starting faces.
Definition: topoDistanceData.H:62
Foam::topoDistanceData::updateCell
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const topoDistanceData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: topoDistanceDataI.H:114
Foam::topoDistanceData::topoDistanceData
topoDistanceData()
Construct null with invalid (-1) for data and distance.
Definition: topoDistanceDataI.H:33
Foam::topoDistanceData::data
label data() const
Definition: topoDistanceData.H:92
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::topoDistanceData::enterDomain
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: topoDistanceDataI.H:101
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::topoDistanceData::equal
bool equal(const topoDistanceData &, TrackingData &td) const
Same (like operator==)
Definition: topoDistanceDataI.H:182
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::distance
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
Foam::topoDistanceData::sameGeometry
bool sameGeometry(const polyMesh &, const topoDistanceData &, const scalar, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
Definition: topoDistanceDataI.H:63
Foam::topoDistanceData::distance
label distance() const
Definition: topoDistanceData.H:96
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::topoDistanceData::valid
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: topoDistanceDataI.H:54
Foam::topoDistanceData::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face.
Definition: topoDistanceDataI.H:77
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:54