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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2021 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 \*---------------------------------------------------------------------------*/
28 
29 #include "enrichedPatch.H"
30 #include "primitiveMesh.H"
31 #include "DynamicList.H"
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>> pp(meshPoints().size());
50 
51  const faceList& lf = localFaces();
52 
53  for (const face& curFace : lf)
54  {
55  forAll(curFace, pointi)
56  {
57  DynamicList<label>& curPp = pp[curFace[pointi]];
58 
59  // Do next label
60  curPp.push_uniq(curFace.nextLabel(pointi));
61 
62  // Do previous label
63  curPp.push_uniq(curFace.prevLabel(pointi));
64  }
65  }
66 
67  // Re-pack the list
68  pointPointsPtr_.reset(new labelListList(pp.size()));
69  auto& ppAddr = *pointPointsPtr_;
70 
71  forAll(pp, pointi)
72  {
73  ppAddr[pointi].transfer(pp[pointi]);
74  }
75 }
76 
77 
78 // ************************************************************************* //
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
List< face > faceList
List of faces.
Definition: faceListFwd.H:39
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const faceList & localFaces() const
Return local faces.
const labelList & meshPoints() const
Return mesh points.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())