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-2019 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 | no |
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,
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  //- Output file header information
159  void writeFileHeader(const writeFile& wf, Ostream& file) const;
160 
161 
162 public:
163 
164  //- Run-time type information
165  TypeName("volRegion");
166 
167 
168  // Constructors
169 
170  //- Construct from fvMesh and dictionary
171  volRegion(const fvMesh& mesh, const dictionary& dict);
172 
173 
174  //- Destructor
175  virtual ~volRegion() = default;
176 
177 
178  // Member Functions
179 
180  //- Return the region type
181  inline const regionTypes& regionType() const;
182 
183  //- Return the local list of cell IDs
184  const labelList& cellIDs() const;
185 
186  //- Return the number of cells selected in the region
187  inline label nCells() const;
188 
189  //- Return total volume of the selected region
190  inline scalar V() const;
191 
192  //- Update the cached values as required
193  // \return False if the values were already up to date
194  bool update();
195 
196 
197  //- Read from dictionary
198  virtual bool read(const dictionary& dict);
199 
200  //- Update for changes of mesh
201  virtual void updateMesh(const mapPolyMesh&);
202 
203  //- Update for mesh point-motion
204  virtual void movePoints(const polyMesh&);
205 };
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace functionObjects
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #include "volRegionI.H"
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
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:62
Foam::functionObjects::volRegion::update
bool update()
Update the cached values as required.
Definition: volRegion.C:228
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::~volRegion
virtual ~volRegion()=default
Destructor.
Foam::functionObjects::volRegion::vrtAll
All cells.
Definition: volRegion.H:147
Foam::functionObjects::volRegion::regionType
const regionTypes & regionType() const
Return the region type.
Definition: volRegionI.H:32
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:240
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:167
Foam::functionObjects::volRegion::volRegion
volRegion(const fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
Definition: volRegion.C:139
volRegionI.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::volRegion::nCells
label nCells() const
Return the number of cells selected in the region.
Definition: volRegionI.H:47
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::volRegion::vrtCellSet
A cellSet.
Definition: volRegion.H:148
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:246
Foam::List< label >
Foam::functionObjects::volRegion::cellIDs
const labelList & cellIDs() const
Return the local list of cell IDs.
Definition: volRegion.C:199
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:123
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:62
Enum.H