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 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 \*---------------------------------------------------------------------------*/
28 
29 #include "primitiveMesh.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 void 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_ = new labelListList(pe.size());
64  labelListList& 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));
130  }
132  return storage;
133  }
134 }
135 
136 
138 (
139  const label pointi
140 ) const
141 {
142  return pointPoints(pointi, labels_);
143 }
144 
145 
146 // ************************************************************************* //
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
List< edge > edgeList
List of edge.
Definition: edgeList.H:32
const labelListList & pointEdges() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:137
errorManip< error > abort(error &err)
Definition: errorManip.H:139
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:201
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & pointPoints() const
List< label > labelList
A List of labels.
Definition: List.H:62
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())