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  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 "Map.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class FaceList, class PointField>
35 (
36  const FaceList& faces,
37  const PointField& points
38 )
39 :
40  FaceList(faces),
41  points_(points),
42  edgesPtr_(nullptr),
43  nInternalEdges_(-1),
44  boundaryPointsPtr_(nullptr),
45  faceFacesPtr_(nullptr),
46  edgeFacesPtr_(nullptr),
47  faceEdgesPtr_(nullptr),
48  pointEdgesPtr_(nullptr),
49  pointFacesPtr_(nullptr),
50  localFacesPtr_(nullptr),
51  meshPointsPtr_(nullptr),
52  meshPointMapPtr_(nullptr),
53  edgeLoopsPtr_(nullptr),
54  localPointsPtr_(nullptr),
55  localPointOrderPtr_(nullptr),
56  faceCentresPtr_(nullptr),
57  faceAreasPtr_(nullptr),
58  magFaceAreasPtr_(nullptr),
59  faceNormalsPtr_(nullptr),
60  pointNormalsPtr_(nullptr)
61 {}
62 
63 
64 template<class FaceList, class PointField>
66 (
67  FaceList&& faces,
68  const PointField& points
69 )
70 :
71  FaceList(std::move(faces)),
72  points_(points),
73  edgesPtr_(nullptr),
74  nInternalEdges_(-1),
75  boundaryPointsPtr_(nullptr),
76  faceFacesPtr_(nullptr),
77  edgeFacesPtr_(nullptr),
78  faceEdgesPtr_(nullptr),
79  pointEdgesPtr_(nullptr),
80  pointFacesPtr_(nullptr),
81  localFacesPtr_(nullptr),
82  meshPointsPtr_(nullptr),
83  meshPointMapPtr_(nullptr),
84  edgeLoopsPtr_(nullptr),
85  localPointsPtr_(nullptr),
86  localPointOrderPtr_(nullptr),
87  faceCentresPtr_(nullptr),
88  faceAreasPtr_(nullptr),
89  magFaceAreasPtr_(nullptr),
90  faceNormalsPtr_(nullptr),
91  pointNormalsPtr_(nullptr)
92 {}
93 
94 
95 template<class FaceList, class PointField>
97 (
98  FaceList& faces,
99  PointField& points,
100  const bool reuse
101 )
102 :
103  FaceList(faces, reuse),
104  points_(points, reuse),
105  edgesPtr_(nullptr),
106  nInternalEdges_(-1),
107  boundaryPointsPtr_(nullptr),
108  faceFacesPtr_(nullptr),
109  edgeFacesPtr_(nullptr),
110  faceEdgesPtr_(nullptr),
111  pointEdgesPtr_(nullptr),
112  pointFacesPtr_(nullptr),
113  localFacesPtr_(nullptr),
114  meshPointsPtr_(nullptr),
115  meshPointMapPtr_(nullptr),
116  edgeLoopsPtr_(nullptr),
117  localPointsPtr_(nullptr),
118  localPointOrderPtr_(nullptr),
119  faceCentresPtr_(nullptr),
120  faceAreasPtr_(nullptr),
121  magFaceAreasPtr_(nullptr),
122  faceNormalsPtr_(nullptr),
123  pointNormalsPtr_(nullptr)
124 {}
125 
126 
127 template<class FaceList, class PointField>
129 (
131 )
132 :
133  PrimitivePatchName(),
134  FaceList(pp),
135  points_(pp.points_),
136  edgesPtr_(nullptr),
137  nInternalEdges_(-1),
138  boundaryPointsPtr_(nullptr),
139  faceFacesPtr_(nullptr),
140  edgeFacesPtr_(nullptr),
141  faceEdgesPtr_(nullptr),
142  pointEdgesPtr_(nullptr),
143  pointFacesPtr_(nullptr),
144  localFacesPtr_(nullptr),
145  meshPointsPtr_(nullptr),
146  meshPointMapPtr_(nullptr),
147  edgeLoopsPtr_(nullptr),
148  localPointsPtr_(nullptr),
149  localPointOrderPtr_(nullptr),
150  faceCentresPtr_(nullptr),
151  faceAreasPtr_(nullptr),
152  magFaceAreasPtr_(nullptr),
153  faceNormalsPtr_(nullptr),
154  pointNormalsPtr_(nullptr)
155 {}
156 
157 
158 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
159 
160 template<class FaceList, class PointField>
162 {
163  clearOut();
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
168 
169 template<class FaceList, class PointField>
170 void
172 (
173  const Field<point_type>&
174 )
175 {
176  if (debug)
177  {
178  Pout<< "PrimitivePatch<FaceList, PointField>::"
179  << "movePoints() : "
180  << "recalculating PrimitivePatch geometry following mesh motion"
181  << endl;
182  }
183 
184  clearGeom();
185 }
186 
187 
188 template<class FaceList, class PointField>
189 const Foam::edgeList&
191 {
192  if (!edgesPtr_)
193  {
194  calcAddressing();
195  }
196 
197  return *edgesPtr_;
198 }
199 
200 
201 template<class FaceList, class PointField>
202 Foam::label
204 {
205  if (!edgesPtr_)
206  {
207  calcAddressing();
208  }
209 
210  return nInternalEdges_;
211 }
212 
213 
214 template<class FaceList, class PointField>
215 const Foam::labelList&
217 {
218  if (!boundaryPointsPtr_)
219  {
220  calcBdryPoints();
221  }
222 
223  return *boundaryPointsPtr_;
224 }
225 
226 
227 template<class FaceList, class PointField>
228 const Foam::labelListList&
230 {
231  if (!faceFacesPtr_)
232  {
233  calcAddressing();
234  }
235 
236  return *faceFacesPtr_;
237 }
238 
239 
240 template<class FaceList, class PointField>
241 const Foam::labelListList&
243 {
244  if (!edgeFacesPtr_)
245  {
246  calcAddressing();
247  }
248 
249  return *edgeFacesPtr_;
250 }
251 
252 
253 template<class FaceList, class PointField>
254 const Foam::labelListList&
256 {
257  if (!faceEdgesPtr_)
258  {
259  calcAddressing();
260  }
261 
262  return *faceEdgesPtr_;
263 }
264 
265 
266 template<class FaceList, class PointField>
267 const Foam::labelListList&
269 {
270  if (!pointEdgesPtr_)
271  {
272  calcPointEdges();
273  }
274 
275  return *pointEdgesPtr_;
276 }
277 
278 
279 template<class FaceList, class PointField>
280 const Foam::labelListList&
282 {
283  if (!pointFacesPtr_)
284  {
285  calcPointFaces();
286  }
287 
288  return *pointFacesPtr_;
289 }
290 
291 
292 template<class FaceList, class PointField>
293 const Foam::List
294 <
296 >&
298 {
299  if (!localFacesPtr_)
300  {
301  calcMeshData();
302  }
303 
304  return *localFacesPtr_;
305 }
306 
307 
308 template<class FaceList, class PointField>
309 const Foam::labelList&
311 {
312  if (!meshPointsPtr_)
313  {
314  calcMeshData();
315  }
316 
317  return *meshPointsPtr_;
318 }
319 
320 
321 template<class FaceList, class PointField>
324 {
325  if (!meshPointMapPtr_)
326  {
327  calcMeshPointMap();
328  }
329 
330  return *meshPointMapPtr_;
331 }
332 
333 
334 template<class FaceList, class PointField>
335 const Foam::Field
336 <
338 >&
340 {
341  if (!localPointsPtr_)
342  {
343  calcLocalPoints();
344  }
345 
346  return *localPointsPtr_;
347 }
348 
349 
350 template<class FaceList, class PointField>
351 const Foam::labelList&
353 {
354  if (!localPointOrderPtr_)
355  {
356  calcLocalPointOrder();
357  }
358 
359  return *localPointOrderPtr_;
360 }
361 
362 
363 template<class FaceList, class PointField>
364 Foam::label
366 (
367  const label gp
368 ) const
369 {
370  // The point found, or -1 if not found
371  return meshPointMap().lookup(gp, -1);
372 }
373 
374 
375 template<class FaceList, class PointField>
376 const Foam::Field
377 <
379 >&
381 {
382  if (!faceCentresPtr_)
383  {
384  calcFaceCentres();
385  }
386 
387  return *faceCentresPtr_;
388 }
389 
390 
391 template<class FaceList, class PointField>
392 const Foam::Field
393 <
395 >&
397 {
398  if (!faceAreasPtr_)
399  {
400  calcFaceAreas();
401  }
402 
403  return *faceAreasPtr_;
404 }
405 
406 
407 template<class FaceList, class PointField>
410 {
411  if (!magFaceAreasPtr_)
412  {
413  calcMagFaceAreas();
414  }
415 
416  return *magFaceAreasPtr_;
417 }
418 
419 
420 template<class FaceList, class PointField>
421 const Foam::Field
422 <
424 >&
426 {
427  if (!faceNormalsPtr_)
428  {
429  calcFaceNormals();
430  }
431 
432  return *faceNormalsPtr_;
433 }
434 
435 
436 template<class FaceList, class PointField>
437 const Foam::Field
438 <
440 >&
442 {
443  if (!pointNormalsPtr_)
444  {
445  calcPointNormals();
446  }
447 
448  return *pointNormalsPtr_;
449 }
450 
451 
452 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
453 
454 template<class FaceList, class PointField>
455 void
457 (
459 )
460 {
461  if (&rhs == this)
462  {
463  return;
464  }
465 
466  clearOut();
467 
468  FaceList::shallowCopy(rhs);
469 
470  // Cannot copy assign points (could be const reference)
471 }
472 
473 
474 template<class FaceList, class PointField>
475 void
477 (
479 )
480 {
481  if (&rhs == this)
482  {
483  return;
484  }
485 
486  clearOut();
487 
488  FaceList::operator=(std::move(rhs));
489 
490  // Cannot move assign points (could be const reference)
491 }
492 
493 
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 
497 #include "PrimitivePatchEdgeLoops.C"
498 #include "PrimitivePatchClear.C"
501 #include "PrimitivePatchMeshData.C"
502 #include "PrimitivePatchMeshEdges.C"
505 #include "PrimitivePatchCheck.C"
506 
507 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::PrimitivePatch::pointFaces
const labelListList & pointFaces() const
Return point-face addressing.
Definition: PrimitivePatch.C:281
Foam::PrimitivePatch::whichPoint
label whichPoint(const label gp) const
Given a global point index, return the local point index.
Definition: PrimitivePatch.C:366
Foam::PrimitivePatch::edgeFaces
const labelListList & edgeFaces() const
Return edge-face addressing.
Definition: PrimitivePatch.C:242
Foam::PrimitivePatch::edges
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Definition: PrimitivePatch.C:190
Foam::PrimitivePatch::pointNormals
const Field< point_type > & pointNormals() const
Return point normals for patch.
Definition: PrimitivePatch.C:441
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::PrimitivePatch::faceEdges
const labelListList & faceEdges() const
Return face-edge addressing.
Definition: PrimitivePatch.C:255
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
PrimitivePatchCheck.C
Checks topology of the patch.
Map.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::PrimitivePatch::faceAreas
const Field< point_type > & faceAreas() const
Return face area vectors for patch.
Definition: PrimitivePatch.C:396
Foam::PrimitivePatch::point_type
std::remove_reference< PointField >::type::value_type point_type
The point type.
Definition: PrimitivePatch.H:100
Foam::PrimitivePatch::pointEdges
const labelListList & pointEdges() const
Return point-edge addressing.
Definition: PrimitivePatch.C:268
PrimitivePatchClear.C
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::localFaces
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatch.C:297
Foam::PrimitivePatch::localPoints
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatch.C:339
Foam::PrimitivePatch::boundaryPoints
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
Definition: PrimitivePatch.C:216
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:203
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 >
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:352
PrimitivePatchLocalPointOrder.C
Orders the local points on the patch for most efficient search.
Foam::PrimitivePatch::faceNormals
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
Definition: PrimitivePatch.C:425
Foam::PrimitivePatch::magFaceAreas
const Field< scalar > & magFaceAreas() const
Return face area magnitudes for patch.
Definition: PrimitivePatch.C:409
Foam::PrimitivePatch::face_type
std::remove_reference< FaceList >::type::value_type face_type
The face type.
Definition: PrimitivePatch.H:96
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< point_type > &)
Correct patch after moving points.
Definition: PrimitivePatch.C:172
Foam::PrimitivePatch::meshPointMap
const Map< label > & meshPointMap() const
Mesh point map.
Definition: PrimitivePatch.C:323
Foam::PrimitivePatch::faceFaces
const labelListList & faceFaces() const
Return face-face addressing.
Definition: PrimitivePatch.C:229
PrimitivePatchMeshData.C
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:310
PrimitivePatchBdryPoints.C
Foam::PrimitivePatch::faceCentres
const Field< point_type > & faceCentres() const
Return face centres for patch.
Definition: PrimitivePatch.C:380
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85
Foam::PrimitivePatch::PrimitivePatch
PrimitivePatch(const FaceList &faces, const PointField &points)
Construct from components.
Definition: PrimitivePatch.C:35