PrimitivePatchPointAddressing.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 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  Point addressing on the patch: pointEdges and pointFaces.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "PrimitivePatch.H"
33 #include "SLList.H"
34 #include "ListOps.H"
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 
38 template
39 <
40  class Face,
41  template<class> class FaceList,
42  class PointField,
43  class PointType
44 >
45 void
47 calcPointEdges() const
48 {
50  << "Calculating pointEdges" << endl;
51 
52  if (pointEdgesPtr_)
53  {
54  // An error to recalculate if already allocated
56  << "pointEdges already calculated"
57  << abort(FatalError);
58  }
59 
60  pointEdgesPtr_ = new labelListList(meshPoints().size());
61 
62  labelListList& pe = *pointEdgesPtr_;
63 
64  invertManyToMany(pe.size(), edges(), pe);
65 
66  DebugInfo
67  << " Finished." << endl;
68 }
69 
70 
71 template
72 <
73  class Face,
74  template<class> class FaceList,
75  class PointField,
76  class PointType
77 >
78 void
80 calcPointFaces() const
81 {
83  << "Calculating pointFaces" << endl;
84 
85  if (pointFacesPtr_)
86  {
87  // An error to recalculate if already allocated
89  << "pointFaces already calculated"
90  << abort(FatalError);
91  }
92 
93  const List<Face>& f = localFaces();
94 
95  // set up storage for pointFaces
96  List<SLList<label>> pointFcs(meshPoints().size());
97 
98  forAll(f, facei)
99  {
100  const Face& curPoints = f[facei];
101 
102  for (const label pointi : curPoints)
103  {
104  pointFcs[pointi].append(facei);
105  }
106  }
107 
108  // sort out the list
109  pointFacesPtr_ = new labelListList(pointFcs.size());
110 
111  labelListList& pf = *pointFacesPtr_;
112 
113  forAll(pointFcs, pointi)
114  {
115  pf[pointi].setSize(pointFcs[pointi].size());
116 
117  label i = 0;
118  for (const label facei : pointFcs[pointi])
119  {
120  pf[pointi][i++] = facei;
121  }
122  }
123 
124  DebugInfo
125  << " Finished." << endl;
126 }
127 
128 
129 // ************************************************************************* //
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Definition: ListOpsTemplates.C:727
Foam::label
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:62
PrimitivePatch.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:356
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:350
f
labelList f(nPoints)
SLList.H
Non-intrusive singly-linked list.
ListOps.H
Various functions to operate on Lists.
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90