1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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
25 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 void Foam::polyMesh::initMesh()
35 Info<< "void polyMesh::initMesh() : "
36 << "initialising primitiveMesh" << endl;
39 // For backward compatibility check if the neighbour array is the same
40 // length as the owner and shrink to remove the -1s padding
41 if (neighbour_.size() == owner_.size())
43 label nInternalFaces = 0;
45 forAll(neighbour_, faceI)
47 if (neighbour_[faceI] == -1)
57 neighbour_.setSize(nInternalFaces);
64 nCells = max(nCells, owner_[facei]);
67 // The neighbour array may or may not be the same length as the owner
68 forAll(neighbour_, facei)
70 nCells = max(nCells, neighbour_[facei]);
75 // Reset the primitiveMesh with the sizes of the primitive arrays
85 "nPoints:" + Foam::name(nPoints())
86 + " nCells:" + Foam::name(this->nCells())
87 + " nFaces:" + Foam::name(nFaces())
88 + " nInternalFaces:" + Foam::name(nInternalFaces());
90 owner_.note() = meshInfo;
91 neighbour_.note() = meshInfo;
95 void Foam::polyMesh::initMesh(cellList& c)
99 Info<< "void polyMesh::initMesh(cellList& c) : "
100 << "calculating owner-neighbour arrays" << endl;
103 owner_.setSize(faces_.size(), -1);
104 neighbour_.setSize(faces_.size(), -1);
106 boolList markedFaces(faces_.size(), false);
108 label nInternalFaces = 0;
112 // get reference to face labels for current cell
113 const labelList& cellfaces = c[cellI];
115 forAll (cellfaces, faceI)
117 if (!markedFaces[cellfaces[faceI]])
119 // First visit: owner
120 owner_[cellfaces[faceI]] = cellI;
121 markedFaces[cellfaces[faceI]] = true;
125 // Second visit: neighbour
126 neighbour_[cellfaces[faceI]] = cellI;
132 // The neighbour array is initialised with the same length as the owner
133 // padded with -1s and here it is truncated to the correct size of the
134 // number of internal faces.
135 neighbour_.setSize(nInternalFaces);
137 // Reset the primitiveMesh
148 "nPoints: " + Foam::name(nPoints())
149 + " nCells: " + Foam::name(nCells())
150 + " nFaces: " + Foam::name(nFaces())
151 + " nInternalFaces: " + Foam::name(this->nInternalFaces());
153 owner_.note() = meshInfo;
154 neighbour_.note() = meshInfo;
157 // ************************************************************************* //