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 MeshObject<fvMesh, UpdateableMeshObject, zoneCellStencils>,
62  public labelListList
63 {
64 protected:
65 
66  // Protected Members
67 
69 
71 
72 
73  // Protected Member Functions
74 
75  //- Return patch of all coupled faces.
77 
78  //- Return patch of all coupled faces.
80 
81  //- Valid boundary faces (not empty and not coupled)
82  void validBoundaryFaces(boolList& isValidBFace) const;
83 
84  //- Merge two lists and guarantee globalI is first.
85  static void merge
86  (
87  const label globalI,
88  const labelList& pGlobals,
89  labelList& cCells
90  );
91 
92  //- Collect cell neighbours of faces in global numbering
93  void insertFaceCells
94  (
95  const label exclude0,
96  const label exclude1,
97  const boolList& nonEmptyFace,
98  const labelList& faceLabels,
99  labelHashSet& globals
100  ) const;
101 
102  //- Collect cell neighbours of faces in global numbering
104  (
105  const boolList& nonEmptyFace,
106  const labelList& faceLabels,
107  labelHashSet& globals
108  ) const;
109 
110  virtual void calculateStencil
111  (
112  const boolList& zone,
113  labelListList& globalCellCells
114  ) = 0;
115 
116 
117 public:
118 
119  // Declare name of the class and its debug switch
120  TypeName("zoneCellStencils");
121 
122 
123  // Constructors
124 
125  //- Construct from all cells and boundary faces
126  explicit zoneCellStencils(const fvMesh&);
127 
128 
129  // Member Functions
130 
131  //- Calculates per cell the neighbour data
132  // (= cell or boundary in global numbering).
133  // First element is always cell itself!
135  (
136  const boolList& zone
137  )
138  {
139  calculateStencil(zone,*this);
140  }
141 
142  const labelHashSet& needsComm()
143  {
144  return needComm_;
145  }
146 
147  //- Global numbering for cells and boundary faces
148  const globalIndex& globalNumbering() const
149  {
150  return globalNumbering_;
151  }
152 
153  virtual void updateMesh(const mapPolyMesh& mpm);
154 
155  virtual bool movePoints()
156  {
157  // Do nothing
158  return false;
159  }
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
Foam::zoneCellStencils::needsComm
const labelHashSet & needsComm()
Definition: zoneCellStencils.H:141
Foam::zoneCellStencils::nonEmptyFacesPatch
autoPtr< indirectPrimitivePatch > nonEmptyFacesPatch() const
Return patch of all coupled faces.
Definition: zoneCellStencils.C:44
Foam::zoneCellStencils::allCoupledFacesPatch
autoPtr< indirectPrimitivePatch > allCoupledFacesPatch() const
Return patch of all coupled faces.
Definition: zoneCellStencils.C:86
boolList.H
Foam::zoneCellStencils::zoneCellStencils
zoneCellStencils(const fvMesh &)
Construct from all cells and boundary faces.
Definition: zoneCellStencils.C:259
Foam::zoneCellStencils::validBoundaryFaces
void validBoundaryFaces(boolList &isValidBFace) const
Valid boundary faces (not empty and not coupled)
Definition: zoneCellStencils.C:127
Foam::zoneCellStencils::merge
static void merge(const label globalI, const labelList &pGlobals, labelList &cCells)
Merge two lists and guarantee globalI is first.
Definition: zoneCellStencils.C:150
globalIndex.H
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::HashSet< label, Hash< label > >
Foam::zoneCellStencils::insertFaceCells
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.
Definition: zoneCellStencils.C:185
Map.H
Foam::zoneCellStencils::TypeName
TypeName("zoneCellStencils")
indirectPrimitivePatch.H
HashSet.H
Foam::zoneCellStencils
base class for cell stencil in a narrow band
Definition: zoneCellStencils.H:58
Foam::zoneCellStencils::globalNumbering
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
Definition: zoneCellStencils.H:147
Foam::zoneCellStencils::movePoints
virtual bool movePoints()
Definition: zoneCellStencils.H:154
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::zoneCellStencils::calculateStencil
virtual void calculateStencil(const boolList &zone, labelListList &globalCellCells)=0
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::zoneCellStencils::calcFaceCells
labelList calcFaceCells(const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
Definition: zoneCellStencils.C:236
Foam::zoneCellStencils::updateStencil
void updateStencil(const boolList &zone)
Calculates per cell the neighbour data.
Definition: zoneCellStencils.H:134
Foam::List< labelList >
MeshObject.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:88
Foam::zoneCellStencils::needComm_
labelHashSet needComm_
Definition: zoneCellStencils.H:67
Foam::zoneCellStencils::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Definition: zoneCellStencils.C:270
Foam::zoneCellStencils::globalNumbering_
globalIndex globalNumbering_
Definition: zoneCellStencils.H:69