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-2019 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<class FaceList, class PointField>
38 {
39  if (debug)
40  {
41  InfoInFunction << "Calculating pointEdges" << endl;
42  }
43 
44  if (pointEdgesPtr_)
45  {
46  // it is considered an error to attempt to recalculate
47  // if already allocated
49  << "pointEdges already calculated"
50  << abort(FatalError);
51  }
52 
53  pointEdgesPtr_ = new labelListList(meshPoints().size());
54 
55  labelListList& pe = *pointEdgesPtr_;
56 
57  invertManyToMany(pe.size(), edges(), pe);
58 
59  if (debug)
60  {
61  Info<< " Finished." << endl;
62  }
63 }
64 
65 
66 template<class FaceList, class PointField>
68 {
69  if (debug)
70  {
71  InfoInFunction << "Calculating pointFaces" << endl;
72  }
73 
74  if (pointFacesPtr_)
75  {
76  // it is considered an error to attempt to recalculate
77  // if already allocated
79  << "pointFaces already calculated"
80  << abort(FatalError);
81  }
82 
83  const List<FaceType>& f = localFaces();
84 
85  // set up storage for pointFaces
86  List<SLList<label>> pointFcs(meshPoints().size());
87 
88  forAll(f, facei)
89  {
90  const FaceType& curPoints = f[facei];
91 
92  forAll(curPoints, pointi)
93  {
94  pointFcs[curPoints[pointi]].append(facei);
95  }
96  }
97 
98  // sort out the list
99  pointFacesPtr_ = new labelListList(pointFcs.size());
100 
101  labelListList& pf = *pointFacesPtr_;
102 
103  forAll(pointFcs, pointi)
104  {
105  pf[pointi].setSize(pointFcs[pointi].size());
106 
107  label i = 0;
108  forAllIter(SLList<label>, pointFcs[pointi], curFacesIter)
109  {
110  pf[pointi][i++] = curFacesIter();
111  }
112  }
113 
114  if (debug)
115  {
116  Info<< " Finished." << endl;
117  }
118 }
119 
120 
121 // ************************************************************************* //
Various functions to operate on Lists.
Non-intrusive singly-linked list.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
A list of faces which address into the list of points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
#define InfoInFunction
Report an information message using Foam::Info.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
errorManip< error > abort(error &err)
Definition: errorManip.H:131
messageStream Info
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
error FatalError
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
labelList f(nPoints)