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 | Copyright (C) 2011-2016 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 "Map.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template
31 <
32  class Face,
33  template<class> class FaceList,
34  class PointField,
35  class PointType
36 >
39 (
40  const FaceList<Face>& faces,
41  const Field<PointType>& points
42 )
43 :
44  FaceList<Face>(faces),
45  points_(points),
46  edgesPtr_(nullptr),
47  nInternalEdges_(-1),
48  boundaryPointsPtr_(nullptr),
49  faceFacesPtr_(nullptr),
50  edgeFacesPtr_(nullptr),
51  faceEdgesPtr_(nullptr),
52  pointEdgesPtr_(nullptr),
53  pointFacesPtr_(nullptr),
54  localFacesPtr_(nullptr),
55  meshPointsPtr_(nullptr),
56  meshPointMapPtr_(nullptr),
57  edgeLoopsPtr_(nullptr),
58  localPointsPtr_(nullptr),
59  localPointOrderPtr_(nullptr),
60  faceCentresPtr_(nullptr),
61  faceNormalsPtr_(nullptr),
62  pointNormalsPtr_(nullptr)
63 {}
64 
65 
66 template
67 <
68  class Face,
69  template<class> class FaceList,
70  class PointField,
71  class PointType
72 >
75 (
76  const Xfer<FaceList<Face>>& faces,
77  const Xfer<List<PointType>>& points
78 )
79 :
80  FaceList<Face>(faces),
81  points_(points),
82  edgesPtr_(nullptr),
83  nInternalEdges_(-1),
84  boundaryPointsPtr_(nullptr),
85  faceFacesPtr_(nullptr),
86  edgeFacesPtr_(nullptr),
87  faceEdgesPtr_(nullptr),
88  pointEdgesPtr_(nullptr),
89  pointFacesPtr_(nullptr),
90  localFacesPtr_(nullptr),
91  meshPointsPtr_(nullptr),
92  meshPointMapPtr_(nullptr),
93  edgeLoopsPtr_(nullptr),
94  localPointsPtr_(nullptr),
95  localPointOrderPtr_(nullptr),
96  faceCentresPtr_(nullptr),
97  faceNormalsPtr_(nullptr),
98  pointNormalsPtr_(nullptr)
99 {}
100 
101 
102 template
103 <
104  class Face,
105  template<class> class FaceList,
106  class PointField,
107  class PointType
108 >
111 (
112  FaceList<Face>& faces,
113  Field<PointType>& points,
114  const bool reuse
115 )
116 :
117  FaceList<Face>(faces, reuse),
118  points_(points, reuse),
119  edgesPtr_(nullptr),
120  nInternalEdges_(-1),
121  boundaryPointsPtr_(nullptr),
122  faceFacesPtr_(nullptr),
123  edgeFacesPtr_(nullptr),
124  faceEdgesPtr_(nullptr),
125  pointEdgesPtr_(nullptr),
126  pointFacesPtr_(nullptr),
127  localFacesPtr_(nullptr),
128  meshPointsPtr_(nullptr),
129  meshPointMapPtr_(nullptr),
130  edgeLoopsPtr_(nullptr),
131  localPointsPtr_(nullptr),
132  localPointOrderPtr_(nullptr),
133  faceCentresPtr_(nullptr),
134  faceNormalsPtr_(nullptr),
135  pointNormalsPtr_(nullptr)
136 {}
137 
138 
139 template
140 <
141  class Face,
142  template<class> class FaceList,
143  class PointField,
144  class PointType
145 >
148 (
150 )
151 :
152  PrimitivePatchName(),
153  FaceList<Face>(pp),
154  points_(pp.points_),
155  edgesPtr_(nullptr),
156  nInternalEdges_(-1),
157  boundaryPointsPtr_(nullptr),
158  faceFacesPtr_(nullptr),
159  edgeFacesPtr_(nullptr),
160  faceEdgesPtr_(nullptr),
161  pointEdgesPtr_(nullptr),
162  pointFacesPtr_(nullptr),
163  localFacesPtr_(nullptr),
164  meshPointsPtr_(nullptr),
165  meshPointMapPtr_(nullptr),
166  edgeLoopsPtr_(nullptr),
167  localPointsPtr_(nullptr),
168  localPointOrderPtr_(nullptr),
169  faceCentresPtr_(nullptr),
170  faceNormalsPtr_(nullptr),
171  pointNormalsPtr_(nullptr)
172 {}
173 
174 
175 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
176 
177 template
178 <
179  class Face,
180  template<class> class FaceList,
181  class PointField,
182  class PointType
183 >
186 {
187  clearOut();
188 }
189 
190 
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
192 
193 template
194 <
195  class Face,
196  template<class> class FaceList,
197  class PointField,
198  class PointType
199 >
200 void
203 (
204  const Field<PointType>&
205 )
206 {
207  if (debug)
208  {
209  Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
210  << "movePoints() : "
211  << "recalculating PrimitivePatch geometry following mesh motion"
212  << endl;
213  }
214 
215  clearGeom();
216 }
217 
218 
219 template
220 <
221  class Face,
222  template<class> class FaceList,
223  class PointField,
224  class PointType
225 >
226 const Foam::edgeList&
228 edges() const
229 {
230  if (!edgesPtr_)
231  {
232  calcAddressing();
233  }
234 
235  return *edgesPtr_;
236 }
237 
238 
239 template
240 <
241  class Face,
242  template<class> class FaceList,
243  class PointField,
244  class PointType
245 >
249 {
250  if (!edgesPtr_)
251  {
252  calcAddressing();
253  }
254 
255  return nInternalEdges_;
256 }
257 
258 
259 template
260 <
261  class Face,
262  template<class> class FaceList,
263  class PointField,
264  class PointType
265 >
266 const Foam::labelList&
269 {
270  if (!boundaryPointsPtr_)
271  {
272  calcBdryPoints();
273  }
274 
275  return *boundaryPointsPtr_;
276 }
277 
278 
279 template
280 <
281  class Face,
282  template<class> class FaceList,
283  class PointField,
284  class PointType
285 >
286 const Foam::labelListList&
288 faceFaces() const
289 {
290  if (!faceFacesPtr_)
291  {
292  calcAddressing();
293  }
294 
295  return *faceFacesPtr_;
296 }
297 
298 
299 template
300 <
301  class Face,
302  template<class> class FaceList,
303  class PointField,
304  class PointType
305 >
306 const Foam::labelListList&
308 edgeFaces() const
309 {
310  if (!edgeFacesPtr_)
311  {
312  calcAddressing();
313  }
314 
315  return *edgeFacesPtr_;
316 }
317 
318 
319 template
320 <
321  class Face,
322  template<class> class FaceList,
323  class PointField,
324  class PointType
325 >
326 const Foam::labelListList&
328 faceEdges() const
329 {
330  if (!faceEdgesPtr_)
331  {
332  calcAddressing();
333  }
334 
335  return *faceEdgesPtr_;
336 }
337 
338 
339 template
340 <
341  class Face,
342  template<class> class FaceList,
343  class PointField,
344  class PointType
345 >
346 const Foam::labelListList&
348 pointEdges() const
349 {
350  if (!pointEdgesPtr_)
351  {
352  calcPointEdges();
353  }
354 
355  return *pointEdgesPtr_;
356 }
357 
358 
359 template
360 <
361  class Face,
362  template<class> class FaceList,
363  class PointField,
364  class PointType
365 >
366 const Foam::labelListList&
368 pointFaces() const
369 {
370  if (!pointFacesPtr_)
371  {
372  calcPointFaces();
373  }
374 
375  return *pointFacesPtr_;
376 }
377 
378 
379 template
380 <
381  class Face,
382  template<class> class FaceList,
383  class PointField,
384  class PointType
385 >
386 const Foam::List<Face>&
388 localFaces() const
389 {
390  if (!localFacesPtr_)
391  {
392  calcMeshData();
393  }
394 
395  return *localFacesPtr_;
396 }
397 
398 
399 template
400 <
401  class Face,
402  template<class> class FaceList,
403  class PointField,
404  class PointType
405 >
406 const Foam::labelList&
408 meshPoints() const
409 {
410  if (!meshPointsPtr_)
411  {
412  calcMeshData();
413  }
414 
415  return *meshPointsPtr_;
416 }
417 
418 
419 template
420 <
421  class Face,
422  template<class> class FaceList,
423  class PointField,
424  class PointType
425 >
429 {
430  if (!meshPointMapPtr_)
431  {
432  calcMeshPointMap();
433  }
434 
435  return *meshPointMapPtr_;
436 }
437 
438 
439 template
440 <
441  class Face,
442  template<class> class FaceList,
443  class PointField,
444  class PointType
445 >
448 localPoints() const
449 {
450  if (!localPointsPtr_)
451  {
452  calcLocalPoints();
453  }
454 
455  return *localPointsPtr_;
456 }
457 
458 
459 template
460 <
461  class Face,
462  template<class> class FaceList,
463  class PointField,
464  class PointType
465 >
466 const Foam::labelList&
469 {
470  if (!localPointOrderPtr_)
471  {
472  calcLocalPointOrder();
473  }
474 
475  return *localPointOrderPtr_;
476 }
477 
478 
479 template
480 <
481  class Face,
482  template<class> class FaceList,
483  class PointField,
484  class PointType
485 >
489 (
490  const label gp
491 ) const
492 {
493  Map<label>::const_iterator fnd = meshPointMap().find(gp);
494 
495  if (fnd != meshPointMap().end())
496  {
497  return fnd();
498  }
499  else
500  {
501  // Not found
502  return -1;
503  }
504 }
505 
506 
507 template
508 <
509  class Face,
510  template<class> class FaceList,
511  class PointField,
512  class PointType
513 >
516 faceCentres() const
517 {
518  if (!faceCentresPtr_)
519  {
520  calcFaceCentres();
521  }
522 
523  return *faceCentresPtr_;
524 }
525 
526 
527 template
528 <
529  class Face,
530  template<class> class FaceList,
531  class PointField,
532  class PointType
533 >
536 faceNormals() const
537 {
538  if (!faceNormalsPtr_)
539  {
540  calcFaceNormals();
541  }
542 
543  return *faceNormalsPtr_;
544 }
545 
546 
547 template
548 <
549  class Face,
550  template<class> class FaceList,
551  class PointField,
552  class PointType
553 >
557 {
558  if (!pointNormalsPtr_)
559  {
560  calcPointNormals();
561  }
562 
563  return *pointNormalsPtr_;
564 }
565 
566 
567 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
568 
569 template
570 <
571  class Face,
572  template<class> class FaceList,
573  class PointField,
574  class PointType
575 >
576 void
578 operator=
579 (
581 )
582 {
583  clearOut();
584 
585  FaceList<Face>::shallowCopy(pp);
586 }
587 
588 
589 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
590 
592 #include "PrimitivePatchEdgeLoops.C"
593 #include "PrimitivePatchClear.C"
596 #include "PrimitivePatchMeshData.C"
597 #include "PrimitivePatchMeshEdges.C"
600 #include "PrimitivePatchCheck.C"
601 
602 // ************************************************************************* //
const labelListList & pointEdges() const
Return point-edge addressing.
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
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:59
const Field< PointType > & pointNormals() const
Return point normals for patch.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
const labelList & boundaryPoints() const
Return list of boundary points,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
label nInternalEdges() const
Number of internal edges.
const Field< PointType > & faceCentres() const
Return face centres for patch.
const Field< PointType > & faceNormals() const
Return face normals 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.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
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...
PrimitivePatch(const FaceList< Face > &faces, const Field< PointType > &points)
Construct from components.
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.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Checks topology of the patch.
virtual ~PrimitivePatch()
Destructor.
Orders the local points on the patch for most efficient search.
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
const labelListList & faceEdges() const
Return face-edge addressing.
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49