volRegion.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) 2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::volRegion
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Volume (cell) region selection class.
35 
36  The adjustments for mesh changes have been implemented with a lazy
37  evaluation, to avoid unnecessary recalculation until the values are
38  actually required. The update() method is used to ensure the cache
39  values are up-to-date.
40 
41  Examples of function object specification:
42  \verbatim
43  volRegion0
44  {
45  .
46  .
47  regionType cellZone;
48  name c0;
49  .
50  .
51  }
52 
53  volRegionAll
54  {
55  .
56  .
57  regionType all;
58  .
59  .
60  }
61  \endverbatim
62 
63 Usage
64  \table
65  Property | Description | Required | Default
66  regionType | Selection type: all/cellSet/cellZone | no | all
67  name | Name of cellSet/cellZone if required | conditional |
68  \endtable
69 
70 See also
71  Foam::functionObject
72 
73 SourceFiles
74  volRegion.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef functionObjects_volRegion_H
79 #define functionObjects_volRegion_H
80 
81 #include "writeFile.H"
82 #include "Enum.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 
89 // Forward Declarations
90 class fvMesh;
91 class polyMesh;
92 class mapPolyMesh;
93 
94 namespace functionObjects
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class volRegion Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class volRegion
102 {
103  // Private Member Data
104 
105  const fvMesh& volMesh_;
106 
107  //- Flag to indicate whether the volRegion requires updating
108  bool requireUpdate_;
109 
110  //- The cell ids, from cellSet
111  labelList cellIds_;
112 
113  //- Cached total number of cells selected
114  label nCells_;
115 
116  //- Cached total selection volume
117  scalar V_;
118 
119 
120  // Private Member Functions
121 
122  //- Update cellIds, nCells, volume
123  void calculateCache();
124 
125 
126 public:
127 
128  // Public data types
129 
130  //- Region type enumeration
131  enum regionTypes
132  {
133  vrtAll = 0,
134  vrtCellSet,
135  vrtCellZone
136  };
137 
138  //- Region type names
139  static const Enum<regionTypes> regionTypeNames_;
140 
141 
142 protected:
143 
144  // Protected Data
145 
146  //- Region type
148 
149  //- Region name (cellSet, cellZone, ...)
151 
152  //- Region ID (zone ID, ...)
153  label regionID_;
154 
155 
156  // Protected Member Functions
157 
158  //- Use all cells, not the cellIDs
159  inline bool useAllCells() const noexcept;
160 
161  //- Output file header information
162  void writeFileHeader(const writeFile& wf, Ostream& file) const;
163 
164 
165 public:
166 
167  //- Run-time type information
168  TypeName("volRegion");
169 
170 
171  // Constructors
172 
173  //- Construct from fvMesh and dictionary
174  volRegion(const fvMesh& mesh, const dictionary& dict);
175 
176 
177  //- Destructor
178  virtual ~volRegion() = default;
179 
180 
181  // Member Functions
182 
183  //- The region type
184  inline regionTypes regionType() const noexcept;
185 
186  //- Return the local list of cell IDs.
187  // Empty or invalid for 'all'
188  const labelList& cellIDs() const;
189 
190  //- Return the total number of cells selected in the region
191  inline label nCells() const;
192 
193  //- Return total volume of the selected region
194  inline scalar V() const;
195 
196  //- Update the cached values as required
197  // \return False if the values were already up to date
198  bool update();
199 
200 
201  //- Read from dictionary
202  virtual bool read(const dictionary& dict);
203 
204  //- Update for changes of mesh
205  virtual void updateMesh(const mapPolyMesh&);
206 
207  //- Update for mesh point-motion
208  virtual void movePoints(const polyMesh&);
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace functionObjects
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #include "volRegionI.H"
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::functionObjects::volRegion::regionID_
label regionID_
Region ID (zone ID, ...)
Definition: volRegion.H:167
writeFile.H
Foam::Enum< regionTypes >
Foam::functionObjects::volRegion::vrtCellZone
A cellZone.
Definition: volRegion.H:149
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::volRegion::update
bool update()
Update the cached values as required.
Definition: volRegion.C:232
Foam::functionObjects::volRegion
Volume (cell) region selection class.
Definition: volRegion.H:115
Foam::functionObjects::volRegion::regionName_
word regionName_
Region name (cellSet, cellZone, ...)
Definition: volRegion.H:164
Foam::functionObjects::volRegion::vrtAll
All cells.
Definition: volRegion.H:147
Foam::functionObjects::volRegion::regionTypes
regionTypes
Region type enumeration.
Definition: volRegion.H:145
Foam::functionObjects::volRegion::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: volRegion.C:244
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObjects::volRegion::regionType_
regionTypes regionType_
Region type.
Definition: volRegion.H:161
Foam::functionObjects::volRegion::TypeName
TypeName("volRegion")
Run-time type information.
Foam::functionObjects::volRegion::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: volRegion.C:171
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::volRegion::nCells
label nCells() const
Return the total number of cells selected in the region.
Definition: volRegionI.H:44
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::functionObjects::volRegion::vrtCellSet
A cellSet.
Definition: volRegion.H:148
Foam::functionObjects::volRegion::useAllCells
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
Definition: volRegionI.H:31
Foam::functionObjects::volRegion::regionTypeNames_
static const Enum< regionTypes > regionTypeNames_
Region type names.
Definition: volRegion.H:153
Foam::functionObjects::volRegion::movePoints
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: volRegion.C:250
Foam::List< label >
Foam::functionObjects::volRegion::regionType
regionTypes regionType() const noexcept
The region type.
Definition: volRegionI.H:38
Foam::functionObjects::volRegion::cellIDs
const labelList & cellIDs() const
Return the local list of cell IDs.
Definition: volRegion.C:203
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::functionObjects::volRegion::writeFileHeader
void writeFileHeader(const writeFile &wf, Ostream &file) const
Output file header information.
Definition: volRegion.C:127
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::volRegion::V
scalar V() const
Return total volume of the selected region.
Definition: volRegionI.H:59
Enum.H