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-2019 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  faceNormalsPtr_(nullptr),
55  pointNormalsPtr_(nullptr)
56 {}
57 
58 
59 template<class FaceList, class PointField>
61 (
62  FaceList&& faces,
63  Field<PointType>&& points
64 )
65 :
66  FaceList(move(faces)),
67  points_(move(points)),
68  edgesPtr_(nullptr),
69  nInternalEdges_(-1),
70  boundaryPointsPtr_(nullptr),
71  faceFacesPtr_(nullptr),
72  edgeFacesPtr_(nullptr),
73  faceEdgesPtr_(nullptr),
74  pointEdgesPtr_(nullptr),
75  pointFacesPtr_(nullptr),
76  localFacesPtr_(nullptr),
77  meshPointsPtr_(nullptr),
78  meshPointMapPtr_(nullptr),
79  edgeLoopsPtr_(nullptr),
80  localPointsPtr_(nullptr),
81  localPointOrderPtr_(nullptr),
82  faceCentresPtr_(nullptr),
83  faceNormalsPtr_(nullptr),
84  pointNormalsPtr_(nullptr)
85 {}
86 
87 
88 template<class FaceList, class PointField>
90 (
91  FaceList&& faces,
92  List<PointType>&& points
93 )
94 :
95  FaceList(move(faces)),
96  points_(move(points)),
97  edgesPtr_(nullptr),
98  nInternalEdges_(-1),
99  boundaryPointsPtr_(nullptr),
100  faceFacesPtr_(nullptr),
101  edgeFacesPtr_(nullptr),
102  faceEdgesPtr_(nullptr),
103  pointEdgesPtr_(nullptr),
104  pointFacesPtr_(nullptr),
105  localFacesPtr_(nullptr),
106  meshPointsPtr_(nullptr),
107  meshPointMapPtr_(nullptr),
108  edgeLoopsPtr_(nullptr),
109  localPointsPtr_(nullptr),
110  localPointOrderPtr_(nullptr),
111  faceCentresPtr_(nullptr),
112  faceNormalsPtr_(nullptr),
113  pointNormalsPtr_(nullptr)
114 {}
115 
116 
117 template<class FaceList, class PointField>
119 (
120  FaceList& faces,
121  Field<PointType>& points,
122  const bool reuse
123 )
124 :
125  FaceList(faces, reuse),
126  points_(points, reuse),
127  edgesPtr_(nullptr),
128  nInternalEdges_(-1),
129  boundaryPointsPtr_(nullptr),
130  faceFacesPtr_(nullptr),
131  edgeFacesPtr_(nullptr),
132  faceEdgesPtr_(nullptr),
133  pointEdgesPtr_(nullptr),
134  pointFacesPtr_(nullptr),
135  localFacesPtr_(nullptr),
136  meshPointsPtr_(nullptr),
137  meshPointMapPtr_(nullptr),
138  edgeLoopsPtr_(nullptr),
139  localPointsPtr_(nullptr),
140  localPointOrderPtr_(nullptr),
141  faceCentresPtr_(nullptr),
142  faceNormalsPtr_(nullptr),
143  pointNormalsPtr_(nullptr)
144 {}
145 
146 
147 template<class FaceList, class PointField>
149 (
151 )
152 :
153  PrimitivePatchName(),
154  FaceList(pp),
155  points_(pp.points_),
156  edgesPtr_(nullptr),
157  nInternalEdges_(-1),
158  boundaryPointsPtr_(nullptr),
159  faceFacesPtr_(nullptr),
160  edgeFacesPtr_(nullptr),
161  faceEdgesPtr_(nullptr),
162  pointEdgesPtr_(nullptr),
163  pointFacesPtr_(nullptr),
164  localFacesPtr_(nullptr),
165  meshPointsPtr_(nullptr),
166  meshPointMapPtr_(nullptr),
167  edgeLoopsPtr_(nullptr),
168  localPointsPtr_(nullptr),
169  localPointOrderPtr_(nullptr),
170  faceCentresPtr_(nullptr),
171  faceNormalsPtr_(nullptr),
172  pointNormalsPtr_(nullptr)
173 {}
174 
175 
176 template<class FaceList, class PointField>
178 (
180 )
181 :
182  PrimitivePatchName(),
183  FaceList(move(pp)),
184  points_(move(pp.points_)),
185  edgesPtr_(nullptr),
186  nInternalEdges_(-1),
187  boundaryPointsPtr_(nullptr),
188  faceFacesPtr_(nullptr),
189  edgeFacesPtr_(nullptr),
190  faceEdgesPtr_(nullptr),
191  pointEdgesPtr_(nullptr),
192  pointFacesPtr_(nullptr),
193  localFacesPtr_(nullptr),
194  meshPointsPtr_(nullptr),
195  meshPointMapPtr_(nullptr),
196  edgeLoopsPtr_(nullptr),
197  localPointsPtr_(nullptr),
198  localPointOrderPtr_(nullptr),
199  faceCentresPtr_(nullptr),
200  faceNormalsPtr_(nullptr),
201  pointNormalsPtr_(nullptr)
202 {}
203 
204 
205 template<class FaceList, class PointField>
207 (
208  Istream& is,
209  const Field<PointType>& points
210 )
211 :
212  FaceList(is),
213  points_(points),
214  edgesPtr_(nullptr),
215  nInternalEdges_(-1),
216  boundaryPointsPtr_(nullptr),
217  faceFacesPtr_(nullptr),
218  edgeFacesPtr_(nullptr),
219  faceEdgesPtr_(nullptr),
220  pointEdgesPtr_(nullptr),
221  pointFacesPtr_(nullptr),
222  localFacesPtr_(nullptr),
223  meshPointsPtr_(nullptr),
224  meshPointMapPtr_(nullptr),
225  edgeLoopsPtr_(nullptr),
226  localPointsPtr_(nullptr),
227  localPointOrderPtr_(nullptr),
228  faceCentresPtr_(nullptr),
229  faceNormalsPtr_(nullptr),
230  pointNormalsPtr_(nullptr)
231 {}
232 
233 
234 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
235 
236 template<class FaceList, class PointField>
238 {
239  clearOut();
240 }
241 
242 
243 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
244 
245 template<class FaceList, class PointField>
247 (
248  const Field<PointType>&
249 )
250 {
251  if (debug)
252  {
253  Pout<< "PrimitivePatch<FaceList, PointField>::"
254  << "movePoints() : "
255  << "recalculating PrimitivePatch geometry following mesh motion"
256  << endl;
257  }
258 
259  clearGeom();
260 }
261 
262 
263 template<class FaceList, class PointField>
265 {
266  if (!edgesPtr_)
267  {
268  calcAddressing();
269  }
270 
271  return *edgesPtr_;
272 }
273 
274 
275 template<class FaceList, class PointField>
277 {
278  if (!edgesPtr_)
279  {
280  calcAddressing();
281  }
282 
283  return nInternalEdges_;
284 }
285 
286 
287 template<class FaceList, class PointField>
288 const Foam::labelList&
290 {
291  if (!boundaryPointsPtr_)
292  {
293  calcBdryPoints();
294  }
295 
296  return *boundaryPointsPtr_;
297 }
298 
299 
300 template<class FaceList, class PointField>
301 const Foam::labelListList&
303 faceFaces() const
304 {
305  if (!faceFacesPtr_)
306  {
307  calcAddressing();
308  }
309 
310  return *faceFacesPtr_;
311 }
312 
313 
314 template<class FaceList, class PointField>
315 const Foam::labelListList&
317 {
318  if (!edgeFacesPtr_)
319  {
320  calcAddressing();
321  }
322 
323  return *edgeFacesPtr_;
324 }
325 
326 
327 template<class FaceList, class PointField>
328 const Foam::labelListList&
330 {
331  if (!faceEdgesPtr_)
332  {
333  calcAddressing();
334  }
335 
336  return *faceEdgesPtr_;
337 }
338 
339 
340 template<class FaceList, class PointField>
341 const Foam::labelListList&
343 {
344  if (!pointEdgesPtr_)
345  {
346  calcPointEdges();
347  }
348 
349  return *pointEdgesPtr_;
350 }
351 
352 
353 template<class FaceList, class PointField>
354 const Foam::labelListList&
356 {
357  if (!pointFacesPtr_)
358  {
359  calcPointFaces();
360  }
361 
362  return *pointFacesPtr_;
363 }
364 
365 
366 template<class FaceList, class PointField>
367 const Foam::List
368 <
370 >&
372 {
373  if (!localFacesPtr_)
374  {
375  calcMeshData();
376  }
377 
378  return *localFacesPtr_;
379 }
380 
381 
382 template<class FaceList, class PointField>
383 const Foam::labelList&
385 {
386  if (!meshPointsPtr_)
387  {
388  calcMeshData();
389  }
390 
391  return *meshPointsPtr_;
392 }
393 
394 
395 template<class FaceList, class PointField>
398 {
399  if (!meshPointMapPtr_)
400  {
401  calcMeshPointMap();
402  }
403 
404  return *meshPointMapPtr_;
405 }
406 
407 
408 template<class FaceList, class PointField>
409 const Foam::Field
410 <
412 >&
414 {
415  if (!localPointsPtr_)
416  {
417  calcLocalPoints();
418  }
419 
420  return *localPointsPtr_;
421 }
422 
423 
424 template<class FaceList, class PointField>
425 const Foam::labelList&
427 {
428  if (!localPointOrderPtr_)
429  {
430  calcLocalPointOrder();
431  }
432 
433  return *localPointOrderPtr_;
434 }
435 
436 
437 template<class FaceList, class PointField>
439 (
440  const label gp
441 ) const
442 {
443  Map<label>::const_iterator fnd = meshPointMap().find(gp);
444 
445  if (fnd != meshPointMap().end())
446  {
447  return fnd();
448  }
449  else
450  {
451  // Not found
452  return -1;
453  }
454 }
455 
456 
457 template<class FaceList, class PointField>
458 const Foam::Field
459 <
461 >&
463 {
464  if (!faceCentresPtr_)
465  {
466  calcFaceCentres();
467  }
468 
469  return *faceCentresPtr_;
470 }
471 
472 
473 template<class FaceList, class PointField>
474 const Foam::Field
475 <
477 >&
479 {
480  if (!faceNormalsPtr_)
481  {
482  calcFaceNormals();
483  }
484 
485  return *faceNormalsPtr_;
486 }
487 
488 
489 template<class FaceList, class PointField>
490 const Foam::Field
491 <
493 >&
495 {
496  if (!pointNormalsPtr_)
497  {
498  calcPointNormals();
499  }
500 
501  return *pointNormalsPtr_;
502 }
503 
504 
505 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
506 
507 template<class FaceList, class PointField>
508 void Foam::PrimitivePatch<FaceList, PointField>::operator=
509 (
511 )
512 {
513  clearOut();
514 
515  FaceList::shallowCopy(pp);
516 }
517 
518 
519 template<class FaceList, class PointField>
520 void Foam::PrimitivePatch<FaceList, PointField>::operator=
521 (
523 )
524 {
525  clearOut();
526 
527  FaceList::operator=(move(pp));
528 
529  // This is only valid if PointField is not a reference
530  // points_ = move(pp.points_);
531 }
532 
533 
534 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
535 
537 #include "PrimitivePatchEdgeLoops.C"
538 #include "PrimitivePatchClear.C"
541 #include "PrimitivePatchMeshData.C"
542 #include "PrimitivePatchMeshEdges.C"
545 #include "PrimitivePatchCheck.C"
546 
547 // ************************************************************************* //
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:256
label nInternalEdges() const
Number of internal edges.
const Field< PointType > & localPoints() const
Return pointField of points in 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