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-2018 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 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  //- Disallow default bitwise copy construct
133  writeObjects(const writeObjects&);
134 
135  //- Disallow default bitwise assignment
136  void operator=(const writeObjects&);
137 
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("writeObjects");
145  // Constructors
146 
147  //- Construct from Time and dictionary
149  (
150  const word& name,
151  const Time& runTime,
152  const dictionary& dict
153  );
154 
155 
156  //- Destructor
157  virtual ~writeObjects();
158 
159 
160  // Member Functions
161 
162  //- Read the writeObjects data
163  virtual bool read(const dictionary&);
164 
165  //- Do nothing
166  virtual bool execute();
167 
168  //- Write the registered objects
169  virtual bool write();
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace functionObjects
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
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:137
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
writeOption
Re-enumeration defining the write options, based on the original.
Definition: writeObjects.H:141
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
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.