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-2020 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  MIN = 0x1,
131  MAX = 0x2,
132  BOTH = (MIN | MAX)
133  };
134 
135 
136 protected:
137 
138  // Protected Data
139 
140  //- Limit type names
141  static const Enum<limitType> limitTypeNames_;
142 
143  //- Limiting type
145 
146  //- Fields to limit
147  volFieldSelection fieldSet_;
148 
149  //- Minimum limit
150  scalar min_;
151 
152  //- Maximum limit
153  scalar max_;
154 
155 
156  // Protected Member Functions
157 
158  //- Limit a scalar field.
159  // \return true if field of this type was found.
160  bool limitScalarField(const word& fieldName);
161 
162  //- Limit a field.
163  // \return true if field of this type was found.
164  template<class Type>
165  bool limitField(const word& fieldName);
166 
167 
168 public:
169 
170  //- Runtime type information
171  TypeName("limitFields");
172 
174  // Constructors
175 
176  //- Construct from Time and dictionary
178  (
179  const word& name,
180  const Time& runTime,
182  );
184  //- No copy construct
185  limitFields(const limitFields&) = delete;
186 
187  //- No copy assignment
188  void operator=(const limitFields&) = delete;
189 
190 
191  //- Destructor
192  virtual ~limitFields() = default;
193 
194 
195  // Member Functions
197  //- Read the field min/max data
198  virtual bool read(const dictionary& dict);
199 
200  //- Execute, currently does nothing
201  virtual bool execute();
202 
203  //- Write the limitFields
204  virtual bool write();
205 };
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace functionObjects
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #ifdef NoRepository
217 #endif
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
virtual ~limitFields()=default
Destructor.
virtual bool write()
Write the limitFields.
Definition: limitFields.C:165
TypeName("limitFields")
Runtime type information.
dictionary dict
scalar min_
Minimum limit.
Definition: limitFields.H:211
limit by both minimum and maximum values
Definition: limitFields.H:185
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
static const Enum< limitType > limitTypeNames_
Limit type names.
Definition: limitFields.H:196
engineTime & runTime
limitType limit_
Limiting type.
Definition: limitFields.H:201
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:216
limitFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: limitFields.C:82
bool limitScalarField(const word &fieldName)
Limit a scalar field.
Definition: limitFields.C:51
volFieldSelection fieldSet_
Fields to limit.
Definition: limitFields.H:206
virtual bool read(const dictionary &dict)
Read the field min/max data.
Definition: limitFields.C:100
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:131
Namespace for OpenFOAM.