initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatch.C
blob6be9ef348b5071e61874fffacc991a7f83505a68
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 // Construct from components
32 template
34     class Face,
35     template<class> class FaceList,
36     class PointField,
37     class PointType
40 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
41 PrimitivePatch
43     const FaceList<Face>& faces,
44     const Field<PointType>& points
47     FaceList<Face>(faces),
48     points_(points),
49     edgesPtr_(NULL),
50     nInternalEdges_(-1),
51     boundaryPointsPtr_(NULL),
52     faceFacesPtr_(NULL),
53     edgeFacesPtr_(NULL),
54     faceEdgesPtr_(NULL),
55     pointEdgesPtr_(NULL),
56     pointFacesPtr_(NULL),
57     localFacesPtr_(NULL),
58     meshPointsPtr_(NULL),
59     meshPointMapPtr_(NULL),
60     edgeLoopsPtr_(NULL),
61     localPointsPtr_(NULL),
62     localPointOrderPtr_(NULL),
63     faceNormalsPtr_(NULL),
64     pointNormalsPtr_(NULL)
68 // Construct from components
69 template
71     class Face,
72     template<class> class FaceList,
73     class PointField,
74     class PointType
77 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
78 PrimitivePatch
80     FaceList<Face>& faces,
81     Field<PointType>& points,
82     const bool reUse
85     FaceList<Face>(faces, reUse),
86     points_(points, reUse),
87     edgesPtr_(NULL),
88     nInternalEdges_(-1),
89     boundaryPointsPtr_(NULL),
90     faceFacesPtr_(NULL),
91     edgeFacesPtr_(NULL),
92     faceEdgesPtr_(NULL),
93     pointEdgesPtr_(NULL),
94     pointFacesPtr_(NULL),
95     localFacesPtr_(NULL),
96     meshPointsPtr_(NULL),
97     meshPointMapPtr_(NULL),
98     edgeLoopsPtr_(NULL),
99     localPointsPtr_(NULL),
100     localPointOrderPtr_(NULL),
101     faceNormalsPtr_(NULL),
102     pointNormalsPtr_(NULL)
106 // Construct as copy
107 template
109     class Face,
110     template<class> class FaceList,
111     class PointField,
112     class PointType
115 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
116 PrimitivePatch
118     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
121     PrimitivePatchName(),
122     FaceList<Face>(pp),
123     points_(pp.points_),
124     edgesPtr_(NULL),
125     nInternalEdges_(-1),
126     boundaryPointsPtr_(NULL),
127     faceFacesPtr_(NULL),
128     edgeFacesPtr_(NULL),
129     faceEdgesPtr_(NULL),
130     pointEdgesPtr_(NULL),
131     pointFacesPtr_(NULL),
132     localFacesPtr_(NULL),
133     meshPointsPtr_(NULL),
134     meshPointMapPtr_(NULL),
135     edgeLoopsPtr_(NULL),
136     localPointsPtr_(NULL),
137     localPointOrderPtr_(NULL),
138     faceNormalsPtr_(NULL),
139     pointNormalsPtr_(NULL)
143 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
145 template
147     class Face,
148     template<class> class FaceList,
149     class PointField,
150     class PointType
153 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
155     clearOut();
159 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
161 // Correct patch after moving points
162 template
164     class Face,
165     template<class> class FaceList,
166     class PointField,
167     class PointType
170 void
171 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
172 movePoints
174     const Field<PointType>&
177     if (debug)
178     {
179         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
180             << "movePoints() : "
181             << "recalculating PrimitivePatch geometry following mesh motion"
182             << endl;
183     }
185     clearGeom();
189 template
191     class Face,
192     template<class> class FaceList,
193     class PointField,
194     class PointType
197 const Foam::edgeList&
198 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
199 edges() const
201     if (!edgesPtr_)
202     {
203         calcAddressing();
204     }
206     return *edgesPtr_;
210 template
212     class Face,
213     template<class> class FaceList,
214     class PointField,
215     class PointType
218 Foam::label
219 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
220 nInternalEdges() const
222     if (!edgesPtr_)
223     {
224         calcAddressing();
225     }
227     return nInternalEdges_;
231 template
233     class Face,
234     template<class> class FaceList,
235     class PointField,
236     class PointType
239 const Foam::labelList&
240 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
241 boundaryPoints() const
243     if (!boundaryPointsPtr_)
244     {
245         calcBdryPoints();
246     }
248     return *boundaryPointsPtr_;
252 template
254     class Face,
255     template<class> class FaceList,
256     class PointField,
257     class PointType
260 const Foam::labelListList&
261 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
262 faceFaces() const
264     if (!faceFacesPtr_)
265     {
266         calcAddressing();
267     }
269     return *faceFacesPtr_;
273 template
275     class Face,
276     template<class> class FaceList,
277     class PointField,
278     class PointType
281 const Foam::labelListList&
282 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
283 edgeFaces() const
285     if (!edgeFacesPtr_)
286     {
287         calcAddressing();
288     }
290     return *edgeFacesPtr_;
294 template
296     class Face,
297     template<class> class FaceList,
298     class PointField,
299     class PointType
302 const Foam::labelListList&
303 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
304 faceEdges() const
306     if (!faceEdgesPtr_)
307     {
308         calcAddressing();
309     }
311     return *faceEdgesPtr_;
315 template
317     class Face,
318     template<class> class FaceList,
319     class PointField,
320     class PointType
323 const Foam::labelListList&
324 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
325 pointEdges() const
327     if (!pointEdgesPtr_)
328     {
329         calcPointEdges();
330     }
332     return *pointEdgesPtr_;
336 template
338     class Face,
339     template<class> class FaceList,
340     class PointField,
341     class PointType
344 const Foam::labelListList&
345 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
346 pointFaces() const
348     if (!pointFacesPtr_)
349     {
350         calcPointFaces();
351     }
353     return *pointFacesPtr_;
357 template
359     class Face,
360     template<class> class FaceList,
361     class PointField,
362     class PointType
365 const Foam::List<Face>&
366 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
367 localFaces() const
369     if (!localFacesPtr_)
370     {
371         calcMeshData();
372     }
374     return *localFacesPtr_;
378 template
380     class Face,
381     template<class> class FaceList,
382     class PointField,
383     class PointType
386 const Foam::labelList&
387 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
388 meshPoints() const
390     if (!meshPointsPtr_)
391     {
392         calcMeshData();
393     }
395     return *meshPointsPtr_;
399 template
401     class Face,
402     template<class> class FaceList,
403     class PointField,
404     class PointType
407 const Foam::Map<Foam::label>&
408 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
409 meshPointMap() const
411     if (!meshPointMapPtr_)
412     {
413         calcMeshPointMap();
414     }
416     return *meshPointMapPtr_;
420 template
422     class Face,
423     template<class> class FaceList,
424     class PointField,
425     class PointType
428 const Foam::Field<PointType>&
429 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
430 localPoints() const
432     if (!localPointsPtr_)
433     {
434         calcLocalPoints();
435     }
437     return *localPointsPtr_;
441 template
443     class Face,
444     template<class> class FaceList,
445     class PointField,
446     class PointType
449 const Foam::labelList&
450 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
451 localPointOrder() const
453     if (!localPointOrderPtr_)
454     {
455         calcLocalPointOrder();
456     }
458     return *localPointOrderPtr_;
462 template
464     class Face,
465     template<class> class FaceList,
466     class PointField,
467     class PointType
470 Foam::label
471 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
472 whichPoint
474     const label gp
475 ) const
477     Map<label>::const_iterator fnd = meshPointMap().find(gp);
479     if (fnd != meshPointMap().end())
480     {
481         return fnd();
482     }
483     else
484     {
485         // Not found
486         return -1;
487     }
491 template
493     class Face,
494     template<class> class FaceList,
495     class PointField,
496     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
520 const Foam::Field<PointType>&
521 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
522 pointNormals() const
524     if (!pointNormalsPtr_)
525     {
526         calcPointNormals();
527     }
529     return *pointNormalsPtr_;
533 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
535 template
537     class Face,
538     template<class> class FaceList,
539     class PointField,
540     class PointType
543 void
544 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
545 operator=
547     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
550     clearOut();
552     FaceList<Face>::operator=(pp);
555 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
557 #include "PrimitivePatchAddressing.C"
558 #include "PrimitivePatchEdgeLoops.C"
559 #include "PrimitivePatchClear.C"
560 #include "PrimitivePatchBdryPoints.C"
561 #include "PrimitivePatchLocalPointOrder.C"
562 #include "PrimitivePatchMeshData.C"
563 #include "PrimitivePatchMeshEdges.C"
564 #include "PrimitivePatchPointAddressing.C"
565 #include "PrimitivePatchProjectPoints.C"
566 #include "PrimitivePatchCheck.C"
568 // ************************************************************************* //