PrimitivePatch.C
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 "Map.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template
33 <
34  class Face,
35  template<class> class FaceList,
36  class PointField,
37  class PointType
38 >
41 (
42  const FaceList<Face>& faces,
44 )
45 :
46  FaceList<Face>(faces),
47  points_(points),
48  edgesPtr_(nullptr),
49  nInternalEdges_(-1),
50  boundaryPointsPtr_(nullptr),
51  faceFacesPtr_(nullptr),
52  edgeFacesPtr_(nullptr),
53  faceEdgesPtr_(nullptr),
54  pointEdgesPtr_(nullptr),
55  pointFacesPtr_(nullptr),
56  localFacesPtr_(nullptr),
57  meshPointsPtr_(nullptr),
58  meshPointMapPtr_(nullptr),
59  edgeLoopsPtr_(nullptr),
60  localPointsPtr_(nullptr),
61  localPointOrderPtr_(nullptr),
62  faceCentresPtr_(nullptr),
63  faceAreasPtr_(nullptr),
64  magFaceAreasPtr_(nullptr),
65  faceNormalsPtr_(nullptr),
66  pointNormalsPtr_(nullptr)
67 {}
68 
69 
70 template
71 <
72  class Face,
73  template<class> class FaceList,
74  class PointField,
75  class PointType
76 >
79 (
80  FaceList<Face>&& faces,
82 )
83 :
84  FaceList<Face>(std::move(faces)),
85  points_(points),
86  edgesPtr_(nullptr),
87  nInternalEdges_(-1),
88  boundaryPointsPtr_(nullptr),
89  faceFacesPtr_(nullptr),
90  edgeFacesPtr_(nullptr),
91  faceEdgesPtr_(nullptr),
92  pointEdgesPtr_(nullptr),
93  pointFacesPtr_(nullptr),
94  localFacesPtr_(nullptr),
95  meshPointsPtr_(nullptr),
96  meshPointMapPtr_(nullptr),
97  edgeLoopsPtr_(nullptr),
98  localPointsPtr_(nullptr),
99  localPointOrderPtr_(nullptr),
100  faceCentresPtr_(nullptr),
101  faceAreasPtr_(nullptr),
102  magFaceAreasPtr_(nullptr),
103  faceNormalsPtr_(nullptr),
104  pointNormalsPtr_(nullptr)
105 {}
106 
107 
108 template
109 <
110  class Face,
111  template<class> class FaceList,
112  class PointField,
113  class PointType
114 >
117 (
118  FaceList<Face>& faces,
120  const bool reuse
121 )
122 :
123  FaceList<Face>(faces, reuse),
124  points_(points, reuse),
125  edgesPtr_(nullptr),
126  nInternalEdges_(-1),
127  boundaryPointsPtr_(nullptr),
128  faceFacesPtr_(nullptr),
129  edgeFacesPtr_(nullptr),
130  faceEdgesPtr_(nullptr),
131  pointEdgesPtr_(nullptr),
132  pointFacesPtr_(nullptr),
133  localFacesPtr_(nullptr),
134  meshPointsPtr_(nullptr),
135  meshPointMapPtr_(nullptr),
136  edgeLoopsPtr_(nullptr),
137  localPointsPtr_(nullptr),
138  localPointOrderPtr_(nullptr),
139  faceCentresPtr_(nullptr),
140  faceAreasPtr_(nullptr),
141  magFaceAreasPtr_(nullptr),
142  faceNormalsPtr_(nullptr),
143  pointNormalsPtr_(nullptr)
144 {}
145 
146 
147 template
148 <
149  class Face,
150  template<class> class FaceList,
151  class PointField,
152  class PointType
153 >
156 (
158 )
159 :
160  PrimitivePatchName(),
161  FaceList<Face>(pp),
162  points_(pp.points_),
163  edgesPtr_(nullptr),
164  nInternalEdges_(-1),
165  boundaryPointsPtr_(nullptr),
166  faceFacesPtr_(nullptr),
167  edgeFacesPtr_(nullptr),
168  faceEdgesPtr_(nullptr),
169  pointEdgesPtr_(nullptr),
170  pointFacesPtr_(nullptr),
171  localFacesPtr_(nullptr),
172  meshPointsPtr_(nullptr),
173  meshPointMapPtr_(nullptr),
174  edgeLoopsPtr_(nullptr),
175  localPointsPtr_(nullptr),
176  localPointOrderPtr_(nullptr),
177  faceCentresPtr_(nullptr),
178  faceAreasPtr_(nullptr),
179  magFaceAreasPtr_(nullptr),
180  faceNormalsPtr_(nullptr),
181  pointNormalsPtr_(nullptr)
182 {}
183 
184 
185 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
186 
187 template
188 <
189  class Face,
190  template<class> class FaceList,
191  class PointField,
192  class PointType
193 >
196 {
197  clearOut();
198 }
199 
200 
201 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
202 
203 template
204 <
205  class Face,
206  template<class> class FaceList,
207  class PointField,
208  class PointType
209 >
210 void
213 (
214  const Field<PointType>&
215 )
216 {
217  if (debug)
218  {
219  Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
220  << "movePoints() : "
221  << "recalculating PrimitivePatch geometry following mesh motion"
222  << endl;
223  }
224 
225  clearGeom();
226 }
227 
228 
229 template
230 <
231  class Face,
232  template<class> class FaceList,
233  class PointField,
234  class PointType
235 >
236 const Foam::edgeList&
238 edges() const
239 {
240  if (!edgesPtr_)
241  {
242  calcAddressing();
243  }
244 
245  return *edgesPtr_;
246 }
247 
248 
249 template
250 <
251  class Face,
252  template<class> class FaceList,
253  class PointField,
254  class PointType
255 >
259 {
260  if (!edgesPtr_)
261  {
262  calcAddressing();
263  }
264 
265  return nInternalEdges_;
266 }
267 
268 
269 template
270 <
271  class Face,
272  template<class> class FaceList,
273  class PointField,
274  class PointType
275 >
276 const Foam::labelList&
279 {
280  if (!boundaryPointsPtr_)
281  {
282  calcBdryPoints();
283  }
284 
285  return *boundaryPointsPtr_;
286 }
287 
288 
289 template
290 <
291  class Face,
292  template<class> class FaceList,
293  class PointField,
294  class PointType
295 >
296 const Foam::labelListList&
298 faceFaces() const
299 {
300  if (!faceFacesPtr_)
301  {
302  calcAddressing();
303  }
304 
305  return *faceFacesPtr_;
306 }
307 
308 
309 template
310 <
311  class Face,
312  template<class> class FaceList,
313  class PointField,
314  class PointType
315 >
316 const Foam::labelListList&
318 edgeFaces() const
319 {
320  if (!edgeFacesPtr_)
321  {
322  calcAddressing();
323  }
324 
325  return *edgeFacesPtr_;
326 }
327 
328 
329 template
330 <
331  class Face,
332  template<class> class FaceList,
333  class PointField,
334  class PointType
335 >
336 const Foam::labelListList&
338 faceEdges() const
339 {
340  if (!faceEdgesPtr_)
341  {
342  calcAddressing();
343  }
344 
345  return *faceEdgesPtr_;
346 }
347 
348 
349 template
350 <
351  class Face,
352  template<class> class FaceList,
353  class PointField,
354  class PointType
355 >
356 const Foam::labelListList&
358 pointEdges() const
359 {
360  if (!pointEdgesPtr_)
361  {
362  calcPointEdges();
363  }
364 
365  return *pointEdgesPtr_;
366 }
367 
368 
369 template
370 <
371  class Face,
372  template<class> class FaceList,
373  class PointField,
374  class PointType
375 >
376 const Foam::labelListList&
378 pointFaces() const
379 {
380  if (!pointFacesPtr_)
381  {
382  calcPointFaces();
383  }
384 
385  return *pointFacesPtr_;
386 }
387 
388 
389 template
390 <
391  class Face,
392  template<class> class FaceList,
393  class PointField,
394  class PointType
395 >
396 const Foam::List<Face>&
398 localFaces() const
399 {
400  if (!localFacesPtr_)
401  {
402  calcMeshData();
403  }
404 
405  return *localFacesPtr_;
406 }
407 
408 
409 template
410 <
411  class Face,
412  template<class> class FaceList,
413  class PointField,
414  class PointType
415 >
416 const Foam::labelList&
418 meshPoints() const
419 {
420  if (!meshPointsPtr_)
421  {
422  calcMeshData();
423  }
424 
425  return *meshPointsPtr_;
426 }
427 
428 
429 template
430 <
431  class Face,
432  template<class> class FaceList,
433  class PointField,
434  class PointType
435 >
439 {
440  if (!meshPointMapPtr_)
441  {
442  calcMeshPointMap();
443  }
444 
445  return *meshPointMapPtr_;
446 }
447 
448 
449 template
450 <
451  class Face,
452  template<class> class FaceList,
453  class PointField,
454  class PointType
455 >
458 localPoints() const
459 {
460  if (!localPointsPtr_)
461  {
462  calcLocalPoints();
463  }
464 
465  return *localPointsPtr_;
466 }
467 
468 
469 template
470 <
471  class Face,
472  template<class> class FaceList,
473  class PointField,
474  class PointType
475 >
476 const Foam::labelList&
479 {
480  if (!localPointOrderPtr_)
481  {
482  calcLocalPointOrder();
483  }
484 
485  return *localPointOrderPtr_;
486 }
487 
488 
489 template
490 <
491  class Face,
492  template<class> class FaceList,
493  class PointField,
494  class PointType
495 >
499 (
500  const label gp
501 ) const
502 {
503  // The point found, or -1 if not found
504  return meshPointMap().lookup(gp, -1);
505 }
506 
507 
508 template
509 <
510  class Face,
511  template<class> class FaceList,
512  class PointField,
513  class PointType
514 >
517 faceCentres() const
518 {
519  if (!faceCentresPtr_)
520  {
521  calcFaceCentres();
522  }
523 
524  return *faceCentresPtr_;
525 }
526 
527 
528 template
529 <
530  class Face,
531  template<class> class FaceList,
532  class PointField,
533  class PointType
534 >
537 faceAreas() const
538 {
539  if (!faceAreasPtr_)
540  {
541  calcFaceAreas();
542  }
543 
544  return *faceAreasPtr_;
545 }
546 
547 
548 template
549 <
550  class Face,
551  template<class> class FaceList,
552  class PointField,
553  class PointType
554 >
558 {
559  if (!magFaceAreasPtr_)
560  {
561  calcMagFaceAreas();
562  }
563 
564  return *magFaceAreasPtr_;
565 }
566 
567 
568 template
569 <
570  class Face,
571  template<class> class FaceList,
572  class PointField,
573  class PointType
574 >
577 faceNormals() const
578 {
579  if (!faceNormalsPtr_)
580  {
581  calcFaceNormals();
582  }
583 
584  return *faceNormalsPtr_;
585 }
586 
587 
588 template
589 <
590  class Face,
591  template<class> class FaceList,
592  class PointField,
593  class PointType
594 >
598 {
599  if (!pointNormalsPtr_)
600  {
601  calcPointNormals();
602  }
603 
604  return *pointNormalsPtr_;
605 }
606 
607 
608 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
609 
610 template
611 <
612  class Face,
613  template<class> class FaceList,
614  class PointField,
615  class PointType
616 >
617 void
619 operator=
620 (
622 )
623 {
624  clearOut();
625 
626  FaceList<Face>::shallowCopy(pp);
627 }
628 
629 
630 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 
633 #include "PrimitivePatchEdgeLoops.C"
634 #include "PrimitivePatchClear.C"
637 #include "PrimitivePatchMeshData.C"
638 #include "PrimitivePatchMeshEdges.C"
641 #include "PrimitivePatchCheck.C"
642 
643 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::PrimitivePatch::pointFaces
const labelListList & pointFaces() const
Return point-face addressing.
Definition: PrimitivePatch.C:378
Foam::PrimitivePatch::whichPoint
label whichPoint(const label gp) const
Given a global point index, return the local point index.
Definition: PrimitivePatch.C:499
Foam::PrimitivePatch::edgeFaces
const labelListList & edgeFaces() const
Return edge-face addressing.
Definition: PrimitivePatch.C:318
Foam::PrimitivePatch::edges
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Definition: PrimitivePatch.C:238
Foam::PrimitivePatch::PrimitivePatch
PrimitivePatch(const FaceList< Face > &faces, const Field< PointType > &points)
Construct from components.
Definition: PrimitivePatch.C:41
Foam::PrimitivePatch::localPoints
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatch.C:458
Foam::PrimitivePatch::~PrimitivePatch
virtual ~PrimitivePatch()
Destructor.
Definition: PrimitivePatch.C:195
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: HashTableFwd.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::PrimitivePatch::faceEdges
const labelListList & faceEdges() const
Return face-edge addressing.
Definition: PrimitivePatch.C:338
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
PrimitivePatchCheck.C
Checks topology of the patch.
Foam::PrimitivePatch::faceAreas
const Field< PointType > & faceAreas() const
Return face area vectors for patch.
Definition: PrimitivePatch.C:537
Map.H
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::Field< PointType >
Foam::PrimitivePatch::pointEdges
const labelListList & pointEdges() const
Return point-edge addressing.
Definition: PrimitivePatch.C:358
PrimitivePatchClear.C
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatch.C:213
PrimitivePatchEdgeLoops.C
Create the list of loops of outside vertices. Goes wrong on multiply connected edges (loops will be u...
PrimitivePatchPointAddressing.C
Point addressing on the patch: pointEdges and pointFaces.
Foam::PrimitivePatch::boundaryPoints
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
Definition: PrimitivePatch.C:278
PrimitivePatchAddressing.C
This function calculates the list of patch edges, defined on the list of points supporting the patch....
Foam::PrimitivePatch::nInternalEdges
label nInternalEdges() const
Number of internal edges.
Definition: PrimitivePatch.C:258
Foam::PrimitivePatch::pointNormals
const Field< PointType > & pointNormals() const
Return point normals for patch.
Definition: PrimitivePatch.C:597
Foam::PrimitivePatch::faceNormals
const Field< PointType > & faceNormals() const
Return face unit normals for patch.
Definition: PrimitivePatch.C:577
PrimitivePatchProjectPoints.C
For every point on the patch find the closest face on the target side. Return a target face label for...
PrimitivePatchMeshEdges.C
Foam::List< edge >
Foam::PrimitivePatch::faceCentres
const Field< PointType > & faceCentres() const
Return face centres for patch.
Definition: PrimitivePatch.C:517
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::PrimitivePatch::localPointOrder
const labelList & localPointOrder() const
Return orders the local points for most efficient search.
Definition: PrimitivePatch.C:478
PrimitivePatchLocalPointOrder.C
Orders the local points on the patch for most efficient search.
Foam::PrimitivePatch::magFaceAreas
const Field< scalar > & magFaceAreas() const
Return face area magnitudes for patch.
Definition: PrimitivePatch.C:557
Foam::PrimitivePatch::localFaces
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatch.C:398
Foam::PrimitivePatch::meshPointMap
const Map< label > & meshPointMap() const
Mesh point map.
Definition: PrimitivePatch.C:438
Foam::PrimitivePatch::faceFaces
const labelListList & faceFaces() const
Return face-face addressing.
Definition: PrimitivePatch.C:298
PrimitivePatchMeshData.C
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:418
PrimitivePatchBdryPoints.C
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90