CFCCellToCellStencil.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 | Copyright (C) 2011-2013 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 "CFCCellToCellStencil.H"
27 #include "syncTools.H"
28 #include "SortableList.H"
29 #include "emptyPolyPatch.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 // Calculates per face the neighbour data (= cell or boundary face)
35 (
36  labelList& neiGlobal
37 ) const
38 {
39  const polyBoundaryMesh& patches = mesh().boundaryMesh();
40  const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
41  const labelList& own = mesh().faceOwner();
42 
43  neiGlobal.setSize(nBnd);
44 
45  forAll(patches, patchI)
46  {
47  const polyPatch& pp = patches[patchI];
48  label faceI = pp.start();
49 
50  if (pp.coupled())
51  {
52  // For coupled faces get the cell on the other side
53  forAll(pp, i)
54  {
55  label bFaceI = faceI-mesh().nInternalFaces();
56  neiGlobal[bFaceI] = globalNumbering().toGlobal(own[faceI]);
57  faceI++;
58  }
59  }
60  else if (isA<emptyPolyPatch>(pp))
61  {
62  forAll(pp, i)
63  {
64  label bFaceI = faceI-mesh().nInternalFaces();
65  neiGlobal[bFaceI] = -1;
66  faceI++;
67  }
68  }
69  else
70  {
71  // For noncoupled faces get the boundary face.
72  forAll(pp, i)
73  {
74  label bFaceI = faceI-mesh().nInternalFaces();
75  neiGlobal[bFaceI] =
76  globalNumbering().toGlobal(mesh().nCells()+bFaceI);
77  faceI++;
78  }
79  }
80  }
81  syncTools::swapBoundaryFaceList(mesh(), neiGlobal);
82 }
83 
84 
85 // Calculates per cell the neighbour data (= cell or boundary in global
86 // numbering). First element is always cell itself!
88  const
89 {
90  const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
91  const labelList& own = mesh().faceOwner();
92  const labelList& nei = mesh().faceNeighbour();
93 
94 
95  // Calculate coupled neighbour (in global numbering)
96  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97 
98  labelList neiGlobal(nBnd);
99  calcFaceBoundaryData(neiGlobal);
100 
101 
102  // Determine cellCells in global numbering
103  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104 
105  globalCellCells.setSize(mesh().nCells());
106  forAll(globalCellCells, cellI)
107  {
108  const cell& cFaces = mesh().cells()[cellI];
109 
110  labelList& cCells = globalCellCells[cellI];
111 
112  cCells.setSize(cFaces.size()+1);
113 
114  label nNbr = 0;
115 
116  // Myself
117  cCells[nNbr++] = globalNumbering().toGlobal(cellI);
118 
119  // Collect neighbouring cells/faces
120  forAll(cFaces, i)
121  {
122  label faceI = cFaces[i];
123 
124  if (mesh().isInternalFace(faceI))
125  {
126  label nbrCellI = own[faceI];
127  if (nbrCellI == cellI)
128  {
129  nbrCellI = nei[faceI];
130  }
131  cCells[nNbr++] = globalNumbering().toGlobal(nbrCellI);
132  }
133  else
134  {
135  label nbrCellI = neiGlobal[faceI-mesh().nInternalFaces()];
136  if (nbrCellI != -1)
137  {
138  cCells[nNbr++] = nbrCellI;
139  }
140  }
141  }
142  cCells.setSize(nNbr);
143  }
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 
150 :
152 {
153  // Calculate per cell the (face) connected cells (in global numbering)
154  calcCellStencil(*this);
155 }
156 
157 
158 // ************************************************************************* //
Foam::cellToCellStencil::mesh
const polyMesh & mesh() const
Definition: cellToCellStencil.H:122
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:322
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:136
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::cellToCellStencil::globalNumbering
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
Definition: cellToCellStencil.H:128
SortableList.H
Foam::CFCCellToCellStencil::calcFaceBoundaryData
void calcFaceBoundaryData(labelList &neiGlobal) const
Definition: CFCCellToCellStencil.C:35
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::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1017
Foam::primitiveMesh::nInternalFaces
label nInternalFaces() const
Definition: primitiveMeshI.H:52
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
emptyPolyPatch.H
Foam::CFCCellToCellStencil::calcCellStencil
void calcCellStencil(labelListList &globalCellCells) const
Definition: CFCCellToCellStencil.C:87
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::primitiveMesh::nFaces
label nFaces() const
Definition: primitiveMeshI.H:58
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
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::cellToCellStencil
baseclass for extended cell centred addressing. Contains per cell a list of neighbouring cells and/or...
Definition: cellToCellStencil.H:54
CFCCellToCellStencil.H
Foam::CFCCellToCellStencil::CFCCellToCellStencil
CFCCellToCellStencil(const polyMesh &mesh)
Construct from mesh.
Definition: CFCCellToCellStencil.C:149
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Foam::polyMesh::faceNeighbour
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition: polyMesh.C:1023
Foam::globalIndex::toGlobal
label toGlobal(const label i) const
From local to global.
Definition: globalIndexI.H:82