fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMeshPointEdges.C
blob0082906a7ce2b8ddb8130bdf4ec7e46b91570d9c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 \*---------------------------------------------------------------------------*/
27 #include "primitiveMesh.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
36 void primitiveMesh::calcPointEdges() const
38     // Loop through edges and mark up points
40     if (debug)
41     {
42         Pout<< "primitiveMesh::calcPointEdges() : "
43             << "calculating pointEdges"
44             << endl;
45     }
47     // It is an error to attempt to recalculate pointEdges
48     // if the pointer is already set
49     if (pePtr_)
50     {
51         FatalErrorIn("primitiveMesh::calcPointEdges() const")
52             << "pointEdges already calculated"
53             << abort(FatalError);
54     }
55     else
56     {
57         const edgeList& e = edges();
59         // Count edges per point
61         labelList npe(nPoints(), 0);
63         forAll (e, edgeI)
64         {
65             npe[e[edgeI].start()]++;
66             npe[e[edgeI].end()]++;
67         }
70         // Size and fill edges per point
72         pePtr_ = new labelListList(npe.size());
73         labelListList& pointEdgeAddr = *pePtr_;
75         forAll (pointEdgeAddr, pointI)
76         {
77             pointEdgeAddr[pointI].setSize(npe[pointI]);
78         }
79         npe = 0;
81         forAll (e, edgeI)
82         {
83             label v0 = e[edgeI].start();
85             pointEdgeAddr[v0][npe[v0]++] = edgeI;
87             label v1 = e[edgeI].end();
89             pointEdgeAddr[v1][npe[v1]++] = edgeI;
90         }
91     }
95 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
97 const labelListList& primitiveMesh::pointEdges() const
99     if (!pePtr_)
100     {
101         calcPointEdges();
102     }
104     return *pePtr_;
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 } // End namespace Foam
112 // ************************************************************************* //