cellInfoI.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) 2020 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 "cellClassification.H"
30 #include "polyMesh.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 // Update this with w2 information
35 template<class TrackingData>
36 inline bool Foam::cellInfo::update
37 (
38  const cellInfo& w2,
39  const label thisFacei,
40  const label thisCelli,
41  const label neighbourFacei,
42  const label neighbourCelli,
43  TrackingData& td
44 )
45 {
46  if
47  (
48  (w2.type() == cellClassification::NOTSET)
49  || (w2.type() == cellClassification::CUT)
50  )
51  {
53  << "Problem: trying to propagate NOTSET or CUT type:" << w2.type()
54  << " into cell/face with type:" << type() << endl
55  << "thisFacei:" << thisFacei
56  << " thisCelli:" << thisCelli
57  << " neighbourFacei:" << neighbourFacei
58  << " neighbourCelli:" << neighbourCelli
59  << abort(FatalError);
60  return false;
61  }
62 
64  {
65  type_ = w2.type();
66 
67  return true;
68  }
69 
71  {
72  // Reached boundary. Stop.
73  return false;
74  }
75 
76  if (type() == w2.type())
77  {
78  // Should never happen; already checked in meshWave
79  return false;
80  }
81 
82  // Two conflicting types
84  << "Problem: trying to propagate conflicting types:" << w2.type()
85  << " into cell/face with type:" << type() << endl
86  << "thisFacei:" << thisFacei
87  << " thisCelli:" << thisCelli
88  << " neighbourFacei:" << neighbourFacei
89  << " neighbourCelli:" << neighbourCelli
90  << abort(FatalError);
91 
92  return false;
93 }
94 
95 
96 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
97 
99 :
100  type_(cellClassification::NOTSET)
101 {}
102 
103 
104 inline Foam::cellInfo::cellInfo(const label ctype)
105 :
106  type_(ctype)
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 template<class TrackingData>
113 inline bool Foam::cellInfo::valid(TrackingData& td) const
114 {
115  return type_ != cellClassification::NOTSET;
116 }
117 
118 
119 // No geometric data so never any problem on cyclics
120 template<class TrackingData>
122 (
123  const polyMesh&,
124  const cellInfo& w2,
125  const scalar tol,
126  TrackingData& td
127 ) const
128 {
129  return true;
130 }
131 
132 
133 // No geometric data.
134 template<class TrackingData>
135 inline void Foam::cellInfo::leaveDomain
136 (
137  const polyMesh&,
138  const polyPatch& patch,
139  const label patchFacei,
140  const point& faceCentre,
141  TrackingData& td
142 )
143 {}
144 
145 
146 // No geometric data.
147 template<class TrackingData>
148 inline void Foam::cellInfo::transform
149 (
150  const polyMesh&,
151  const tensor& rotTensor,
152  TrackingData& td
153 )
154 {}
155 
156 
157 // No geometric data.
158 template<class TrackingData>
159 inline void Foam::cellInfo::enterDomain
160 (
161  const polyMesh&,
162  const polyPatch& patch,
163  const label patchFacei,
164  const point& faceCentre,
165  TrackingData& td
166 )
167 {}
168 
169 
170 // Update this with neighbour information
171 template<class TrackingData>
172 inline bool Foam::cellInfo::updateCell
173 (
174  const polyMesh&,
175  const label thisCelli,
176  const label neighbourFacei,
177  const cellInfo& neighbourInfo,
178  const scalar tol,
179  TrackingData& td
180 )
181 {
182  return update
183  (
184  neighbourInfo,
185  -1,
186  thisCelli,
187  neighbourFacei,
188  -1,
189  td
190  );
191 }
192 
193 
194 // Update this with neighbour information
195 template<class TrackingData>
196 inline bool Foam::cellInfo::updateFace
197 (
198  const polyMesh&,
199  const label thisFacei,
200  const label neighbourCelli,
201  const cellInfo& neighbourInfo,
202  const scalar tol,
203  TrackingData& td
204 )
205 {
206  return update
207  (
208  neighbourInfo,
209  thisFacei,
210  -1,
211  -1,
212  neighbourCelli,
213  td
214  );
215 }
216 
217 
218 // Update this with neighbour information
219 template<class TrackingData>
220 inline bool Foam::cellInfo::updateFace
221 (
222  const polyMesh&,
223  const label thisFacei,
224  const cellInfo& neighbourInfo,
225  const scalar tol,
226  TrackingData& td
227 )
228 {
229  return update
230  (
231  neighbourInfo,
232  thisFacei,
233  -1,
234  -1,
235  -1,
236  td
237  );
238 }
239 
240 
241 template<class TrackingData>
242 inline bool Foam::cellInfo::equal
243 (
244  const cellInfo& rhs,
245  TrackingData& td
246 ) const
247 {
248  return operator==(rhs);
249 }
250 
251 
252 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
253 
254 inline bool Foam::cellInfo::operator==
255 (
256  const cellInfo& rhs
257 ) const
258 {
259  return type_ == rhs.type_;
260 }
261 
262 
263 inline bool Foam::cellInfo::operator!=
264 (
265  const cellInfo& rhs
266 ) const
267 {
268  return !(*this == rhs);
269 }
270 
271 
272 // ************************************************************************* //
cellClassification.H
Foam::Tensor< scalar >
update
mesh update()
Foam::cellClassification::CUT
Definition: cellClassification.H:132
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::cellInfo::updateCell
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const cellInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: cellInfoI.H:173
Foam::cellInfo::updateFace
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const cellInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: cellInfoI.H:197
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::cellInfo::sameGeometry
bool sameGeometry(const polyMesh &, const cellInfo &, const scalar, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
Definition: cellInfoI.H:122
Foam::cellInfo::transform
void transform(const polyMesh &, const tensor &rotTensor, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition: cellInfoI.H:149
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::cellInfo::type
label type() const
Definition: cellInfo.H:102
Foam::cellClassification::NOTSET
Definition: cellClassification.H:129
Foam::FatalError
error FatalError
w2
#define w2
Definition: blockCreate.C:35
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::cellClassification
'Cuts' a mesh with a surface.
Definition: cellClassification.H:117
Foam::cellInfo::enterDomain
void enterDomain(const polyMesh &, const polyPatch &patch, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: cellInfoI.H:160
Foam::cellInfo
Holds information regarding type of cell. Used in inside/outside determination in cellClassification.
Definition: cellInfo.H:64
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::cellInfo::valid
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition: cellInfoI.H:113
Foam::cellInfo::cellInfo
cellInfo()
Default construct - as cellClassification::NOTSET.
Definition: cellInfoI.H:98
Foam::cellInfo::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &patch, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face.
Definition: cellInfoI.H:136
Foam::cellInfo::equal
bool equal(const cellInfo &, TrackingData &td) const
Test for equality, with TrackingData.
Definition: cellInfoI.H:243