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-2019 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  libs ("libutilityFunctionObjects.so");
54  ...
55  objects (obj1 obj2);
56  writeOption anyWrite;
57  }
58  \endverbatim
59 
60 Usage
61  \table
62  Property | Description | Required | Default value
63  type | type name: writeObjects | yes |
64  objects | objects to write | yes |
65  writeOption | only those with this write option | no | anyWrite
66  \endtable
67 
68  Note: Regular expressions can also be used in \c objects.
69 
70 See also
71  Foam::functionObject
72  Foam::functionObjects::writeObjectsBase
73  Foam::functionObjects::timeControl
74 
75 SourceFiles
76  writeObjects.C
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef functionObjects_writeObjects_H
81 #define functionObjects_writeObjects_H
82 
83 #include "functionObject.H"
84 #include "writeObjectsBase.H"
85 #include "NamedEnum.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 
92 namespace functionObjects
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class writeObjects Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class writeObjects
100 :
101  public functionObject,
102  public writeObjectsBase
103 {
104 public:
105 
106  // Public data types
107 
108  //- Re-enumeration defining the write options, based on the original
109  // ones at IOobject::writeOption
110  enum class writeOption
111  {
112  AUTO_WRITE,
113  NO_WRITE,
114  ANY_WRITE
115  };
116 
117  static const NamedEnum<writeOption, 3> writeOptionNames_;
118 
119 private:
120 
121  // Private Data
122 
123  //- To only write objects of defined writeOption
124  writeOption writeOption_;
125 
126 
127  // Private Member Functions
128 
129  //- Write the requested registered IO object
130  virtual void writeObject(const regIOobject& obj);
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("writeObjects");
137 
138 
139  // Constructors
140 
141  //- Construct from Time and dictionary
143  (
144  const word& name,
145  const Time& runTime,
146  const dictionary& dict
147  );
149  //- Disallow default bitwise copy construction
150  writeObjects(const writeObjects&) = delete;
151 
152 
153  //- Destructor
154  virtual ~writeObjects();
155 
156 
157  // Member Functions
158 
159  //- Read the writeObjects data
160  virtual bool read(const dictionary&);
161 
162  //- Do nothing
163  virtual bool execute();
164 
165  //- Write the registered objects
166  virtual bool write();
167 
168 
169  // Member Operators
170 
171  //- Disallow default bitwise assignment
172  void operator=(const writeObjects&) = delete;
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace functionObjects
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
dictionary dict
const word & name() const
Return the name of this functionObject.
virtual bool write()
Write the registered objects.
Definition: writeObjects.C:190
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
static const NamedEnum< writeOption, 3 > writeOptionNames_
Definition: writeObjects.H:148
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
TypeName("writeObjects")
Runtime type information.
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:126
writeOption
Re-enumeration defining the write options, based on the original.
Definition: writeObjects.H:141
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:55
Allows specification of different writing frequency of objects registered to the database.
Definition: writeObjects.H:130
virtual bool execute()
Do nothing.
Definition: writeObjects.C:184
virtual ~writeObjects()
Destructor.
Definition: writeObjects.C:149
virtual bool read(const dictionary &)
Read the writeObjects data.
Definition: writeObjects.C:155
Namespace for OpenFOAM.