fieldValue.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::fieldValue
26 
27 Description
28  Base class for field value -based function objects.
29 
30 See also
31  Foam::functionObject
32  Foam::functionObjects::fvMeshFunctionObject
33  Foam::functionObjects::logFiles
34 
35 SourceFiles
36  fieldValue.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_fieldValue_H
41 #define functionObjects_fieldValue_H
42 
43 #include "fvMeshFunctionObject.H"
44 #include "logFiles.H"
45 #include "Switch.H"
46 #include "Field.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class fvMesh;
55 
56 namespace functionObjects
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class fieldValue Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class fieldValue
64 :
65  public fvMeshFunctionObject,
66  public logFiles
67 {
68 
69 protected:
70 
71  // Protected data
72 
73  //- Construction dictionary
75 
76  //- The name of the type of value (volFieldValue, or surfaceFieldValue)
77  const word valueType_;
78 
79  //- List of field names to operate on
81 
82  //- Output field values flag
84 
85  //- Results dictionary for external access of results
87 
88 
89  // Protected Member Functions
90 
91  //- Combine fields from all processor domains into single field
92  template<class Type>
93  void combineFields(Field<Type>& field);
94 
95  //- Combine fields from all processor domains into single field
96  template<class Type>
98 
99 
100 public:
101 
102  //- Run-time type information
103  TypeName("fieldValue");
104 
105  // Declare runtime constructor selection table
106 
108  (
109  autoPtr,
110  fieldValue,
111  dictionary,
112  (
113  const word& name,
114  const objectRegistry& obr,
115  const dictionary& dict
116  ),
117  (name, obr, dict)
118  );
119 
120 
121  // Constructors
122 
123  //- Construct from Time and dictionary
124  fieldValue
125  (
126  const word& name,
127  const Time& runTime,
128  const dictionary& dict,
129  const word& valueType
130  );
131 
132  //- Construct from objectRegistry and dictionary
133  fieldValue
134  (
135  const word& name,
136  const objectRegistry& obr,
137  const dictionary& dict,
138  const word& valueType
139  );
140 
141  //- Return a reference to the selected fieldValue
142  static autoPtr<fieldValue> New
143  (
144  const word& name,
145  const objectRegistry& obr,
146  const dictionary& dict,
147  const bool output = true
148  );
149 
150 
151  //- Destructor
152  virtual ~fieldValue();
153 
154 
155  // Member Functions
156 
157  //- Return the reference to the construction dictionary
158  inline const dictionary& dict() const;
159 
160  //- Return the list of fields required
161  inline virtual wordList fields() const;
162 
163  //- Return the output field values flag
164  inline const Switch& writeFields() const;
165 
166  //- Return access to the latest set of results
167  inline const dictionary& resultDict() const;
168 
169  //- Read from dictionary
170  virtual bool read(const dictionary& dict);
171 
172  //- Execute
173  virtual bool execute();
174 
175  //- Write
176  virtual bool write();
177 };
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace functionObjects
183 } // End namespace Foam
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #include "fieldValueI.H"
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #ifdef NoRepository
192  #include "fieldValueTemplates.C"
193 #endif
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:83
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Base class for field value -based function objects.
Definition: fieldValue.H:66
const Switch & writeFields() const
Return the output field values flag.
Definition: fieldValueI.H:44
const dictionary & resultDict() const
Return access to the latest set of results.
Definition: fieldValueI.H:51
declareRunTimeSelectionTable(autoPtr, fieldValue, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict),(name, obr, dict))
dictionary resultDict_
Results dictionary for external access of results.
Definition: fieldValue.H:85
virtual wordList fields() const
Return the list of fields required.
Definition: fieldValueI.H:37
TypeName("fieldValue")
Run-time type information.
Switch writeFields_
Output field values flag.
Definition: fieldValue.H:82
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:73
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:82
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:88
wordList fields_
List of field names to operate on.
Definition: fieldValue.H:79
const word valueType_
The name of the type of value (volFieldValue, or surfaceFieldValue)
Definition: fieldValue.H:76
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from Time and dictionary.
Definition: fieldValue.C:45
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:32
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
virtual bool execute()
Execute.
Definition: fieldValue.C:106
virtual bool write()
Write.
Definition: fieldValue.C:112
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define valueType(Type, none)
The field's value.
Definition: uniform.H:71
Namespace for OpenFOAM.