generateZone.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::generateZone
26 
27 Description
28  Generates, registers and optionally writes the \c zoneSet generated by
29  a \c zoneGenerator.
30 
31 Usage
32  \table
33  Property | Description | Required | Default value
34  type | type name: generateZone | yes |
35  zone | zoneGenerator specification | yes |
36  \endtable
37 
38  Example of a functionObjects::generateZone which creates a \c cellZone named
39  \c kZone of the cells in which the value of the turbulent kinetic energy is
40  within the highest 10% and then functionObjects::volFieldValue
41  is used to average the velocity within this zone:
42  \verbatim
43  kZone
44  {
45  type generateZone;
46 
47  libs ("libutilityFunctionObjects.so");
48 
49  executeControl writeTime;
50  writeControl writeTime;
51 
52  zone
53  {
54  type coded;
55 
56  code
57  #{
58  // Lookup field from the objectRegistry, e.g. k
59  const volScalarField& k =
60  mesh().lookupObject<volScalarField>("k");
61 
62  // Calculate the minimum and maximum k values
63  const scalar mink = min(k).value();
64  const scalar maxk = max(k).value();
65 
66  // Fraction of the range of k
67  const scalar f = 0.1;
68 
69  // Lowest k in selection
70  const scalar lowk = f*mink + (1.0 - f)*maxk;
71 
72  cellIndices = selectIndices
73  (
74  k,
75  [&](const scalar k)
76  {
77  return k > lowk;
78  }
79  );
80  #};
81  }
82  }
83 
84  UAverage
85  {
86  type volFieldValue;
87 
88  libs ("libfieldFunctionObjects.so");
89 
90  executeControl writeTime;
91  writeControl writeTime;
92 
93  writeFields no;
94 
95  cellZone kZone;
96 
97  operation volAverage;
98 
99  fields (U);
100  }
101  \endverbatim
102 
103 See also
104  Foam::functionObject
105 
106 SourceFiles
107  generateZone.C
108 
109 \*---------------------------------------------------------------------------*/
110 
111 #ifndef generateZone_functionObject_H
112 #define generateZone_functionObject_H
113 
114 #include "fvMeshFunctionObject.H"
115 #include "zoneGenerator.H"
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 namespace Foam
120 {
121 namespace functionObjects
122 {
123 
124 /*---------------------------------------------------------------------------*\
125  Class generateZone Declaration
126 \*---------------------------------------------------------------------------*/
127 
128 class generateZone
129 :
130  public fvMeshFunctionObject
131 {
132  // Private Data
133 
134  //- Run-time selected zoneGenerator
135  autoPtr<zoneGenerator> zg_;
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("generateZone");
142 
143 
144  // Constructors
145 
146  //- Construct from Time and dictionary
148  (
149  const word& name,
150  const Time& runTime,
151  const dictionary& dict
152  );
153 
154  //- Disallow default bitwise copy construction
155  generateZone(const generateZone&) = delete;
156 
157 
158  //- Destructor
159  virtual ~generateZone();
160 
161 
162  // Member Functions
163 
164  //- Return the list of fields required
165  virtual wordList fields() const
166  {
167  return wordList::null();
168  }
169 
170  //- Remove the registered objects
171  virtual bool execute();
172 
173  //- Do nothing
174  virtual bool write();
175 
176 
177  // Member Operators
178 
179  //- Disallow default bitwise assignment
180  void operator=(const generateZone&) = delete;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Generates, registers and optionally writes the zoneSet generated by a zoneGenerator.
Definition: generateZone.H:145
virtual ~generateZone()
Destructor.
Definition: generateZone.C:61
virtual wordList fields() const
Return the list of fields required.
Definition: generateZone.H:179
generateZone(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: generateZone.C:46
void operator=(const generateZone &)=delete
Disallow default bitwise assignment.
TypeName("generateZone")
Runtime type information.
virtual bool execute()
Remove the registered objects.
Definition: generateZone.C:67
virtual bool write()
Do nothing.
Definition: generateZone.C:74
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
dictionary dict