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 / createFundamentalSheets / createFundamentalSheetsFJ / createFundamentalSheetsFJ.C
blob35dbda5f0a48f6caf6e732515c6715e18de978b9
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 "createFundamentalSheetsFJ.H"
29 #include "demandDrivenData.H"
30 #include "meshSurfaceEngine.H"
31 #include "extrudeLayer.H"
33 #include "addToRunTimeSelectionTable.H"
35 # ifdef USE_OMP
36 #include <omp.h>
37 # endif
39 // #define DEBUGSearch
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 defineTypeNameAndDebug(createFundamentalSheetsFJ, 0);
49 addToRunTimeSelectionTable
51     createFundamentalSheets,
52     createFundamentalSheetsFJ,
53     polyMeshGen
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 void createFundamentalSheetsFJ::createInitialSheet()
60     if( !createWrapperSheet_ )
61         return;
63     const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
65     const label start = boundaries[0].patchStart();
66     const label end
67     (
68         boundaries[boundaries.size()-1].patchStart() +
69         boundaries[boundaries.size()-1].patchSize()
70     );
72     faceListPMG::subList bFaces(mesh_.faces(), end-start, start);
74     const labelList& owner = mesh_.owner();
76     LongList<labelPair> extrudeFaces(end-start);
78     # ifdef USE_OMP
79     # pragma omp parallel for
80     # endif
81     for(label faceI=start;faceI<end;++faceI)
82         extrudeFaces[faceI-start] = labelPair(faceI, owner[faceI]);
84     extrudeLayer(mesh_, extrudeFaces);
87 void createFundamentalSheetsFJ::createSheetsAtFeatureEdges()
89     const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
91     forAll(boundaries, patchI)
92     {
93         const cellListPMG& cells = mesh_.cells();
94         boolList patchCell(cells.size(), false);
96         const labelList& owner = mesh_.owner();
97         const labelList& neighbour = mesh_.neighbour();
99         const label start = boundaries[patchI].patchStart();
100         const label end = start + boundaries[patchI].patchSize();
102         for(label faceI=start;faceI<end;++faceI)
103             patchCell[owner[faceI]] = true;
105         LongList<labelPair> front;
107         for(label faceI=start;faceI<end;++faceI)
108         {
109             const cell& c = cells[owner[faceI]];
111             forAll(c, fI)
112             {
113                 if( neighbour[c[fI]] < 0 )
114                     continue;
116                 label nei = owner[c[fI]];
117                 if( nei == owner[faceI] )
118                     nei = neighbour[c[fI]];
120                 if( !patchCell[nei] )
121                     front.append(labelPair(c[fI], nei));
122             }
123         }
125         extrudeLayer(mesh_, front);
126     }
127 //     const cellListPMG& cells = mesh_.cells();
128 //     const labelList& owner = mesh_.owner();
129 //     const labelList& neighbour = mesh_.neighbour();
131 //     const label start = boundaries[0].patchStart();
132 //     const label end
133 //     (
134 //         boundaries[boundaries.size()-1].patchStart() +
135 //         boundaries[boundaries.size()-1].patchSize()
136 //     );
138 //     faceListPMG::subList bFaces(mesh_.faces(), end-start, start);
140 //     labelList patchCell(mesh_.cells().size());
142 //     LongList<labelPair> front;
144 //     const label nThreads = 2 * omp_get_num_procs();
145 //     # pragma omp parallel num_threads(nThreads)
146 //     {
147 //         # pragma omp for
148 //         forAll(patchCell, cellI)
149 //             patchCell[cellI] = -1;
151 //         # pragma omp barrier
153 //         # pragma omp for
154 //         for(label faceI=start;faceI<end;++faceI)
155 //             patchCell[owner[faceI]] = mesh_.faceIsInPatch(faceI);
157 //         //- create the front faces
158 //         LongList<labelPair> localFront;
160 //         # pragma omp for
161 //         for(label faceI=start;faceI<end;++faceI)
162 //         {
163 //             const cell& c = cells[owner[faceI]];
164 //             const label patchI = mesh_.faceIsInPatch(faceI);
166 //             forAll(c, fI)
167 //             {
168 //                 if( neighbour[c[fI]] < 0 )
169 //                     continue;
171 //                 label nei = owner[c[fI]];
172 //                 if( nei == owner[faceI] )
173 //                     nei = neighbour[c[fI]];
175 //                 if( patchCell[nei] != patchI )
176 //                     localFront.append(labelPair(c[fI], nei));
177 //             }
178 //         }
180 //         label frontStart(-1);
181 //         # pragma omp critical
182 //         {
183 //             frontStart = front.size();
184 //             front.setSize(front.size()+localFront.size());
185 //         }
187 //         # pragma omp barrier
189 //         //- copy the local front into the global front
190 //         forAll(localFront, lfI)
191 //             front[frontStart+lfI] = localFront[lfI];
192 //     }
194 //     //- extrude the layer
195 //     extrudeLayer(mesh_, front);
198 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
200 // Construct from mesh, octree, regions for boundary vertices
201 createFundamentalSheetsFJ::createFundamentalSheetsFJ
203     polyMeshGen& mesh,
204     const bool createWrapperSheet
207     createFundamentalSheets(mesh, createWrapperSheet)
209     createInitialSheet();
211     createSheetsAtFeatureEdges();
214 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
216 createFundamentalSheetsFJ::~createFundamentalSheetsFJ()
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 } // End namespace Foam
223 // ************************************************************************* //