Loading...
Searching...
No Matches
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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
29#include "syncTools.H"
30#include "emptyPolyPatch.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
34void Foam::CFCCellToCellStencil::calcFaceBoundaryData
35(
36 labelList& neiGlobal
37) const
38{
39 const polyBoundaryMesh& patches = mesh().boundaryMesh();
40 const label nBnd = mesh().nBoundaryFaces();
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 }
82}
83
84
85void Foam::CFCCellToCellStencil::calcCellStencil
86(
87 labelListList& globalCellCells
88) const
89{
90 const label nBnd = mesh().nBoundaryFaces();
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:
151 cellToCellStencil(mesh)
152{
153 // Calculate per cell the (face) connected cells (in global numbering)
154 calcCellStencil(*this);
155}
156
157
158// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
CFCCellToCellStencil(const polyMesh &mesh)
Construct from mesh.
void setSize(label n)
Alias for resize().
Definition List.H:536
const polyMesh & mesh() const
cellToCellStencil(const polyMesh &)
Construct from mesh.
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
A cell is defined as a list of faces with extra functionality.
Definition cell.H:56
label toGlobal(const label proci, const label i) const
From local to global on proci.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
virtual const labelList & faceOwner() const
Return face owner.
Definition polyMesh.C:1101
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition polyMesh.C:1107
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces).
label nInternalFaces() const noexcept
Number of internal faces.
const cellList & cells() const
static void swapBoundaryFaceList(const polyMesh &mesh, UList< T > &faceValues, const bool parRun=UPstream::parRun())
Swap coupled boundary face values. Uses eqOp.
Definition syncTools.H:524
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299