primitiveMeshEdgeCells.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-2016 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "primitiveMesh.H"
30 #include "ListOps.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
35 {
36  if (!ecPtr_)
37  {
38  if (debug)
39  {
40  Pout<< "primitiveMesh::edgeCells() : calculating edgeCells" << endl;
41 
42  if (debug == -1)
43  {
44  // For checking calls:abort so we can quickly hunt down
45  // origin of call
47  << abort(FatalError);
48  }
49  }
50  // Invert cellEdges
51  ecPtr_ = new labelListList(nEdges());
52  invertManyToMany(nEdges(), cellEdges(), *ecPtr_);
53  }
54 
55  return *ecPtr_;
56 }
57 
58 
60 (
61  const label edgei,
62  DynamicList<label>& storage
63 ) const
64 {
65  if (hasEdgeCells())
66  {
67  return edgeCells()[edgei];
68  }
69  else
70  {
71  const labelList& own = faceOwner();
72  const labelList& nei = faceNeighbour();
73 
74  // Construct edgeFaces
75  DynamicList<label> eFacesStorage;
76  const labelList& eFaces = edgeFaces(edgei, eFacesStorage);
77 
78  storage.clear();
79 
80  // Do quadratic insertion.
81  for (const label facei : eFaces)
82  {
83  {
84  // Owner cell
85  if (!storage.contains(own[facei]))
86  {
87  storage.push_back(own[facei]);
88  }
89  }
90 
91  if (isInternalFace(facei))
92  {
93  // Neighbour cell
94  if (!storage.contains(nei[facei]))
95  {
96  storage.push_back(nei[facei]);
97  }
98  }
99  }
100 
101  return storage;
102  }
103 }
104 
105 
106 const Foam::labelList& Foam::primitiveMesh::edgeCells(const label edgei) const
107 {
108  return edgeCells(edgei, labels_);
109 }
110 
111 
112 // ************************************************************************* //
const labelListList & cellEdges() const
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Various functions to operate on Lists.
const labelListList & edgeCells() const
errorManip< error > abort(error &err)
Definition: errorManip.H:139
label nEdges() const
Number of mesh edges.
int debug
Static debugging option.
List< label > labelList
A List of labels.
Definition: List.H:62
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.