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 The insertion of edges in the edge list is dictated by the upper
26 triangular ordering. The current decomposition of a polyhedral cell into
27 tetrahedra requires insertion of face centres and cell centres. The points
28 are ordered in the following way:
29 1) points of the polyMesh (supporting polyhedral cells)
33 The algorithm for owner-neighbour insertion first adds all the points the
34 owner point shares the edge with (only the ones with the higher label than
35 the owner point), followed by the face centres of the pointFaces, followed
36 by the pointCells. This is because the face and the the cell centres are
37 guaranteed to have a higher index than the internal vertices.
40 It is assumed that the edges are constructed such that the start label
41 is lower than the end label and that pointFaces and pointCells lists are
45 \*---------------------------------------------------------------------------*/
47 #include "tetPolyMesh.H"
48 #include "tetPointRef.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 const lduAddressing& tetPolyMesh::lduAddr() const
61 lduPtr_ = new tetPolyMeshLduAddressing(*this);
68 label tetPolyMesh::maxNPointsForCell() const
70 if (maxNPointsForCell_ < 0)
72 const faceList& meshFaces = mesh_.faces();
73 const cellList& polyCells = mesh_.cells();
75 forAll (polyCells, cellI)
81 polyCells[cellI].labels(meshFaces).size()
82 + polyCells[cellI].size()
88 return maxNPointsForCell_;
92 // Fill buffer with addressing for the cell
93 label tetPolyMesh::addressing
96 labelList& localToGlobalBuffer,
97 labelList& globalToLocalBuffer
100 const unallocFaceList& meshFaces = mesh_.faces();
102 const labelList& cellFaces = mesh_.cells()[cellID];
106 // First mark up the vertices
107 forAll (cellFaces, faceI)
109 const face& curFace = meshFaces[cellFaces[faceI]];
111 forAll (curFace, pointI)
113 // If the point has not been already inserted into the local
115 if (globalToLocalBuffer[curFace[pointI]] == -1)
117 localToGlobalBuffer[nextLocal] = curFace[pointI];
118 globalToLocalBuffer[curFace[pointI]] = nextLocal;
124 // Mark up face centres
125 forAll (cellFaces, faceI)
127 const label curFaceIndex = cellFaces[faceI] + faceOffset();
130 if (globalToLocalBuffer[curFaceIndex] == -1)
132 localToGlobalBuffer[nextLocal] = curFaceIndex;
133 globalToLocalBuffer[curFaceIndex] = nextLocal;
138 // Mark up the cell centre
139 localToGlobalBuffer[nextLocal] = cellOffset() + cellID;
140 globalToLocalBuffer[cellOffset() + cellID] = nextLocal;
143 // Return size of addressing
148 // Clear global to local addressing
149 void tetPolyMesh::clearAddressing
152 const label nCellPoints,
153 labelList& localToGlobalBuffer,
154 labelList& globalToLocalBuffer
157 // Only clear the places that have been used. The rest of the buffer
158 // is already initiated to -1
159 for (label localI = 0; localI < nCellPoints; localI++)
161 globalToLocalBuffer[localToGlobalBuffer[localI]] = -1;
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 } // End namespace Foam
170 // ************************************************************************* //