enrichedPatchPointPoints.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-2021 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
27\*---------------------------------------------------------------------------*/
28
29#include "enrichedPatch.H"
30#include "primitiveMesh.H"
31#include "DynamicList.H"
32
33// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34
35void Foam::enrichedPatch::calcPointPoints() const
36{
37 // Calculate point-point addressing
38 if (pointPointsPtr_)
39 {
41 << "Point-point addressing already calculated."
42 << abort(FatalError);
43 }
44
45 // Algorithm:
46 // Go through all faces and add the previous and next point as the
47 // neighbour for each point. While inserting points, reject the
48 // duplicates (as every internal edge will be visited twice).
49 List<DynamicList<label>> pp(meshPoints().size());
50
51 const faceList& lf = localFaces();
52
53 for (const face& curFace : lf)
54 {
55 forAll(curFace, pointi)
56 {
57 DynamicList<label>& curPp = pp[curFace[pointi]];
58
59 // Do next label
60 const label next = curFace.nextLabel(pointi);
61 curPp.appendUniq(next);
62
63 // Do previous label
64 const label prev = curFace.prevLabel(pointi);
65 curPp.appendUniq(prev);
66 }
67 }
68
69 // Re-pack the list
70 pointPointsPtr_.reset(new labelListList(pp.size()));
71 auto& ppAddr = *pointPointsPtr_;
72
73 forAll(pp, pointi)
74 {
75 ppAddr[pointi].transfer(pp[pointi]);
76 }
77}
78
79
80// ************************************************************************* //
const faceList & localFaces() const
Return local faces.
const labelList & meshPoints() const
Return mesh points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333