ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMeshCellEdges.C
blob21e14118ffa02245c2b0ba771eea01dd84b665d7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "primitiveMesh.H"
27 #include "DynamicList.H"
28 #include "ListOps.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 void Foam::primitiveMesh::calcCellEdges() const
34     // Loop through all faces and mark up cells with edges of the face.
35     // Check for duplicates
37     if (debug)
38     {
39         Pout<< "primitiveMesh::calcCellEdges() : "
40             << "calculating cellEdges"
41             << endl;
43         if (debug == -1)
44         {
45             // For checking calls:abort so we can quickly hunt down
46             // origin of call
47             FatalErrorIn("primitiveMesh::calcCellEdges()")
48                 << abort(FatalError);
49         }
50     }
52     // It is an error to attempt to recalculate cellEdges
53     // if the pointer is already set
54     if (cePtr_)
55     {
56         FatalErrorIn("primitiveMesh::calcCellEdges() const")
57             << "cellEdges already calculated"
58             << abort(FatalError);
59     }
60     else
61     {
62         // Set up temporary storage
63         List<DynamicList<label, edgesPerCell_> > ce(nCells());
66         // Get reference to faceCells and faceEdges
67         const labelList& own = faceOwner();
68         const labelList& nei = faceNeighbour();
69         const labelListList& fe = faceEdges();
71         // loop through the list again and add edges; checking for duplicates
72         forAll(own, faceI)
73         {
74             DynamicList<label, edgesPerCell_>& curCellEdges = ce[own[faceI]];
76             const labelList& curEdges = fe[faceI];
78             forAll(curEdges, edgeI)
79             {
80                 if (findIndex(curCellEdges, curEdges[edgeI]) == -1)
81                 {
82                     // Add the edge
83                     curCellEdges.append(curEdges[edgeI]);
84                 }
85             }
86         }
88         forAll(nei, faceI)
89         {
90             DynamicList<label, edgesPerCell_>& curCellEdges = ce[nei[faceI]];
92             const labelList& curEdges = fe[faceI];
94             forAll(curEdges, edgeI)
95             {
96                 if (findIndex(curCellEdges, curEdges[edgeI]) == -1)
97                 {
98                     // add the edge
99                     curCellEdges.append(curEdges[edgeI]);
100                 }
101             }
102         }
104         cePtr_ = new labelListList(ce.size());
105         labelListList& cellEdgeAddr = *cePtr_;
107         // reset the size
108         forAll(ce, cellI)
109         {
110             cellEdgeAddr[cellI].transfer(ce[cellI]);
111         }
112     }
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 const Foam::labelListList& Foam::primitiveMesh::cellEdges() const
120     if (!cePtr_)
121     {
122         calcCellEdges();
123     }
125     return *cePtr_;
129 // ************************************************************************* //