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-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::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 functionObjects_fieldExtents_H
103 #define 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 
126 protected:
127 
128  // Protected Data
129 
130  //- Flag to write the internal field extents
131  bool internalField_;
132 
133  //- Threshold value
134  scalar threshold_;
135 
136  //- Reference position
137  point C0_;
138 
139  //- Fields to assess
140  volFieldSelection fieldSet_;
141 
142  //- Patches to assess
144 
145 
146  // Protected Member Functions
147 
148  //- Output file header information
149  virtual void writeFileHeader(Ostream& os);
150 
151  //- Return the field mask
152  template<class Type>
153  tmp<volScalarField> calcMask
154  (
155  const GeometricField<Type, fvPatchField, volMesh>& field
156  ) const;
157 
158  //- Main calculation
159  template<class Type>
160  void calcFieldExtents
161  (
162  const word& fieldName,
163  const bool calcMag = false
164  );
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("fieldExtents");
171 
172 
173  // Constructors
174 
175  //- Construct from Time and dictionary
177  (
178  const word& name,
179  const Time& runTime,
180  const dictionary& dict
181  );
182 
183  //- No copy construct
184  fieldExtents(const fieldExtents&) = delete;
185 
186  //- No copy assignment
187  void operator=(const fieldExtents&) = delete;
188 
189 
190  //- Destructor
191  virtual ~fieldExtents() = default;
192 
193 
194  // Member Functions
195 
196  //- Read the field extents data
197  virtual bool read(const dictionary&);
198 
199  //- Execute, currently does nothing
200  virtual bool execute();
201 
202  //- Write the fieldExtents
203  virtual bool write();
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 template<>
211 (
213 ) const;
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace functionObjects
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #ifdef NoRepository
223  #include "fieldExtentsTemplates.C"
224 #endif
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #endif
229 
230 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::functionObjects::fieldExtents::patchIDs_
labelHashSet patchIDs_
Patches to assess.
Definition: fieldExtents.H:206
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::fieldExtents::calcMask
tmp< volScalarField > calcMask(const GeometricField< Type, fvPatchField, volMesh > &field) const
Return the field mask.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::fieldExtents::calcFieldExtents
void calcFieldExtents(const word &fieldName, const bool calcMag=false)
Main calculation.
Definition: fieldExtentsTemplates.C:51
Foam::functionObjects::fieldExtents::fieldSet_
volFieldSelection fieldSet_
Fields to assess.
Definition: fieldExtents.H:203
Foam::functionObjects::fieldExtents::execute
virtual bool execute()
Execute, currently does nothing.
Definition: fieldExtents.C:175
Foam::HashSet< label, Hash< label > >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fieldExtents::~fieldExtents
virtual ~fieldExtents()=default
Destructor.
Foam::functionObjects::fieldExtents::TypeName
TypeName("fieldExtents")
Runtime type information.
Foam::functionObjects::volFieldSelection
Helper class to manage solver field selections.
Definition: volFieldSelection.H:52
Foam::functionObjects::fieldExtents::internalField_
bool internalField_
Flag to write the internal field extents.
Definition: fieldExtents.H:194
Foam::functionObjects::fieldExtents::C0_
point C0_
Reference position.
Definition: fieldExtents.H:200
Foam::functionObjects::fieldExtents::writeFileHeader
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: fieldExtents.C:45
field
rDeltaTY field()
Foam::functionObjects::fieldExtents::fieldExtents
fieldExtents(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldExtents.C:102
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::fieldExtents::threshold_
scalar threshold_
Threshold value.
Definition: fieldExtents.H:197
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldExtents::read
virtual bool read(const dictionary &)
Read the field extents data.
Definition: fieldExtents.C:125
Foam::Vector< scalar >
fieldExtentsTemplates.C
Foam::functionObjects::fieldExtents::write
virtual bool write()
Write the fieldExtents.
Definition: fieldExtents.C:181
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::functionObjects::fieldExtents
Computes the spatial minimum and maximum extents of an input field.
Definition: fieldExtents.H:183
Foam::functionObjects::fieldExtents::operator=
void operator=(const fieldExtents &)=delete
No copy assignment.