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 zoneSubSet_H
66 #define 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
180 
181  //- Map from the sub-mesh to original cell zones
182  template<class Type>
184  (
186  ) const;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Detail
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #ifdef NoRepository
198  #include "zoneSubSetTemplates.C"
199 #endif
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #endif
203 
204 // ************************************************************************* //
Foam::Detail::zoneSubSet::subsetter
fvMeshSubset & subsetter()
The mesh subsetter.
Definition: zoneSubSet.H:172
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
zoneSubSetTemplates.C
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvMeshSubset
Given the original mesh and the list of selected cells, it creates the mesh consisting only of the de...
Definition: fvMeshSubset.H:73
fvMeshSubset.H
zoneSubSet
Intermediate tool for handling cellZones for function objects (e.g. momentumError) wherein the sub-me...
Foam::Detail::zoneSubSet::useSubMesh
bool useSubMesh() const noexcept
True if sub-mesh is expected to be used.
Definition: zoneSubSet.H:178
Foam::Detail::zoneSubSet::zones
const wordRes & zones() const noexcept
Return the current zones selector.
Definition: zoneSubSet.H:184
Foam::Detail::zoneSubSet::mapToZone
tmp< GeometricField< Type, fvPatchField, volMesh > > mapToZone(const GeometricField< Type, fvPatchField, volMesh > &subVolField) const
Map from the sub-mesh to original cell zones.
Foam::Detail::zoneSubSet
Definition: zoneSubSet.H:98
Foam::Detail::zoneSubSet::baseMesh
const fvMesh & baseMesh() const noexcept
The entire base mesh.
Definition: zoneSubSet.H:160
Foam::Detail::zoneSubSet::~zoneSubSet
virtual ~zoneSubSet()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Detail::zoneSubSet::nLayers
label nLayers() const noexcept
Return number of layers around cell zones.
Definition: zoneSubSet.H:190
Foam::fvMeshSubset::baseMesh
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:30
Foam::Detail::zoneSubSet::TypeName
TypeName("zoneSubSet")
Runtime type information.
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::Detail::zoneSubSet::subsetter
const fvMeshSubset & subsetter() const
The mesh subsetter.
Definition: zoneSubSet.H:166
Foam::GeometricField< Type, fvPatchField, volMesh >