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 
120 private:
121 
122  // Private Data
123 
124  //- To only write objects of defined writeOption
125  writeOption writeOption_;
126 
127 
128  // Private Member Functions
129 
130  //- Write the requested registered IO object
131  virtual void writeObject(const regIOobject& obj);
132 
133 
134 public:
135 
136  //- Runtime type information
137  TypeName("writeObjects");
138 
139 
140  // Constructors
142  //- Construct from Time and dictionary
144  (
145  const word& name,
146  const Time& runTime,
147  const dictionary& dict
148  );
149 
150  //- Disallow default bitwise copy construction
151  writeObjects(const writeObjects&) = delete;
152 
153 
154  //- Destructor
155  virtual ~writeObjects();
156 
157 
158  // Member Functions
159 
160  //- Read the writeObjects data
161  virtual bool read(const dictionary&);
162 
163  //- Do nothing
164  virtual bool execute();
165 
166  //- Write the registered objects
167  virtual bool write();
168 
169 
170  // Member Operators
171 
172  //- Disallow default bitwise assignment
173  void operator=(const writeObjects&) = delete;
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace functionObjects
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #endif
185 
186 // ************************************************************************* //
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.