PrimitivePatchPointAddressing.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. 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 "PrimitivePatchTemplate.H"
30 #include "SLList.H"
31 
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 template
36 <
37  class Face,
38  template<class> class FaceList,
39  class PointField,
40  class PointType
41 >
42 void
45 {
46  if (debug)
47  {
48  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
49  << "calcPointEdges() : calculating pointEdges"
50  << endl;
51  }
52 
53  if (pointEdgesPtr_)
54  {
55  // it is considered an error to attempt to recalculate
56  // if already allocated
58  (
59  "PrimitivePatch<Face, FaceList, PointField, PointType>::"
60  "calcPointEdges()"
61  ) << "pointEdges already calculated"
62  << abort(FatalError);
63  }
64 
65  const edgeList& e = edges();
66 
67  // set up storage for pointEdges
68  List<SLList<label> > pointEdges(meshPoints().size());
69 
70  forAll (e, edgeI)
71  {
72  pointEdges[e[edgeI].start()].append(edgeI);
73  pointEdges[e[edgeI].end()].append(edgeI);
74  }
75 
76  // sort out the list
77  pointEdgesPtr_ = new labelListList(pointEdges.size());
78 
79  labelListList& pe = *pointEdgesPtr_;
80 
81  forAll (pointEdges, pointI)
82  {
83  pe[pointI].setSize(pointEdges[pointI].size());
84 
85  label i = 0;
86  for
87  (
88  SLList<label>::iterator curEdgesIter = pointEdges[pointI].begin();
89  curEdgesIter != pointEdges[pointI].end();
90  ++curEdgesIter, ++i
91  )
92  {
93  pe[pointI][i] = curEdgesIter();
94  }
95  }
96 
97  if (debug)
98  {
99  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
100  << "calcPointEdges() finished calculating pointEdges"
101  << endl;
102  }
103 }
104 
105 
106 template
107 <
108  class Face,
109  template<class> class FaceList,
110  class PointField,
111  class PointType
112 >
113 void
116 {
117  if (debug)
118  {
119  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
120  << "calcPointFaces() : calculating pointFaces"
121  << endl;
122  }
123 
124  if (pointFacesPtr_)
125  {
126  // it is considered an error to attempt to recalculate
127  // if already allocated
129  (
130  "PrimitivePatch<Face, FaceList, PointField, PointType>::"
131  "calcPointFaces()"
132  ) << "pointFaces already calculated"
133  << abort(FatalError);
134  }
135 
136  const List<Face>& f = localFaces();
137 
138  // set up storage for pointFaces
139  List<SLList<label> > pointFcs(meshPoints().size());
140 
141  forAll (f, faceI)
142  {
143  const Face& curPoints = f[faceI];
144 
145  forAll (curPoints, pointI)
146  {
147  pointFcs[curPoints[pointI]].append(faceI);
148  }
149  }
150 
151  // sort out the list
152  pointFacesPtr_ = new labelListList(pointFcs.size());
153 
154  labelListList& pf = *pointFacesPtr_;
155 
156  forAll (pointFcs, pointI)
157  {
158  pf[pointI].setSize(pointFcs[pointI].size());
159 
160  label i = 0;
161  for
162  (
163  SLList<label>::iterator curFacesIter = pointFcs[pointI].begin();
164  curFacesIter != pointFcs[pointI].end();
165  ++curFacesIter, ++i
166  )
167  {
168  pf[pointI][i] = curFacesIter();
169  }
170  }
171 
172  if (debug)
173  {
174  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
175  << "calcPointFaces() finished calculating pointFaces"
176  << endl;
177  }
178 }
179 
180 
181 // ************************************************************************* //
Foam::SLList
Non-intrusive singly-linked list.
Definition: SLList.H:47
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
PrimitivePatchTemplate.H
Foam::PrimitivePatch::calcPointFaces
void calcPointFaces() const
Calculate point-face addressing.
Definition: PrimitivePatchPointAddressing.C:115
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:59
Foam::List::append
void append(const T &)
Append an element at the end of the list.
Foam::Info
messageStream Info
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
f
labelList f(nPoints)
SLList.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:94
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::PrimitivePatch::calcPointEdges
void calcPointEdges() const
Calculate point-edge addressing.
Definition: PrimitivePatchPointAddressing.C:44