All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
enrichedPatchPointPoints.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "enrichedPatch.H"
27 #include "primitiveMesh.H"
28 #include "DynamicList.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 void Foam::enrichedPatch::calcPointPoints() const
36 {
37  // Calculate point-point addressing
38  if (pointPointsPtr_)
39  {
41  << "Point-point addressing already calculated."
42  << abort(FatalError);
43  }
44 
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());
51 
52  const faceList& lf = localFaces();
53 
54  bool found = false;
55 
56  forAll(lf, facei)
57  {
58  const face& curFace = lf[facei];
59 
60  forAll(curFace, pointi)
61  {
62  DynamicList<label, primitiveMesh::edgesPerPoint_>&
63  curPp = pp[curFace[pointi]];
64 
65  // Do next label
66  label next = curFace.nextLabel(pointi);
67 
68  found = false;
69 
70  forAll(curPp, i)
71  {
72  if (curPp[i] == next)
73  {
74  found = true;
75  break;
76  }
77  }
78 
79  if (!found)
80  {
81  curPp.append(next);
82  }
83 
84  // Do previous label
85  label prev = curFace.prevLabel(pointi);
86  found = false;
87 
88  forAll(curPp, i)
89  {
90  if (curPp[i] == prev)
91  {
92  found = true;
93  break;
94  }
95  }
96 
97  if (!found)
98  {
99  curPp.append(prev);
100  }
101  }
102  }
103 
104  // Re-pack the list
105  pointPointsPtr_ = new labelListList(pp.size());
106  labelListList& ppAddr = *pointPointsPtr_;
107 
108  forAll(pp, pointi)
109  {
110  ppAddr[pointi].transfer(pp[pointi]);
111  }
112 }
113 
114 
115 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
List< face > faceList
Definition: faceListFwd.H:43
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const faceList & localFaces() const
Return local faces.
const labelList & meshPoints() const
Return mesh points.