primitiveMeshEdgeFaces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. 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" << endl;
38 
39  if (debug == -1)
40  {
41  // For checking calls:abort so we can quickly hunt down
42  // origin of call
44  << abort(FatalError);
45  }
46  }
47 
48  // Invert faceEdges
49  efPtr_ = new labelListList(nEdges());
50  invertManyToMany(nEdges(), faceEdges(), *efPtr_);
51  }
52 
53  return *efPtr_;
54 }
55 
56 
58 (
59  const label edgeI,
60  DynamicList<label>& storage
61 ) const
62 {
63  if (hasEdgeFaces())
64  {
65  return edgeFaces()[edgeI];
66  }
67  else
68  {
69  // Use the fact that pointEdges are sorted in incrementing edge order
70  const edge& e = edges()[edgeI];
71  const labelList& pFaces0 = pointFaces()[e[0]];
72  const labelList& pFaces1 = pointFaces()[e[1]];
73 
74  label i0 = 0;
75  label i1 = 0;
76 
77  storage.clear();
78 
79  while (i0 < pFaces0.size() && i1 < pFaces1.size())
80  {
81  if (pFaces0[i0] < pFaces1[i1])
82  {
83  ++i0;
84  }
85  else if (pFaces0[i0] > pFaces1[i1])
86  {
87  ++i1;
88  }
89  else
90  {
91  // Equal. Append.
92  storage.append(pFaces0[i0]);
93  ++i0;
94  ++i1;
95  }
96  }
97 
98  return storage;
99  }
100 }
101 
102 
104 {
105  return edgeFaces(edgeI, labels_);
106 }
107 
108 
109 // ************************************************************************* //
bool hasEdgeFaces() const
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
error FatalError
const labelListList & faceEdges() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label nEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
const labelListList & pointFaces() const
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:236
const labelListList & edgeFaces() const