zoneCellStencils.H
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) 2020 DLR
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 Class
27  Foam::zoneCellStencils
28 
29 Description
30  base class for cell stencil in a narrow band
31 
32  Original code supplied by Henning Scheufler, DLR (2019)
33 
34 SourceFiles
35  zoneCellStencils.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef zoneCellStencils_H
40 #define zoneCellStencils_H
41 
42 #include "boolList.H"
43 #include "HashSet.H"
44 #include "Map.H"
45 #include "indirectPrimitivePatch.H"
46 #include "MeshObject.H"
47 #include "fvMesh.H"
48 #include "globalIndex.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class zoneCellStencils Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class zoneCellStencils
60 :
61  public labelListList
62 {
63 protected:
64 
65  // Protected Data
66 
67  //- const reference to fvMesh
68  const fvMesh& meshRef_;
69 
70  //- cells requiring processor communciation
72 
73  //- Global numbering for cells and boundary faces
75 
76 
77  // Protected Member Functions
78 
79  //- Return patch of all coupled faces.
81 
82  //- Return patch of all coupled faces.
84 
85  //- Valid boundary faces (not empty and not coupled)
86  void validBoundaryFaces(boolList& isValidBFace) const;
87 
88  //- Merge two lists and guarantee globalI is first.
89  static void merge
90  (
91  const label globalI,
92  const labelList& pGlobals,
93  labelList& cCells
94  );
95 
96  //- Collect cell neighbours of faces in global numbering
97  void insertFaceCells
98  (
99  const label exclude0,
100  const label exclude1,
101  const boolList& nonEmptyFace,
102  const labelList& faceLabels,
103  labelHashSet& globals
104  ) const;
105 
106  //- Collect cell neighbours of faces in global numbering
108  (
109  const boolList& nonEmptyFace,
110  const labelList& faceLabels,
111  labelHashSet& globals
112  ) const;
113 
114  virtual void calculateStencil
115  (
116  const boolList& zone,
117  labelListList& globalCellCells
118  ) = 0;
119 
120 
121  //- No copy construct
122  zoneCellStencils(const zoneCellStencils&) = delete;
123 
124  //- No copy assignment
125  void operator=(const zoneCellStencils&) = delete;
126 
127 public:
128 
129  // Declare name of the class and its debug switch
130  TypeName("zoneCellStencils");
131 
132 
133  // Constructors
134 
135  //- Construct from all cells and boundary faces
136  explicit zoneCellStencils(const fvMesh&);
137 
138  //- Calculates per cell the neighbour data
139  // (= cell or boundary in global numbering).
140  // First element is always cell itself!
141  //- Destructor
142  virtual ~zoneCellStencils() = default;
143 
144 
145  // Member Functions
146 
147  void updateStencil
148  (
149  const boolList& zone
150  )
151  {
152  calculateStencil(zone,*this);
153  }
154 
156  {
157  return needComm_;
158  }
159 
160  const polyMesh& mesh() const noexcept
161  {
162  return meshRef_;
163  }
164 
165  //- Global numbering for cells and boundary faces
166  const globalIndex& globalNumbering() const noexcept
167  {
168  return globalNumbering_;
169  }
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
void validBoundaryFaces(boolList &isValidBFace) const
Valid boundary faces (not empty and not coupled)
static void merge(const label globalI, const labelList &pGlobals, labelList &cCells)
Merge two lists and guarantee globalI is first.
zoneCellStencils(const zoneCellStencils &)=delete
No copy construct.
TypeName("zoneCellStencils")
void insertFaceCells(const label exclude0, const label exclude1, const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
labelHashSet needComm_
cells requiring processor communciation
void operator=(const zoneCellStencils &)=delete
No copy assignment.
const polyMesh & mesh() const noexcept
labelList calcFaceCells(const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
autoPtr< indirectPrimitivePatch > nonEmptyFacesPatch() const
Return patch of all coupled faces.
labelList faceLabels(nFaceLabels)
const labelHashSet & needsComm() noexcept
const fvMesh & meshRef_
const reference to fvMesh
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:61
Base class for mesh zones.
Definition: zone.H:59
autoPtr< indirectPrimitivePatch > allCoupledFacesPatch() const
Return patch of all coupled faces.
const direction noexcept
Definition: Scalar.H:258
void updateStencil(const boolList &zone)
virtual ~zoneCellStencils()=default
Calculates per cell the neighbour data.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
base class for cell stencil in a narrow band
const globalIndex & globalNumbering() const noexcept
Global numbering for cells and boundary faces.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
globalIndex globalNumbering_
Global numbering for cells and boundary faces.
virtual void calculateStencil(const boolList &zone, labelListList &globalCellCells)=0
Namespace for OpenFOAM.