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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Description
28 Point addressing on the patch: pointEdges and pointFaces.
29
30\*---------------------------------------------------------------------------*/
31
32#include "PrimitivePatch.H"
33#include "DynamicList.H"
34#include "ListOps.H"
35
36// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37
38template<class FaceList, class PointField>
39void
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
61template<class FaceList, class PointField>
62void
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 // Local storage while creating pointFaces
77 List<DynamicList<label>> pointFcs(meshPoints().size());
78
79 const List<face_type>& locFcs = localFaces();
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 lists, recovering content
90 pointFacesPtr_.reset(new labelListList(pointFcs.size()));
91 auto& pf = *pointFacesPtr_;
92
93 forAll(pointFcs, pointi)
94 {
95 pf[pointi].transfer(pointFcs[pointi]);
96 }
97
98 DebugInfo << " Finished." << endl;
99}
100
101
102// ************************************************************************* //
Various functions to operate on Lists.
A list of faces which address into the list of points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
#define DebugInfo
Report an information message using Foam::Info.
#define DebugInFunction
Report an information message using Foam::Info.
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:144
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333