fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatch.C
blob9b2d5bd18f632e444480e85e6a8231499c47d1be
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 template
33     class Face,
34     template<class> class FaceList,
35     class PointField,
36     class PointType
38 const bool
39 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
40 nSquaredProjection_
42     debug::optimisationSwitch("nSquaredProjection", 0) > 0
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 template
50     class Face,
51     template<class> class FaceList,
52     class PointField,
53     class PointType
55 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
56 PrimitivePatch
58     const FaceList<Face>& faces,
59     const Field<PointType>& points
62     FaceList<Face>(faces),
63     points_(points),
64     edgesPtr_(NULL),
65     nInternalEdges_(-1),
66     boundaryPointsPtr_(NULL),
67     faceFacesPtr_(NULL),
68     edgeFacesPtr_(NULL),
69     faceEdgesPtr_(NULL),
70     pointEdgesPtr_(NULL),
71     pointFacesPtr_(NULL),
72     localFacesPtr_(NULL),
73     meshPointsPtr_(NULL),
74     meshPointMapPtr_(NULL),
75     edgeLoopsPtr_(NULL),
76     localPointsPtr_(NULL),
77     localPointOrderPtr_(NULL),
78     faceCentresPtr_(NULL),
79     faceNormalsPtr_(NULL),
80     pointNormalsPtr_(NULL)
84 template
86     class Face,
87     template<class> class FaceList,
88     class PointField,
89     class PointType
91 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
92 PrimitivePatch
94     FaceList<Face>& faces,
95     Field<PointType>& points,
96     const bool reUse
99     FaceList<Face>(faces, reUse),
100     points_(points, reUse),
101     edgesPtr_(NULL),
102     nInternalEdges_(-1),
103     boundaryPointsPtr_(NULL),
104     faceFacesPtr_(NULL),
105     edgeFacesPtr_(NULL),
106     faceEdgesPtr_(NULL),
107     pointEdgesPtr_(NULL),
108     pointFacesPtr_(NULL),
109     localFacesPtr_(NULL),
110     meshPointsPtr_(NULL),
111     meshPointMapPtr_(NULL),
112     edgeLoopsPtr_(NULL),
113     localPointsPtr_(NULL),
114     localPointOrderPtr_(NULL),
115     faceCentresPtr_(NULL),
116     faceNormalsPtr_(NULL),
117     pointNormalsPtr_(NULL)
121 template
123     class Face,
124     template<class> class FaceList,
125     class PointField,
126     class PointType
128 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
129 PrimitivePatch
131     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
134     PrimitivePatchName(),
135     FaceList<Face>(pp),
136     points_(pp.points_),
137     edgesPtr_(NULL),
138     nInternalEdges_(-1),
139     boundaryPointsPtr_(NULL),
140     faceFacesPtr_(NULL),
141     edgeFacesPtr_(NULL),
142     faceEdgesPtr_(NULL),
143     pointEdgesPtr_(NULL),
144     pointFacesPtr_(NULL),
145     localFacesPtr_(NULL),
146     meshPointsPtr_(NULL),
147     meshPointMapPtr_(NULL),
148     edgeLoopsPtr_(NULL),
149     localPointsPtr_(NULL),
150     localPointOrderPtr_(NULL),
151     faceCentresPtr_(NULL),
152     faceNormalsPtr_(NULL),
153     pointNormalsPtr_(NULL)
157 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
159 template
161     class Face,
162     template<class> class FaceList,
163     class PointField,
164     class PointType
166 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
167 ~PrimitivePatch()
169     clearOut();
173 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
175 template
177     class Face,
178     template<class> class FaceList,
179     class PointField,
180     class PointType
182 void
183 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
184 movePoints
186     const Field<PointType>&
189     if (debug)
190     {
191         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
192             << "movePoints() : "
193             << "recalculating PrimitivePatch geometry following mesh motion"
194             << endl;
195     }
197     clearGeom();
201 template
203     class Face,
204     template<class> class FaceList,
205     class PointField,
206     class PointType
208 const Foam::edgeList&
209 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
210 edges() const
212     if (!edgesPtr_)
213     {
214         calcAddressing();
215     }
217     return *edgesPtr_;
221 template
223     class Face,
224     template<class> class FaceList,
225     class PointField,
226     class PointType
228 Foam::label
229 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
230 nInternalEdges() const
232     if (!edgesPtr_)
233     {
234         calcAddressing();
235     }
237     return nInternalEdges_;
241 template
243     class Face,
244     template<class> class FaceList,
245     class PointField,
246     class PointType
248 const Foam::labelList&
249 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
250 boundaryPoints() const
252     if (!boundaryPointsPtr_)
253     {
254         calcBdryPoints();
255     }
257     return *boundaryPointsPtr_;
261 template
263     class Face,
264     template<class> class FaceList,
265     class PointField,
266     class PointType
268 const Foam::labelListList&
269 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
270 faceFaces() const
272     if (!faceFacesPtr_)
273     {
274         calcAddressing();
275     }
277     return *faceFacesPtr_;
281 template
283     class Face,
284     template<class> class FaceList,
285     class PointField,
286     class PointType
288 const Foam::labelListList&
289 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
290 edgeFaces() const
292     if (!edgeFacesPtr_)
293     {
294         calcAddressing();
295     }
297     return *edgeFacesPtr_;
301 template
303     class Face,
304     template<class> class FaceList,
305     class PointField,
306     class PointType
308 const Foam::labelListList&
309 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
310 faceEdges() const
312     if (!faceEdgesPtr_)
313     {
314         calcAddressing();
315     }
317     return *faceEdgesPtr_;
321 template
323     class Face,
324     template<class> class FaceList,
325     class PointField,
326     class PointType
328 const Foam::labelListList&
329 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
330 pointEdges() const
332     if (!pointEdgesPtr_)
333     {
334         calcPointEdges();
335     }
337     return *pointEdgesPtr_;
341 template
343     class Face,
344     template<class> class FaceList,
345     class PointField,
346     class PointType
348 const Foam::labelListList&
349 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
350 pointFaces() const
352     if (!pointFacesPtr_)
353     {
354         calcPointFaces();
355     }
357     return *pointFacesPtr_;
361 template
363     class Face,
364     template<class> class FaceList,
365     class PointField,
366     class PointType
368 const Foam::List<Face>&
369 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
370 localFaces() const
372     if (!localFacesPtr_)
373     {
374         calcMeshData();
375     }
377     return *localFacesPtr_;
381 template
383     class Face,
384     template<class> class FaceList,
385     class PointField,
386     class PointType
388 const Foam::labelList&
389 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
390 meshPoints() const
392     if (!meshPointsPtr_)
393     {
394         calcMeshData();
395     }
397     return *meshPointsPtr_;
401 template
403     class Face,
404     template<class> class FaceList,
405     class PointField,
406     class PointType
408 const Foam::Map<Foam::label>&
409 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
410 meshPointMap() const
412     if (!meshPointMapPtr_)
413     {
414         calcMeshPointMap();
415     }
417     return *meshPointMapPtr_;
421 template
423     class Face,
424     template<class> class FaceList,
425     class PointField,
426     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
448 const Foam::labelList&
449 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
450 localPointOrder() const
452     if (!localPointOrderPtr_)
453     {
454         calcLocalPointOrder();
455     }
457     return *localPointOrderPtr_;
461 template
463     class Face,
464     template<class> class FaceList,
465     class PointField,
466     class PointType
468 Foam::label
469 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
470 whichPoint
472     const label gp
473 ) const
475     Map<label>::const_iterator fnd = meshPointMap().find(gp);
477     if (fnd != meshPointMap().end())
478     {
479         return fnd();
480     }
481     else
482     {
483         // Not found
484         return -1;
485     }
489 template
491     class Face,
492     template<class> class FaceList,
493     class PointField,
494     class PointType
496 const Foam::Field<PointType>&
497 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
498 faceCentres() const
500     if (!faceCentresPtr_)
501     {
502         calcFaceCentres();
503     }
505     return *faceCentresPtr_;
509 template
511     class Face,
512     template<class> class FaceList,
513     class PointField,
514     class PointType
516 const Foam::Field<PointType>&
517 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
518 faceNormals() const
520     if (!faceNormalsPtr_)
521     {
522         calcFaceNormals();
523     }
525     return *faceNormalsPtr_;
529 template
531     class Face,
532     template<class> class FaceList,
533     class PointField,
534     class PointType
536 const Foam::Field<PointType>&
537 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
538 pointNormals() const
540     if (!pointNormalsPtr_)
541     {
542         calcPointNormals();
543     }
545     return *pointNormalsPtr_;
549 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
551 template
553     class Face,
554     template<class> class FaceList,
555     class PointField,
556     class PointType
558 void
559 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
560 operator=
562     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
565     clearOut();
567     FaceList<Face>::operator=(pp);
571 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
573 #include "PrimitivePatchAddressing.C"
574 #include "PrimitivePatchEdgeLoops.C"
575 #include "PrimitivePatchClear.C"
576 #include "PrimitivePatchBdryPoints.C"
577 #include "PrimitivePatchLocalPointOrder.C"
578 #include "PrimitivePatchMeshData.C"
579 #include "PrimitivePatchMeshEdges.C"
580 #include "PrimitivePatchPointAddressing.C"
581 #include "PrimitivePatchProjectPoints.C"
582 #include "PrimitivePatchCheck.C"
584 // ************************************************************************* //