primitiveMeshEdgeCells.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 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
33 {
34  if (!ecPtr_)
35  {
36  if (debug)
37  {
38  Pout<< "primitiveMesh::edgeCells() : calculating edgeCells"
39  << endl;
40 
41  if (debug == -1)
42  {
43  // For checking calls:abort so we can quickly hunt down
44  // origin of call
45  FatalErrorIn("primitiveMesh::edgeCells()")
46  << abort(FatalError);
47  }
48  }
49  // Invert cellEdges
50  ecPtr_ = new labelListList(nEdges());
52  }
53 
54  return *ecPtr_;
55 }
56 
57 
59 (
60  const label edgeI,
61  dynamicLabelList& storage
62 ) const
63 {
64  if (hasEdgeCells())
65  {
66  return edgeCells()[edgeI];
67  }
68  else
69  {
70  const labelList& own = faceOwner();
71  const labelList& nei = faceNeighbour();
72 
73  // Construct edgeFaces
74  dynamicLabelList eFacesStorage;
75  const labelList& eFaces = edgeFaces(edgeI, eFacesStorage);
76 
77  storage.clear();
78 
79  // Do quadratic insertion.
80  forAll(eFaces, i)
81  {
82  label faceI = eFaces[i];
83 
84  {
85  label ownCellI = own[faceI];
86 
87  // Check if not already in storage
88  forAll(storage, j)
89  {
90  if (storage[j] == ownCellI)
91  {
92  ownCellI = -1;
93  break;
94  }
95  }
96 
97  if (ownCellI != -1)
98  {
99  storage.append(ownCellI);
100  }
101  }
102 
103  if (isInternalFace(faceI))
104  {
105  label neiCellI = nei[faceI];
106 
107  forAll(storage, j)
108  {
109  if (storage[j] == neiCellI)
110  {
111  neiCellI = -1;
112  break;
113  }
114  }
115 
116  if (neiCellI != -1)
117  {
118  storage.append(neiCellI);
119  }
120  }
121  }
122 
123  return storage;
124  }
125 }
126 
127 
129 {
130  return edgeCells(edgeI, labels_);
131 }
132 
133 
134 // ************************************************************************* //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::primitiveMesh::ecPtr_
labelListList * ecPtr_
Edge-cells.
Definition: primitiveMesh.H:119
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
Foam::primitiveMesh::cellEdges
const labelListList & cellEdges() const
Definition: primitiveMeshCellEdges.C:118
primitiveMesh.H
Foam::primitiveMesh::edgeCells
const labelListList & edgeCells() const
Definition: primitiveMeshEdgeCells.C:32
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
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
ListOps.H
Various functions to operate on Lists.