fieldValue.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::fieldValue
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Intermediate class for handling field value-based function objects.
35 
36 Usage
37  Minimal example by using \c system/controlDict.functions:
38  \verbatim
39  FOname
40  {
41  // Mandatory and optional entries
42  ...
43 
44  // Mandatory entries
45  fields (<wordList>); // (<field1> <field2> ... <fieldN>);
46 
47  // Optional entries
48  writeFields <bool>;
49  scaleFactor <scalar>;
50  }
51  \endverbatim
52 
53  where the entries mean:
54  \table
55  Property | Description | Type | Reqd | Deflt
56  fields | Names of operand fields | wordList | yes | -
57  writeFields | Flag to output field values | bool | no | false
58  scaleFactor | Scaling factor | scalar | no | 1.0
59  \endtable
60 
61  The inherited entries are elaborated in:
62  - \link functionObject.H \endlink
63  - \link writeFile.H \endlink
64 
65 SourceFiles
66  fieldValue.C
67  fieldValueTemplates.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef Foam_functionObjects_fieldValue_H
72 #define Foam_functionObjects_fieldValue_H
73 
74 #include "fvMeshFunctionObject.H"
75 #include "writeFile.H"
76 #include "Field.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 namespace functionObjects
84 {
85 
86 /*---------------------------------------------------------------------------*\
87  Class fieldValue Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 class fieldValue
91 :
92  public fvMeshFunctionObject,
93  public writeFile
94 {
95 protected:
96 
97  // Protected Data
98 
99  //- Flag to output field values
100  bool writeFields_;
101 
102  //- Name of region (patch, zone, etc.)
103  word regionName_;
104 
105  //- Scaling factor
106  scalar scaleFactor_;
107 
108  //- Construction dictionary
110 
111  //- Names of operand fields
113 
114 
115  // Protected Member Functions
116 
117  //- Combine fields from all processor domains into single field
118  template<class Type>
120 
121  //- Combine fields from all processor domains into single field
122  template<class Type>
123  void combineFields(tmp<Field<Type>>&);
124 
125 
126 public:
127 
128  //- Run-time type information
129  TypeName("fieldValue");
130 
131  // Declare runtime constructor selection table
132 
134  (
135  autoPtr,
137  runTime,
138  (
139  const word& name,
140  const Time& runTime,
142  ),
143  (name, runTime, dict)
144  );
145 
146  // Constructors
147 
148  //- Construct from name, Time and dictionary
149  fieldValue
150  (
151  const word& name,
152  const Time& runTime,
153  const dictionary& dict,
154  const word& valueType
155  );
156 
157  //- Construct from objectRegistry and dictionary
158  fieldValue
159  (
160  const word& name,
161  const objectRegistry& obr,
162  const dictionary& dict,
163  const word& valueType
164  );
165 
166  //- Return a reference to the selected fieldValue
167  static autoPtr<fieldValue> New
168  (
169  const word& name,
170  const Time& runTime,
171  const dictionary& dict,
172  const bool output = true
173  );
174 
175 
176  //- Destructor
177  virtual ~fieldValue() = default;
178 
179 
180  // Member Functions
181 
182  //- Return the reference to the construction dictionary
183  inline const dictionary& dict() const noexcept;
184 
185  //- Return the region name
186  inline const word& regionName() const noexcept;
187 
188  //- Return the list of field names
189  inline const wordList& fields() const noexcept;
190 
191  //- Return the output field values flag
192  inline bool writeFields() const noexcept;
193 
194  //- Read the function-object dictionary
195  virtual bool read(const dictionary& dict);
196 
197  //- Execute the function-object operations
198  virtual bool execute();
199 
200  //- Write the function-object results
201  virtual bool write();
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace functionObjects
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #include "fieldValueI.H"
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #ifdef NoRepository
217  #include "fieldValueTemplates.C"
218 #endif
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
virtual bool execute()
Execute the function-object operations.
Definition: fieldValue.C:102
virtual ~fieldValue()=default
Destructor.
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:136
rDeltaTY field()
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
engineTime & runTime
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition: fieldValue.C:82
const wordList & fields() const noexcept
Return the list of field names.
Definition: fieldValueI.H:38
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const word & name() const noexcept
Return the name of this functionObject.
const dictionary & dict() const noexcept
Return the reference to the construction dictionary.
Definition: fieldValueI.H:24
TypeName("fieldValue")
Run-time type information.
static autoPtr< fieldValue > New(const word &name, const Time &runTime, const dictionary &dict, const bool output=true)
Return a reference to the selected fieldValue.
Definition: fieldValueNew.C:28
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
const word & regionName() const noexcept
Return the region name.
Definition: fieldValueI.H:31
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition: Field.H:69
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from name, Time and dictionary.
Definition: fieldValue.C:41
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalar scaleFactor_
Scaling factor.
Definition: fieldValue.H:131
wordList fields_
Names of operand fields.
Definition: fieldValue.H:141
const direction noexcept
Definition: scalarImpl.H:265
bool writeFields_
Flag to output field values.
Definition: fieldValue.H:121
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:126
declareRunTimeSelectionTable(autoPtr, fieldValue, runTime,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
Intermediate class for handling field value-based function objects.
Definition: fieldValue.H:109
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
bool writeFields() const noexcept
Return the output field values flag.
Definition: fieldValueI.H:45
Namespace for OpenFOAM.
virtual bool write()
Write the function-object results.
Definition: fieldValue.C:108