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