PrimitivePatchLocalPointOrder.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-2019 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 Description
25  Orders the local points on the patch for most efficient search
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "SLList.H"
30 #include "boolList.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 template<class FaceList, class PointField>
36 {
37  // Note: Cannot use bandCompressing as point-point addressing does
38  // not exist and is not considered generally useful.
39  //
40 
41  if (debug)
42  {
43  Pout<< "PrimitivePatch<FaceList, PointField>::"
44  << "calcLocalPointOrder() : "
45  << "calculating local point order"
46  << endl;
47  }
48 
49  if (localPointOrderPtr_)
50  {
51  // it is considered an error to attempt to recalculate
52  // if already allocated
54  << "local point order already calculated"
55  << abort(FatalError);
56  }
57 
58  const List<FaceType>& lf = localFaces();
59 
60  const labelListList& ff = faceFaces();
61 
62  boolList visitedFace(lf.size(), false);
63 
64  localPointOrderPtr_ = new labelList(meshPoints().size(), -1);
65 
66  labelList& pointOrder = *localPointOrderPtr_;
67 
68  boolList visitedPoint(pointOrder.size(), false);
69 
70  label nPoints = 0;
71 
72  forAll(lf, facei)
73  {
74  if (!visitedFace[facei])
75  {
76  SLList<label> faceOrder(facei);
77 
78  do
79  {
80  const label curFace = faceOrder.first();
81 
82  faceOrder.removeHead();
83 
84  if (!visitedFace[curFace])
85  {
86  visitedFace[curFace] = true;
87 
88  const labelList& curPoints = lf[curFace];
89 
90  // mark points
91  forAll(curPoints, pointi)
92  {
93  if (!visitedPoint[curPoints[pointi]])
94  {
95  visitedPoint[curPoints[pointi]] = true;
96 
97  pointOrder[nPoints] = curPoints[pointi];
98 
99  nPoints++;
100  }
101  }
102 
103  // add face neighbours to the list
104  const labelList& nbrs = ff[curFace];
105 
106  forAll(nbrs, nbrI)
107  {
108  if (!visitedFace[nbrs[nbrI]])
109  {
110  faceOrder.append(nbrs[nbrI]);
111  }
112  }
113  }
114  } while (faceOrder.size());
115  }
116  }
117 
118  if (debug)
119  {
120  Pout<< "PrimitivePatch<FaceList, PointField>::"
121  << "calcLocalPointOrder() "
122  << "finished calculating local point order"
123  << endl;
124  }
125 }
126 
127 
128 // ************************************************************************* //
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
A list of faces which address into the list of points.
label nPoints
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Non-intrusive singly-linked list.