PrimitivePatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "PrimitivePatch.H"
27 #include "Map.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class FaceList, class PointField>
33 (
34  const FaceList& faces,
35  const Field<PointType>& points
36 )
37 :
38  FaceList(faces),
39  points_(points),
40  edgesPtr_(nullptr),
41  nInternalEdges_(-1),
42  boundaryPointsPtr_(nullptr),
43  faceFacesPtr_(nullptr),
44  edgeFacesPtr_(nullptr),
45  faceEdgesPtr_(nullptr),
46  pointEdgesPtr_(nullptr),
47  pointFacesPtr_(nullptr),
48  localFacesPtr_(nullptr),
49  meshPointsPtr_(nullptr),
50  meshPointMapPtr_(nullptr),
51  edgeLoopsPtr_(nullptr),
52  localPointsPtr_(nullptr),
53  localPointOrderPtr_(nullptr),
54  faceCentresPtr_(nullptr),
55  faceAreasPtr_(nullptr),
56  faceNormalsPtr_(nullptr),
57  pointNormalsPtr_(nullptr)
58 {}
59 
60 
61 template<class FaceList, class PointField>
63 (
64  FaceList&& faces,
65  Field<PointType>&& points
66 )
67 :
68  FaceList(move(faces)),
69  points_(move(points)),
70  edgesPtr_(nullptr),
71  nInternalEdges_(-1),
72  boundaryPointsPtr_(nullptr),
73  faceFacesPtr_(nullptr),
74  edgeFacesPtr_(nullptr),
75  faceEdgesPtr_(nullptr),
76  pointEdgesPtr_(nullptr),
77  pointFacesPtr_(nullptr),
78  localFacesPtr_(nullptr),
79  meshPointsPtr_(nullptr),
80  meshPointMapPtr_(nullptr),
81  edgeLoopsPtr_(nullptr),
82  localPointsPtr_(nullptr),
83  localPointOrderPtr_(nullptr),
84  faceCentresPtr_(nullptr),
85  faceAreasPtr_(nullptr),
86  faceNormalsPtr_(nullptr),
87  pointNormalsPtr_(nullptr)
88 {}
89 
90 
91 template<class FaceList, class PointField>
93 (
94  FaceList& faces,
95  Field<PointType>& points,
96  const bool reuse
97 )
98 :
99  FaceList(faces, reuse),
100  points_(points, reuse),
101  edgesPtr_(nullptr),
102  nInternalEdges_(-1),
103  boundaryPointsPtr_(nullptr),
104  faceFacesPtr_(nullptr),
105  edgeFacesPtr_(nullptr),
106  faceEdgesPtr_(nullptr),
107  pointEdgesPtr_(nullptr),
108  pointFacesPtr_(nullptr),
109  localFacesPtr_(nullptr),
110  meshPointsPtr_(nullptr),
111  meshPointMapPtr_(nullptr),
112  edgeLoopsPtr_(nullptr),
113  localPointsPtr_(nullptr),
114  localPointOrderPtr_(nullptr),
115  faceCentresPtr_(nullptr),
116  faceAreasPtr_(nullptr),
117  faceNormalsPtr_(nullptr),
118  pointNormalsPtr_(nullptr)
119 {}
120 
121 
122 template<class FaceList, class PointField>
124 (
126 )
127 :
128  PrimitivePatchName(),
129  FaceList(pp),
130  points_(pp.points_),
131  edgesPtr_(nullptr),
132  nInternalEdges_(-1),
133  boundaryPointsPtr_(nullptr),
134  faceFacesPtr_(nullptr),
135  edgeFacesPtr_(nullptr),
136  faceEdgesPtr_(nullptr),
137  pointEdgesPtr_(nullptr),
138  pointFacesPtr_(nullptr),
139  localFacesPtr_(nullptr),
140  meshPointsPtr_(nullptr),
141  meshPointMapPtr_(nullptr),
142  edgeLoopsPtr_(nullptr),
143  localPointsPtr_(nullptr),
144  localPointOrderPtr_(nullptr),
145  faceCentresPtr_(nullptr),
146  faceAreasPtr_(nullptr),
147  faceNormalsPtr_(nullptr),
148  pointNormalsPtr_(nullptr)
149 {}
150 
151 
152 template<class FaceList, class PointField>
154 (
156 )
157 :
158  PrimitivePatchName(),
159  FaceList(move(pp)),
160  points_(move(pp.points_)),
161  edgesPtr_(nullptr),
162  nInternalEdges_(-1),
163  boundaryPointsPtr_(nullptr),
164  faceFacesPtr_(nullptr),
165  edgeFacesPtr_(nullptr),
166  faceEdgesPtr_(nullptr),
167  pointEdgesPtr_(nullptr),
168  pointFacesPtr_(nullptr),
169  localFacesPtr_(nullptr),
170  meshPointsPtr_(nullptr),
171  meshPointMapPtr_(nullptr),
172  edgeLoopsPtr_(nullptr),
173  localPointsPtr_(nullptr),
174  localPointOrderPtr_(nullptr),
175  faceCentresPtr_(nullptr),
176  faceAreasPtr_(nullptr),
177  faceNormalsPtr_(nullptr),
178  pointNormalsPtr_(nullptr)
179 {}
180 
181 
182 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183 
184 template<class FaceList, class PointField>
186 {
187  clearOut();
188 }
189 
190 
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
192 
193 template<class FaceList, class PointField>
195 {
196  if (!edgesPtr_)
197  {
198  calcAddressing();
199  }
200 
201  return *edgesPtr_;
202 }
203 
204 
205 template<class FaceList, class PointField>
207 {
208  if (!edgesPtr_)
209  {
210  calcAddressing();
211  }
212 
213  return nInternalEdges_;
214 }
215 
216 
217 template<class FaceList, class PointField>
218 const Foam::labelList&
220 {
221  if (!boundaryPointsPtr_)
222  {
223  calcBdryPoints();
224  }
225 
226  return *boundaryPointsPtr_;
227 }
228 
229 
230 template<class FaceList, class PointField>
231 const Foam::labelListList&
233 faceFaces() const
234 {
235  if (!faceFacesPtr_)
236  {
237  calcAddressing();
238  }
239 
240  return *faceFacesPtr_;
241 }
242 
243 
244 template<class FaceList, class PointField>
245 const Foam::labelListList&
247 {
248  if (!edgeFacesPtr_)
249  {
250  calcAddressing();
251  }
252 
253  return *edgeFacesPtr_;
254 }
255 
256 
257 template<class FaceList, class PointField>
258 const Foam::labelListList&
260 {
261  if (!faceEdgesPtr_)
262  {
263  calcAddressing();
264  }
265 
266  return *faceEdgesPtr_;
267 }
268 
269 
270 template<class FaceList, class PointField>
271 const Foam::labelListList&
273 {
274  if (!pointEdgesPtr_)
275  {
276  calcPointEdges();
277  }
278 
279  return *pointEdgesPtr_;
280 }
281 
282 
283 template<class FaceList, class PointField>
284 const Foam::labelListList&
286 {
287  if (!pointFacesPtr_)
288  {
289  calcPointFaces();
290  }
291 
292  return *pointFacesPtr_;
293 }
294 
295 
296 template<class FaceList, class PointField>
297 const Foam::List
298 <
300 >&
302 {
303  if (!localFacesPtr_)
304  {
305  calcMeshData();
306  }
307 
308  return *localFacesPtr_;
309 }
310 
311 
312 template<class FaceList, class PointField>
313 const Foam::labelList&
315 {
316  if (!meshPointsPtr_)
317  {
318  calcMeshData();
319  }
320 
321  return *meshPointsPtr_;
322 }
323 
324 
325 template<class FaceList, class PointField>
328 {
329  if (!meshPointMapPtr_)
330  {
331  calcMeshPointMap();
332  }
333 
334  return *meshPointMapPtr_;
335 }
336 
337 
338 template<class FaceList, class PointField>
339 const Foam::Field
340 <
342 >&
344 {
345  if (!localPointsPtr_)
346  {
347  calcLocalPoints();
348  }
349 
350  return *localPointsPtr_;
351 }
352 
353 
354 template<class FaceList, class PointField>
355 const Foam::labelList&
357 {
358  if (!localPointOrderPtr_)
359  {
360  calcLocalPointOrder();
361  }
362 
363  return *localPointOrderPtr_;
364 }
365 
366 
367 template<class FaceList, class PointField>
369 (
370  const label gp
371 ) const
372 {
373  Map<label>::const_iterator fnd = meshPointMap().find(gp);
374 
375  if (fnd != meshPointMap().end())
376  {
377  return fnd();
378  }
379  else
380  {
381  // Not found
382  return -1;
383  }
384 }
385 
386 
387 template<class FaceList, class PointField>
388 const Foam::Field
389 <
391 >&
393 {
394  if (!faceCentresPtr_)
395  {
396  calcFaceCentres();
397  }
398 
399  return *faceCentresPtr_;
400 }
401 
402 
403 template<class FaceList, class PointField>
404 const Foam::Field
405 <
407 >&
409 {
410  if (!faceAreasPtr_)
411  {
412  calcFaceAreas();
413  }
414 
415  return *faceAreasPtr_;
416 }
417 
418 
419 template<class FaceList, class PointField>
420 const Foam::Field
421 <
423 >&
425 {
426  if (!faceNormalsPtr_)
427  {
428  calcFaceNormals();
429  }
430 
431  return *faceNormalsPtr_;
432 }
433 
434 
435 template<class FaceList, class PointField>
436 const Foam::Field
437 <
439 >&
441 {
442  if (!pointNormalsPtr_)
443  {
444  calcPointNormals();
445  }
446 
447  return *pointNormalsPtr_;
448 }
449 
450 
451 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
452 
453 template<class FaceList, class PointField>
454 void Foam::PrimitivePatch<FaceList, PointField>::operator=
455 (
457 )
458 {
459  clearOut();
460 
461  FaceList::shallowCopy(pp);
462 }
463 
464 
465 template<class FaceList, class PointField>
466 void Foam::PrimitivePatch<FaceList, PointField>::operator=
467 (
469 )
470 {
471  clearOut();
472 
473  FaceList::operator=(move(pp));
474 
475  // This is only valid if PointField is not a reference
476  // points_ = move(pp.points_);
477 }
478 
479 
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
481 
483 #include "PrimitivePatchEdgeLoops.C"
484 #include "PrimitivePatchClear.C"
487 #include "PrimitivePatchMeshData.C"
488 #include "PrimitivePatchMeshEdges.C"
491 #include "PrimitivePatchCheck.C"
492 
493 // ************************************************************************* //
const labelListList & pointEdges() const
Return point-edge addressing.
const Field< PointType > & faceCentres() const
Return face centres for patch.
PrimitivePatch(const FaceList &faces, const Field< PointType > &points)
Construct from components.
const labelList & boundaryPoints() const
Return list of boundary points,.
label nInternalEdges() const
Number of internal edges.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const Field< PointType > & faceAreas() const
Return face areas for patch.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const labelList & localPointOrder() const
Return orders the local points for most efficient search.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
For every point on the patch find the closest face on the target side. Return a target face label for...
This function calculates the list of patch edges, defined on the list of points supporting the patch...
A list of faces which address into the list of points.
const labelListList & faceFaces() const
Return face-face addressing.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Create the list of loops of outside vertices. Goes wrong on multiply connected edges (loops will be u...
const Field< PointType > & faceNormals() const
Return face normals for patch.
Point addressing on the patch: pointEdges and pointFaces.
label whichPoint(const label gp) const
Given a global point index, return the local point index.
const labelListList & pointFaces() const
Return point-face addressing.
Checks topology of the patch.
~PrimitivePatch()
Destructor.
const Field< PointType > & pointNormals() const
Return point normals for patch.
Orders the local points on the patch for most efficient search.
std::remove_reference< FaceList >::type::value_type FaceType
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & faceEdges() const
Return face-edge addressing.
std::remove_reference< PointField >::type::value_type PointType
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49