Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / meshes / primitiveMesh / PrimitivePatchTemplate / PrimitivePatchTemplate.C
blob82cad156b33ae962e8c8662c8e30eafb535fd2af
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.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "Map.H"
27 #include "debug.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 template
33     class Face,
34     template<class> class FaceList,
35     class PointField,
36     class PointType
38 const Foam::debug::optimisationSwitch
39 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
40 nSquaredProjection_
42     "nSquaredProjection",
43     0
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 template
51     class Face,
52     template<class> class FaceList,
53     class PointField,
54     class PointType
56 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
57 PrimitivePatch
59     const FaceList<Face>& faces,
60     const Field<PointType>& points
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)
86 template
88     class Face,
89     template<class> class FaceList,
90     class PointField,
91     class PointType
93 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
94 PrimitivePatch
96     FaceList<Face>& faces,
97     Field<PointType>& points,
98     const bool reUse
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)
123 template
125     class Face,
126     template<class> class FaceList,
127     class PointField,
128     class PointType
130 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
131 PrimitivePatch
133     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
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)
159 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
161 template
163     class Face,
164     template<class> class FaceList,
165     class PointField,
166     class PointType
168 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
169 ~PrimitivePatch()
171     clearOut();
175 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
177 template
179     class Face,
180     template<class> class FaceList,
181     class PointField,
182     class PointType
184 void
185 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
186 movePoints
188     const Field<PointType>&
191     if (debug)
192     {
193         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
194             << "movePoints() : "
195             << "recalculating PrimitivePatch geometry following mesh motion"
196             << endl;
197     }
199     clearGeom();
203 template
205     class Face,
206     template<class> class FaceList,
207     class PointField,
208     class PointType
210 const Foam::edgeList&
211 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
212 edges() const
214     if (!edgesPtr_)
215     {
216         calcAddressing();
217     }
219     return *edgesPtr_;
223 template
225     class Face,
226     template<class> class FaceList,
227     class PointField,
228     class PointType
230 Foam::label
231 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
232 nInternalEdges() const
234     if (!edgesPtr_)
235     {
236         calcAddressing();
237     }
239     return nInternalEdges_;
243 template
245     class Face,
246     template<class> class FaceList,
247     class PointField,
248     class PointType
250 const Foam::labelList&
251 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
252 boundaryPoints() const
254     if (!boundaryPointsPtr_)
255     {
256         calcBdryPoints();
257     }
259     return *boundaryPointsPtr_;
263 template
265     class Face,
266     template<class> class FaceList,
267     class PointField,
268     class PointType
270 const Foam::labelListList&
271 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
272 faceFaces() const
274     if (!faceFacesPtr_)
275     {
276         calcAddressing();
277     }
279     return *faceFacesPtr_;
283 template
285     class Face,
286     template<class> class FaceList,
287     class PointField,
288     class PointType
290 const Foam::labelListList&
291 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
292 edgeFaces() const
294     if (!edgeFacesPtr_)
295     {
296         calcAddressing();
297     }
299     return *edgeFacesPtr_;
303 template
305     class Face,
306     template<class> class FaceList,
307     class PointField,
308     class PointType
310 const Foam::labelListList&
311 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
312 faceEdges() const
314     if (!faceEdgesPtr_)
315     {
316         calcAddressing();
317     }
319     return *faceEdgesPtr_;
323 template
325     class Face,
326     template<class> class FaceList,
327     class PointField,
328     class PointType
330 const Foam::labelListList&
331 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
332 pointEdges() const
334     if (!pointEdgesPtr_)
335     {
336         calcPointEdges();
337     }
339     return *pointEdgesPtr_;
343 template
345     class Face,
346     template<class> class FaceList,
347     class PointField,
348     class PointType
350 const Foam::labelListList&
351 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
352 pointFaces() const
354     if (!pointFacesPtr_)
355     {
356         calcPointFaces();
357     }
359     return *pointFacesPtr_;
363 template
365     class Face,
366     template<class> class FaceList,
367     class PointField,
368     class PointType
370 const Foam::List<Face>&
371 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
372 localFaces() const
374     if (!localFacesPtr_)
375     {
376         calcMeshData();
377     }
379     return *localFacesPtr_;
383 template
385     class Face,
386     template<class> class FaceList,
387     class PointField,
388     class PointType
390 const Foam::labelList&
391 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
392 meshPoints() const
394     if (!meshPointsPtr_)
395     {
396         calcMeshData();
397     }
399     return *meshPointsPtr_;
403 template
405     class Face,
406     template<class> class FaceList,
407     class PointField,
408     class PointType
410 const Foam::Map<Foam::label>&
411 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
412 meshPointMap() const
414     if (!meshPointMapPtr_)
415     {
416         calcMeshPointMap();
417     }
419     return *meshPointMapPtr_;
423 template
425     class Face,
426     template<class> class FaceList,
427     class PointField,
428     class PointType
430 const Foam::Field<PointType>&
431 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
432 localPoints() const
434     if (!localPointsPtr_)
435     {
436         calcLocalPoints();
437     }
439     return *localPointsPtr_;
443 template
445     class Face,
446     template<class> class FaceList,
447     class PointField,
448     class PointType
450 const Foam::labelList&
451 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
452 localPointOrder() const
454     if (!localPointOrderPtr_)
455     {
456         calcLocalPointOrder();
457     }
459     return *localPointOrderPtr_;
463 template
465     class Face,
466     template<class> class FaceList,
467     class PointField,
468     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
498 const Foam::Field<PointType>&
499 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
500 faceCentres() const
502     if (!faceCentresPtr_)
503     {
504         calcFaceCentres();
505     }
507     return *faceCentresPtr_;
511 template
513     class Face,
514     template<class> class FaceList,
515     class PointField,
516     class PointType
518 const Foam::Field<PointType>&
519 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
520 faceNormals() const
522     if (!faceNormalsPtr_)
523     {
524         calcFaceNormals();
525     }
527     return *faceNormalsPtr_;
531 template
533     class Face,
534     template<class> class FaceList,
535     class PointField,
536     class PointType
538 const Foam::Field<PointType>&
539 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
540 pointNormals() const
542     if (!pointNormalsPtr_)
543     {
544         calcPointNormals();
545     }
547     return *pointNormalsPtr_;
551 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
553 template
555     class Face,
556     template<class> class FaceList,
557     class PointField,
558     class PointType
560 void
561 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
562 operator=
564     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
567     clearOut();
569     FaceList<Face>::operator=(pp);
573 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
575 #include "PrimitivePatchAddressing.C"
576 #include "PrimitivePatchEdgeLoops.C"
577 #include "PrimitivePatchClear.C"
578 #include "PrimitivePatchBdryPoints.C"
579 #include "PrimitivePatchLocalPointOrder.C"
580 #include "PrimitivePatchMeshData.C"
581 #include "PrimitivePatchMeshEdges.C"
582 #include "PrimitivePatchPointAddressing.C"
583 #include "PrimitivePatchProjectPoints.C"
584 #include "PrimitivePatchCheck.C"
586 // ************************************************************************* //