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-2020 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<class FaceList, class PointField>
39 void
41 {
42  DebugInFunction << "Calculating pointEdges" << endl;
43 
44  if (pointEdgesPtr_)
45  {
46  // An error to recalculate if already allocated
48  << "pointEdges already calculated"
49  << abort(FatalError);
50  }
51 
52  pointEdgesPtr_.reset(new labelListList(meshPoints().size()));
53  auto& pe = *pointEdgesPtr_;
54 
55  invertManyToMany(pe.size(), edges(), pe);
56 
57  DebugInfo
58  << " Finished." << endl;
59 }
60 
61 
62 template<class FaceList, class PointField>
63 void
65 {
67  << "Calculating pointFaces" << endl;
68 
69  if (pointFacesPtr_)
70  {
71  // An error to recalculate if already allocated
73  << "pointFaces already calculated"
74  << abort(FatalError);
75  }
76 
77  const List<face_type>& locFcs = localFaces();
78 
79  // set up storage for pointFaces
80  List<SLList<label>> pointFcs(meshPoints().size());
81 
82  forAll(locFcs, facei)
83  {
84  const face_type& curPoints = locFcs[facei];
85 
86  for (const label pointi : curPoints)
87  {
88  pointFcs[pointi].append(facei);
89  }
90  }
91 
92  // Copy the list
93  pointFacesPtr_.reset(new labelListList(pointFcs.size()));
94  auto& pf = *pointFacesPtr_;
95 
96  forAll(pointFcs, pointi)
97  {
98  pf[pointi] = pointFcs[pointi];
99  }
100 
101  DebugInfo
102  << " Finished." << endl;
103 }
104 
105 
106 // ************************************************************************* //
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Definition: ListOpsTemplates.C:727
PrimitivePatch.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:365
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
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:381
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:359
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:85