Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / dynamicMesh / slidingInterface / enrichedPatch / enrichedPatchPointPoints.C
blobdf9497fedf2e240f756e716ea6b53795d69abca8
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 "enrichedPatch.H"
27 #include "primitiveMesh.H"
28 #include "DynamicList.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
35 void Foam::enrichedPatch::calcPointPoints() const
37     // Calculate point-point addressing
38     if (pointPointsPtr_)
39     {
40         FatalErrorIn("void enrichedPatch::calcPointPoints() const")
41             << "Point-point addressing already calculated."
42             << abort(FatalError);
43     }
45     // Algorithm:
46     // Go through all faces and add the previous and next point as the
47     // neighbour for each point. While inserting points, reject the
48     // duplicates (as every internal edge will be visited twice).
49     List<DynamicList<label, primitiveMesh::edgesPerPoint_> >
50         pp(meshPoints().size());
52     const faceList& lf = localFaces();
54     register bool found = false;
56     forAll(lf, faceI)
57     {
58         const face& curFace = lf[faceI];
60         forAll(curFace, pointI)
61         {
62             DynamicList<label, primitiveMesh::edgesPerPoint_>&
63                 curPp = pp[curFace[pointI]];
65             // Do next label
66             label next = curFace.nextLabel(pointI);
68             found = false;
70             forAll(curPp, i)
71             {
72                 if (curPp[i] == next)
73                 {
74                     found = true;
75                     break;
76                 }
77             }
79             if (!found)
80             {
81                 curPp.append(next);
82             }
84             // Do previous label
85             label prev = curFace.prevLabel(pointI);
86             found = false;
88             forAll(curPp, i)
89             {
90                 if (curPp[i] == prev)
91                 {
92                     found = true;
93                     break;
94                 }
95             }
97             if (!found)
98             {
99                 curPp.append(prev);
100             }
101         }
102     }
104     // Re-pack the list
105     pointPointsPtr_ = new labelListList(pp.size());
106     labelListList& ppAddr = *pointPointsPtr_;
108     forAll(pp, pointI)
109     {
110         ppAddr[pointI].transfer(pp[pointI]);
111     }
115 // ************************************************************************* //