Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / surfaceTools / meshSurfaceEngine / meshSurfaceEngineI.H
blobdc5d6cfcfd6581d6a6c8e4d1d19b084d98d1686f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9     This file is part of cfMesh.
11     cfMesh 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     cfMesh 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 cfMesh.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "meshSurfaceEngine.H"
29 #include "demandDrivenData.H"
31 # ifdef USE_OMP
32 #include <omp.h>
33 # endif
35 // #define DEBUGSearch
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 namespace Foam
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 inline const polyMeshGen& meshSurfaceEngine::mesh() const
46     return mesh_;
49 inline const pointFieldPMG& meshSurfaceEngine::points() const
51     return mesh_.points();
54 inline const faceListPMG& meshSurfaceEngine::faces() const
56     return mesh_.faces();
59 inline const cellListPMG& meshSurfaceEngine::cells() const
61     return mesh_.cells();
64 inline const labelList& meshSurfaceEngine::bp() const
66     if( !bppPtr_ )
67     {
68         # ifdef USE_OMP
69         if( omp_in_parallel() )
70             FatalErrorIn
71             (
72                 "const labelList& meshSurfaceEngine::bp() const"
73             ) << "Calculating addressing inside a parallel region."
74                 << " This is not thread safe" << exit(FatalError);
75         # endif
77         calculateBoundaryFaces();
78         calculateBoundaryNodes();
79     }
81     return *bppPtr_;
84 inline const labelList& meshSurfaceEngine::boundaryPoints() const
86     if( !boundaryPointsPtr_ )
87     {
88         # ifdef USE_OMP
89         if( omp_in_parallel() )
90             FatalErrorIn
91             (
92                 "const labelList& meshSurfaceEngine::boundaryPoints() const"
93             ) << "Calculating addressing inside a parallel region."
94                 << " This is not thread safe" << exit(FatalError);
95         # endif
97         calculateBoundaryNodes();
98     }
100     return *boundaryPointsPtr_;
103 inline const faceList::subList& meshSurfaceEngine::boundaryFaces() const
105     if( !boundaryFacesPtr_ )
106     {
107         # ifdef USE_OMP
108         if( omp_in_parallel() )
109             FatalErrorIn
110             (
111                 "const faceList::subList&"
112                 "meshSurfaceEngine::boundaryFaces() const"
113             ) << "Calculating addressing inside a parallel region."
114                 << " This is not thread safe" << exit(FatalError);
115         # endif
117         calculateBoundaryFaces();
118     }
120     return *boundaryFacesPtr_;
123 inline const labelList& meshSurfaceEngine::boundaryFacePatches() const
125     if( !boundaryFacePatchPtr_ )
126     {
127         # ifdef USE_OMP
128         if( omp_in_parallel() )
129             FatalErrorIn
130             (
131                 "const labelList&"
132                 " meshSurfaceEngine::boundaryFacePatches() const"
133             ) << "Calculating addressing inside a parallel region."
134                 << " This is not thread safe" << exit(FatalError);
135         # endif
137         calculateBoundaryFacePatches();
138     }
140     return *boundaryFacePatchPtr_;
143 inline const labelList& meshSurfaceEngine::faceOwners() const
145     if( !boundaryFaceOwnersPtr_ )
146     {
147         # ifdef USE_OMP
148         if( omp_in_parallel() )
149             FatalErrorIn
150             (
151                 "const labelList& meshSurfaceEngine::faceOwners() const"
152             ) << "Calculating addressing inside a parallel region."
153                 << " This is not thread safe" << exit(FatalError);
154         # endif
156         calculateBoundaryOwners();
157     }
159     return *boundaryFaceOwnersPtr_;
162 inline const VRWGraph& meshSurfaceEngine::pointFaces() const
164     if( !pointFacesPtr_ )
165     {
166         # ifdef USE_OMP
167         if( omp_in_parallel() )
168             FatalErrorIn
169             (
170                 "const VRWGraph& meshSurfaceEngine::pointFaces() const"
171             ) << "Calculating addressing inside a parallel region."
172                 << " This is not thread safe" << exit(FatalError);
173         # endif
175         calculatePointFaces();
176     }
178     return *pointFacesPtr_;
181 inline const VRWGraph& meshSurfaceEngine::pointInFaces() const
183     if( !pointInFacePtr_ )
184     {
185         # ifdef USE_OMP
186         if( omp_in_parallel() )
187             FatalErrorIn
188             (
189                 "const VRWGraph& meshSurfaceEngine::pointInFaces() const"
190             ) << "Calculating addressing inside a parallel region."
191                 << " This is not thread safe" << exit(FatalError);
192         # endif
194         calculatePointFaces();
195     }
197     return *pointInFacePtr_;
200 inline const VRWGraph& meshSurfaceEngine::pointPatches() const
202     if( !pointPatchesPtr_ )
203     {
204         # ifdef USE_OMP
205         if( omp_in_parallel() )
206             FatalErrorIn
207             (
208                 "const VRWGraph& meshSurfaceEngine::pointPatches() const"
209             ) << "Calculating addressing inside a parallel region."
210                 << " This is not thread safe" << exit(FatalError);
211         # endif
213         calculatePointPatches();
214     }
216     return *pointPatchesPtr_;
220 inline const VRWGraph& meshSurfaceEngine::pointPoints() const
222     if( !pointPointsPtr_ )
223     {
224         # ifdef USE_OMP
225         if( omp_in_parallel() )
226             FatalErrorIn
227             (
228                 "const VRWGraph& meshSurfaceEngine::pointPoints() const"
229             ) << "Calculating addressing inside a parallel region."
230                 << " This is not thread safe" << exit(FatalError);
231         # endif
233         calculatePointPoints();
234     }
236     return *pointPointsPtr_;
239 inline const vectorField& meshSurfaceEngine::pointNormals() const
241     if( !pointNormalsPtr_ )
242     {
243         # ifdef USE_OMP
244         if( omp_in_parallel() )
245             FatalErrorIn
246             (
247                 "const vectorField& meshSurfaceEngine::pointNormals() const"
248             ) << "Calculating addressing inside a parallel region."
249                 << " This is not thread safe" << exit(FatalError);
250         # endif
252         calculatePointNormals();
253     }
255     return *pointNormalsPtr_;
258 inline const vectorField& meshSurfaceEngine::faceNormals() const
260     if( !faceNormalsPtr_ )
261     {
262         # ifdef USE_OMP
263         if( omp_in_parallel() )
264             FatalErrorIn
265             (
266                 "const vectorField& meshSurfaceEngine::faceNormals() const"
267             ) << "Calculating addressing inside a parallel region."
268                 << " This is not thread safe" << exit(FatalError);
269         # endif
271         calculateFaceNormals();
272     }
274     return *faceNormalsPtr_;
277 inline const vectorField& meshSurfaceEngine::faceCentres() const
279     if( !faceCentresPtr_ )
280     {
281         # ifdef USE_OMP
282         if( omp_in_parallel() )
283             FatalErrorIn
284             (
285                 "const vectorField& meshSurfaceEngine::faceCentres() const"
286             ) << "Calculating addressing inside a parallel region."
287                 << " This is not thread safe" << exit(FatalError);
288         # endif
290         calculateFaceCentres();
291     }
293     return *faceCentresPtr_;
296 inline const edgeList& meshSurfaceEngine::edges() const
298     if( !edgesPtr_ )
299     {
300         # ifdef USE_OMP
301         if( omp_in_parallel() )
302             FatalErrorIn
303             (
304                 "const edgeList& meshSurfaceEngine::edges() const"
305             ) << "Calculating addressing inside a parallel region."
306                 << " This is not thread safe" << exit(FatalError);
307         # endif
309         calculateEdgesAndAddressing();
310     }
312     return *edgesPtr_;
315 inline const VRWGraph& meshSurfaceEngine::boundaryPointEdges() const
317     if( !bpEdgesPtr_ )
318     {
319         # ifdef USE_OMP
320         if( omp_in_parallel() )
321             FatalErrorIn
322             (
323                 "const VRWGraph& meshSurfaceEngine::boundaryPointEdges() const"
324             ) << "Calculating addressing inside a parallel region."
325                 << " This is not thread safe" << exit(FatalError);
326         # endif
328         calculateEdgesAndAddressing();
329     }
331     return *bpEdgesPtr_;
334 inline const VRWGraph& meshSurfaceEngine::edgeFaces() const
336     if( !edgeFacesPtr_ )
337     {
338         # ifdef USE_OMP
339         if( omp_in_parallel() )
340             FatalErrorIn
341             (
342                 "const VRWGraph& meshSurfaceEngine::edgeFaces() const"
343             ) << "Calculating addressing inside a parallel region."
344                 << " This is not thread safe" << exit(FatalError);
345         # endif
347         calculateEdgeFacesAddressing();
348     }
350     return *edgeFacesPtr_;
353 inline const VRWGraph& meshSurfaceEngine::faceEdges() const
355     if( !faceEdgesPtr_ )
356     {
357         # ifdef USE_OMP
358         if( omp_in_parallel() )
359             FatalErrorIn
360             (
361                 "const VRWGraph& meshSurfaceEngine::faceEdges() const"
362             ) << "Calculating addressing inside a parallel region."
363                 << " This is not thread safe" << exit(FatalError);
364         # endif
366         calculateFaceEdgesAddressing();
367     }
369     return *faceEdgesPtr_;
372 inline const VRWGraph& meshSurfaceEngine::edgePatches() const
374     if( !edgePatchesPtr_ )
375     {
376         # ifdef USE_OMP
377         if( omp_in_parallel() )
378             FatalErrorIn
379             (
380                 "const VRWGraph& meshSurfaceEngine::edgePatches() const"
381             ) << "Calculating addressing inside a parallel region."
382                 << " This is not thread safe" << exit(FatalError);
383         # endif
385         calculateEdgePatchesAddressing();
386     }
388     return *edgePatchesPtr_;
391 inline const VRWGraph& meshSurfaceEngine::faceFaces() const
393     if( !faceFacesPtr_ )
394     {
395         # ifdef USE_OMP
396         if( omp_in_parallel() )
397             FatalErrorIn
398             (
399                 "const VRWGraph& meshSurfaceEngine::faceFaces() const"
400             ) << "Calculating addressing inside a parallel region."
401                 << " This is not thread safe" << exit(FatalError);
402         # endif
404         calculateFaceFacesAddressing();
405     }
407     return *faceFacesPtr_;
410 inline const labelList& meshSurfaceEngine::globalBoundaryPointLabel() const
412     if( !globalBoundaryPointLabelPtr_ )
413     {
414         # ifdef USE_OMP
415         if( omp_in_parallel() )
416             FatalErrorIn
417             (
418                 "const labelList&"
419                 " meshSurfaceEngine::globalBoundaryPointLabel() const"
420             ) << "Calculating addressing inside a parallel region."
421                 << " This is not thread safe" << exit(FatalError);
422         # endif
424         calcGlobalBoundaryPointLabels();
425     }
427     return *globalBoundaryPointLabelPtr_;
430 inline const Map<label>&
431 meshSurfaceEngine::globalToLocalBndPointAddressing() const
433     if( !globalBoundaryPointToLocalPtr_ )
434     {
435         # ifdef USE_OMP
436         if( omp_in_parallel() )
437             FatalErrorIn
438             (
439                 "const Map<label>&"
440                 " meshSurfaceEngine::globalToLocalBndPointAddressing() const"
441             ) << "Calculating addressing inside a parallel region."
442                 << " This is not thread safe" << exit(FatalError);
443         # endif
445         calcGlobalBoundaryPointLabels();
446     }
448     return *globalBoundaryPointToLocalPtr_;
451 inline const VRWGraph& meshSurfaceEngine::bpAtProcs() const
453     if( !globalBoundaryPointLabelPtr_ )
454     {
455         # ifdef USE_OMP
456         if( omp_in_parallel() )
457             FatalErrorIn
458             (
459                 "const VRWGraph& meshSurfaceEngine::bpAtProcs() const"
460             ) << "Calculating addressing inside a parallel region."
461                 << " This is not thread safe" << exit(FatalError);
462         # endif
464         calcGlobalBoundaryPointLabels();
465     }
467     return *bpProcsPtr_;
470 inline const DynList<label>& meshSurfaceEngine::bpNeiProcs() const
472     if( !bpNeiProcsPtr_ )
473     {
474         # ifdef USE_OMP
475         if( omp_in_parallel() )
476             FatalErrorIn
477             (
478                 "const DynList<label>& meshSurfaceEngine::bpNeiProcs() const"
479             ) << "Calculating addressing inside a parallel region."
480                 << " This is not thread safe" << exit(FatalError);
481         # endif
483         calcGlobalBoundaryPointLabels();
484     }
486     return *bpNeiProcsPtr_;
489 inline const labelList& meshSurfaceEngine::globalBoundaryEdgeLabel() const
491     if( !globalBoundaryEdgeLabelPtr_ )
492     {
493         # ifdef USE_OMP
494         if( omp_in_parallel() )
495             FatalErrorIn
496             (
497                 "const labelList&"
498                 " meshSurfaceEngine::globalBoundaryEdgeLabel() const"
499             ) << "Calculating addressing inside a parallel region."
500                 << " This is not thread safe" << exit(FatalError);
501         # endif
503         calcGlobalBoundaryEdgeLabels();
504     }
506     return *globalBoundaryEdgeLabelPtr_;
509 inline const Map<label>&
510 meshSurfaceEngine::globalToLocalBndEdgeAddressing() const
512     if( !globalBoundaryEdgeToLocalPtr_ )
513     {
514         # ifdef USE_OMP
515         if( omp_in_parallel() )
516             FatalErrorIn
517             (
518                 "const Map<label>&"
519                 " meshSurfaceEngine::globalToLocalBndEdgeAddressing() const"
520             ) << "Calculating addressing inside a parallel region."
521                 << " This is not thread safe" << exit(FatalError);
522         # endif
524         calcGlobalBoundaryEdgeLabels();
525     }
527     return *globalBoundaryEdgeToLocalPtr_;
530 inline const VRWGraph& meshSurfaceEngine::beAtProcs() const
532     if( !globalBoundaryEdgeLabelPtr_ )
533     {
534         # ifdef USE_OMP
535         if( omp_in_parallel() )
536             FatalErrorIn
537             (
538                 "const VRWGraph& meshSurfaceEngine::beAtProcs() const"
539             ) << "Calculating addressing inside a parallel region."
540                 << " This is not thread safe" << exit(FatalError);
541         # endif
543         calcGlobalBoundaryEdgeLabels();
544     }
546     return *beProcsPtr_;
549 inline const DynList<label>& meshSurfaceEngine::beNeiProcs() const
551     if( !beNeiProcsPtr_ )
552     {
553         # ifdef USE_OMP
554         if( omp_in_parallel() )
555             FatalErrorIn
556             (
557                 "const DynList<label>& meshSurfaceEngine::beNeiProcs() const"
558             ) << "Calculating addressing inside a parallel region."
559                 << " This is not thread safe" << exit(FatalError);
560         # endif
562         calcGlobalBoundaryEdgeLabels();
563     }
565     return *beNeiProcsPtr_;
568 inline const Map<label>& meshSurfaceEngine::otherEdgeFaceAtProc() const
570     if( !otherEdgeFaceAtProcPtr_ )
571     {
572         # ifdef USE_OMP
573         if( omp_in_parallel() )
574             FatalErrorIn
575             (
576                 "const Map<label>&"
577                 " meshSurfaceEngine::otherEdgeFaceAtProc() const"
578             ) << "Calculating addressing inside a parallel region."
579                 << " This is not thread safe" << exit(FatalError);
580         # endif
582         calcAddressingForProcEdges();
583     }
585     return *otherEdgeFaceAtProcPtr_;
588 inline const Map<label>& meshSurfaceEngine::otherEdgeFacePatch() const
590     if( !otherEdgeFacePatchPtr_ )
591     {
592         # ifdef USE_OMP
593         if( omp_in_parallel() )
594             FatalErrorIn
595             (
596                 "const Map<label>&"
597                 " meshSurfaceEngine::otherEdgeFacePatch() const"
598             ) << "Calculating addressing inside a parallel region."
599                 << " This is not thread safe" << exit(FatalError);
600         # endif
602         calcAddressingForProcEdges();
603     }
605     return *otherEdgeFacePatchPtr_;
608 inline const labelList& meshSurfaceEngine::globalBoundaryFaceLabel() const
610     if( !globalBoundaryFaceLabelPtr_ )
611     {
612         # ifdef USE_OMP
613         if( omp_in_parallel() )
614             FatalErrorIn
615             (
616                 "const labelList&"
617                 " meshSurfaceEngine::globalBoundaryFaceLabel() const"
618             ) << "Calculating addressing inside a parallel region."
619                 << " This is not thread safe" << exit(FatalError);
620         # endif
622         calcGlobalBoundaryFaceLabels();
623     }
625     return *globalBoundaryFaceLabelPtr_;
629 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 } // End namespace Foam
633 // ************************************************************************* //