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 cell centres. The points
29 are ordered in the following way:
30 1) points of the polyMesh (supporting polyhedral cells)
33 The algorithm for owner-neighbour insertion first adds all the
34 points the owner point shares the edge with (only the ones with
35 the higher label than the owner point), followed by the
36 pointCells. This is because 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
41 label is lower than the end label and that the pointCells list are
44 \*---------------------------------------------------------------------------*/
46 #include "tetPolyMeshCellDecomp.H"
47 #include "tetPolyMeshLduAddressingCellDecomp.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 const lduAddressing& tetPolyMeshCellDecomp::lduAddr() const
60 lduPtr_ = new tetPolyMeshLduAddressingCellDecomp(*this);;
67 label tetPolyMeshCellDecomp::maxNPointsForCell() const
69 if (maxNPointsForCell_ < 0)
71 const faceList& faces = mesh_.faces();
72 const cellList& polyCells = mesh_.cells();
74 forAll (polyCells, cellI)
80 polyCells[cellI].labels(faces).size() + 1
85 return maxNPointsForCell_;
89 // Fill buffer with addressing for the cell
90 label tetPolyMeshCellDecomp::addressing
93 labelList& localToGlobalBuffer,
94 labelList& globalToLocalBuffer
97 const unallocFaceList& meshFaces = mesh_.faces();
99 const labelList& cellFaces = mesh_.cells()[cellID];
103 forAll (cellFaces, faceI)
105 const face& curFace = meshFaces[cellFaces[faceI]];
107 forAll (curFace, pointI)
109 // If the point has not been already inserted into the local
111 if (globalToLocalBuffer[curFace[pointI]] == -1)
113 localToGlobalBuffer[nextLocal] = curFace[pointI];
114 globalToLocalBuffer[curFace[pointI]] = nextLocal;
120 // Mark up the cell centre
121 localToGlobalBuffer[nextLocal] = cellOffset() + cellID;
122 globalToLocalBuffer[cellOffset() + cellID] = nextLocal;
125 // Return size of addressing
130 // Clear global to local addressing
131 void tetPolyMeshCellDecomp::clearAddressing
134 const label nCellPoints,
135 labelList& localToGlobalBuffer,
136 labelList& globalToLocalBuffer
139 // Only clear the places that have been used. The rest of the buffer
140 // is already initiated to -1
141 for (label localI = 0; localI < nCellPoints; localI++)
143 globalToLocalBuffer[localToGlobalBuffer[localI]] = -1;
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 } // End namespace Foam
152 // ************************************************************************* //