Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / surfaceTools / meshSurfaceMapper2D / meshSurfaceMapper2D.C
blob8358ab61779f8365badd368c0f74dcf4e198d168
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 "meshSurfaceMapper2D.H"
29 #include "meshSurfaceEngine.H"
30 #include "meshSurfacePartitioner.H"
31 #include "polyMeshGen2DEngine.H"
32 #include "triSurf.H"
33 #include "triSurfacePartitioner.H"
34 #include "demandDrivenData.H"
35 #include "meshOctree.H"
36 #include "helperFunctions.H"
38 // #define DEBUGSearch
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 void meshSurfaceMapper2D::findActiveBoundaryEdges()
49     const VRWGraph& edgeFaces = surfaceEngine_.edgeFaces();
51     const polyMeshGen2DEngine& mesh2DEngine = this->mesh2DEngine();
52     const boolList& activeFace = mesh2DEngine.activeFace();
54     const label startFace = surfaceEngine_.mesh().boundaries()[0].patchStart();
56     activeBoundaryEdges_.clear();
58     //- check which edges are at the boundary
59     forAll(edgeFaces, edgeI)
60     {
61         if( edgeFaces.sizeOfRow(edgeI) == 2 )
62         {
63             const bool active0 = activeFace[startFace + edgeFaces(edgeI, 0)];
64             const bool active1 = activeFace[startFace + edgeFaces(edgeI, 1)];
66             if( active0 && active1 )
67                 activeBoundaryEdges_.append(edgeI);
68         }
69     }
71     if( Pstream::parRun() )
72     {
73         const Map<label>& globalToLocal =
74             surfaceEngine_.globalToLocalBndEdgeAddressing();
75         const Map<label>& otherProc = surfaceEngine_.otherEdgeFaceAtProc();
77         const DynList<label>& neiProcs = surfaceEngine_.beNeiProcs();
79         std::map<label, labelLongList> exchangeData;
80         forAll(neiProcs, i)
81                 exchangeData[neiProcs[i]].clear();
83         forAllConstIter(Map<label>, globalToLocal, it)
84         {
85             const label beI = it();
87             if( activeFace[startFace + edgeFaces(beI, 0)] )
88             {
89                 exchangeData[otherProc[beI]].append(it.key());
90             }
91         }
93         labelLongList receivedData;
94         help::exchangeMap(exchangeData, receivedData);
96         forAll(receivedData, i)
97         {
98             const label beI = globalToLocal[receivedData[i]];
100             if( activeFace[startFace + edgeFaces(beI, 0)] )
101                 activeBoundaryEdges_.append(beI);
102         }
103     }
106 void meshSurfaceMapper2D::create2DEngine() const
108     polyMeshGen& mesh = const_cast<polyMeshGen&>(surfaceEngine_.mesh());
109     mesh2DEnginePtr_ = new polyMeshGen2DEngine(mesh);
112 void meshSurfaceMapper2D::createTriSurfacePartitioner() const
114     surfPartitionerPtr_ = new triSurfacePartitioner(meshOctree_.surface());
117 void meshSurfaceMapper2D::createMeshSurfacePartitioner() const
119     meshPartitionerPtr_ = new meshSurfacePartitioner(surfaceEngine_);
122 void meshSurfaceMapper2D::clearOut()
124     deleteDemandDrivenData(mesh2DEnginePtr_);
125     deleteDemandDrivenData(surfPartitionerPtr_);
126     deleteDemandDrivenData(meshPartitionerPtr_);
129 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
131 meshSurfaceMapper2D::meshSurfaceMapper2D
133     const meshSurfaceEngine& mse,
134     const meshOctree& octree
137     surfaceEngine_(mse),
138     meshOctree_(octree),
139     mesh2DEnginePtr_(NULL),
140     surfPartitionerPtr_(NULL),
141     meshPartitionerPtr_(NULL)
143     if( Pstream::parRun() )
144     {
145         //- allocate bpAtProcs and other addressing
146         //- this is done here to prevent possible deadlocks
147         surfaceEngine_.bpAtProcs();
148     }
150     findActiveBoundaryEdges();
152     createMeshSurfacePartitioner();
155 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
157 meshSurfaceMapper2D::~meshSurfaceMapper2D()
159     clearOut();
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 } // End namespace Foam
166 // ************************************************************************* //