fieldExtents.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) 2018-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::fieldExtents
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Computes the spatial minimum and maximum extents of an input field.
34 
35  The extents are derived from the bound box limits after identifying the
36  locations where field values exceed the user-supplied threshold value.
37 
38  Operands:
39  \table
40  Operand | Type | Location
41  input | - | -
42  output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
43  output field | - | -
44  \endtable
45 
46 Usage
47  Minimal example by using \c system/controlDict.functions:
48  \verbatim
49  fieldExtents1
50  {
51  // Mandatory entries (unmodifiable)
52  type fieldExtents;
53  libs (fieldFunctionObjects);
54 
55  // Mandatory entries (runtime modifiable)
56  fields (<field1> <field2> ... <fieldN>);
57  threshold 0.5;
58 
59  // Optional entries (runtime modifiable)
60  internalField true;
61  referencePosition (0 0 0);
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: fieldExtents | word | yes | -
72  libs | Library name: fieldFunctionObjects | word | yes | -
73  threshold | Value to identify extents boundary | scalar | yes | -
74  fields | List of operand fields | wordList | yes | -
75  internalField | Flag to process the internal field | bool | no | true
76  referencePosition | Reference position | vector | no | (0 0 0)
77  patches | List of patches to process | wordList | no | <all patches>
78  \endtable
79 
80  The inherited entries are elaborated in:
81  - \link functionObject.H \endlink
82  - \link writeFile.H \endlink
83 
84  Usage by the \c postProcess utility is not available.
85 
86 Note
87  For non-scalar fields, the magnitude of the field is employed and compared
88  to the value of \c threshold.
89 
90 See also
91  - Foam::functionObject
92  - Foam::functionObjects::fvMeshFunctionObject
93  - Foam::functionObjects::writeFile
94  - ExtendedCodeGuide::functionObjects::field::fieldExtents
95 
96 SourceFiles
97  fieldExtents.C
98  fieldExtentsTemplates.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef Foam_functionObjects_fieldExtents_H
103 #define Foam_functionObjects_fieldExtents_H
104 
105 #include "fvMeshFunctionObject.H"
106 #include "writeFile.H"
107 #include "volFieldSelection.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 namespace functionObjects
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class fieldExtents Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class fieldExtents
121 :
122  public fvMeshFunctionObject,
123  public writeFile
124 {
125 protected:
126 
127  // Protected Data
128 
129  //- Flag to write the internal field extents
130  bool internalField_;
131 
132  //- Threshold value
133  scalar threshold_;
134 
135  //- Reference position
136  point C0_;
137 
138  //- Fields to assess
139  volFieldSelection fieldSet_;
140 
141  //- Patches to assess
143 
144 
145  // Protected Member Functions
146 
147  //- Output file header information
148  virtual void writeFileHeader(Ostream& os);
149 
150  //- Return the field mask
151  template<class Type>
152  tmp<volScalarField> calcMask
153  (
154  const GeometricField<Type, fvPatchField, volMesh>& field
155  ) const;
156 
157  //- Main calculation
158  template<class Type>
159  void calcFieldExtents
160  (
161  const word& fieldName,
162  const bool calcMag = false
163  );
164 
165 
166 public:
167 
168  //- Runtime type information
169  TypeName("fieldExtents");
170 
171 
172  // Constructors
173 
174  //- Construct from Time and dictionary
176  (
177  const word& name,
178  const Time& runTime,
180  );
181 
182  //- No copy construct
183  fieldExtents(const fieldExtents&) = delete;
184 
185  //- No copy assignment
186  void operator=(const fieldExtents&) = delete;
187 
188 
189  //- Destructor
190  virtual ~fieldExtents() = default;
192 
193  // Member Functions
194 
195  //- Read the field extents data
196  virtual bool read(const dictionary&);
197 
198  //- Execute, currently does nothing
199  virtual bool execute();
200 
201  //- Write the fieldExtents
202  virtual bool write();
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 template<>
210 (
212 ) const;
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace functionObjects
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #ifdef NoRepository
222  #include "fieldExtentsTemplates.C"
223 #endif
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
dictionary dict
Computes the spatial minimum and maximum extents of an input field.
Definition: fieldExtents.H:179
rDeltaTY field()
void operator=(const fieldExtents &)=delete
No copy assignment.
labelList patchIDs_
Patches to assess.
Definition: fieldExtents.H:211
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
tmp< volScalarField > calcMask(const GeometricField< Type, fvPatchField, volMesh > &field) const
Return the field mask.
engineTime & runTime
point C0_
Reference position.
Definition: fieldExtents.H:201
TypeName("fieldExtents")
Runtime type information.
const word & name() const noexcept
Return the name of this functionObject.
scalar threshold_
Threshold value.
Definition: fieldExtents.H:196
virtual bool write()
Write the fieldExtents.
Definition: fieldExtents.C:179
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: fieldExtents.C:39
void calcFieldExtents(const word &fieldName, const bool calcMag=false)
Main calculation.
virtual ~fieldExtents()=default
Destructor.
OBJstream os(runTime.globalPath()/outputName)
volFieldSelection fieldSet_
Fields to assess.
Definition: fieldExtents.H:206
vector point
Point is a vector.
Definition: point.H:37
virtual bool read(const dictionary &)
Read the field extents data.
Definition: fieldExtents.C:118
bool internalField_
Flag to write the internal field extents.
Definition: fieldExtents.H:191
virtual bool execute()
Execute, currently does nothing.
Definition: fieldExtents.C:173
List< label > labelList
A List of labels.
Definition: List.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50
fieldExtents(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldExtents.C:96
Namespace for OpenFOAM.