fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMeshPointPoints.C
blobc5a2b093989a69267d790d01b4d809eb8de5b16a
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "primitiveMesh.H"
29 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
31 void Foam::primitiveMesh::calcPointPoints() const
33     if (debug)
34     {
35         Pout<< "primitiveMesh::calcPointPoints() : "
36             << "calculating pointPoints"
37             << endl;
39         if (debug == -1)
40         {
41             // For checking calls:abort so we can quickly hunt down
42             // origin of call
43             FatalErrorIn("primitiveMesh::calcPointPoints()")
44                 << abort(FatalError);
45         }
46     }
48     // It is an error to attempt to recalculate pointPoints
49     // if the pointer is already set
50     if (ppPtr_)
51     {
52         FatalErrorIn("primitiveMesh::calcPointPoints() const")
53             << "pointPoints already calculated"
54             << abort(FatalError);
55     }
56     else
57     {
58         const edgeList& e = edges();
59         const labelListList& pe = pointEdges();
61         ppPtr_ = new labelListList(pe.size());
62         labelListList& pp = *ppPtr_;
64         forAll (pe, pointI)
65         {
66             pp[pointI].setSize(pe[pointI].size());
68             forAll (pe[pointI], ppi)
69             {
70                 if (e[pe[pointI][ppi]].start() == pointI)
71                 {
72                     pp[pointI][ppi] = e[pe[pointI][ppi]].end();
73                 }
74                 else if (e[pe[pointI][ppi]].end() == pointI)
75                 {
76                     pp[pointI][ppi] = e[pe[pointI][ppi]].start();
77                 }
78                 else
79                 {
80                     FatalErrorIn("primitiveMesh::calcPointPoints() const")
81                         << "something wrong with edges"
82                         << abort(FatalError);
83                 }
84             }
85         }
86     }
90 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
92 const Foam::labelListList& Foam::primitiveMesh::pointPoints() const
94     if (!ppPtr_)
95     {
96         calcPointPoints();
97     }
99     return *ppPtr_;
103 const Foam::labelList& Foam::primitiveMesh::pointPoints
105     const label pointI,
106     DynamicList<label>& storage
107 ) const
109     if (hasPointPoints())
110     {
111         return pointPoints()[pointI];
112     }
113     else
114     {
115         const edgeList& edges = this->edges();
116         const labelList& pEdges = pointEdges()[pointI];
118         storage.clear();
120         if (pEdges.size() > storage.capacity())
121         {
122             storage.setCapacity(pEdges.size());
123         }
125         forAll(pEdges, i)
126         {
127             storage.append(edges[pEdges[i]].otherVertex(pointI));
128         }
130         return storage;
131     }
135 const Foam::labelList& Foam::primitiveMesh::pointPoints
137     const label pointI
138 ) const
140     return pointPoints(pointI, labels_);
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 // ************************************************************************* //