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 SourceFiles
34  fieldValue.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef functionObjects_fieldValue_H
39 #define functionObjects_fieldValue_H
40 
41 #include "writeFiles.H"
42 #include "Switch.H"
43 #include "Field.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class fvMesh;
52 
53 namespace functionObjects
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class fieldValue Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class fieldValue
61 :
62  public writeFiles
63 {
64 
65 protected:
66 
67  // Protected data
68 
69  //- Construction dictionary
71 
72  //- Name of region (patch, zone, etc.)
74 
75  //- List of field names to operate on
77 
78  //- Output field values flag
80 
81  //- Results dictionary for external access of results
83 
84 
85  // Protected Member Functions
86 
87  //- Combine fields from all processor domains into single field
88  template<class Type>
89  void combineFields(Field<Type>& field);
90 
91  //- Combine fields from all processor domains into single field
92  template<class Type>
94 
95 
96 public:
97 
98  //- Run-time type information
99  TypeName("fieldValue");
100 
101  // Declare runtime constructor selection table
102 
104  (
105  autoPtr,
106  fieldValue,
107  dictionary,
108  (
109  const word& name,
110  const objectRegistry& obr,
111  const dictionary& dict
112  ),
113  (name, obr, dict)
114  );
115 
116 
117  // Constructors
118 
119  //- Construct from Time and dictionary
120  fieldValue
121  (
122  const word& name,
123  const Time& runTime,
124  const dictionary& dict,
125  const word& valueType
126  );
127 
128  //- Construct from objectRegistry and dictionary
129  fieldValue
130  (
131  const word& name,
132  const objectRegistry& obr,
133  const dictionary& dict,
134  const word& valueType
135  );
136 
137  //- Return a reference to the selected fieldValue
138  static autoPtr<fieldValue> New
139  (
140  const word& name,
141  const objectRegistry& obr,
142  const dictionary& dict,
143  const bool output = true
144  );
145 
146 
147  //- Destructor
148  virtual ~fieldValue();
149 
150 
151  // Member Functions
152 
153  //- Return the reference to the construction dictionary
154  inline const dictionary& dict() const;
155 
156  //- Return the region name
157  inline const word& regionName() const;
158 
159  //- Return the list of field names
160  inline const wordList& fields() const;
161 
162  //- Return the output field values flag
163  inline const Switch& writeFields() const;
164 
165  //- Helper function to return the reference to the mesh
166  inline const fvMesh& mesh() const;
167 
168  //- Return access to the latest set of results
169  inline const dictionary& resultDict() const;
170 
171  //- Read from dictionary
172  virtual bool read(const dictionary& dict);
173 
174  //- Execute
175  virtual bool execute();
176 
177  //- Write to screen/file
178  virtual bool write();
179 };
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace functionObjects
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #include "fieldValueI.H"
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #ifdef NoRepository
194  #include "fieldValueTemplates.C"
195 #endif
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
virtual bool execute()
Execute.
Definition: fieldValue.C:100
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:69
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:82
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
functionObject base class for writing files
Definition: writeFiles.H:56
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:88
const word & regionName() const
Return the region name.
Definition: fieldValueI.H:37
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 wordList & fields() const
Return the list of field names.
Definition: fieldValueI.H:43
Switch writeFields_
Output field values flag.
Definition: fieldValue.H:78
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:81
TypeName("fieldValue")
Run-time type information.
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
Definition: fieldValueI.H:56
const word & name() const
Return the name of this functionObject.
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
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:75
const Switch & writeFields() const
Return the output field values flag.
Definition: fieldValueI.H:50
declareRunTimeSelectionTable(autoPtr, fieldValue, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict),(name, obr, dict))
word regionName_
Name of region (patch, zone, etc.)
Definition: fieldValue.H:72
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const dictionary & resultDict() const
Return access to the latest set of results.
Definition: fieldValueI.H:63
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
A class for managing temporary objects.
Definition: PtrList.H:54
Registry of regIOobjects.
Namespace for OpenFOAM.
virtual bool write()
Write to screen/file.
Definition: fieldValue.C:106