writeObjects.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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::functionObjects::writeObjects
26 
27 Description
28  Allows specification of different writing frequency of objects registered
29  to the database.
30 
31  It has similar functionality as the main time database through the
32  \c writeControl setting:
33  - timeStep
34  - writeTime
35  - adjustableRunTime
36  - runTime
37  - clockTime
38  - cpuTime
39 
40  It also has the ability to write the selected objects that were defined
41  with the respective write mode for the requested \c writeOption, namely:
42  \vartable
43  autoWrite | objects set to write at output time
44  noWrite | objects set to not write by default
45  anyWrite | any option of the previous two
46  \endvartable
47 
48  Example of function object specification:
49  \verbatim
50  writeObjects1
51  {
52  type writeObjects;
53 
54  libs ("libutilityFunctionObjects.so");
55 
56  objects (obj1 obj2);
57  writeOption anyWrite;
58  }
59  \endverbatim
60 
61 Usage
62  \table
63  Property | Description | Required | Default value
64  type | type name: writeObjects | yes |
65  objects | objects to write | yes |
66  writeOption | only those with this write option | no | anyWrite
67  \endtable
68 
69  Note: Regular expressions can also be used in \c objects.
70 
71 See also
72  Foam::functionObject
73  Foam::functionObjects::writeObjectsBase
74  Foam::functionObjects::timeControl
75 
76 SourceFiles
77  writeObjects.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef functionObjects_writeObjects_H
82 #define functionObjects_writeObjects_H
83 
84 #include "functionObject.H"
85 #include "writeObjectsBase.H"
86 #include "NamedEnum.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 namespace functionObjects
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class writeObjects Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class writeObjects
101 :
102  public functionObject,
103  public writeObjectsBase
104 {
105 public:
106 
107  // Public data types
108 
109  //- Re-enumeration defining the write options, based on the original
110  // ones at IOobject::writeOption
111  enum class writeOption
112  {
113  AUTO_WRITE,
114  NO_WRITE,
115  ANY_WRITE
116  };
117 
118  static const NamedEnum<writeOption, 3> writeOptionNames_;
119 
120 
121 private:
122 
123  // Private Data
124 
125  //- To only write objects of defined writeOption
126  writeOption writeOption_;
127 
128 
129  // Private Member Functions
130 
131  //- Write the requested registered IO object
132  virtual void writeObject(const regIOobject& obj);
133 
134 
135 public:
136 
137  //- Runtime type information
138  TypeName("writeObjects");
139 
140 
141  // Constructors
143  //- Construct from Time and dictionary
145  (
146  const word& name,
147  const Time& runTime,
148  const dictionary& dict
149  );
150 
151  //- Disallow default bitwise copy construction
152  writeObjects(const writeObjects&) = delete;
153 
154 
155  //- Destructor
156  virtual ~writeObjects();
157 
158 
159  // Member Functions
160 
161  //- Read the writeObjects data
162  virtual bool read(const dictionary&);
163 
164  //- Return the list of fields required
165  virtual wordList fields() const
166  {
167  return wordList::null();
168  }
169 
170  //- Do nothing
171  virtual bool execute();
172 
173  //- Write the registered objects
174  virtual bool write();
175 
176 
177  // Member Operators
178 
179  //- Disallow default bitwise assignment
180  void operator=(const writeObjects&) = delete;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
dictionary dict
const word & name() const
Return the name of this functionObject.
virtual bool write()
Write the registered objects.
Definition: writeObjects.C:204
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
static const NamedEnum< writeOption, 3 > writeOptionNames_
Definition: writeObjects.H:149
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
TypeName("writeObjects")
Runtime type information.
virtual wordList fields() const
Return the list of fields required.
Definition: writeObjects.H:196
A class for handling words, derived from string.
Definition: word.H:59
writeObjects(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: writeObjects.C:138
writeOption
Re-enumeration defining the write options, based on the original.
Definition: writeObjects.H:142
void operator=(const writeObjects &)=delete
Disallow default bitwise assignment.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
Allows specification of different writing frequency of objects registered to the database.
Definition: writeObjects.H:131
virtual bool execute()
Do nothing.
Definition: writeObjects.C:198
virtual ~writeObjects()
Destructor.
Definition: writeObjects.C:161
virtual bool read(const dictionary &)
Read the writeObjects data.
Definition: writeObjects.C:167
Namespace for OpenFOAM.