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/>.
25 tetPolyMeshLduAddressing
30 Hrvoje Jasak. All rights reserved.
32 \*---------------------------------------------------------------------------*/
34 #include "tetPolyMeshLduAddressing.H"
35 #include "globalMeshData.H"
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 Foam::tetPolyMeshLduAddressing::tetPolyMeshLduAddressing
41 const tetPolyMesh& mesh
44 lduAddressing(mesh.nPoints()),
45 lowerAddr_(mesh.nEdges(), -1),
46 upperAddr_(mesh.nEdges(), -1),
47 patchAddr_(mesh.boundary().size()),
48 patchSchedule_(mesh.globalData().patchSchedule())
50 // Get reference to edges
51 const edgeList& meshEdges = mesh().edges();
53 // Get references to pointFaces and pointCells
54 const labelListList& pointFaces = mesh().pointFaces();
55 const labelListList& pointCells = mesh().pointCells();
57 // Loop through all points
58 label nCreatedEdges = 0;
62 // Loop through all points
63 forAll (pointFaces, pointI)
65 // Add the point neighbours
67 // The edge construction is such that the end label (neighbour)
68 // is higher than the start label (owner)
71 edgeI < meshEdges.size()
72 && meshEdges[edgeI].start() == pointI
75 lowerAddr_[nCreatedEdges] = curOwner;
76 upperAddr_[nCreatedEdges] = meshEdges[edgeI].end();
82 // Add the face neighbours
84 // Get the sorted list of pointFaces
85 const labelList& curPointFaces = pointFaces[pointI];
87 forAll (curPointFaces, faceI)
90 lowerAddr_[nCreatedEdges] = curOwner;
91 upperAddr_[nCreatedEdges] =
92 mesh.faceOffset() + curPointFaces[faceI];
96 // Add the cell neighbours
98 // Get the list of sorted pointCells
99 const labelList& curPointCells = pointCells[pointI];
101 forAll (curPointCells, cellI)
104 lowerAddr_[nCreatedEdges] = curOwner;
105 upperAddr_[nCreatedEdges] =
106 mesh.cellOffset() + curPointCells[cellI];
110 // Increment the current owner node
114 // Loop through all internal faces and add owner and neighbour of the face
115 const unallocLabelList& meshOwner = mesh().faceOwner();
116 const unallocLabelList& meshNeighbour = mesh().faceNeighbour();
118 forAll (meshOwner, faceI)
120 // Add owner cell centre
121 lowerAddr_[nCreatedEdges] = curOwner;
123 upperAddr_[nCreatedEdges] = mesh.cellOffset() + meshOwner[faceI];
127 // Inelegant. Change.
128 if (faceI < meshNeighbour.size())
130 // Add neighbour cell centre
131 lowerAddr_[nCreatedEdges] = curOwner;
132 upperAddr_[nCreatedEdges] =
133 mesh.cellOffset() + meshNeighbour[faceI];
140 // Add dummy boundary addressing
141 forAll (patchAddr_, patchI)
143 patchAddr_[patchI].setSize(0);
146 if (nCreatedEdges != mesh.nEdges())
150 "tetPolyMeshLduAddressing::"
151 "tetPolyMeshLduAddressing\n"
153 " const tetPolyMesh& mesh\n"
155 ) << "Problem with edge counting in lduAddressing. nCreatedEdges: "
156 << nCreatedEdges << " nEdges: " << mesh.nEdges()
157 << abort(FatalError);
162 // ************************************************************************* //