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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::volRegion
29
30Group
31 grpFieldFunctionObjects
32
33Description
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
63Usage
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
70See also
71 Foam::functionObject
72
73SourceFiles
74 volRegion.C
75
76\*---------------------------------------------------------------------------*/
77
78#ifndef Foam_functionObjects_volRegion_H
79#define Foam_functionObjects_volRegion_H
80
81#include "writeFile.H"
82#include "Enum.H"
83
84// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85
86namespace Foam
87{
88
89// Forward Declarations
90class fvMesh;
91class polyMesh;
92class mapPolyMesh;
93
94namespace functionObjects
95{
96
97/*---------------------------------------------------------------------------*\
98 Class volRegion Declaration
99\*---------------------------------------------------------------------------*/
100
101class volRegion
102{
103public:
104
105 // Public Data Types
106
107 //- Region type enumeration
108 enum regionTypes : char
109 {
110 vrtAll = 0,
111 vrtCellSet,
113 };
114
115 //- Region type names
117
118
119private:
120
121 // Private Member Data
123 //- Reference to the volume mesh
124 const fvMesh& volMesh_;
126 //- The cell ids, from cellSet or multiple cell zones
127 labelList cellIds_;
128
129 //- Region IDs (zone ID, ...)
130 labelList regionIDs_;
131
132 //- Cached total number of cells selected
133 label nCells_;
134
135 //- Cached total selection volume
136 scalar V_;
137
138 //- Flag to indicate whether the volRegion requires updating
139 bool requireUpdate_;
140
141
142 // Private Member Functions
143
144 //- Update cellIds, nCells, volume
145 void calculateCache();
146
147
148protected:
149
150 // Protected Data
151
152 //- Region type
154
155 //- Region name (cellSet, cellZone, ...)
157
158
159 // Protected Member Functions
160
161 //- Use all cells, not the cellIDs
162 inline bool useAllCells() const noexcept;
163
164 //- Output file header information
165 void writeFileHeader(const writeFile& wf, Ostream& file) const;
166
168public:
169
170 //- Run-time type information
172
173
174 // Constructors
175
176 //- Construct from fvMesh and dictionary
177 volRegion(const fvMesh& mesh, const dictionary& dict);
178
179
180 //- Destructor
181 virtual ~volRegion() = default;
182
183
184 // Member Functions
186 //- The region type
187 inline regionTypes regionType() const noexcept;
188
189 //- Return the local list of cell IDs.
190 // Empty or invalid for 'all'
191 const labelList& cellIDs() const;
192
193 //- Return the total number of cells selected in the region
194 inline label nCells() const;
196 //- Return total volume of the selected region
197 inline scalar V() const;
198
199 //- Update the cached values as required
200 // \return False if the values were already up to date
201 bool update();
202
203
204 //- Read from dictionary
205 virtual bool read(const dictionary& dict);
206
207 //- Update for changes of mesh
208 virtual void updateMesh(const mapPolyMesh&);
209
210 //- Update for mesh point-motion
211 virtual void movePoints(const polyMesh&);
212};
213
214
215// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216
217} // End namespace functionObjects
218} // End namespace Foam
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222#include "volRegionI.H"
223
224// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225
226#endif
227
228// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Volume (cell) region selection class.
Definition: volRegion.H:116
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
Definition: volRegionI.H:31
scalar V() const
Return total volume of the selected region.
Definition: volRegionI.H:59
wordRe regionName_
Region name (cellSet, cellZone, ...)
Definition: volRegion.H:170
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: volRegion.C:178
static const Enum< regionTypes > regionTypeNames_
Region type names.
Definition: volRegion.H:130
bool update()
Update the cached values as required.
Definition: volRegion.C:250
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: volRegion.C:268
label nCells() const
Return the total number of cells selected in the region.
Definition: volRegionI.H:44
regionTypes regionType_
Region type.
Definition: volRegion.H:167
regionTypes
Region type enumeration.
Definition: volRegion.H:123
regionTypes regionType() const noexcept
The region type.
Definition: volRegionI.H:38
void writeFileHeader(const writeFile &wf, Ostream &file) const
Output file header information.
Definition: volRegion.C:134
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: volRegion.C:262
const labelList & cellIDs() const
Return the local list of cell IDs.
Definition: volRegion.C:210
Base class for writing single files from the function objects.
Definition: writeFile.H:120
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
dynamicFvMesh & mesh
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73