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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::readFields
29
30Group
31 grpFieldFunctionObjects
32
33Description
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
47Usage
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
81See also
82 - Foam::functionObject
83 - Foam::functionObjects::fvMeshFunctionObject
84 - ExtendedCodeGuide::functionObjects::field::readFields
85
86SourceFiles
87 readFields.C
88 readFieldsTemplates.C
89
90\*---------------------------------------------------------------------------*/
91
92#ifndef functionObjects_readFields_H
93#define functionObjects_readFields_H
94
96#include "volFieldsFwd.H"
97#include "surfaceFieldsFwd.H"
98
99// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100
101namespace Foam
102{
103namespace functionObjects
104{
105
106/*---------------------------------------------------------------------------*\
107 Class readFields Declaration
108\*---------------------------------------------------------------------------*/
109
110class readFields
111:
112 public fvMeshFunctionObject
113{
114protected:
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
136public:
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
147 (
148 const word& name,
149 const Time& runTime,
150 const dictionary& dict
151 );
152
153 //- No copy construct
154 readFields(const readFields&) = delete;
156 //- No copy assignment
157 void operator=(const readFields&) = delete;
158
159
160 //- Destructor
161 virtual ~readFields() = default;
162
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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:158
bool readOnStart_
Read immediately on construction (default: true)
Definition: readFields.H:164
virtual ~readFields()=default
Destructor.
void operator=(const readFields &)=delete
No copy assignment.
TypeName("readFields")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the set of fields from dictionary.
Definition: readFields.C:68
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:47
wordList fieldSet_
Fields to load.
Definition: readFields.H:167
readFields(const readFields &)=delete
No copy construct.
bool loadAndStore(const IOobject &io)
Attempt load from io, store on database if successful.
virtual bool execute()
Read the fields.
Definition: readFields.C:78
virtual bool write()
Do nothing.
Definition: readFields.C:129
bool loadField(const IOobject &io)
Forward to loadAndStore for supported types.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73