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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::fieldValue
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Intermediate class for handling field value-based function objects.
35
36Usage
37 Minimal example by using \c system/controlDict.functions:
38 \verbatim
39 <userDefinedSubDictName1>
40 {
41 // Mandatory and other optional entries
42 ...
43
44 // Mandatory (inherited) entries (runtime modifiable)
45 fields (<field1> <field2> ... <fieldN>);
46
47 // Optional (inherited) entries (runtime modifiable)
48 writeFields false;
49 scaleFactor 1.0;
50 }
51 \endverbatim
52
53 where the entries mean:
54 \table
55 Property | Description | Type | Req'd | Dflt
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
65See also
66 - Foam::functionObject
67 - Foam::functionObjects::fvMeshFunctionObject
68 - Foam::functionObjects::writeFile
69 - ExtendedCodeGuide::functionObjects::field::fieldValue
70
71SourceFiles
72 fieldValue.C
73 fieldValueTemplates.C
74
75\*---------------------------------------------------------------------------*/
76
77#ifndef functionObjects_fieldValue_H
78#define functionObjects_fieldValue_H
79
81#include "writeFile.H"
82#include "Field.H"
83
84// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85
86namespace Foam
87{
88
89namespace functionObjects
90{
91
92/*---------------------------------------------------------------------------*\
93 Class fieldValue Declaration
94\*---------------------------------------------------------------------------*/
95
96class fieldValue
97:
98 public fvMeshFunctionObject,
99 public writeFile
100{
101protected:
102
103 // Protected Data
104
105 //- Flag to output field values
106 bool writeFields_;
107
108 //- Name of region (patch, zone, etc.)
109 word regionName_;
110
111 //- Scaling factor
112 scalar scaleFactor_;
113
114 //- Construction dictionary
115 dictionary dict_;
116
117 //- Names of operand fields
120
121 // Protected Member Functions
122
123 //- Combine fields from all processor domains into single field
124 template<class Type>
126
127 //- Combine fields from all processor domains into single field
128 template<class Type>
130
131
132public:
133
134 //- Run-time type information
135 TypeName("fieldValue");
136
137 // Declare runtime constructor selection table
140 (
143 runTime,
144 (
145 const word& name,
146 const Time& runTime,
147 const dictionary& dict
148 ),
149 (name, runTime, dict)
150 );
151
152 // Constructors
153
154 //- Construct from Time and dictionary
156 (
157 const word& name,
158 const Time& runTime,
159 const dictionary& dict,
160 const word& valueType
161 );
163 //- Construct from objectRegistry and dictionary
165 (
166 const word& name,
167 const objectRegistry& obr,
168 const dictionary& dict,
169 const word& valueType
170 );
171
172 //- Return a reference to the selected fieldValue
174 (
175 const word& name,
176 const Time& runTime,
177 const dictionary& dict,
178 const bool output = true
179 );
180
181
182 //- Destructor
183 virtual ~fieldValue() = default;
184
185
186 // Member Functions
187
188 //- Return the reference to the construction dictionary
189 inline const dictionary& dict() const noexcept;
190
191 //- Return the region name
192 inline const word& regionName() const noexcept;
193
194 //- Return the list of field names
195 inline const wordList& fields() const noexcept;
196
197 //- Return the output field values flag
198 inline bool writeFields() const noexcept;
199
200 //- Read from dictionary
201 virtual bool read(const dictionary& dict);
202
203 //- Execute
204 virtual bool execute();
205
206 //- Write
207 virtual bool write();
208};
209
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213} // End namespace functionObjects
214} // End namespace Foam
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#include "fieldValueI.H"
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222#ifdef NoRepository
223 #include "fieldValueTemplates.C"
224#endif
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228#endif
229
230// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field value-based function objects.
Definition: fieldValue.H:123
const wordList & fields() const noexcept
Return the list of field names.
Definition: fieldValueI.H:45
declareRunTimeSelectionTable(autoPtr, fieldValue, runTime,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
scalar scaleFactor_
Scaling factor.
Definition: fieldValue.H:135
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:132
bool writeFields() const noexcept
Return the output field values flag.
Definition: fieldValueI.H:52
TypeName("fieldValue")
Run-time type information.
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:138
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:89
wordList fields_
Names of operand fields.
Definition: fieldValue.H:141
virtual ~fieldValue()=default
Destructor.
const dictionary & dict() const noexcept
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
const word & regionName() const noexcept
Return the region name.
Definition: fieldValueI.H:38
bool writeFields_
Flag to output field values.
Definition: fieldValue.H:129
virtual bool execute()
Execute.
Definition: fieldValue.C:109
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:35
virtual bool write()
Write.
Definition: fieldValue.C:115
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Base class for writing single files from the function objects.
Definition: writeFile.H:120
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
engineTime & runTime
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:66
const direction noexcept
Definition: Scalar.H:223
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73