fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / tetDecompositionFiniteElement / tetPolyMeshFaceDecomp / calcTetPolyMeshFaceDecompParPointData.C
blob5110eb1b1fd0459ee7b13e79b256883c0bba65c3
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 Description
27 \*---------------------------------------------------------------------------*/
29 #include "tetPolyMeshFaceDecomp.H"
30 #include "processorPolyPatch.H"
31 #include "demandDrivenData.H"
33 using namespace Foam;
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 void Foam::tetPolyMeshFaceDecomp::calcParPointData() const
39     if (!Pstream::parRun())
40     {
41         parPointsPtr_ = new labelList(0);
42         parEdgesPtr_ = new edgeList(0);
44         return;
45     }
46     else
47     {
48         // Make a global point markup list and find out which vertices
49         // belong to more than one patch.
51         // Create a local check list for all vertices
53         labelList multiProcVertices(mesh_.nPoints(), 0);
55         forAll (mesh_.boundaryMesh(), patchI)
56         {
57             if
58             (
59                 isA<processorPolyPatch>(mesh_.boundaryMesh()[patchI])
60             )
61             {
62                 const labelList& p = mesh_.boundaryMesh()[patchI].meshPoints();
64                 forAll (p, pointI)
65                 {
66                     multiProcVertices[p[pointI]]++;
67                 }
68             }
69         }
71         SLList<label> parPoints;
73         // Find all vertices that have been addressed more than once
74         forAll (multiProcVertices, pointI)
75         {
76             if (multiProcVertices[pointI] > 1)
77             {
78                 parPoints.append(pointI);
79             }
80         }
82         // Re-pack the list
83         parPointsPtr_ = new labelList(parPoints);
85         // At the same time calculate all edges located between two
86         // parallel points.  The list will have duplicates, which need
87         // to be eliminated
89         SLList<edge> parEdges;
91         forAll (mesh_.boundaryMesh(), patchI)
92         {
93             if
94             (
95                 isA<processorPolyPatch>(mesh_.boundaryMesh()[patchI])
96             )
97             {
98                 const labelList& p = mesh_.boundaryMesh()[patchI].meshPoints();
100                 const edgeList& e = mesh_.boundaryMesh()[patchI].edges();
102                 forAll (e, eI)
103                 {
104                     if
105                     (
106                         multiProcVertices[p[e[eI].start()]] > 1
107                      && multiProcVertices[p[e[eI].end()]] > 1
108                     )
109                     {
110                         // Found a possible edge
111                         edge newEdge = edge(p[e[eI].start()], p[e[eI].end()]);
113                         // Check if the edge is already on the list
114                         bool found = false;
116                         for
117                         (
118                             SLList<edge>::iterator parEIter =
119                                 parEdges.begin();
120                             parEIter != parEdges.end();
121                             ++parEIter
122                         )
123                         {
124                             if (parEIter() == newEdge)
125                             {
126                                 found = true;
127                                 break;
128                             }
129                         }
131                         if (!found)
132                         {
133                             parEdges.append(newEdge);
134                         }
135                     }
136                 }
137             }
138         }
140         // Re-pack the list
141         parEdgesPtr_ = new edgeList(parEdges);
142     }
146 void Foam::tetPolyMeshFaceDecomp::clearOutParPointData() const
148     deleteDemandDrivenData(parPointsPtr_);
149     deleteDemandDrivenData(parEdgesPtr_);
153 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
155 const labelList& Foam::tetPolyMeshFaceDecomp::parallelPoints() const
157     if (!parPointsPtr_)
158     {
159         calcParPointData();
160     }
162     return *parPointsPtr_;
166 const edgeList& Foam::tetPolyMeshFaceDecomp::parallelEdges() const
168     if (!parEdgesPtr_)
169     {
170         calcParPointData();
171     }
173     return *parEdgesPtr_;
177 // ************************************************************************* //