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-2020 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<class FaceList, class PointField>
32 (
33  const FaceList& faces,
34  const Field<PointType>& points
35 )
36 :
37  FaceList(faces),
38  points_(points),
39  edgesPtr_(nullptr),
40  nInternalEdges_(-1),
41  boundaryPointsPtr_(nullptr),
42  faceFacesPtr_(nullptr),
43  edgeFacesPtr_(nullptr),
44  faceEdgesPtr_(nullptr),
45  pointEdgesPtr_(nullptr),
46  pointFacesPtr_(nullptr),
47  localFacesPtr_(nullptr),
48  meshPointsPtr_(nullptr),
49  meshPointMapPtr_(nullptr),
50  edgeLoopsPtr_(nullptr),
51  localPointsPtr_(nullptr),
52  localPointOrderPtr_(nullptr),
53  faceCentresPtr_(nullptr),
54  faceAreasPtr_(nullptr),
55  faceNormalsPtr_(nullptr),
56  pointNormalsPtr_(nullptr)
57 {}
58 
59 
60 template<class FaceList, class PointField>
62 (
63  FaceList&& faces,
64  Field<PointType>&& points
65 )
66 :
67  FaceList(move(faces)),
68  points_(move(points)),
69  edgesPtr_(nullptr),
70  nInternalEdges_(-1),
71  boundaryPointsPtr_(nullptr),
72  faceFacesPtr_(nullptr),
73  edgeFacesPtr_(nullptr),
74  faceEdgesPtr_(nullptr),
75  pointEdgesPtr_(nullptr),
76  pointFacesPtr_(nullptr),
77  localFacesPtr_(nullptr),
78  meshPointsPtr_(nullptr),
79  meshPointMapPtr_(nullptr),
80  edgeLoopsPtr_(nullptr),
81  localPointsPtr_(nullptr),
82  localPointOrderPtr_(nullptr),
83  faceCentresPtr_(nullptr),
84  faceAreasPtr_(nullptr),
85  faceNormalsPtr_(nullptr),
86  pointNormalsPtr_(nullptr)
87 {}
88 
89 
90 template<class FaceList, class PointField>
92 (
93  FaceList&& faces,
94  List<PointType>&& points
95 )
96 :
97  FaceList(move(faces)),
98  points_(move(points)),
99  edgesPtr_(nullptr),
100  nInternalEdges_(-1),
101  boundaryPointsPtr_(nullptr),
102  faceFacesPtr_(nullptr),
103  edgeFacesPtr_(nullptr),
104  faceEdgesPtr_(nullptr),
105  pointEdgesPtr_(nullptr),
106  pointFacesPtr_(nullptr),
107  localFacesPtr_(nullptr),
108  meshPointsPtr_(nullptr),
109  meshPointMapPtr_(nullptr),
110  edgeLoopsPtr_(nullptr),
111  localPointsPtr_(nullptr),
112  localPointOrderPtr_(nullptr),
113  faceCentresPtr_(nullptr),
114  faceAreasPtr_(nullptr),
115  faceNormalsPtr_(nullptr),
116  pointNormalsPtr_(nullptr)
117 {}
118 
119 
120 template<class FaceList, class PointField>
122 (
123  FaceList& faces,
124  Field<PointType>& points,
125  const bool reuse
126 )
127 :
128  FaceList(faces, reuse),
129  points_(points, reuse),
130  edgesPtr_(nullptr),
131  nInternalEdges_(-1),
132  boundaryPointsPtr_(nullptr),
133  faceFacesPtr_(nullptr),
134  edgeFacesPtr_(nullptr),
135  faceEdgesPtr_(nullptr),
136  pointEdgesPtr_(nullptr),
137  pointFacesPtr_(nullptr),
138  localFacesPtr_(nullptr),
139  meshPointsPtr_(nullptr),
140  meshPointMapPtr_(nullptr),
141  edgeLoopsPtr_(nullptr),
142  localPointsPtr_(nullptr),
143  localPointOrderPtr_(nullptr),
144  faceCentresPtr_(nullptr),
145  faceAreasPtr_(nullptr),
146  faceNormalsPtr_(nullptr),
147  pointNormalsPtr_(nullptr)
148 {}
149 
150 
151 template<class FaceList, class PointField>
153 (
155 )
156 :
157  PrimitivePatchName(),
158  FaceList(pp),
159  points_(pp.points_),
160  edgesPtr_(nullptr),
161  nInternalEdges_(-1),
162  boundaryPointsPtr_(nullptr),
163  faceFacesPtr_(nullptr),
164  edgeFacesPtr_(nullptr),
165  faceEdgesPtr_(nullptr),
166  pointEdgesPtr_(nullptr),
167  pointFacesPtr_(nullptr),
168  localFacesPtr_(nullptr),
169  meshPointsPtr_(nullptr),
170  meshPointMapPtr_(nullptr),
171  edgeLoopsPtr_(nullptr),
172  localPointsPtr_(nullptr),
173  localPointOrderPtr_(nullptr),
174  faceCentresPtr_(nullptr),
175  faceAreasPtr_(nullptr),
176  faceNormalsPtr_(nullptr),
177  pointNormalsPtr_(nullptr)
178 {}
179 
180 
181 template<class FaceList, class PointField>
183 (
185 )
186 :
187  PrimitivePatchName(),
188  FaceList(move(pp)),
189  points_(move(pp.points_)),
190  edgesPtr_(nullptr),
191  nInternalEdges_(-1),
192  boundaryPointsPtr_(nullptr),
193  faceFacesPtr_(nullptr),
194  edgeFacesPtr_(nullptr),
195  faceEdgesPtr_(nullptr),
196  pointEdgesPtr_(nullptr),
197  pointFacesPtr_(nullptr),
198  localFacesPtr_(nullptr),
199  meshPointsPtr_(nullptr),
200  meshPointMapPtr_(nullptr),
201  edgeLoopsPtr_(nullptr),
202  localPointsPtr_(nullptr),
203  localPointOrderPtr_(nullptr),
204  faceCentresPtr_(nullptr),
205  faceAreasPtr_(nullptr),
206  faceNormalsPtr_(nullptr),
207  pointNormalsPtr_(nullptr)
208 {}
209 
210 
211 template<class FaceList, class PointField>
213 (
214  Istream& is,
215  const Field<PointType>& points
216 )
217 :
218  FaceList(is),
219  points_(points),
220  edgesPtr_(nullptr),
221  nInternalEdges_(-1),
222  boundaryPointsPtr_(nullptr),
223  faceFacesPtr_(nullptr),
224  edgeFacesPtr_(nullptr),
225  faceEdgesPtr_(nullptr),
226  pointEdgesPtr_(nullptr),
227  pointFacesPtr_(nullptr),
228  localFacesPtr_(nullptr),
229  meshPointsPtr_(nullptr),
230  meshPointMapPtr_(nullptr),
231  edgeLoopsPtr_(nullptr),
232  localPointsPtr_(nullptr),
233  localPointOrderPtr_(nullptr),
234  faceCentresPtr_(nullptr),
235  faceAreasPtr_(nullptr),
236  faceNormalsPtr_(nullptr),
237  pointNormalsPtr_(nullptr)
238 {}
239 
240 
241 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
242 
243 template<class FaceList, class PointField>
245 {
246  clearOut();
247 }
248 
249 
250 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
251 
252 template<class FaceList, class PointField>
254 (
255  const Field<PointType>&
256 )
257 {
258  if (debug)
259  {
260  Pout<< "PrimitivePatch<FaceList, PointField>::"
261  << "movePoints() : "
262  << "recalculating PrimitivePatch geometry following mesh motion"
263  << endl;
264  }
265 
266  clearGeom();
267 }
268 
269 
270 template<class FaceList, class PointField>
272 {
273  if (!edgesPtr_)
274  {
275  calcAddressing();
276  }
277 
278  return *edgesPtr_;
279 }
280 
281 
282 template<class FaceList, class PointField>
284 {
285  if (!edgesPtr_)
286  {
287  calcAddressing();
288  }
289 
290  return nInternalEdges_;
291 }
292 
293 
294 template<class FaceList, class PointField>
295 const Foam::labelList&
297 {
298  if (!boundaryPointsPtr_)
299  {
300  calcBdryPoints();
301  }
302 
303  return *boundaryPointsPtr_;
304 }
305 
306 
307 template<class FaceList, class PointField>
308 const Foam::labelListList&
310 faceFaces() const
311 {
312  if (!faceFacesPtr_)
313  {
314  calcAddressing();
315  }
316 
317  return *faceFacesPtr_;
318 }
319 
320 
321 template<class FaceList, class PointField>
322 const Foam::labelListList&
324 {
325  if (!edgeFacesPtr_)
326  {
327  calcAddressing();
328  }
329 
330  return *edgeFacesPtr_;
331 }
332 
333 
334 template<class FaceList, class PointField>
335 const Foam::labelListList&
337 {
338  if (!faceEdgesPtr_)
339  {
340  calcAddressing();
341  }
342 
343  return *faceEdgesPtr_;
344 }
345 
346 
347 template<class FaceList, class PointField>
348 const Foam::labelListList&
350 {
351  if (!pointEdgesPtr_)
352  {
353  calcPointEdges();
354  }
355 
356  return *pointEdgesPtr_;
357 }
358 
359 
360 template<class FaceList, class PointField>
361 const Foam::labelListList&
363 {
364  if (!pointFacesPtr_)
365  {
366  calcPointFaces();
367  }
368 
369  return *pointFacesPtr_;
370 }
371 
372 
373 template<class FaceList, class PointField>
374 const Foam::List
375 <
377 >&
379 {
380  if (!localFacesPtr_)
381  {
382  calcMeshData();
383  }
384 
385  return *localFacesPtr_;
386 }
387 
388 
389 template<class FaceList, class PointField>
390 const Foam::labelList&
392 {
393  if (!meshPointsPtr_)
394  {
395  calcMeshData();
396  }
397 
398  return *meshPointsPtr_;
399 }
400 
401 
402 template<class FaceList, class PointField>
405 {
406  if (!meshPointMapPtr_)
407  {
408  calcMeshPointMap();
409  }
410 
411  return *meshPointMapPtr_;
412 }
413 
414 
415 template<class FaceList, class PointField>
416 const Foam::Field
417 <
419 >&
421 {
422  if (!localPointsPtr_)
423  {
424  calcLocalPoints();
425  }
426 
427  return *localPointsPtr_;
428 }
429 
430 
431 template<class FaceList, class PointField>
432 const Foam::labelList&
434 {
435  if (!localPointOrderPtr_)
436  {
437  calcLocalPointOrder();
438  }
439 
440  return *localPointOrderPtr_;
441 }
442 
443 
444 template<class FaceList, class PointField>
446 (
447  const label gp
448 ) const
449 {
450  Map<label>::const_iterator fnd = meshPointMap().find(gp);
451 
452  if (fnd != meshPointMap().end())
453  {
454  return fnd();
455  }
456  else
457  {
458  // Not found
459  return -1;
460  }
461 }
462 
463 
464 template<class FaceList, class PointField>
465 const Foam::Field
466 <
468 >&
470 {
471  if (!faceCentresPtr_)
472  {
473  calcFaceCentres();
474  }
475 
476  return *faceCentresPtr_;
477 }
478 
479 
480 template<class FaceList, class PointField>
481 const Foam::Field
482 <
484 >&
486 {
487  if (!faceAreasPtr_)
488  {
489  calcFaceAreas();
490  }
491 
492  return *faceAreasPtr_;
493 }
494 
495 
496 template<class FaceList, class PointField>
497 const Foam::Field
498 <
500 >&
502 {
503  if (!faceNormalsPtr_)
504  {
505  calcFaceNormals();
506  }
507 
508  return *faceNormalsPtr_;
509 }
510 
511 
512 template<class FaceList, class PointField>
513 const Foam::Field
514 <
516 >&
518 {
519  if (!pointNormalsPtr_)
520  {
521  calcPointNormals();
522  }
523 
524  return *pointNormalsPtr_;
525 }
526 
527 
528 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
529 
530 template<class FaceList, class PointField>
531 void Foam::PrimitivePatch<FaceList, PointField>::operator=
532 (
534 )
535 {
536  clearOut();
537 
538  FaceList::shallowCopy(pp);
539 }
540 
541 
542 template<class FaceList, class PointField>
543 void Foam::PrimitivePatch<FaceList, PointField>::operator=
544 (
546 )
547 {
548  clearOut();
549 
550  FaceList::operator=(move(pp));
551 
552  // This is only valid if PointField is not a reference
553  // points_ = move(pp.points_);
554 }
555 
556 
557 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
558 
560 #include "PrimitivePatchEdgeLoops.C"
561 #include "PrimitivePatchClear.C"
564 #include "PrimitivePatchMeshData.C"
565 #include "PrimitivePatchMeshEdges.C"
568 #include "PrimitivePatchCheck.C"
569 
570 // ************************************************************************* //
const labelListList & pointEdges() const
Return point-edge addressing.
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 > & faceCentres() const
Return face centres for patch.
PrimitivePatch(const FaceList &faces, const Field< PointType > &points)
Construct from components.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const labelList & boundaryPoints() const
Return list of boundary points,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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.
virtual ~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
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
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