zoneSubSet.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) 2021 OpenCFD Ltd.
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::zoneSubSet
28 
29 Description
30  Intermediate tool for handling \c cellZones
31  for function objects (e.g. \c momentumError)
32  wherein the sub-mesh option is available.
33 
34 Usage
35  Minimal example by using \c system/controlDict.functions:
36  \verbatim
37  <functionObject>
38  {
39  // Mandatory and optional entries
40  ...
41 
42  // Inherited entries
43  cellZones ( <cellZone1> <cellZone2> ... <cellZoneN> );
44  nLayers <label>;
45  }
46  \endverbatim
47 
48  where the entries mean:
49  \table
50  Property | Description | Type | Reqd | Deflt
51  cellZones | Names of cellZones | wordRes | no | -
52  nLayers | Number of cell layers around cellZones | label | no | 0
53  \endtable
54 
55 See also
56  - Foam::functionObjects::momentumError
57  - Foam::functionObjects::div
58 
59 SourceFiles
60  zoneSubSet.C
61  zoneSubSetTemplates.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef Foam_zoneSubSet_H
66 #define Foam_zoneSubSet_H
67 
68 #include "fvMeshSubset.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 namespace Detail
75 {
76 
77 /*---------------------------------------------------------------------------*\
78  Class zoneSubSet Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 class zoneSubSet
82 {
83  // Private Data
84 
85  //- Subsetting engine
86  fvMeshSubset subsetter_;
87 
88  //- Matcher for zones
89  wordRes zoneMatcher_;
90 
91  //- Number of layers around zones
92  label nLayers_;
93 
94  //- The halo cells
95  bitSet haloCells_;
96 
97 
98  // Private Members Functions
99 
100  //- Initialise the sub-mesh
101  bool correct();
102 
103  //- No copy construct
104  zoneSubSet(const zoneSubSet&) = delete;
105 
106  //- No copy assignment
107  void operator=(const zoneSubSet&) = delete;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("zoneSubSet");
114 
115 
116  // Constructors
117 
118  //- Construct from components
119  zoneSubSet
120  (
121  const fvMesh& mesh,
122  const wordRes& zoneSelector,
123  const label nZoneLayers = 0
124  );
125 
126  //- Construct from mesh and dictionary
127  zoneSubSet
128  (
129  const fvMesh& mesh,
130  const dictionary& dict
131  );
132 
133 
134  //- Destructor
135  virtual ~zoneSubSet() = default;
136 
137 
138  // Member Functions
139 
140  // Access
141 
142  //- The entire base mesh
143  const fvMesh& baseMesh() const noexcept
144  {
145  return subsetter_.baseMesh();
146  }
147 
148  //- The mesh subsetter
149  const fvMeshSubset& subsetter() const
150  {
151  return subsetter_;
152  }
153 
154  //- The mesh subsetter
156  {
157  return subsetter_;
158  }
159 
160  //- True if sub-mesh is expected to be used
161  bool useSubMesh() const noexcept
162  {
163  return !zoneMatcher_.empty();
164  }
165 
166  //- Return the current zones selector
167  const wordRes& zones() const noexcept
168  {
169  return zoneMatcher_;
170  }
171 
172  //- Return number of layers around cell zones
173  label nLayers() const noexcept
174  {
175  return nLayers_;
176  }
177 
178 
179  // Fields
181  //- Map from the sub-mesh to original cell zones
182  template<class Type>
184  (
186  ) const;
187 };
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Detail
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 #ifdef NoRepository
198  #include "zoneSubSetTemplates.C"
199 #endif
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #endif
203 
204 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
tmp< GeometricField< Type, fvPatchField, volMesh > > mapToZone(const GeometricField< Type, fvPatchField, volMesh > &subVolField) const
Map from the sub-mesh to original cell zones.
const fvMesh & baseMesh() const noexcept
The entire base mesh.
Definition: zoneSubSet.H:180
const wordRes & zones() const noexcept
Return the current zones selector.
Definition: zoneSubSet.H:212
bool useSubMesh() const noexcept
True if sub-mesh is expected to be used.
Definition: zoneSubSet.H:204
virtual ~zoneSubSet()=default
Destructor.
dynamicFvMesh & mesh
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
const direction noexcept
Definition: Scalar.H:258
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:75
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
const fvMeshSubset & subsetter() const
The mesh subsetter.
Definition: zoneSubSet.H:188
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label nLayers() const noexcept
Return number of layers around cell zones.
Definition: zoneSubSet.H:220
A class for managing temporary objects.
Definition: HashPtrTable.H:50
TypeName("zoneSubSet")
Runtime type information.
Namespace for OpenFOAM.