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 | Copyright (C) 2011-2016 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::fieldValue
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  Base class for field value -based function objects.
32 
33 See also
34  Foam::functionObject
35  Foam::functionObjects::fvMeshFunctionObject
36  Foam::functionObjects::logFiles
37 
38 SourceFiles
39  fieldValue.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef functionObjects_fieldValue_H
44 #define functionObjects_fieldValue_H
45 
46 #include "fvMeshFunctionObject.H"
47 #include "logFiles.H"
48 #include "Switch.H"
49 #include "Field.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of classes
57 class fvMesh;
58 
59 namespace functionObjects
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class fieldValue Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class fieldValue
67 :
68  public fvMeshFunctionObject,
69  public logFiles
70 {
71 
72 protected:
73 
74  // Protected data
75 
76  //- Construction dictionary
78 
79  //- Name of region (patch, zone, etc.)
81 
82  //- List of field names to operate on
84 
85  //- Output field values flag
87 
88  //- Results dictionary for external access of results
90 
91 
92  // Protected Member Functions
93 
94  //- Combine fields from all processor domains into single field
95  template<class Type>
96  void combineFields(Field<Type>& field);
97 
98  //- Combine fields from all processor domains into single field
99  template<class Type>
100  void combineFields(tmp<Field<Type>>&);
101 
102 
103 public:
104 
105  //- Run-time type information
106  TypeName("fieldValue");
107 
108  // Declare runtime constructor selection table
109 
111  (
112  autoPtr,
113  fieldValue,
114  dictionary,
115  (
116  const word& name,
117  const objectRegistry& obr,
118  const dictionary& dict
119  ),
120  (name, obr, dict)
121  );
122 
123 
124  // Constructors
125 
126  //- Construct from Time and dictionary
127  fieldValue
128  (
129  const word& name,
130  const Time& runTime,
131  const dictionary& dict,
132  const word& valueType
133  );
134 
135  //- Construct from objectRegistry and dictionary
136  fieldValue
137  (
138  const word& name,
139  const objectRegistry& obr,
140  const dictionary& dict,
141  const word& valueType
142  );
143 
144  //- Return a reference to the selected fieldValue
145  static autoPtr<fieldValue> New
146  (
147  const word& name,
148  const objectRegistry& obr,
149  const dictionary& dict,
150  const bool output = true
151  );
152 
153 
154  //- Destructor
155  virtual ~fieldValue();
156 
157 
158  // Member Functions
159 
160  //- Return the reference to the construction dictionary
161  inline const dictionary& dict() const;
162 
163  //- Return the region name
164  inline const word& regionName() const;
165 
166  //- Return the list of field names
167  inline const wordList& fields() const;
168 
169  //- Return the output field values flag
170  inline const Switch& writeFields() const;
171 
172  //- Return access to the latest set of results
173  inline const dictionary& resultDict() const;
174 
175  //- Read from dictionary
176  virtual bool read(const dictionary& dict);
177 
178  //- Execute
179  virtual bool execute();
180 
181  //- Write
182  virtual bool write();
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace functionObjects
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #include "fieldValueI.H"
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #ifdef NoRepository
198  #include "fieldValueTemplates.C"
199 #endif
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
virtual bool execute()
Execute.
Definition: fieldValue.C:106
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:76
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:84
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:90
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
const Switch & writeFields() const
Return the output field values flag.
Definition: fieldValueI.H:50
Switch writeFields_
Output field values flag.
Definition: fieldValue.H:85
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
dictionary resultDict_
Results dictionary for external access of results.
Definition: fieldValue.H:88
TypeName("fieldValue")
Run-time type information.
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Pre-declare SubField and related Field type.
Definition: Field.H:57
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from Time and dictionary.
Definition: fieldValue.C:45
A class for handling words, derived from string.
Definition: word.H:59
const dictionary & resultDict() const
Return access to the latest set of results.
Definition: fieldValueI.H:57
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
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
wordList fields_
List of field names to operate on.
Definition: fieldValue.H:82
declareRunTimeSelectionTable(autoPtr, fieldValue, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict),(name, obr, dict))
const wordList & fields() const
Return the list of field names.
Definition: fieldValueI.H:43
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:79
const word & regionName() const
Return the region name.
Definition: fieldValueI.H:37
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
Namespace for OpenFOAM.
virtual bool write()
Write.
Definition: fieldValue.C:112
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57