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 "voronoiMeshExtractor.H"
29 #include "demandDrivenData.H"
35 //#define DEBUGVoronoi
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 void voronoiMeshExtractor::createAddressing() const
46 if( pointEdgesPtr_ || edgeTetsPtr_ || boundaryEdgePtr_ || edgesPtr_ )
49 pointEdgesPtr_ = new VRWGraph(tetCreator_.tetPoints().size());
50 VRWGraph& pointEdges = *pointEdgesPtr_;
52 edgeTetsPtr_ = new VRWGraph();
53 VRWGraph& edgeTets = *edgeTetsPtr_;
55 boundaryEdgePtr_ = new boolList();
56 boolList& boundaryEdges = *boundaryEdgePtr_;
58 edgesPtr_ = new LongList<edge>();
59 LongList<edge>& edges = *edgesPtr_;
61 //- create edges and edgeTets
62 const LongList<partTet>& tets = tetCreator_.tets();
65 pointTets.reverseAddressing(tets);
69 const FixedList<edge, 6> tetEdges = tets[tetI].edges();
73 const edge& e = tetEdges[eI];
74 const label start = e.start();
76 const row endTets = pointTets[e.end()];
81 forAllRow(pointTets, start, ptI)
83 const label tetJ = pointTets(start, ptI);
85 if( !endTets.contains(tetJ) )
99 edgeTets.appendList(eTets);
107 Info << "Edge tets " << edgeTets << endl;
110 //- calculate point-edges addressing
111 pointEdges.reverseAddressing(edges);
113 //- sort edge-tets in circular order
114 boundaryEdges.setSize(edgeTets.size());
115 boundaryEdges = false;
118 # pragma omp parallel for schedule(dynamic, 100)
120 forAll(edgeTets, edgeI)
122 const edge& e = edges[edgeI];
123 row eTets = edgeTets[edgeI];
126 Info << "Edge " << edgeI << " has points " << e << endl;
131 const partTet& pt = tets[eTets[tetI]];
134 Info << "Checking tet " << eTets[tetI] << " points " << pt << endl;
137 //- find the face shared with the neighbour
138 const FixedList<edge, 6> tetEdges = pt.edges();
140 label searchPoint(-1);
143 if( tetEdges[eI] == e )
145 if( tetEdges[eI].start() == e.start() )
147 searchPoint = pt[sameOrientation_[eI]];
151 searchPoint = pt[oppositeOrientation_[eI]];
158 if( searchPoint < 0 )
161 "void voronoiMeshExtractor::createAddressing() const"
162 ) << " invalid search point " << abort(FatalError);
170 const partTet& ptNei = tets[eTets[i]];
172 const label pos = ptNei.whichPosition(searchPoint);
177 if( tetI < eTets.size()-1 )
179 const label add = eTets[tetI+1];
180 eTets[tetI+1] = eTets[i];
188 boundaryEdges[edgeI] = true;
193 const VRWGraph& voronoiMeshExtractor::pointEdges() const
195 if( !pointEdgesPtr_ )
198 return *pointEdgesPtr_;
201 const LongList<edge>& voronoiMeshExtractor::edges() const
209 const VRWGraph& voronoiMeshExtractor::edgeTets() const
214 return *edgeTetsPtr_;
217 const boolList& voronoiMeshExtractor::boundaryEdge() const
219 if( !boundaryEdgePtr_ )
222 return *boundaryEdgePtr_;
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 } // End namespace Foam
229 // ************************************************************************* //