Moving cfMesh into place. Updated contibutors list
[foam-extend-3.2.git] / src / mesh / cfMesh / meshLibrary / utilities / triSurfaceTools / triSurfacePatchManipulator / triSurfacePatchManipulatorFunctions.C
blob3cc65a00579282196a6b30a30597a4e6fec9cf6a
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 "triSurfacePatchManipulator.H"
29 #include "helperFunctions.H"
30 #include "demandDrivenData.H"
32 # ifdef USE_OMP
33 #include <omp.h>
34 # endif
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 namespace Foam
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void triSurfacePatchManipulator::allocateFeatureEdges()
45     const edgeLongList& edges = surf_.edges();
46     const VRWGraph& pEdges = surf_.pointEdges();
48     //- allocate featureEdges list
49     featureEdges_.setSize(edges.size());
50     featureEdges_ = direction(0);
52     const edgeLongList& featureEdges = surf_.featureEdges();
54     forAll(featureEdges, feI)
55     {
56         const edge& e = featureEdges[feI];
58         forAllRow(pEdges, e.start(), peI)
59         {
60             const label eI = pEdges(e.start(), peI);
62             if( edges[eI] == e )
63                 featureEdges_[eI] |= 1;
64         }
65     }
68 void triSurfacePatchManipulator::createPatches()
70     nPatches_ = 0;
71     facetInPatch_.setSize(surf_.size());
72     facetInPatch_ = -1;
74     const VRWGraph& faceEdges = surf_.facetEdges();
75     const VRWGraph& edgeFaces = surf_.edgeFacets();
77     forAll(facetInPatch_, triI)
78     {
79         if( facetInPatch_[triI] != -1 )
80             continue;
82         labelLongList front;
83         front.append(triI);
84         facetInPatch_[triI] = nPatches_;
86         while( front.size() )
87         {
88             const label fLabel = front.removeLastElement();
90             const constRow fEdges = faceEdges[fLabel];
92             forAll(fEdges, feI)
93             {
94                 const label edgeI = fEdges[feI];
96                 //- check if th edges is marked as a feature edge
97                 if( featureEdges_[edgeI] )
98                     continue;
100                 const constRow eFaces = edgeFaces[edgeI];
102                 //- stop at non-manifold edges
103                 if( eFaces.size() != 2 )
104                     continue;
106                 label neiTri = eFaces[0];
107                 if( neiTri == fLabel )
108                     neiTri = eFaces[1];
110                 //- do not overwrite existing patch information
111                 if( surf_[fLabel].region() != surf_[neiTri].region() )
112                     continue;
113                 if( facetInPatch_[neiTri] != -1 )
114                     continue;
116                 facetInPatch_[neiTri] = nPatches_;
117                 front.append(neiTri);
118             }
119         }
121         ++nPatches_;
122     }
124     Info << "Created " << nPatches_ << " surface patches" << endl;
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 } // End namespace Foam
131 // ************************************************************************* //