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-2013 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 fieldValue_H
39 #define fieldValue_H
40 
41 #include "functionObjectFile.H"
42 #include "Switch.H"
43 #include "OFstream.H"
44 #include "dictionary.H"
45 #include "Field.H"
46 #include "runTimeSelectionTables.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class objectRegistry;
55 class fvMesh;
56 class polyMesh;
57 class mapPolyMesh;
58 
59 /*---------------------------------------------------------------------------*\
60  Class fieldValue Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class fieldValue
64 :
65  public functionObjectFile
66 {
67 
68 protected:
69 
70  // Protected data
71 
72  //- Name of this fieldValue object
73  word name_;
74 
75  //- Database this class is registered to
76  const objectRegistry& obr_;
77 
78  //- Construction dictionary
80 
81  //- Active flag
82  bool active_;
83 
84  //- Switch to send output to Info as well as to file
85  Switch log_;
86 
87  //- Name of source object
89 
90  //- List of field names to operate on
92 
93  //- Output field values flag
95 
96  //- Results dictionary for external access of results
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  const bool loadFromFiles
117  ),
118  (name, obr, dict, loadFromFiles)
119  );
120 
121  //- Construct from components
122  fieldValue
123  (
124  const word& name,
125  const objectRegistry& obr,
126  const dictionary& dict,
127  const word& valueType,
128  const bool loadFromFiles = false
129  );
130 
131  //- Return a reference to the selected fieldValue
132  static autoPtr<fieldValue> New
133  (
134  const word& name,
135  const objectRegistry& obr,
136  const dictionary& dict,
137  const bool loadFromFiles = false,
138  const bool output = true
139  );
140 
141  //- Destructor
142  virtual ~fieldValue();
143 
144 
145  // Public Member Functions
146 
147  // Access
148 
149  //- Return the name of the geometric source
150  inline const word& name() const;
151 
152  //- Return the reference to the object registry
153  inline const objectRegistry& obr() const;
154 
155  //- Return the reference to the construction dictionary
156  inline const dictionary& dict() const;
157 
158  //- Return the active flag
159  inline bool active() const;
160 
161  //- Return the switch to send output to Info as well as to file
162  inline const Switch& log() const;
163 
164  //- Return the source name
165  inline const word& sourceName() const;
166 
167  //- Return the list of field names
168  inline const wordList& fields() const;
169 
170  //- Return the output field values flag
171  inline const Switch& valueOutput() const;
172 
173  //- Helper function to return the reference to the mesh
174  inline const fvMesh& mesh() const;
175 
176  //- Return access to the latest set of results
177  inline const dictionary& resultDict() const;
178 
179 
180  // Function object functions
181 
182  //- Read from dictionary
183  virtual void read(const dictionary& dict);
184 
185  //- Write to screen/file
186  virtual void write();
187 
188  //- Execute
189  virtual void execute();
190 
191  //- Execute the at the final time-loop, currently does nothing
192  virtual void end();
193 
194  //- Called when time was set at the end of the Time::operator++
195  virtual void timeSet();
196 
197  //- Update mesh
198  virtual void updateMesh(const mapPolyMesh&);
199 
200  //- Move points
201  virtual void movePoints(const polyMesh&);
202 
203  //- Combine fields from all processor domains into single field
204  template<class Type>
205  void combineFields(Field<Type>& field);
206 
207  //- Combine fields from all processor domains into single field
208  template<class Type>
209  void combineFields(tmp<Field<Type> >&);
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #include "fieldValueI.H"
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #ifdef NoRepository
224  #include "fieldValueTemplates.C"
225 #endif
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
const wordList & fields() const
Return the list of field names.
Definition: fieldValueI.H:67
declareRunTimeSelectionTable(autoPtr, fieldValue, dictionary,( const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles ),(name, obr, dict, loadFromFiles))
word name_
Name of this fieldValue object.
Definition: fieldValue.H:72
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
word sourceName_
Name of source object.
Definition: fieldValue.H:87
virtual void execute()
Execute.
Definition: fieldValue.C:119
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldValue.C:131
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static autoPtr< fieldValue > New(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false, const bool output=true)
Return a reference to the selected fieldValue.
Definition: fieldValueNew.C:31
Macros to ease declaration of run-time selection tables.
TypeName("fieldValue")
Run-time type information.
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
const Switch & log() const
Return the switch to send output to Info as well as to file.
Definition: fieldValueI.H:55
Switch valueOutput_
Output field values flag.
Definition: fieldValue.H:93
A class for handling words, derived from string.
Definition: word.H:59
bool active_
Active flag.
Definition: fieldValue.H:81
Switch log_
Switch to send output to Info as well as to file.
Definition: fieldValue.H:84
Base class for field value -based function objects.
Definition: fieldValue.H:62
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
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:78
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void write()
Write to screen/file.
Definition: fieldValue.C:55
Namespace for OpenFOAM.
virtual void updateMesh(const mapPolyMesh &)
Update mesh.
Definition: fieldValue.C:137
virtual void read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:42
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:43
const dictionary & resultDict() const
Return access to the latest set of results.
Definition: fieldValueI.H:85
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
Definition: fieldValueI.H:79
const word & name() const
Return the name of the geometric source.
Definition: fieldValueI.H:31
fieldValue(const word &name, const objectRegistry &obr, const dictionary &dict, const word &valueType, const bool loadFromFiles=false)
Construct from components.
Definition: fieldValue.C:69
const objectRegistry & obr_
Database this class is registered to.
Definition: fieldValue.H:75
bool active() const
Return the active flag.
Definition: fieldValueI.H:49
Pre-declare SubField and related Field type.
Definition: Field.H:57
const objectRegistry & obr() const
Return the reference to the object registry.
Definition: fieldValueI.H:37
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Registry of regIOobjects.
wordList fields_
List of field names to operate on.
Definition: fieldValue.H:90
virtual void end()
Execute the at the final time-loop, currently does nothing.
Definition: fieldValue.C:125
dictionary resultDict_
Results dictionary for external access of results.
Definition: fieldValue.H:96
Base class for output file data handling.
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:113
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
const word & sourceName() const
Return the source name.
Definition: fieldValueI.H:61
const Switch & valueOutput() const
Return the output field values flag.
Definition: fieldValueI.H:73
virtual void movePoints(const polyMesh &)
Move points.
Definition: fieldValue.C:143