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 | Copyright (C) 2011-2015 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  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
50  << "calcPointEdges() : calculating pointEdges"
51  << endl;
52  }
53 
54  if (pointEdgesPtr_)
55  {
56  // it is considered an error to attempt to recalculate
57  // if already allocated
59  << "pointEdges already calculated"
60  << abort(FatalError);
61  }
62 
63  pointEdgesPtr_ = new labelListList(meshPoints().size());
64 
65  labelListList& pe = *pointEdgesPtr_;
66 
67  invertManyToMany(pe.size(), edges(), pe);
68 
69  if (debug)
70  {
71  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
72  << "calcPointEdges() finished calculating pointEdges"
73  << endl;
74  }
75 }
76 
77 
78 template
79 <
80  class Face,
81  template<class> class FaceList,
82  class PointField,
83  class PointType
84 >
85 void
87 calcPointFaces() const
88 {
89  if (debug)
90  {
91  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
92  << "calcPointFaces() : calculating pointFaces"
93  << endl;
94  }
95 
96  if (pointFacesPtr_)
97  {
98  // it is considered an error to attempt to recalculate
99  // if already allocated
101  << "pointFaces already calculated"
102  << abort(FatalError);
103  }
104 
105  const List<Face>& f = localFaces();
106 
107  // set up storage for pointFaces
108  List<SLList<label> > pointFcs(meshPoints().size());
109 
110  forAll(f, faceI)
111  {
112  const Face& curPoints = f[faceI];
113 
114  forAll(curPoints, pointI)
115  {
116  pointFcs[curPoints[pointI]].append(faceI);
117  }
118  }
119 
120  // sort out the list
121  pointFacesPtr_ = new labelListList(pointFcs.size());
122 
123  labelListList& pf = *pointFacesPtr_;
124 
125  forAll(pointFcs, pointI)
126  {
127  pf[pointI].setSize(pointFcs[pointI].size());
128 
129  label i = 0;
130  forAllIter(SLList<label>, pointFcs[pointI], curFacesIter)
131  {
132  pf[pointI][i++] = curFacesIter();
133  }
134  }
135 
136  if (debug)
137  {
138  Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
139  << "calcPointFaces() finished calculating pointFaces"
140  << endl;
141  }
142 }
143 
144 
145 // ************************************************************************* //
forAllIter
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:431
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
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Definition: ListOpsTemplates.C:418
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
PrimitivePatch.H
Foam::Info
messageStream Info
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
f
labelList f(nPoints)
SLList.H
List
Definition: Test.C:19
ListOps.H
Various functions to operate on Lists.
Foam::PrimitivePatch::calcPointEdges
void calcPointEdges() const
Calculate point-edge addressing.
Definition: PrimitivePatchPointAddressing.C:44