PrimitivePatchTemplate.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "Map.H"
27 #include "debug.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 template
32 <
33  class Face,
34  template<class> class FaceList,
35  class PointField,
36  class PointType
37 >
41 (
42  "nSquaredProjection",
43  0
44 );
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 template
50 <
51  class Face,
52  template<class> class FaceList,
53  class PointField,
54  class PointType
55 >
58 (
59  const FaceList<Face>& faces,
61 )
62 :
63  FaceList<Face>(faces),
64  points_(points),
65  edgesPtr_(NULL),
66  nInternalEdges_(-1),
67  boundaryPointsPtr_(NULL),
68  faceFacesPtr_(NULL),
69  edgeFacesPtr_(NULL),
70  faceEdgesPtr_(NULL),
71  pointEdgesPtr_(NULL),
72  pointFacesPtr_(NULL),
73  localFacesPtr_(NULL),
74  meshPointsPtr_(NULL),
75  meshPointMapPtr_(NULL),
76  edgeLoopsPtr_(NULL),
77  localPointsPtr_(NULL),
78  localPointOrderPtr_(NULL),
79  faceCentresPtr_(NULL),
80  faceNormalsPtr_(NULL),
81  pointNormalsPtr_(NULL)
82 {
83 }
84 
85 
86 template
87 <
88  class Face,
89  template<class> class FaceList,
90  class PointField,
91  class PointType
92 >
95 (
96  FaceList<Face>& faces,
98  const bool reUse
99 )
100 :
101  FaceList<Face>(faces, reUse),
102  points_(points, reUse),
103  edgesPtr_(NULL),
104  nInternalEdges_(-1),
105  boundaryPointsPtr_(NULL),
106  faceFacesPtr_(NULL),
107  edgeFacesPtr_(NULL),
108  faceEdgesPtr_(NULL),
109  pointEdgesPtr_(NULL),
110  pointFacesPtr_(NULL),
111  localFacesPtr_(NULL),
112  meshPointsPtr_(NULL),
113  meshPointMapPtr_(NULL),
114  edgeLoopsPtr_(NULL),
115  localPointsPtr_(NULL),
116  localPointOrderPtr_(NULL),
117  faceCentresPtr_(NULL),
118  faceNormalsPtr_(NULL),
119  pointNormalsPtr_(NULL)
120 {}
121 
122 
123 template
124 <
125  class Face,
126  template<class> class FaceList,
127  class PointField,
128  class PointType
129 >
132 (
134 )
135 :
136  PrimitivePatchName(),
137  FaceList<Face>(pp),
138  points_(pp.points_),
139  edgesPtr_(NULL),
140  nInternalEdges_(-1),
141  boundaryPointsPtr_(NULL),
142  faceFacesPtr_(NULL),
143  edgeFacesPtr_(NULL),
144  faceEdgesPtr_(NULL),
145  pointEdgesPtr_(NULL),
146  pointFacesPtr_(NULL),
147  localFacesPtr_(NULL),
148  meshPointsPtr_(NULL),
149  meshPointMapPtr_(NULL),
150  edgeLoopsPtr_(NULL),
151  localPointsPtr_(NULL),
152  localPointOrderPtr_(NULL),
153  faceCentresPtr_(NULL),
154  faceNormalsPtr_(NULL),
155  pointNormalsPtr_(NULL)
156 {}
157 
158 
159 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
160 
161 template
162 <
163  class Face,
164  template<class> class FaceList,
165  class PointField,
166  class PointType
167 >
170 {
171  clearOut();
172 }
173 
174 
175 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
176 
177 template
178 <
179  class Face,
180  template<class> class FaceList,
181  class PointField,
182  class PointType
183 >
184 void
187 (
188  const Field<PointType>&
189 )
190 {
191  if (debug)
192  {
193  Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
194  << "movePoints() : "
195  << "recalculating PrimitivePatch geometry following mesh motion"
196  << endl;
197  }
198 
199  clearGeom();
200 }
201 
202 
203 template
204 <
205  class Face,
206  template<class> class FaceList,
207  class PointField,
208  class PointType
209 >
210 const Foam::edgeList&
212 edges() const
213 {
214  if (!edgesPtr_)
215  {
216  calcAddressing();
217  }
218 
219  return *edgesPtr_;
220 }
221 
222 
223 template
224 <
225  class Face,
226  template<class> class FaceList,
227  class PointField,
228  class PointType
229 >
233 {
234  if (!edgesPtr_)
235  {
236  calcAddressing();
237  }
238 
239  return nInternalEdges_;
240 }
241 
242 
243 template
244 <
245  class Face,
246  template<class> class FaceList,
247  class PointField,
248  class PointType
249 >
250 const Foam::labelList&
253 {
254  if (!boundaryPointsPtr_)
255  {
256  calcBdryPoints();
257  }
258 
259  return *boundaryPointsPtr_;
260 }
261 
262 
263 template
264 <
265  class Face,
266  template<class> class FaceList,
267  class PointField,
268  class PointType
269 >
270 const Foam::labelListList&
272 faceFaces() const
273 {
274  if (!faceFacesPtr_)
275  {
276  calcAddressing();
277  }
278 
279  return *faceFacesPtr_;
280 }
281 
282 
283 template
284 <
285  class Face,
286  template<class> class FaceList,
287  class PointField,
288  class PointType
289 >
290 const Foam::labelListList&
292 edgeFaces() const
293 {
294  if (!edgeFacesPtr_)
295  {
296  calcAddressing();
297  }
298 
299  return *edgeFacesPtr_;
300 }
301 
302 
303 template
304 <
305  class Face,
306  template<class> class FaceList,
307  class PointField,
308  class PointType
309 >
310 const Foam::labelListList&
312 faceEdges() const
313 {
314  if (!faceEdgesPtr_)
315  {
316  calcAddressing();
317  }
318 
319  return *faceEdgesPtr_;
320 }
321 
322 
323 template
324 <
325  class Face,
326  template<class> class FaceList,
327  class PointField,
328  class PointType
329 >
330 const Foam::labelListList&
332 pointEdges() const
333 {
334  if (!pointEdgesPtr_)
335  {
336  calcPointEdges();
337  }
338 
339  return *pointEdgesPtr_;
340 }
341 
342 
343 template
344 <
345  class Face,
346  template<class> class FaceList,
347  class PointField,
348  class PointType
349 >
350 const Foam::labelListList&
352 pointFaces() const
353 {
354  if (!pointFacesPtr_)
355  {
356  calcPointFaces();
357  }
358 
359  return *pointFacesPtr_;
360 }
361 
362 
363 template
364 <
365  class Face,
366  template<class> class FaceList,
367  class PointField,
368  class PointType
369 >
370 const Foam::List<Face>&
372 localFaces() const
373 {
374  if (!localFacesPtr_)
375  {
376  calcMeshData();
377  }
378 
379  return *localFacesPtr_;
380 }
381 
382 
383 template
384 <
385  class Face,
386  template<class> class FaceList,
387  class PointField,
388  class PointType
389 >
390 const Foam::labelList&
392 meshPoints() const
393 {
394  if (!meshPointsPtr_)
395  {
396  calcMeshData();
397  }
398 
399  return *meshPointsPtr_;
400 }
401 
402 
403 template
404 <
405  class Face,
406  template<class> class FaceList,
407  class PointField,
408  class PointType
409 >
413 {
414  if (!meshPointMapPtr_)
415  {
416  calcMeshPointMap();
417  }
418 
419  return *meshPointMapPtr_;
420 }
421 
422 
423 template
424 <
425  class Face,
426  template<class> class FaceList,
427  class PointField,
428  class PointType
429 >
432 localPoints() const
433 {
434  if (!localPointsPtr_)
435  {
436  calcLocalPoints();
437  }
438 
439  return *localPointsPtr_;
440 }
441 
442 
443 template
444 <
445  class Face,
446  template<class> class FaceList,
447  class PointField,
448  class PointType
449 >
450 const Foam::labelList&
453 {
454  if (!localPointOrderPtr_)
455  {
456  calcLocalPointOrder();
457  }
458 
459  return *localPointOrderPtr_;
460 }
461 
462 
463 template
464 <
465  class Face,
466  template<class> class FaceList,
467  class PointField,
468  class PointType
469 >
473 (
474  const label gp
475 ) const
476 {
477  Map<label>::const_iterator fnd = meshPointMap().find(gp);
478 
479  if (fnd != meshPointMap().end())
480  {
481  return fnd();
482  }
483  else
484  {
485  // Not found
486  return -1;
487  }
488 }
489 
490 
491 template
492 <
493  class Face,
494  template<class> class FaceList,
495  class PointField,
496  class PointType
497 >
500 faceCentres() const
501 {
502  if (!faceCentresPtr_)
503  {
504  calcFaceCentres();
505  }
506 
507  return *faceCentresPtr_;
508 }
509 
510 
511 template
512 <
513  class Face,
514  template<class> class FaceList,
515  class PointField,
516  class PointType
517 >
520 faceNormals() const
521 {
522  if (!faceNormalsPtr_)
523  {
524  calcFaceNormals();
525  }
526 
527  return *faceNormalsPtr_;
528 }
529 
530 
531 template
532 <
533  class Face,
534  template<class> class FaceList,
535  class PointField,
536  class PointType
537 >
541 {
542  if (!pointNormalsPtr_)
543  {
544  calcPointNormals();
545  }
546 
547  return *pointNormalsPtr_;
548 }
549 
550 
551 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
552 
553 template
554 <
555  class Face,
556  template<class> class FaceList,
557  class PointField,
558  class PointType
559 >
560 void
562 operator=
563 (
565 )
566 {
567  clearOut();
568 
569  FaceList<Face>::operator=(pp);
570 }
571 
572 
573 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
574 
576 #include "PrimitivePatchEdgeLoops.C"
577 #include "PrimitivePatchClear.C"
580 #include "PrimitivePatchMeshData.C"
581 #include "PrimitivePatchMeshEdges.C"
584 #include "PrimitivePatchCheck.C"
585 
586 // ************************************************************************* //
PrimitivePatchMeshData.C
Foam::PrimitivePatch::pointFaces
const labelListList & pointFaces() const
Return point-face addressing.
Definition: PrimitivePatchTemplate.C:352
Foam::PrimitivePatch::whichPoint
label whichPoint(const label gp) const
Given a global point index, return the local point.
Definition: PrimitivePatchTemplate.C:473
debug.H
Foam::PrimitivePatch::edgeFaces
const labelListList & edgeFaces() const
Return edge-face addressing.
Definition: PrimitivePatchTemplate.C:292
Foam::PrimitivePatch::edges
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Definition: PrimitivePatchTemplate.C:212
Foam::PrimitivePatch::PrimitivePatch
PrimitivePatch(const FaceList< Face > &faces, const Field< PointType > &points)
Construct from components.
Definition: PrimitivePatchTemplate.C:58
Foam::PrimitivePatch::localPoints
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatchTemplate.C:432
Foam::PrimitivePatch::~PrimitivePatch
virtual ~PrimitivePatch()
Definition: PrimitivePatchTemplate.C:169
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: PrimitivePatchTemplate.H:68
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::PrimitivePatch::faceEdges
const labelListList & faceEdges() const
Return face-edge addressing.
Definition: PrimitivePatchTemplate.C:312
Map.H
Foam::debug::optimisationSwitch
int optimisationSwitch(const char *name, const int defaultValue=0)
Lookup optimisation switch or add default value.
Definition: debug.C:182
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
PrimitivePatchProjectPoints.C
For every point on the patch find the closest face on the target side. Return a target face label for...
PrimitivePatchPointAddressing.C
Point addressing on the patch: pointEdges and pointFaces.
Foam::PrimitivePatch::pointEdges
const labelListList & pointEdges() const
Return point-edge addressing.
Definition: PrimitivePatchTemplate.C:332
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatchTemplate.C:187
PrimitivePatchLocalPointOrder.C
Orders the local points on the patch for most efficient search.
Foam::PrimitivePatch::boundaryPoints
const labelList & boundaryPoints() const
Return list of boundary points,.
Definition: PrimitivePatchTemplate.C:252
Foam::PrimitivePatch::nInternalEdges
label nInternalEdges() const
Number of internal edges.
Definition: PrimitivePatchTemplate.C:232
Foam::PrimitivePatch::pointNormals
const Field< PointType > & pointNormals() const
Return point normals for patch.
Definition: PrimitivePatchTemplate.C:540
PrimitivePatchAddressing.C
This function calculates the list of patch edges, defined on the list of points supporting the patch....
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::PrimitivePatch::faceNormals
const Field< PointType > & faceNormals() const
Return face normals for patch.
Definition: PrimitivePatchTemplate.C:520
Foam::List
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
Foam::PrimitivePatch::faceCentres
const Field< PointType > & faceCentres() const
Return face centres for patch.
Definition: PrimitivePatchTemplate.C:500
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: PrimitivePatchTemplate.C:452
PrimitivePatchMeshEdges.C
Foam::PrimitivePatch::points_
PointField points_
Reference to global list of points.
Definition: PrimitivePatchTemplate.H:118
Foam::PrimitivePatch::localFaces
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatchTemplate.C:372
PrimitivePatchClear.C
Foam::PrimitivePatch::nSquaredProjection_
static const debug::optimisationSwitch nSquaredProjection_
N-squared projection forced.
Definition: PrimitivePatchTemplate.H:181
PrimitivePatchCheck.C
Checks topology of the patch.
Foam::PrimitivePatch::meshPointMap
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
Definition: PrimitivePatchTemplate.C:412
Foam::PrimitivePatch::faceFaces
const labelListList & faceFaces() const
Return face-face addressing.
Definition: PrimitivePatchTemplate.C:272
PrimitivePatchBdryPoints.C
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatchTemplate.C:392
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
PrimitivePatchEdgeLoops.C
Create the list of loops of outside vertices. Goes wrong on multiply connected edges (loops will be u...