Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / tetFiniteElement / tetPolyMesh / tetPolyMeshLduAddressing.C
blob38a1643663fc335b2584e7522dfe626da36f36f0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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/>.
24 Class
25     tetPolyMeshLduAddressing
27 Description
29 Author
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;
59     label curOwner = 0;
60     label edgeI = 0;
62     // Loop through all points
63     forAll (pointFaces, pointI)
64     {
65         // Add the point neighbours
67         // The edge construction is such that the end label (neighbour)
68         // is higher than the start label (owner)
69         while
70         (
71             edgeI < meshEdges.size()
72          && meshEdges[edgeI].start() == pointI
73         )
74         {
75             lowerAddr_[nCreatedEdges] = curOwner;
76             upperAddr_[nCreatedEdges] = meshEdges[edgeI].end();
77             nCreatedEdges++;
79             edgeI++;
80         }
82         // Add the face neighbours
84         // Get the sorted list of pointFaces
85         const labelList& curPointFaces = pointFaces[pointI];
87         forAll (curPointFaces, faceI)
88         {
89             // add as neighbour
90             lowerAddr_[nCreatedEdges] = curOwner;
91             upperAddr_[nCreatedEdges] =
92                 mesh.faceOffset() + curPointFaces[faceI];
93             nCreatedEdges++;
94         }
96         // Add the cell neighbours
98         // Get the list of sorted pointCells
99         const labelList& curPointCells = pointCells[pointI];
101         forAll (curPointCells, cellI)
102         {
103             // Add as neighbour
104             lowerAddr_[nCreatedEdges] = curOwner;
105             upperAddr_[nCreatedEdges] =
106                 mesh.cellOffset() + curPointCells[cellI];
107             nCreatedEdges++;
108         }
110         // Increment the current owner node
111         curOwner++;
112     }
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)
119     {
120         // Add owner cell centre
121         lowerAddr_[nCreatedEdges] = curOwner;
123         upperAddr_[nCreatedEdges] = mesh.cellOffset() + meshOwner[faceI];
125         nCreatedEdges++;
127         // Inelegant. Change.
128         if (faceI < meshNeighbour.size())
129         {
130             // Add neighbour cell centre
131             lowerAddr_[nCreatedEdges] = curOwner;
132             upperAddr_[nCreatedEdges] =
133                 mesh.cellOffset() + meshNeighbour[faceI];
134             nCreatedEdges++;
135         }
137         curOwner++;
138     }
140     // Add dummy boundary addressing
141     forAll (patchAddr_, patchI)
142     {
143         patchAddr_[patchI].setSize(0);
144     }
146     if (nCreatedEdges != mesh.nEdges())
147     {
148         FatalErrorIn
149         (
150             "tetPolyMeshLduAddressing::"
151             "tetPolyMeshLduAddressing\n"
152             "(\n"
153             "    const tetPolyMesh& mesh\n"
154             ")"
155         )   << "Problem with edge counting in lduAddressing.  nCreatedEdges: "
156             << nCreatedEdges << " nEdges: " << mesh.nEdges()
157             << abort(FatalError);
158     }
162 // ************************************************************************* //