Added faceCentres member function.
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatch.C
bloba86dd36010a9c7207c3f7a1b3551807866f265b5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "Map.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template
33     class Face,
34     template<class> class FaceList,
35     class PointField,
36     class PointType
38 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
39 PrimitivePatch
41     const FaceList<Face>& faces,
42     const Field<PointType>& points
45     FaceList<Face>(faces),
46     points_(points),
47     edgesPtr_(NULL),
48     nInternalEdges_(-1),
49     boundaryPointsPtr_(NULL),
50     faceFacesPtr_(NULL),
51     edgeFacesPtr_(NULL),
52     faceEdgesPtr_(NULL),
53     pointEdgesPtr_(NULL),
54     pointFacesPtr_(NULL),
55     localFacesPtr_(NULL),
56     meshPointsPtr_(NULL),
57     meshPointMapPtr_(NULL),
58     edgeLoopsPtr_(NULL),
59     localPointsPtr_(NULL),
60     localPointOrderPtr_(NULL),
61     faceCentresPtr_(NULL),
62     faceNormalsPtr_(NULL),
63     pointNormalsPtr_(NULL)
67 template
69     class Face,
70     template<class> class FaceList,
71     class PointField,
72     class PointType
74 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
75 PrimitivePatch
77     FaceList<Face>& faces,
78     Field<PointType>& points,
79     const bool reUse
82     FaceList<Face>(faces, reUse),
83     points_(points, reUse),
84     edgesPtr_(NULL),
85     nInternalEdges_(-1),
86     boundaryPointsPtr_(NULL),
87     faceFacesPtr_(NULL),
88     edgeFacesPtr_(NULL),
89     faceEdgesPtr_(NULL),
90     pointEdgesPtr_(NULL),
91     pointFacesPtr_(NULL),
92     localFacesPtr_(NULL),
93     meshPointsPtr_(NULL),
94     meshPointMapPtr_(NULL),
95     edgeLoopsPtr_(NULL),
96     localPointsPtr_(NULL),
97     localPointOrderPtr_(NULL),
98     faceCentresPtr_(NULL),
99     faceNormalsPtr_(NULL),
100     pointNormalsPtr_(NULL)
104 template
106     class Face,
107     template<class> class FaceList,
108     class PointField,
109     class PointType
111 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
112 PrimitivePatch
114     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
117     PrimitivePatchName(),
118     FaceList<Face>(pp),
119     points_(pp.points_),
120     edgesPtr_(NULL),
121     nInternalEdges_(-1),
122     boundaryPointsPtr_(NULL),
123     faceFacesPtr_(NULL),
124     edgeFacesPtr_(NULL),
125     faceEdgesPtr_(NULL),
126     pointEdgesPtr_(NULL),
127     pointFacesPtr_(NULL),
128     localFacesPtr_(NULL),
129     meshPointsPtr_(NULL),
130     meshPointMapPtr_(NULL),
131     edgeLoopsPtr_(NULL),
132     localPointsPtr_(NULL),
133     localPointOrderPtr_(NULL),
134     faceCentresPtr_(NULL),
135     faceNormalsPtr_(NULL),
136     pointNormalsPtr_(NULL)
140 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
142 template
144     class Face,
145     template<class> class FaceList,
146     class PointField,
147     class PointType
149 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
150 ~PrimitivePatch()
152     clearOut();
156 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
158 template
160     class Face,
161     template<class> class FaceList,
162     class PointField,
163     class PointType
165 void
166 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
167 movePoints
169     const Field<PointType>&
172     if (debug)
173     {
174         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
175             << "movePoints() : "
176             << "recalculating PrimitivePatch geometry following mesh motion"
177             << endl;
178     }
180     clearGeom();
184 template
186     class Face,
187     template<class> class FaceList,
188     class PointField,
189     class PointType
191 const Foam::edgeList&
192 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
193 edges() const
195     if (!edgesPtr_)
196     {
197         calcAddressing();
198     }
200     return *edgesPtr_;
204 template
206     class Face,
207     template<class> class FaceList,
208     class PointField,
209     class PointType
211 Foam::label
212 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
213 nInternalEdges() const
215     if (!edgesPtr_)
216     {
217         calcAddressing();
218     }
220     return nInternalEdges_;
224 template
226     class Face,
227     template<class> class FaceList,
228     class PointField,
229     class PointType
231 const Foam::labelList&
232 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
233 boundaryPoints() const
235     if (!boundaryPointsPtr_)
236     {
237         calcBdryPoints();
238     }
240     return *boundaryPointsPtr_;
244 template
246     class Face,
247     template<class> class FaceList,
248     class PointField,
249     class PointType
251 const Foam::labelListList&
252 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
253 faceFaces() const
255     if (!faceFacesPtr_)
256     {
257         calcAddressing();
258     }
260     return *faceFacesPtr_;
264 template
266     class Face,
267     template<class> class FaceList,
268     class PointField,
269     class PointType
271 const Foam::labelListList&
272 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
273 edgeFaces() const
275     if (!edgeFacesPtr_)
276     {
277         calcAddressing();
278     }
280     return *edgeFacesPtr_;
284 template
286     class Face,
287     template<class> class FaceList,
288     class PointField,
289     class PointType
291 const Foam::labelListList&
292 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
293 faceEdges() const
295     if (!faceEdgesPtr_)
296     {
297         calcAddressing();
298     }
300     return *faceEdgesPtr_;
304 template
306     class Face,
307     template<class> class FaceList,
308     class PointField,
309     class PointType
311 const Foam::labelListList&
312 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
313 pointEdges() const
315     if (!pointEdgesPtr_)
316     {
317         calcPointEdges();
318     }
320     return *pointEdgesPtr_;
324 template
326     class Face,
327     template<class> class FaceList,
328     class PointField,
329     class PointType
331 const Foam::labelListList&
332 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
333 pointFaces() const
335     if (!pointFacesPtr_)
336     {
337         calcPointFaces();
338     }
340     return *pointFacesPtr_;
344 template
346     class Face,
347     template<class> class FaceList,
348     class PointField,
349     class PointType
351 const Foam::List<Face>&
352 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
353 localFaces() const
355     if (!localFacesPtr_)
356     {
357         calcMeshData();
358     }
360     return *localFacesPtr_;
364 template
366     class Face,
367     template<class> class FaceList,
368     class PointField,
369     class PointType
371 const Foam::labelList&
372 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
373 meshPoints() const
375     if (!meshPointsPtr_)
376     {
377         calcMeshData();
378     }
380     return *meshPointsPtr_;
384 template
386     class Face,
387     template<class> class FaceList,
388     class PointField,
389     class PointType
391 const Foam::Map<Foam::label>&
392 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
393 meshPointMap() const
395     if (!meshPointMapPtr_)
396     {
397         calcMeshPointMap();
398     }
400     return *meshPointMapPtr_;
404 template
406     class Face,
407     template<class> class FaceList,
408     class PointField,
409     class PointType
411 const Foam::Field<PointType>&
412 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
413 localPoints() const
415     if (!localPointsPtr_)
416     {
417         calcLocalPoints();
418     }
420     return *localPointsPtr_;
424 template
426     class Face,
427     template<class> class FaceList,
428     class PointField,
429     class PointType
431 const Foam::labelList&
432 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
433 localPointOrder() const
435     if (!localPointOrderPtr_)
436     {
437         calcLocalPointOrder();
438     }
440     return *localPointOrderPtr_;
444 template
446     class Face,
447     template<class> class FaceList,
448     class PointField,
449     class PointType
451 Foam::label
452 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
453 whichPoint
455     const label gp
456 ) const
458     Map<label>::const_iterator fnd = meshPointMap().find(gp);
460     if (fnd != meshPointMap().end())
461     {
462         return fnd();
463     }
464     else
465     {
466         // Not found
467         return -1;
468     }
472 template
474     class Face,
475     template<class> class FaceList,
476     class PointField,
477     class PointType
479 const Foam::Field<PointType>&
480 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
481 faceCentres() const
483     if (!faceCentresPtr_)
484     {
485         calcFaceCentres();
486     }
488     return *faceCentresPtr_;
492 template
494     class Face,
495     template<class> class FaceList,
496     class PointField,
497     class PointType
499 const Foam::Field<PointType>&
500 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
501 faceNormals() const
503     if (!faceNormalsPtr_)
504     {
505         calcFaceNormals();
506     }
508     return *faceNormalsPtr_;
512 template
514     class Face,
515     template<class> class FaceList,
516     class PointField,
517     class PointType
519 const Foam::Field<PointType>&
520 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
521 pointNormals() const
523     if (!pointNormalsPtr_)
524     {
525         calcPointNormals();
526     }
528     return *pointNormalsPtr_;
532 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
534 template
536     class Face,
537     template<class> class FaceList,
538     class PointField,
539     class PointType
541 void
542 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
543 operator=
545     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
548     clearOut();
550     FaceList<Face>::operator=(pp);
554 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
556 #include "PrimitivePatchAddressing.C"
557 #include "PrimitivePatchEdgeLoops.C"
558 #include "PrimitivePatchClear.C"
559 #include "PrimitivePatchBdryPoints.C"
560 #include "PrimitivePatchLocalPointOrder.C"
561 #include "PrimitivePatchMeshData.C"
562 #include "PrimitivePatchMeshEdges.C"
563 #include "PrimitivePatchPointAddressing.C"
564 #include "PrimitivePatchProjectPoints.C"
565 #include "PrimitivePatchCheck.C"
567 // ************************************************************************* //