Loading...
Searching...
No Matches
primitiveMeshPointPoints.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) 2023-2024 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 "primitiveMesh.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33void Foam::primitiveMesh::calcPointPoints() const
34{
35 if (debug)
36 {
37 Pout<< "primitiveMesh::calcPointPoints() : "
38 << "calculating pointPoints"
39 << endl;
40
41 if (debug == -1)
42 {
43 // For checking calls:abort so we can quickly hunt down
44 // origin of call
46 << abort(FatalError);
47 }
48 }
49
50 // It is an error to attempt to recalculate pointPoints
51 // if the pointer is already set
52 if (ppPtr_)
53 {
55 << "pointPoints already calculated"
56 << abort(FatalError);
57 }
58 else
59 {
60 const edgeList& e = edges();
61 const labelListList& pe = pointEdges();
62
63 ppPtr_ = std::make_unique<labelListList>(pe.size());
64 auto& pp = *ppPtr_;
65
66 forAll(pe, pointi)
67 {
68 pp[pointi].setSize(pe[pointi].size());
69
70 forAll(pe[pointi], ppi)
71 {
72 if (e[pe[pointi][ppi]].start() == pointi)
73 {
74 pp[pointi][ppi] = e[pe[pointi][ppi]].end();
75 }
76 else if (e[pe[pointi][ppi]].end() == pointi)
77 {
78 pp[pointi][ppi] = e[pe[pointi][ppi]].start();
79 }
80 else
81 {
83 << "something wrong with edges"
84 << abort(FatalError);
85 }
86 }
87 }
88 }
89}
90
91
92// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93
95{
96 if (!ppPtr_)
97 {
98 calcPointPoints();
99 }
100
101 return *ppPtr_;
102}
103
104
106(
107 const label pointi,
108 DynamicList<label>& storage
109) const
110{
111 if (hasPointPoints())
112 {
113 return pointPoints()[pointi];
114 }
115 else
116 {
117 const edgeList& edges = this->edges();
118 const labelList& pEdges = pointEdges()[pointi];
119
120 storage.clear();
121
122 if (storage.capacity() < pEdges.size())
123 {
124 storage.setCapacity(pEdges.size());
125 }
126
127 for (const label edgei : pEdges)
128 {
129 storage.push_back(edges[edgei].otherVertex(pointi));
131
132 return storage;
133 }
134}
135
136
138(
139 const label pointi
140) const
141{
142 return pointPoints(pointi, labels_);
143}
144
145
146// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void push_back(const T &val)
Copy append an element to the end of this list.
label capacity() const noexcept
Size of the underlying storage.
void setCapacity(const label len)
Alter the size of the underlying storage.
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
bool hasPointPoints() const noexcept
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & pointPoints() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
const char * end
Definition SVGTools.H:223
List< edge > edgeList
List of edge.
Definition edgeList.H:32
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
volScalarField & e
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299