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