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-2025 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 fieldValue_functionObject_H
41 #define fieldValue_functionObject_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  //- The name of the type of value (volFieldValue, or surfaceFieldValue)
74  const word valueType_;
75 
76  //- List of field names to operate on
78 
79  //- Output field values flag
81 
82  //- Results dictionary for external access of results
84 
85 
86 public:
87 
88  //- Run-time type information
89  TypeName("fieldValue");
90 
91  // Declare runtime constructor selection table
92 
94  (
95  autoPtr,
96  fieldValue,
97  dictionary,
98  (
99  const word& name,
100  const objectRegistry& obr,
101  const dictionary& dict
102  ),
103  (name, obr, dict)
104  );
105 
106 
107  // Constructors
108 
109  //- Construct from Time and dictionary
110  fieldValue
111  (
112  const word& name,
113  const Time& runTime,
114  const dictionary& dict,
115  const word& valueType
116  );
117 
118  //- Construct from objectRegistry and dictionary
119  fieldValue
120  (
121  const word& name,
122  const objectRegistry& obr,
123  const dictionary& dict,
124  const word& valueType
125  );
126 
127  //- Return a reference to the selected fieldValue
128  static autoPtr<fieldValue> New
129  (
130  const word& name,
131  const objectRegistry& obr,
132  const dictionary& dict,
133  const bool output = true
134  );
135 
136 
137  //- Destructor
138  virtual ~fieldValue();
139 
140 
141  // Member Functions
142 
143  //- Return the reference to the construction dictionary
144  inline const dictionary& dict() const;
145 
146  //- Return the list of fields required
147  inline virtual wordList fields() const;
148 
149  //- Return the output field values flag
150  inline const Switch& writeFields() const;
151 
152  //- Return access to the latest set of results
153  inline const dictionary& resultDict() const;
154 
155  //- Read from dictionary
156  virtual bool read(const dictionary& dict);
157 
158  //- Execute
159  virtual bool execute();
160 
161  //- Write
162  virtual bool write();
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace functionObjects
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #include "fieldValueI.H"
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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 dictionary & dict() const
Return the reference to the construction dictionary.
const Switch & writeFields() const
Return the output field values flag.
Definition: fieldValueI.H:38
const dictionary & resultDict() const
Return access to the latest set of results.
Definition: fieldValueI.H:45
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:82
virtual wordList fields() const
Return the list of fields required.
Definition: fieldValueI.H:31
TypeName("fieldValue")
Run-time type information.
Switch writeFields_
Output field values flag.
Definition: fieldValue.H:79
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:80
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:86
wordList fields_
List of field names to operate on.
Definition: fieldValue.H:76
const word valueType_
The name of the type of value (volFieldValue, or surfaceFieldValue)
Definition: fieldValue.H:73
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
virtual bool execute()
Execute.
Definition: fieldValue.C:99
virtual bool write()
Write.
Definition: fieldValue.C:105
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 handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
#define valueType(Type, none)
The field's value.
Definition: uniform.H:71