1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 The insertion of edges in the edge list is dictated by the upper
27 triangular ordering. The current decomposition of a polyhedral cell into
28 tetrahedra requires insertion of face centres and cell centres. The points
29 are ordered in the following way:
30 1) points of the polyMesh (supporting polyhedral cells)
34 The algorithm for owner-neighbour insertion first adds all the points the
35 owner point shares the edge with (only the ones with the higher label than
36 the owner point), followed by the face centres of the pointFaces, followed
37 by the pointCells. This is because the face and the the cell centres are
38 guaranteed to have a higher index than the internal vertices.
41 It is assumed that the edges are constructed such that the start label
42 is lower than the end label and that pointFaces and pointCells lists are
46 \*---------------------------------------------------------------------------*/
48 #include "tetPolyMeshFaceDecomp.H"
49 #include "tetPointRef.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 const lduAddressing& tetPolyMeshFaceDecomp::lduAddr() const
62 lduPtr_ = new tetPolyMeshLduAddressingFaceDecomp(*this);
69 label tetPolyMeshFaceDecomp::maxNPointsForCell() const
71 if (maxNPointsForCell_ < 0)
73 const faceList& meshFaces = mesh_.faces();
74 const cellList& polyCells = mesh_.cells();
76 forAll (polyCells, cellI)
82 polyCells[cellI].labels(meshFaces).size()
83 + polyCells[cellI].size()
89 return maxNPointsForCell_;
93 // Fill buffer with addressing for the cell
94 label tetPolyMeshFaceDecomp::addressing
97 labelList& localToGlobalBuffer,
98 labelList& globalToLocalBuffer
101 const unallocFaceList& meshFaces = mesh_.faces();
103 const labelList& cellFaces = mesh_.cells()[cellID];
107 // First mark up the vertices
108 forAll (cellFaces, faceI)
110 const face& curFace = meshFaces[cellFaces[faceI]];
112 forAll (curFace, pointI)
114 // If the point has not been already inserted into the local
116 if (globalToLocalBuffer[curFace[pointI]] == -1)
118 localToGlobalBuffer[nextLocal] = curFace[pointI];
119 globalToLocalBuffer[curFace[pointI]] = nextLocal;
125 // Mark up face centres
126 forAll (cellFaces, faceI)
128 const label curFaceIndex = cellFaces[faceI] + faceOffset();
131 if (globalToLocalBuffer[curFaceIndex] == -1)
133 localToGlobalBuffer[nextLocal] = curFaceIndex;
134 globalToLocalBuffer[curFaceIndex] = nextLocal;
139 // Mark up the cell centre
140 localToGlobalBuffer[nextLocal] = cellOffset() + cellID;
141 globalToLocalBuffer[cellOffset() + cellID] = nextLocal;
144 // Return size of addressing
149 // Clear global to local addressing
150 void tetPolyMeshFaceDecomp::clearAddressing
153 const label nCellPoints,
154 labelList& localToGlobalBuffer,
155 labelList& globalToLocalBuffer
158 // Only clear the places that have been used. The rest of the buffer
159 // is already initiated to -1
160 for (label localI = 0; localI < nCellPoints; localI++)
162 globalToLocalBuffer[localToGlobalBuffer[localI]] = -1;
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // ************************************************************************* //