BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMeshPointPoints.C
bloba37ecef04040099fdb06b812882b06cb968b28a3
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"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 void Foam::primitiveMesh::calcPointPoints() const
32     if (debug)
33     {
34         Pout<< "primitiveMesh::calcPointPoints() : "
35             << "calculating pointPoints"
36             << endl;
38         if (debug == -1)
39         {
40             // For checking calls:abort so we can quickly hunt down
41             // origin of call
42             FatalErrorIn("primitiveMesh::calcPointPoints()")
43                 << abort(FatalError);
44         }
45     }
47     // It is an error to attempt to recalculate pointPoints
48     // if the pointer is already set
49     if (ppPtr_)
50     {
51         FatalErrorIn("primitiveMesh::calcPointPoints() const")
52             << "pointPoints already calculated"
53             << abort(FatalError);
54     }
55     else
56     {
57         const edgeList& e = edges();
58         const labelListList& pe = pointEdges();
60         ppPtr_ = new labelListList(pe.size());
61         labelListList& pp = *ppPtr_;
63         forAll(pe, pointI)
64         {
65             pp[pointI].setSize(pe[pointI].size());
67             forAll(pe[pointI], ppi)
68             {
69                 if (e[pe[pointI][ppi]].start() == pointI)
70                 {
71                     pp[pointI][ppi] = e[pe[pointI][ppi]].end();
72                 }
73                 else if (e[pe[pointI][ppi]].end() == pointI)
74                 {
75                     pp[pointI][ppi] = e[pe[pointI][ppi]].start();
76                 }
77                 else
78                 {
79                     FatalErrorIn("primitiveMesh::calcPointPoints() const")
80                         << "something wrong with edges"
81                         << abort(FatalError);
82                 }
83             }
84         }
85     }
89 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
91 const Foam::labelListList& Foam::primitiveMesh::pointPoints() const
93     if (!ppPtr_)
94     {
95         calcPointPoints();
96     }
98     return *ppPtr_;
102 const Foam::labelList& Foam::primitiveMesh::pointPoints
104     const label pointI,
105     DynamicList<label>& storage
106 ) const
108     if (hasPointPoints())
109     {
110         return pointPoints()[pointI];
111     }
112     else
113     {
114         const edgeList& edges = this->edges();
115         const labelList& pEdges = pointEdges()[pointI];
117         storage.clear();
119         if (pEdges.size() > storage.capacity())
120         {
121             storage.setCapacity(pEdges.size());
122         }
124         forAll(pEdges, i)
125         {
126             storage.append(edges[pEdges[i]].otherVertex(pointI));
127         }
129         return storage;
130     }
134 const Foam::labelList& Foam::primitiveMesh::pointPoints
136     const label pointI
137 ) const
139     return pointPoints(pointI, labels_);
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 // ************************************************************************* //