1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
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
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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "meshSurfaceMapper2D.H"
29 #include "meshSurfaceEngine.H"
30 #include "meshSurfacePartitioner.H"
31 #include "polyMeshGen2DEngine.H"
33 #include "triSurfacePartitioner.H"
34 #include "demandDrivenData.H"
35 #include "meshOctree.H"
36 #include "helperFunctions.H"
38 // #define DEBUGSearch
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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)
61 if( edgeFaces.sizeOfRow(edgeI) == 2 )
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);
71 if( Pstream::parRun() )
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;
81 exchangeData[neiProcs[i]].clear();
83 forAllConstIter(Map<label>, globalToLocal, it)
85 const label beI = it();
87 if( activeFace[startFace + edgeFaces(beI, 0)] )
89 exchangeData[otherProc[beI]].append(it.key());
93 labelLongList receivedData;
94 help::exchangeMap(exchangeData, receivedData);
96 forAll(receivedData, i)
98 const label beI = globalToLocal[receivedData[i]];
100 if( activeFace[startFace + edgeFaces(beI, 0)] )
101 activeBoundaryEdges_.append(beI);
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
139 mesh2DEnginePtr_(NULL),
140 surfPartitionerPtr_(NULL),
141 meshPartitionerPtr_(NULL)
143 if( Pstream::parRun() )
145 //- allocate bpAtProcs and other addressing
146 //- this is done here to prevent possible deadlocks
147 surfaceEngine_.bpAtProcs();
150 findActiveBoundaryEdges();
152 createMeshSurfacePartitioner();
155 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
157 meshSurfaceMapper2D::~meshSurfaceMapper2D()
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 } // End namespace Foam
166 // ************************************************************************* //