FreeFOAM The Cross-Platform CFD Toolkit
enrichedPatchPointPoints.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "enrichedPatch.H"
29 #include <OpenFOAM/primitiveMesh.H>
30 #include <OpenFOAM/DynamicList.H>
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
37 void Foam::enrichedPatch::calcPointPoints() const
38 {
39  // Calculate point-point addressing
40  if (pointPointsPtr_)
41  {
42  FatalErrorIn("void enrichedPatch::calcPointPoints() const")
43  << "Point-point addressing already calculated."
44  << abort(FatalError);
45  }
46 
47  // Algorithm:
48  // Go through all faces and add the previous and next point as the
49  // neighbour for each point. While inserting points, reject the
50  // duplicates (as every internal edge will be visited twice).
51  List<DynamicList<label, primitiveMesh::edgesPerPoint_> >
52  pp(meshPoints().size());
53 
54  const faceList& lf = localFaces();
55 
56  register bool found = false;
57 
58  forAll (lf, faceI)
59  {
60  const face& curFace = lf[faceI];
61 
62  forAll (curFace, pointI)
63  {
64  DynamicList<label, primitiveMesh::edgesPerPoint_>&
65  curPp = pp[curFace[pointI]];
66 
67  // Do next label
68  label next = curFace.nextLabel(pointI);
69 
70  found = false;
71 
72  forAll (curPp, i)
73  {
74  if (curPp[i] == next)
75  {
76  found = true;
77  break;
78  }
79  }
80 
81  if (!found)
82  {
83  curPp.append(next);
84  }
85 
86  // Do previous label
87  label prev = curFace.prevLabel(pointI);
88  found = false;
89 
90  forAll (curPp, i)
91  {
92  if (curPp[i] == prev)
93  {
94  found = true;
95  break;
96  }
97  }
98 
99  if (!found)
100  {
101  curPp.append(prev);
102  }
103  }
104  }
105 
106  // Re-pack the list
107  pointPointsPtr_ = new labelListList(pp.size());
108  labelListList& ppAddr = *pointPointsPtr_;
109 
110  forAll (pp, pointI)
111  {
112  ppAddr[pointI].transfer(pp[pointI]);
113  }
114 }
115 
116 
117 // ************************ vim: set sw=4 sts=4 et: ************************ //