limitFields.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) 2019-2023 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::functionObjects::limitFields
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Limits input fields to user-specified min and max bounds.
34 
35  Operands:
36  \table
37  Operand | Type | Location
38  input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
39  output file | - | -
40  output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
41  \endtable
42 
43  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
44 
45 Note
46  For non-scalar types of input field, the user limit is used to create a
47  scaling factor using the field magnitudes.
48 
49 Usage
50  Minimal example by using \c system/controlDict.functions:
51  \verbatim
52  limitFields1
53  {
54  // Mandatory entries (unmodifiable)
55  type limitFields;
56  libs (fieldFunctionObjects);
57 
58  // Mandatory entries (runtime modifiable)
59  fields (U);
60  limit max;
61  max 100;
62 
63  // Optional (inherited) entries
64  ...
65  }
66  \endverbatim
67 
68  where the entries mean:
69  \table
70  Property | Description | Type | Req'd | Dflt
71  type | Type name: limitFields | word | yes | -
72  libs | Library name: fieldFunctionObjects | word | yes | -
73  fields | List of fields to process | wordList | yes | -
74  limit | Bound to limit - see below | word | yes | -
75  min | Min limit value | scalar | conditional | -
76  max | Max limit value | scalar | conditional | -
77  \endtable
78 
79  Options for the \c limit entry:
80  \verbatim
81  min : specify a minimum value
82  max : specify a maximum value
83  both : specify a minimum value and a maximum value
84  \endverbatim
85 
86  The inherited entries are elaborated in:
87  - \link functionObject.H \endlink
88 
89  Usage by the \c postProcess utility is not available.
90 
91 See also
92  - Foam::functionObject
93  - Foam::functionObjects::fvMeshFunctionObject
94  - ExtendedCodeGuide::functionObjects::field::limitFields
95 
96 SourceFiles
97  limitFields.C
98  limitFieldsTemplates.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef functionObjects_limitFields_H
103 #define functionObjects_limitFields_H
104 
105 #include "Enum.H"
106 #include "fvMeshFunctionObject.H"
107 #include "volFieldSelection.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 namespace functionObjects
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class limitFields Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class limitFields
121 :
122  public fvMeshFunctionObject
123 {
124 public:
125 
126  // Public Enumerations
127 
128  enum limitType : unsigned
129  {
130  CLAMP_NONE = 0,
131  CLAMP_MIN = 0x1,
132  CLAMP_MAX = 0x2,
134  };
135 
136 
137 protected:
138 
139  // Protected Data
140 
141  //- Limit type names
142  static const Enum<limitType> limitTypeNames_;
143 
144  //- Fields to limit
145  volFieldSelection fieldSet_;
146 
147  //- Limiting type
149 
150  //- Minimum limit
151  scalar min_;
152 
153  //- Maximum limit
154  scalar max_;
155 
156 
157  // Protected Member Functions
158 
159  //- Limit a scalar field.
160  // \return true if field of this type was found.
161  bool limitScalarField(const word& fieldName);
162 
163  //- Limit a field.
164  // \return true if field of this type was found.
165  template<class Type>
166  bool limitField(const word& fieldName);
167 
168 
169 public:
170 
171  //- Runtime type information
172  TypeName("limitFields");
174 
175  // Constructors
176 
177  //- Construct from Time and dictionary
179  (
180  const word& name,
181  const Time& runTime,
182  const dictionary& dict
183  );
185  //- No copy construct
186  limitFields(const limitFields&) = delete;
187 
188  //- No copy assignment
189  void operator=(const limitFields&) = delete;
190 
191 
192  //- Destructor
193  virtual ~limitFields() = default;
194 
195 
196  // Member Functions
198  //- Read the field min/max data
199  virtual bool read(const dictionary& dict);
200 
201  //- Execute, currently does nothing
202  virtual bool execute();
203 
204  //- Write the limitFields
205  virtual bool write();
206 };
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace functionObjects
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #ifdef NoRepository
218 #endif
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
virtual ~limitFields()=default
Destructor.
virtual bool write()
Write the limitFields.
Definition: limitFields.C:184
TypeName("limitFields")
Runtime type information.
dictionary dict
scalar min_
Minimum limit.
Definition: limitFields.H:212
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static const Enum< limitType > limitTypeNames_
Limit type names.
Definition: limitFields.H:197
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
const word & name() const noexcept
Return the name of this functionObject.
bool limitField(const word &fieldName)
Limit a field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalar max_
Maximum limit.
Definition: limitFields.H:217
limitFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: limitFields.C:98
bool limitScalarField(const word &fieldName)
Limit a scalar field.
Definition: limitFields.C:52
limitType withBounds_
Limiting type.
Definition: limitFields.H:207
volFieldSelection fieldSet_
Fields to limit.
Definition: limitFields.H:202
virtual bool read(const dictionary &dict)
Read the field min/max data.
Definition: limitFields.C:116
void operator=(const limitFields &)=delete
No copy assignment.
Limits input fields to user-specified min and max bounds.
Definition: limitFields.H:173
virtual bool execute()
Execute, currently does nothing.
Definition: limitFields.C:149
Namespace for OpenFOAM.