primitiveMeshPointEdges.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "primitiveMesh.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
36 {
37  // Loop through edges and mark up points
38 
39  if (debug)
40  {
41  Pout<< "primitiveMesh::calcPointEdges() : "
42  << "calculating pointEdges"
43  << endl;
44  }
45 
46  // It is an error to attempt to recalculate pointEdges
47  // if the pointer is already set
48  if (pePtr_)
49  {
50  FatalErrorIn("primitiveMesh::calcPointEdges() const")
51  << "pointEdges already calculated"
52  << abort(FatalError);
53  }
54  else
55  {
56  const edgeList& e = edges();
57 
58  // Count edges per point
59 
60  labelList npe(nPoints(), 0);
61 
62  forAll (e, edgeI)
63  {
64  npe[e[edgeI].start()]++;
65  npe[e[edgeI].end()]++;
66  }
67 
68 
69  // Size and fill edges per point
70 
71  pePtr_ = new labelListList(npe.size());
72  labelListList& pointEdgeAddr = *pePtr_;
73 
74  forAll (pointEdgeAddr, pointI)
75  {
76  pointEdgeAddr[pointI].setSize(npe[pointI]);
77  }
78  npe = 0;
79 
80  forAll (e, edgeI)
81  {
82  label v0 = e[edgeI].start();
83 
84  pointEdgeAddr[v0][npe[v0]++] = edgeI;
85 
86  label v1 = e[edgeI].end();
87 
88  pointEdgeAddr[v1][npe[v1]++] = edgeI;
89  }
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 {
98  if (!pePtr_)
99  {
100  calcPointEdges();
101  }
102 
103  return *pePtr_;
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // ************************************************************************* //
Foam::primitiveMesh::pePtr_
labelListList * pePtr_
Point-edges.
Definition: primitiveMesh.H:140
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::primitiveMesh::edges
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Definition: primitiveMeshEdges.C:353
Foam::primitiveMesh::pointEdges
const labelListList & pointEdges() const
Definition: primitiveMeshPointEdges.C:96
Foam::primitiveMesh::nPoints
label nPoints() const
Definition: primitiveMeshI.H:35
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
primitiveMesh.H
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::primitiveMesh::calcPointEdges
void calcPointEdges() const
Calculate point-edge addressing.
Definition: primitiveMeshPointEdges.C:35
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.