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;
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
Foam::functionObjects::readFields::readFields
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:47
Foam::functionObjects::readFields::readOnStart_
bool readOnStart_
Read immediately on construction (default: true)
Definition: readFields.H:164
Foam::functionObjects::readFields::loadAndStore
bool loadAndStore(const IOobject &io)
Attempt load from io, store on database if successful.
Definition: readFieldsTemplates.C:37
Foam::functionObjects::readFields::operator=
void operator=(const readFields &)=delete
No copy assignment.
Foam::functionObjects::readFields::execute
virtual bool execute()
Read the fields.
Definition: readFields.C:78
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::functionObjects::readFields::loadField
bool loadField(const IOobject &io)
Forward to loadAndStore for supported types.
Definition: readFieldsTemplates.C:54
Foam::functionObjects::readFields::~readFields
virtual ~readFields()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::readFields::write
virtual bool write()
Do nothing.
Definition: readFields.C:129
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::readFields::fieldSet_
wordList fieldSet_
Fields to load.
Definition: readFields.H:167
Foam::List< word >
Foam::functionObjects::readFields::TypeName
TypeName("readFields")
Runtime type information.
surfaceFieldsFwd.H
Foam::functionObjects::readFields
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:155
readFieldsTemplates.C
Foam::functionObjects::readFields::read
virtual bool read(const dictionary &dict)
Read the set of fields from dictionary.
Definition: readFields.C:68