PrimitivePatchLocalPointOrder.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Description
28  Orders the local points on the patch for most efficient search
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "SLList.H"
33 #include "boolList.H"
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
37 template<class FaceList, class PointField>
38 void
40 {
41  // Note: Cannot use bandCompressing as point-point addressing does
42  // not exist and is not considered generally useful.
43 
44  if (debug)
45  {
46  Pout<< "PrimitivePatch<FaceList, PointField>::"
47  << "calcLocalPointOrder() : "
48  << "calculating local point order"
49  << endl;
50  }
51 
52  if (localPointOrderPtr_)
53  {
54  // An error to recalculate if already allocated
56  << "local point order already calculated"
57  << abort(FatalError);
58  }
59 
60  const List<face_type>& lf = localFaces();
61 
62  const labelListList& ff = faceFaces();
63 
64  boolList visitedFace(lf.size(), false);
65 
66  localPointOrderPtr_.reset(new labelList(meshPoints().size(), -1));
67  auto& pointOrder = *localPointOrderPtr_;
68 
69  boolList visitedPoint(pointOrder.size(), false);
70 
71  label nPoints = 0;
72 
73  forAll(lf, facei)
74  {
75  if (!visitedFace[facei])
76  {
77  SLList<label> faceOrder(facei);
78 
79  do
80  {
81  const label curFace = faceOrder.first();
82 
83  faceOrder.removeHead();
84 
85  if (!visitedFace[curFace])
86  {
87  visitedFace[curFace] = true;
88 
89  const labelList& curPoints = lf[curFace];
90 
91  // mark points
92  forAll(curPoints, pointi)
93  {
94  if (!visitedPoint[curPoints[pointi]])
95  {
96  visitedPoint[curPoints[pointi]] = true;
97 
98  pointOrder[nPoints] = curPoints[pointi];
99 
100  nPoints++;
101  }
102  }
103 
104  // add face neighbours to the list
105  const labelList& nbrs = ff[curFace];
106 
107  forAll(nbrs, nbrI)
108  {
109  if (!visitedFace[nbrs[nbrI]])
110  {
111  faceOrder.append(nbrs[nbrI]);
112  }
113  }
114  }
115  } while (faceOrder.size());
116  }
117  }
118 
119  if (debug)
120  {
121  Pout<< "PrimitivePatch<FaceList, PointField>::"
122  << "calcLocalPointOrder() "
123  << "finished calculating local point order"
124  << endl;
125  }
126 }
127 
128 
129 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
boolList.H
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
Foam::fv::ff
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Definition: CrankNicolsonDdtScheme.C:275
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
SLList.H
Non-intrusive singly-linked list.
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85