primitiveMeshEdgeFaces.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-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "primitiveMesh.H"
29 #include "ListOps.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
34 {
35  if (!efPtr_)
36  {
37  if (debug)
38  {
39  Pout<< "primitiveMesh::edgeFaces() : calculating edgeFaces" << 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  // Invert faceEdges
51  efPtr_ = new labelListList(nEdges());
52  invertManyToMany(nEdges(), faceEdges(), *efPtr_);
53  }
54 
55  return *efPtr_;
56 }
57 
58 
60 (
61  const label edgeI,
62  DynamicList<label>& storage
63 ) const
64 {
65  if (hasEdgeFaces())
66  {
67  return edgeFaces()[edgeI];
68  }
69  else
70  {
71  // Use the fact that pointEdges are sorted in incrementing edge order
72  const edge& e = edges()[edgeI];
73  const labelList& pFaces0 = pointFaces()[e[0]];
74  const labelList& pFaces1 = pointFaces()[e[1]];
75 
76  label i0 = 0;
77  label i1 = 0;
78 
79  storage.clear();
80 
81  while (i0 < pFaces0.size() && i1 < pFaces1.size())
82  {
83  if (pFaces0[i0] < pFaces1[i1])
84  {
85  ++i0;
86  }
87  else if (pFaces0[i0] > pFaces1[i1])
88  {
89  ++i1;
90  }
91  else
92  {
93  // Equal. Append.
94  storage.append(pFaces0[i0]);
95  ++i0;
96  ++i1;
97  }
98  }
99 
100  return storage;
101  }
102 }
103 
104 
105 const Foam::labelList& Foam::primitiveMesh::edgeFaces(const label edgeI) const
106 {
107  return edgeFaces(edgeI, labels_);
108 }
109 
110 
111 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::DynamicList< label >
Foam::primitiveMesh::edgeFaces
const labelListList & edgeFaces() const
Definition: primitiveMeshEdgeFaces.C:33
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::primitiveMesh::nEdges
label nEdges() const
Number of mesh edges.
Definition: primitiveMeshI.H:67
primitiveMesh.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Definition: ListOpsTemplates.C:727
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:474
Foam::DynamicList::clear
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:348
Foam::primitiveMesh::faceEdges
const labelListList & faceEdges() const
Definition: primitiveMeshEdges.C:528
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::List< labelList >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
ListOps.H
Various functions to operate on Lists.