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 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  Calculates the spatial minimum and maximum extents of a 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 Usage
39  Example of function object specification:
40  \verbatim
41  fieldExtents1
42  {
43  type fieldExtents;
44  libs ("libfieldFunctionObjects.so");
45  ...
46  writeToFile yes;
47  log yes;
48  fields (alpha);
49  threshold 0.5;
50  patches ();
51  }
52  \endverbatim
53 
54  Where the entries comprise:
55  \table
56  Property | Description | Required | Default value
57  type | type name: fieldExtents | yes |
58  writeToFile | write extents data to file | no | yes
59  log | write extents data to standard output | no | yes
60  internalField | Process the internal field | no | yes
61  threshold | Field value to identify extents boundary | yes |
62  referencePosition | Reference position | no | (0 0 0)
63  fields | list of fields to process | yes |
64  patches | list of patches to process | no | <all patches>
65  \endtable
66 
67  Output data is written to the file <timeDir>/fieldExtents.dat
68 
69 Note
70  For non-scalar fields, the magnitude of the field is employed and compared
71  to the threshold value.
72 
73 See also
74  Foam::functionObjects::fvMeshFunctionObject
75  Foam::functionObjects::writeFile
76 
77 SourceFiles
78  fieldExtents.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef functionObjects_fieldExtents_H
83 #define functionObjects_fieldExtents_H
84 
85 #include "fvMeshFunctionObject.H"
86 #include "writeFile.H"
87 #include "volFieldSelection.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 namespace functionObjects
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class fieldExtents Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class fieldExtents
101 :
102  public fvMeshFunctionObject,
103  public writeFile
104 {
105 protected:
106 
107  // Protected data
108 
109  //- Flag to write the internal field extents
110  bool internalField_;
111 
112  //- Threshold value
113  scalar threshold_;
114 
115  //- Reference position; default = (0 0 0)
116  point C0_;
117 
118  //- Fields to assess
119  volFieldSelection fieldSet_;
120 
121  //- Patches to assess
123 
124 
125  // Protected Member Functions
126 
127  //- Output file header information
128  virtual void writeFileHeader(Ostream& os);
129 
130  //- Return the field mask
131  template<class Type>
132  tmp<volScalarField> calcMask
133  (
134  const GeometricField<Type, fvPatchField, volMesh>& field
135  ) const;
136 
137  //- Main calculation
138  template<class Type>
139  void calcFieldExtents
140  (
141  const word& fieldName,
142  const bool calcMag = false
143  );
144 
145  //- No copy construct
146  fieldExtents(const fieldExtents&) = delete;
147 
148  //- No copy assignment
149  void operator=(const fieldExtents&) = delete;
150 
151 
152 public:
153 
154  //- Runtime type information
155  TypeName("fieldExtents");
156 
157 
158  // Constructors
159 
160  //- Construct from Time and dictionary
162  (
163  const word& name,
164  const Time& runTime,
165  const dictionary& dict
166  );
167 
168 
169  //- Destructor
170  virtual ~fieldExtents() = default;
171 
172 
173  // Member Functions
174 
175  //- Read the field extents data
176  virtual bool read(const dictionary&);
177 
178  //- Execute, currently does nothing
179  virtual bool execute();
180 
181  //- Write the fieldExtents
182  virtual bool write();
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 template<>
190 (
192 ) const;
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace functionObjects
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #ifdef NoRepository
202  #include "fieldExtentsTemplates.C"
203 #endif
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::functionObjects::fieldExtents::patchIDs_
labelHashSet patchIDs_
Patches to assess.
Definition: fieldExtents.H:166
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:62
fvMeshFunctionObject.H
Foam::tmp< volScalarField >
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:163
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:154
Foam::functionObjects::fieldExtents::C0_
point C0_
Reference position; default = (0 0 0)
Definition: fieldExtents.H:160
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 fieldExtents &)=delete
No copy construct.
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:121
Foam::functionObjects::fieldExtents::threshold_
scalar threshold_
Threshold value.
Definition: fieldExtents.H:157
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::functionObjects::fieldExtents::read
virtual bool read(const dictionary &)
Read the field extents data.
Definition: fieldExtents.C:125
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::Vector< scalar >
fieldExtentsTemplates.C
Foam::functionObjects::fieldExtents::write
virtual bool write()
Write the fieldExtents.
Definition: fieldExtents.C:181
Foam::functionObjects::writeFile
functionObject base class for writing single files
Definition: writeFile.H:59
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 with label keys and label hasher.
Definition: HashSet.H:415
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::functionObjects::fieldExtents
Calculates the spatial minimum and maximum extents of a field.
Definition: fieldExtents.H:144
Foam::functionObjects::fieldExtents::operator=
void operator=(const fieldExtents &)=delete
No copy assignment.