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-2021 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  nInternalEdges_(-1)
43 {}
44 
45 
46 template<class FaceList, class PointField>
48 (
49  FaceList&& faces,
50  const PointField& points
51 )
52 :
53  FaceList(std::move(faces)),
54  points_(points),
55  nInternalEdges_(-1)
56 {}
57 
58 
59 template<class FaceList, class PointField>
61 (
62  FaceList& faces,
64  const bool reuse
65 )
66 :
67  FaceList(faces, reuse),
68  points_(points, reuse),
69  nInternalEdges_(-1)
70 {}
71 
72 
73 template<class FaceList, class PointField>
75 (
77 )
78 :
79  FaceList(pp),
80  points_(pp.points_),
81  nInternalEdges_(-1)
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
87 template<class FaceList, class PointField>
89 {
90  clearOut();
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class FaceList, class PointField>
97 void
99 (
100  const Field<point_type>&
101 )
102 {
103  DebugInFunction << "Recalculating geometry following mesh motion" << endl;
105  clearGeom();
106 }
107 
108 
109 template<class FaceList, class PointField>
110 const Foam::edgeList&
112 {
113  if (!edgesPtr_)
114  {
115  calcAddressing();
116  }
118  return *edgesPtr_;
119 }
120 
121 
122 template<class FaceList, class PointField>
125 {
126  const edgeList& allEdges = this->edges(); // Force demand-driven
127  return edgeList::subList(allEdges, nInternalEdges());
128 }
129 
130 
131 template<class FaceList, class PointField>
134 {
135  const edgeList& allEdges = this->edges(); // Force demand-driven
136  return edgeList::subList(allEdges, nBoundaryEdges(), nInternalEdges());
137 }
138 
139 
140 template<class FaceList, class PointField>
141 Foam::label
143 {
144  if (!edgesPtr_)
145  {
146  calcAddressing();
147  }
149  return nInternalEdges_;
150 }
151 
152 
153 template<class FaceList, class PointField>
154 Foam::label
156 {
157  const edgeList& allEdges = this->edges(); // Force demand-driven
158  return (allEdges.size() - this->nInternalEdges());
159 }
160 
161 
162 template<class FaceList, class PointField>
163 const Foam::labelList&
165 {
166  if (!boundaryPointsPtr_)
167  {
168  calcBdryPoints();
169  }
171  return *boundaryPointsPtr_;
172 }
173 
174 
175 template<class FaceList, class PointField>
176 const Foam::labelListList&
178 {
179  if (!faceFacesPtr_)
180  {
181  calcAddressing();
182  }
184  return *faceFacesPtr_;
185 }
186 
187 
188 template<class FaceList, class PointField>
189 const Foam::labelListList&
191 {
192  if (!edgeFacesPtr_)
193  {
194  calcAddressing();
195  }
197  return *edgeFacesPtr_;
198 }
199 
200 
201 template<class FaceList, class PointField>
202 const Foam::labelListList&
204 {
205  if (!faceEdgesPtr_)
206  {
207  calcAddressing();
208  }
210  return *faceEdgesPtr_;
211 }
212 
213 
214 template<class FaceList, class PointField>
215 const Foam::labelListList&
217 {
218  if (!pointEdgesPtr_)
219  {
220  calcPointEdges();
221  }
223  return *pointEdgesPtr_;
224 }
225 
226 
227 template<class FaceList, class PointField>
228 const Foam::labelListList&
230 {
231  if (!pointFacesPtr_)
232  {
233  calcPointFaces();
234  }
235 
236  return *pointFacesPtr_;
237 }
239 
240 template<class FaceList, class PointField>
241 const Foam::List
242 <
244 >&
246 {
247  if (!localFacesPtr_)
248  {
249  calcMeshData();
250  }
252  return *localFacesPtr_;
253 }
254 
255 
256 template<class FaceList, class PointField>
257 const Foam::labelList&
259 {
260  if (!meshPointsPtr_)
261  {
262  calcMeshData();
263  }
265  return *meshPointsPtr_;
266 }
267 
268 
269 template<class FaceList, class PointField>
272 {
273  if (!meshPointMapPtr_)
274  {
275  calcMeshPointMap();
276  }
277 
278  return *meshPointMapPtr_;
279 }
281 
282 template<class FaceList, class PointField>
283 const Foam::Field
284 <
286 >&
288 {
289  if (!localPointsPtr_)
290  {
291  calcLocalPoints();
292  }
294  return *localPointsPtr_;
295 }
296 
297 
298 template<class FaceList, class PointField>
299 const Foam::labelList&
301 {
302  if (!localPointOrderPtr_)
303  {
304  calcLocalPointOrder();
305  }
306 
307  return *localPointOrderPtr_;
308 }
309 
310 
311 template<class FaceList, class PointField>
312 Foam::label
314 (
315  const label gp
316 ) const
317 {
318  // The point found, or -1 if not found
319  return meshPointMap().lookup(gp, -1);
320 }
322 
323 template<class FaceList, class PointField>
324 const Foam::Field
325 <
327 >&
329 {
330  if (!faceCentresPtr_)
331  {
332  calcFaceCentres();
333  }
334 
335  return *faceCentresPtr_;
336 }
338 
339 template<class FaceList, class PointField>
340 const Foam::Field
341 <
343 >&
345 {
346  if (!faceAreasPtr_)
347  {
348  calcFaceAreas();
349  }
351  return *faceAreasPtr_;
352 }
353 
354 
355 template<class FaceList, class PointField>
358 {
359  if (!magFaceAreasPtr_)
360  {
361  calcMagFaceAreas();
362  }
363 
364  return *magFaceAreasPtr_;
365 }
367 
368 template<class FaceList, class PointField>
369 const Foam::Field
370 <
372 >&
374 {
375  if (!faceNormalsPtr_)
376  {
377  calcFaceNormals();
378  }
379 
380  return *faceNormalsPtr_;
381 }
383 
384 template<class FaceList, class PointField>
385 const Foam::Field
386 <
388 >&
390 {
391  if (!pointNormalsPtr_)
392  {
393  calcPointNormals();
394  }
395 
396  return *pointNormalsPtr_;
397 }
399 
400 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
401 
402 template<class FaceList, class PointField>
403 void
405 (
407 )
408 {
409  if (&rhs == this)
410  {
411  return;
412  }
413 
414  clearOut();
415 
416  FaceList::shallowCopy(rhs);
417 
418  // Cannot copy assign points (could be const reference)
419 }
420 
421 
422 template<class FaceList, class PointField>
423 void
425 (
427 )
428 {
429  if (&rhs == this)
430  {
431  return;
432  }
433 
434  clearOut();
435 
436  FaceList::operator=(std::move(rhs));
437 
438  // Cannot move assign points (could be const reference)
439 }
440 
441 
442 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
443 
445 #include "PrimitivePatchEdgeLoops.C"
446 #include "PrimitivePatchClear.C"
447 #include "PrimitivePatchBdryFaces.C"
450 #include "PrimitivePatchMeshData.C"
451 #include "PrimitivePatchMeshEdges.C"
454 #include "PrimitivePatchCheck.C"
455 
456 // ************************************************************************* //
const labelListList & pointEdges() const
Return point-edge addressing.
const Field< point_type > & faceAreas() const
Return face area vectors for patch.
std::remove_reference< PointField >::type::value_type point_type
The point type.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:529
label nInternalEdges() const
Number of internal edges.
const Field< scalar > & magFaceAreas() const
Return face area magnitudes for patch.
std::remove_reference< FaceList >::type::value_type face_type
The face type.
const edgeList::subList boundaryEdges() const
Return sub-list of boundary edges, address into LOCAL point list.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const labelList & localPointOrder() const
Return orders the local points for most efficient search.
For every point on the patch find the closest face on the target side. Return a target face label for...
virtual void movePoints(const Field< point_type > &)
Correct patch after moving points.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
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.
A non-owning sub-view of a List (allocated or unallocated storage).
Definition: SubList.H:46
const labelListList & faceFaces() const
Return face-face addressing.
const Map< label > & meshPointMap() const
Mesh point map.
const pointField & points
PrimitivePatch(const FaceList &faces, const PointField &points)
Construct from components.
Generic templated field type.
Definition: Field.H:63
const edgeList::subList internalEdges() const
Return sub-list of internal edges, address into LOCAL point list.
#define DebugInFunction
Report an information message using Foam::Info.
const Field< point_type > & faceCentres() const
Return face centres for patch.
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...
label nBoundaryEdges() const
Number of boundary edges == (nEdges() - nInternalEdges())
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< point_type > & pointNormals() const
Return point normals for patch.
Checks topology of the patch.
Orders the local points on the patch for most efficient search.
const labelListList & faceEdges() const
Return face-edge addressing.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A HashTable to objects of type <T> with a label key.