initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToFieldview9 / calcFaceAddressing.C
blob557813337dc319e2e9d37670573f6f32fee9273f
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 Description
27 \*---------------------------------------------------------------------------*/
29 #include "calcFaceAddressing.H"
31 using namespace Foam;
33 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
35 // Returns the face labels of the shape in an order consistent with the
36 // shape.
37 labelList calcFaceAddressing
39     const faceList& allFaces,   // faces given faceLabels
40     const cellShape& shape,
41     const labelList& faces,     // faceLabels for given cell
42     const label cellI
45     // return value. 
46     labelList shapeToMesh(shape.nFaces(), -1);
48     const faceList modelFaces(shape.faces());
50     // Loop over all faces of cellShape
51     forAll(modelFaces, cellFaceI)
52     {
53         // face (vertex list)
54         const face& modelFace = modelFaces[cellFaceI];
56         // Loop over all face labels
57         forAll(faces, faceI)
58         {
59             const face& vertLabels = allFaces[faces[faceI]];
61             if (vertLabels == modelFace)
62             {
63                 //Info<< "match:" << modelFace
64                 //    << "  to " << vertLabels << endl;
65                 shapeToMesh[cellFaceI] = faces[faceI];
66                 break;
67             }
68         }
70         if (shapeToMesh[cellFaceI] == -1)
71         {
72             FatalErrorIn("foamToFieldview : calcFaceAddressing")
73                 << "calcFaceAddressing : can't match face to shape.\n"
74                 << "    shape face:" << modelFace << endl
75                 << "    face labels:" << faces << endl
76                 << "    cellI:" << cellI << endl;
78             FatalError << "Faces consist of vertices:" << endl;
79             forAll(faces, faceI)
80             {
81                 FatalError
82                     << "    face:" << faces[faceI]
83                     << allFaces[faces[faceI]] << endl;
84             }
85             FatalError << exit(FatalError);
86         }
87     }
88     return shapeToMesh;
92 // ************************************************************************* //