1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
26 Demand-driven edge mesh data
28 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 //- Calculate ordered edges
40 void eMesh::calcOrderedEdgeList()
44 Info<< "void eMesh::calcOrderedEdges() const : "
45 << "Calculating ordered edges" << endl;
48 if (edges_.size() || boundary_.size())
52 "void eMesh::calcOrderedEdges() const"
53 ) << "Ordered edges already allocated."
58 nEdges_ = mesh_.nEdges();
60 boundary_.setSize(mesh_.boundaryMesh().size());
62 // Allocate lists for re-ordering
63 labelList edgePatch(nEdges_, -1);
64 labelList edgePatchStarts(mesh_.boundaryMesh().size(), -1);
65 labelList edgePatchSizes(mesh_.boundaryMesh().size(), 0);
67 reverseEdgeMap_.setSize(nEdges_);
69 // Obtain connectivity from primitive mesh
70 const edgeList& edges = mesh_.edges();
71 const labelListList& fEdges = mesh_.faceEdges();
73 // Edge-patches are the same as faces
74 for (label i = mesh_.nInternalFaces(); i < mesh_.nFaces(); i++)
76 const labelList& fEdge = fEdges[i];
80 edgePatch[fEdge[edgeI]] = mesh_.boundaryMesh().whichPatch(i);
84 // Loop through edgePatch and renumber internal edges
85 forAll(edgePatch, edgeI)
87 if (edgePatch[edgeI] == -1)
89 reverseEdgeMap_[edgeI] = nInternalEdges_++;
93 edgePatchSizes[edgePatch[edgeI]]++;
97 // Calculate patch-starts
98 label startCount = nInternalEdges_;
100 forAll(edgePatchStarts, patchI)
102 edgePatchStarts[patchI] = startCount;
103 startCount += edgePatchSizes[patchI];
106 // Now renumber boundary edges
107 labelList patchCount(edgePatchStarts);
109 forAll(edgePatch, edgeI)
111 if (edgePatch[edgeI] > -1)
113 reverseEdgeMap_[edgeI] = patchCount[edgePatch[edgeI]]++;
117 // Renumber and fill in edges
118 edges_.setSize(nEdges_, edge(-1,-1));
122 edges_[reverseEdgeMap_[edgeI]] = edges[edgeI];
125 // Now set the boundary, copy name. (type is default)
126 forAll(boundary_, patchI)
134 mesh_.boundaryMesh()[patchI].name(),
135 edgePatchSizes[patchI],
136 edgePatchStarts[patchI],
143 // Force calculation of other data...
149 void eMesh::calcFaceEdges() const
153 Info<< "void eMesh::calcFaceEdges() const : "
154 << "Calculating FaceEdges" << endl;
161 "void eMesh::calcFaceEdges() const"
162 ) << "fePtr_ already allocated"
163 << abort(FatalError);
173 mesh_.facesInstance(),
176 IOobject::READ_IF_PRESENT,
183 labelListIOList& faceEdges = *fePtr_;
185 // If the read was successful, return.
186 if (faceEdges.headerOk())
191 // If edgeFaces exists, use that.
194 invertManyToMany(mesh_.nFaces(), edgeFaces(), faceEdges);
200 "void eMesh::calcFaceEdges() const"
201 ) << "Cannot calculate faceEdges."
202 << abort(FatalError);
206 void eMesh::calcEdgeFaces() const
210 Info<< "void eMesh::calcEdgeFaces() const : "
211 << "Calculating EdgeFaces" << endl;
218 "void eMesh::calcEdgeFaces() const"
219 ) << "efPtr_ already allocated."
220 << abort(FatalError);
230 mesh_.facesInstance(),
233 IOobject::READ_IF_PRESENT,
240 labelListIOList& edgeFaces = *efPtr_;
242 // If the read was successful, return.
243 if (edgeFaces.headerOk())
250 // If faceEdges exists, use that.
251 invertManyToMany(nEdges_, faceEdges(), edgeFaces);
255 // Obtain connectivity from primitive mesh.
256 if (!reverseEdgeMap_.size())
260 "void eMesh::calcEdgeFaces() const"
261 ) << "reverseEdgeMap has not been allocated."
262 << abort(FatalError);
265 const labelListList& eFaces = mesh_.edgeFaces();
267 forAll(eFaces, edgeI)
269 edgeFaces[reverseEdgeMap_[edgeI]] = eFaces[edgeI];
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 } // End namespace Foam
279 // ************************************************************************* //