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-2020 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 
102 protected:
103 
104  // Protected Data
105 
106  //- Flag to output field values
107  bool writeFields_;
108 
109  //- Name of region (patch, zone, etc.)
110  word regionName_;
111 
112  //- Scaling factor
113  scalar scaleFactor_;
114 
115  //- Construction dictionary
116  dictionary dict_;
117 
118  //- Names of operand fields
120 
121 
122  // Protected Member Functions
123 
124  //- Combine fields from all processor domains into single field
125  template<class Type>
127 
128  //- Combine fields from all processor domains into single field
129  template<class Type>
131 
132 
133 public:
134 
135  //- Run-time type information
136  TypeName("fieldValue");
137 
138  // Declare runtime constructor selection table
139 
141  (
143  fieldValue,
144  dictionary,
145  (
146  const word& name,
147  const objectRegistry& obr,
148  const dictionary& dict
149  ),
150  (name, obr, dict)
151  );
152 
153 
154  // Constructors
155 
156  //- Construct from Time and dictionary
157  fieldValue
158  (
159  const word& name,
160  const Time& runTime,
161  const dictionary& dict,
162  const word& valueType
163  );
164 
165  //- Construct from objectRegistry and dictionary
166  fieldValue
167  (
168  const word& name,
169  const objectRegistry& obr,
170  const dictionary& dict,
171  const word& valueType
172  );
173 
174  //- Return a reference to the selected fieldValue
175  static autoPtr<fieldValue> New
176  (
177  const word& name,
178  const objectRegistry& obr,
179  const dictionary& dict,
180  const bool output = true
181  );
182 
183 
184  //- Destructor
185  virtual ~fieldValue() = default;
186 
187 
188  // Member Functions
189 
190  //- Return the reference to the construction dictionary
191  inline const dictionary& dict() const;
192 
193  //- Return the region name
194  inline const word& regionName() const;
195 
196  //- Return the list of field names
197  inline const wordList& fields() const;
198 
199  //- Return the output field values flag
200  inline bool writeFields() const;
201 
202  //- Read from dictionary
203  virtual bool read(const dictionary& dict);
204 
205  //- Execute
206  virtual bool execute();
207 
208  //- Write
209  virtual bool write();
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace functionObjects
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #include "fieldValueI.H"
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #ifdef NoRepository
225  #include "fieldValueTemplates.C"
226 #endif
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #endif
231 
232 // ************************************************************************* //
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:62
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:107
Foam::functionObjects::fieldValue::dict
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
Foam::functionObjects::fieldValue::scaleFactor_
scalar scaleFactor_
Scaling factor.
Definition: fieldValue.H:136
Foam::functionObjects::fieldValue::New
static autoPtr< fieldValue > New(const word &name, const objectRegistry &obr, const dictionary &dict, const bool output=true)
Return a reference to the selected fieldValue.
Definition: fieldValueNew.C:35
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::~fieldValue
virtual ~fieldValue()=default
Destructor.
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::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, fieldValue, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict),(name, obr, dict))
Foam::functionObjects::fieldValue::dict_
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:139
Foam::functionObjects::fieldValue::writeFields_
bool writeFields_
Flag to output field values.
Definition: fieldValue.H:130
Foam::functionObjects::fieldValue::regionName_
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:133
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::functionObjects::fieldValue::regionName
const word & regionName() const
Return the region name.
Definition: fieldValueI.H:37
Foam::functionObjects::fieldValue::fields_
wordList fields_
Names of operand fields.
Definition: fieldValue.H:142
Field.H
field
rDeltaTY field()
fieldValueI.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fieldValueTemplates.C
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
Return the name of this functionObject.
Definition: functionObject.C:131
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::fieldValue::writeFields
bool writeFields() const
Return the output field values flag.
Definition: fieldValueI.H:49
Foam::functionObjects::fieldValue::fields
const wordList & fields() const
Return the list of field names.
Definition: fieldValueI.H:43
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:113
Foam::functionObjects::fieldValue::combineFields
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Definition: fieldValueTemplates.C:36