primitiveMeshCellEdges.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 -------------------------------------------------------------------------------
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 "DynamicList.H"
30 #include "ListOps.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 void Foam::primitiveMesh::calcCellEdges() const
35 {
36  // Loop through all faces and mark up cells with edges of the face.
37  // Check for duplicates
38 
39  if (debug)
40  {
41  Pout<< "primitiveMesh::calcCellEdges() : "
42  << "calculating cellEdges"
43  << endl;
44 
45  if (debug == -1)
46  {
47  // For checking calls:abort so we can quickly hunt down
48  // origin of call
50  << abort(FatalError);
51  }
52  }
53 
54  // It is an error to attempt to recalculate cellEdges
55  // if the pointer is already set
56  if (cePtr_)
57  {
59  << "cellEdges already calculated"
60  << abort(FatalError);
61  }
62  else
63  {
64  // Set up temporary storage
65  List<DynamicList<label>> ce(nCells());
66 
67 
68  // Get reference to faceCells and faceEdges
69  const labelList& own = faceOwner();
70  const labelList& nei = faceNeighbour();
71  const labelListList& fe = faceEdges();
72 
73  // loop through the list again and add edges; checking for duplicates
74  forAll(own, facei)
75  {
76  DynamicList<label>& curCellEdges = ce[own[facei]];
77 
78  const labelList& curEdges = fe[facei];
79 
80  forAll(curEdges, edgeI)
81  {
82  if (!curCellEdges.found(curEdges[edgeI]))
83  {
84  // Add the edge
85  curCellEdges.append(curEdges[edgeI]);
86  }
87  }
88  }
89 
90  forAll(nei, facei)
91  {
92  DynamicList<label>& curCellEdges = ce[nei[facei]];
93 
94  const labelList& curEdges = fe[facei];
95 
96  forAll(curEdges, edgeI)
97  {
98  if (!curCellEdges.found(curEdges[edgeI]))
99  {
100  // add the edge
101  curCellEdges.append(curEdges[edgeI]);
102  }
103  }
104  }
105 
106  cePtr_ = new labelListList(ce.size());
107  labelListList& cellEdgeAddr = *cePtr_;
108 
109  // reset the size
110  forAll(ce, celli)
111  {
112  cellEdgeAddr[celli].transfer(ce[celli]);
113  }
114  }
115 }
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
121 {
122  if (!cePtr_)
123  {
124  calcCellEdges();
125  }
126 
127  return *cePtr_;
128 }
129 
130 
131 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::primitiveMesh::faceOwner
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
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::primitiveMesh::faceNeighbour
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::primitiveMesh::cellEdges
const labelListList & cellEdges() const
Definition: primitiveMeshCellEdges.C:120
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 >
DynamicList.H
ListOps.H
Various functions to operate on Lists.