Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / surfaceTools / meshSurfaceEdgeExtractor / meshSurfaceEdgeExtractor.C
blob2ec7606baf15017e209e3893e335c9fa5e98e517
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 "meshSurfaceEdgeExtractor.H"
29 #include "demandDrivenData.H"
31 // #define DEBUGSearch
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 // Construct from mesh, octree, regions for boundary vertices
41 meshSurfaceEdgeExtractor::meshSurfaceEdgeExtractor
43     polyMeshGen& mesh,
44     const meshOctree& octree,
45     const labelList& pointRegion
48     mesh_(mesh),
49     nPoints_(mesh.points().size()),
50     boundaryCell_(mesh.cells().size(), false),
51     nFacesInCell_(mesh.cells().size(), direction(0)),
52     meshOctree_(octree),
53     pointRegions_(pointRegion.size())
55     forAll(pointRegion, pointI)
56         if( pointRegion[pointI] != -1 )
57             pointRegions_.append(pointI, pointRegion[pointI]);
59     createEdgeVertices();
61     removeOldBoundaryFaces();
63     createBoundaryFaces();
66 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
68 meshSurfaceEdgeExtractor::~meshSurfaceEdgeExtractor()
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 void meshSurfaceEdgeExtractor::removeOldBoundaryFaces()
76     const labelList neighbour_ = mesh_.neighbour();
77     polyMeshGenModifier meshModifier_(mesh_);
78     cellListPMG& cells_ = meshModifier_.cellsAccess();
80     forAll(cells_, cellI)
81     {
82         const cell& c = cells_[cellI];
84         cell newC(c);
86         forAll(c, fI)
87             if( neighbour_[c[fI]] != -1 )
88             {
89                 boundaryCell_[cellI] = true;
90                 newC[nFacesInCell_[cellI]++] = c[fI];
91             }
93         if( nFacesInCell_[cellI] < direction(c.size()) )
94         {
95             newC.setSize(nFacesInCell_[cellI]);
97             cells_[cellI] = newC;
98         };
99     }
101     PtrList<boundaryPatch>& boundaries = meshModifier_.boundariesAccess();
102     boundaries.setSize(1);
103     boundaries[0].patchSize() = 0;
104     meshModifier_.facesAccess().setSize(boundaries[0].patchStart());
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 } // End namespace Foam
111 // ************************************************************************* //