readFields.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public L2020icense as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::readFields
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Reads fields from the time directories and adds them to the mesh database
35  for further post-processing.
36 
37  Operands:
38  \table
39  Operand | Type | Location
40  input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
41  output file | - | -
42  output field | vol<Type>Field | Mesh database
43  \endtable
44 
45  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
46 
47 Usage
48  Minimal example by using \c system/controlDict.functions:
49  \verbatim
50  readFields1
51  {
52  // Mandatory entries (unmodifiable)
53  type readFields;
54  libs (fieldFunctionObjects);
55 
56  // Mandatory entries (runtime modifiable)
57  fields (<field1> <field2> ... <fieldN>);
58 
59  // Optional entries (runtime unmodifiable)
60  readOnStart true;
61 
62  // Optional (inherited) entries
63  ...
64  }
65  \endverbatim
66 
67  where the entries mean:
68  \table
69  Property | Description | Type | Req'd | Dflt
70  type | Type name: readFields | word | yes | -
71  libs | Library name: fieldFunctionObjects | word | yes | -
72  fields | Names of the operand fields | wordList | yes | -
73  readOnStart | Flag to start reading on start-up | bool | no | true
74  \endtable
75 
76  The inherited entries are elaborated in:
77  - \link functionObject.H \endlink
78 
79  Usage by the \c postProcess utility is not available.
80 
81 See also
82  - Foam::functionObject
83  - Foam::functionObjects::fvMeshFunctionObject
84  - ExtendedCodeGuide::functionObjects::field::readFields
85 
86 SourceFiles
87  readFields.C
88  readFieldsTemplates.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef functionObjects_readFields_H
93 #define functionObjects_readFields_H
94 
95 #include "fvMeshFunctionObject.H"
96 #include "volFieldsFwd.H"
97 #include "surfaceFieldsFwd.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 namespace functionObjects
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class readFields Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class readFields
111 :
112  public fvMeshFunctionObject
113 {
114 protected:
115 
116  // Protected Data
117 
118  //- Read immediately on construction (default: true)
119  bool readOnStart_;
120 
121  //- Fields to load
123 
124 
125  // Protected Member Functions
126 
127  //- Attempt load from io, store on database if successful
128  template<class FieldType>
129  bool loadAndStore(const IOobject& io);
130 
131  //- Forward to loadAndStore for supported types
132  template<class Type>
133  bool loadField(const IOobject& io);
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("readFields");
140 
141 
142  // Constructors
143 
144  //- Construct for given objectRegistry and dictionary.
145  // Allow the possibility to load fields from files
146  readFields
147  (
148  const word& name,
149  const Time& runTime,
150  const dictionary& dict
151  );
152 
153  //- No copy construct
154  readFields(const readFields&) = delete;
155 
156  //- No copy assignment
157  void operator=(const readFields&) = delete;
158 
159 
160  //- Destructor
161  virtual ~readFields() = default;
163 
164  // Member Functions
165 
166  //- Read the set of fields from dictionary
167  virtual bool read(const dictionary& dict);
168 
169  //- Read the fields
170  virtual bool execute();
171 
172  //- Do nothing
173  virtual bool write();
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace functionObjects
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #ifdef NoRepository
185  #include "readFieldsTemplates.C"
186 #endif
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
dictionary dict
virtual ~readFields()=default
Destructor.
Forwards and collection of common volume field types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool loadField(const IOobject &io)
Forward to loadAndStore for supported types.
engineTime & runTime
wordList fieldSet_
Fields to load.
Definition: readFields.H:167
const word & name() const noexcept
Return the name of this functionObject.
virtual bool execute()
Read the fields.
Definition: readFields.C:71
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:40
virtual bool read(const dictionary &dict)
Read the set of fields from dictionary.
Definition: readFields.C:61
void operator=(const readFields &)=delete
No copy assignment.
virtual bool write()
Do nothing.
Definition: readFields.C:135
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:151
List< word > wordList
List of word.
Definition: fileName.H:59
bool readOnStart_
Read immediately on construction (default: true)
Definition: readFields.H:162
TypeName("readFields")
Runtime type information.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
bool loadAndStore(const IOobject &io)
Attempt load from io, store on database if successful.
Namespace for OpenFOAM.