primitiveMeshEdgeFaces.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 #include "ListOps.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 {
33  if (!efPtr_)
34  {
35  if (debug)
36  {
37  Pout<< "primitiveMesh::edgeFaces() : calculating edgeFaces"
38  << endl;
39 
40  if (debug == -1)
41  {
42  // For checking calls:abort so we can quickly hunt down
43  // origin of call
44  FatalErrorIn("primitiveMesh::edgeFaces()")
45  << abort(FatalError);
46  }
47  }
48 
49  // Invert faceEdges
50  efPtr_ = new labelListList(nEdges());
52  }
53 
54  return *efPtr_;
55 }
56 
57 
59 (
60  const label edgeI,
61  dynamicLabelList& storage
62 ) const
63 {
64  if (hasEdgeFaces())
65  {
66  return edgeFaces()[edgeI];
67  }
68  else
69  {
70  // Use the fact that pointEdges are sorted in incrementing edge order
71  const edge& e = edges()[edgeI];
72  const labelList& pFaces0 = pointFaces()[e[0]];
73  const labelList& pFaces1 = pointFaces()[e[1]];
74 
75  label i0 = 0;
76  label i1 = 0;
77 
78  storage.clear();
79 
80  while (i0 < pFaces0.size() && i1 < pFaces1.size())
81  {
82  if (pFaces0[i0] < pFaces1[i1])
83  {
84  ++i0;
85  }
86  else if (pFaces0[i0] > pFaces1[i1])
87  {
88  ++i1;
89  }
90  else
91  {
92  // Equal. Append.
93  storage.append(pFaces0[i0]);
94  ++i0;
95  ++i1;
96  }
97  }
98 
99  return storage;
100  }
101 }
102 
103 
105 {
106  return edgeFaces(edgeI, labels_);
107 }
108 
109 
110 // ************************************************************************* //
Foam::primitiveMesh::edgeFaces
const labelListList & edgeFaces() const
Definition: primitiveMeshEdgeFaces.C:31
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Definition: ListOpsTemplates.C:418
Foam::primitiveMesh::nEdges
label nEdges() const
Definition: primitiveMeshI.H:41
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::primitiveMesh::faceEdges
const labelListList & faceEdges() const
Definition: primitiveMeshEdges.C:366
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
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
Foam::primitiveMesh::efPtr_
labelListList * efPtr_
Edge-faces.
Definition: primitiveMesh.H:128
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: List.C:379
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
ListOps.H
Various functions to operate on Lists.
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.