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 << " Finished." << endl;
58 }
59 
60 
61 template<class FaceList, class PointField>
62 void
64 {
66  << "Calculating pointFaces" << endl;
67 
68  if (pointFacesPtr_)
69  {
70  // An error to recalculate if already allocated
72  << "pointFaces already calculated"
73  << abort(FatalError);
74  }
75 
76  const List<face_type>& locFcs = localFaces();
77 
78  // set up storage for pointFaces
79  List<SLList<label>> pointFcs(meshPoints().size());
80 
81  forAll(locFcs, facei)
82  {
83  for (const label pointi : locFcs[facei])
84  {
85  pointFcs[pointi].append(facei);
86  }
87  }
88 
89  // Copy the list
90  pointFacesPtr_.reset(new labelListList(pointFcs.size()));
91  auto& pf = *pointFacesPtr_;
92 
93  forAll(pointFcs, pointi)
94  {
95  pf[pointi] = pointFcs[pointi];
96  }
97 
98  DebugInfo << " Finished." << endl;
99 }
100 
101 
102 // ************************************************************************* //
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
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:720
PrimitivePatch.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
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:453
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
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:79