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  <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 
65 See also
66  - Foam::functionObject
67  - Foam::functionObjects::fvMeshFunctionObject
68  - Foam::functionObjects::writeFile
69  - ExtendedCodeGuide::functionObjects::field::fieldValue
70 
71 SourceFiles
72  fieldValue.C
73  fieldValueTemplates.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef functionObjects_fieldValue_H
78 #define functionObjects_fieldValue_H
79 
80 #include "fvMeshFunctionObject.H"
81 #include "writeFile.H"
82 #include "Field.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 
89 namespace functionObjects
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class fieldValue Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class fieldValue
97 :
98  public fvMeshFunctionObject,
99  public writeFile
100 {
101 protected:
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
119 
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 
132 public:
133 
134  //- Run-time type information
135  TypeName("fieldValue");
136 
137  // Declare runtime constructor selection table
138 
140  (
142  fieldValue,
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
155  fieldValue
156  (
157  const word& name,
158  const Time& runTime,
159  const dictionary& dict,
160  const word& valueType
161  );
162 
163  //- Construct from objectRegistry and dictionary
164  fieldValue
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
173  static autoPtr<fieldValue> New
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::output
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:66
Foam::functionObjects::fieldValue::TypeName
TypeName("fieldValue")
Run-time type information.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::fieldValue::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:89
fvMeshFunctionObject.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::fieldValue::execute
virtual bool execute()
Execute.
Definition: fieldValue.C:109
Foam::functionObjects::fieldValue::fields
const wordList & fields() const noexcept
Return the list of field names.
Definition: fieldValueI.H:45
Foam::functionObjects::fieldValue::scaleFactor_
scalar scaleFactor_
Scaling factor.
Definition: fieldValue.H:135
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fieldValue::regionName
const word & regionName() const noexcept
Return the region name.
Definition: fieldValueI.H:38
Foam::functionObjects::fieldValue::~fieldValue
virtual ~fieldValue()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::functionObjects::fieldValue::fieldValue
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from Time and dictionary.
Definition: fieldValue.C:48
Foam::functionObjects::fieldValue::dict_
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:138
Foam::functionObjects::fieldValue::writeFields
bool writeFields() const noexcept
Return the output field values flag.
Definition: fieldValueI.H:52
Foam::functionObjects::fieldValue::writeFields_
bool writeFields_
Flag to output field values.
Definition: fieldValue.H:129
Foam::functionObjects::fieldValue::regionName_
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:132
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::functionObjects::fieldValue::dict
const dictionary & dict() const noexcept
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
Foam::functionObjects::fieldValue::fields_
wordList fields_
Names of operand fields.
Definition: fieldValue.H:141
Field.H
Foam::functionObjects::fieldValue::New
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
field
rDeltaTY field()
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fieldValueTemplates.C
Foam::functionObjects::fieldValue::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, fieldValue, runTime,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::List< word >
Foam::functionObjects::fieldValue
Intermediate class for handling field value-based function objects.
Definition: fieldValue.H:119
Foam::functionObjects::regionFunctionObject::obr
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Definition: regionFunctionObject.C:47
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::functionObjects::fieldValue::write
virtual bool write()
Write.
Definition: fieldValue.C:115
Foam::functionObjects::fieldValue::combineFields
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Definition: fieldValueTemplates.C:36