initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyMeshInitMesh.C
blobe364c63f2f1d97aafece5177be7bf6cacf06bb39
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "polyMesh.H"
29 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
31 void Foam::polyMesh::initMesh()
33     if (debug)
34     {
35         Info<< "void polyMesh::initMesh() : "
36             << "initialising primitiveMesh" << endl;
37     }
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())
42     {
43         label nInternalFaces = 0;
45         forAll(neighbour_, faceI)
46         {
47             if (neighbour_[faceI] == -1)
48             {
49                 break;
50             }
51             else
52             {
53                 nInternalFaces++;
54             }
55         }
57         neighbour_.setSize(nInternalFaces);
58     }
60     label nCells = -1;
62     forAll(owner_, facei)
63     {
64         nCells = max(nCells, owner_[facei]);
65     }
67     // The neighbour array may or may not be the same length as the owner
68     forAll(neighbour_, facei)
69     {
70         nCells = max(nCells, neighbour_[facei]);
71     }
73     nCells++;
75     // Reset the primitiveMesh with the sizes of the primitive arrays
76     primitiveMesh::reset
77     (
78         points_.size(),
79         neighbour_.size(),
80         owner_.size(),
81         nCells
82     );
84     string meshInfo =
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)
97     if (debug)
98     {
99         Info<< "void polyMesh::initMesh(cellList& c) : "
100             << "calculating owner-neighbour arrays" << endl;
101     }
103     owner_.setSize(faces_.size(), -1);
104     neighbour_.setSize(faces_.size(), -1);
106     boolList markedFaces(faces_.size(), false);
108     label nInternalFaces = 0;
110     forAll(c, cellI)
111     {
112         // get reference to face labels for current cell
113         const labelList& cellfaces = c[cellI];
115         forAll (cellfaces, faceI)
116         {
117             if (!markedFaces[cellfaces[faceI]])
118             {
119                 // First visit: owner
120                 owner_[cellfaces[faceI]] = cellI;
121                 markedFaces[cellfaces[faceI]] = true;
122             }
123             else
124             {
125                 // Second visit: neighbour
126                 neighbour_[cellfaces[faceI]] = cellI;
127                 nInternalFaces++;
128             }
129         }
130     }
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
138     primitiveMesh::reset
139     (
140         points_.size(),
141         neighbour_.size(),
142         owner_.size(),
143         c.size(),
144         c
145     );
147     string meshInfo =
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 // ************************************************************************* //