writeObjects.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 | Copyright (C) 2011-2016 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 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  Allows specification of different writing frequency of objects registered
32  to the database.
33 
34  It has similar functionality as the main time database through the
35  \c writeControl setting:
36  - timeStep
37  - writeTime
38  - adjustableRunTime
39  - runTime
40  - clockTime
41  - cpuTime
42 
43  It also has the ability to write the selected objects that were defined
44  with the respective write mode for the requested \c writeOption, namely:
45  \vartable
46  autoWrite | objects set to write at output time
47  noWrite | objects set to not write by default
48  anyWrite | any option of the previous two
49  \endvartable
50 
51  Example of function object specification:
52  \verbatim
53  writeObjects1
54  {
55  type writeObjects;
56  libs ("libutilityFunctionObjects.so");
57  ...
58  objects (obj1 obj2);
59  writeOption anyWrite;
60  }
61  \endverbatim
62 
63 Usage
64  \table
65  Property | Description | Required | Default value
66  type | type name: writeObjects | yes |
67  objects | objects to write | yes |
68  writeOption | only those with this write option | no | anyWrite
69  \endtable
70 
71  Note: Regular expressions can also be used in \c objects.
72 
73 See also
74  Foam::functionObject
75  Foam::functionObjects::writeObjectsBase
76  Foam::functionObjects::timeControl
77 
78 SourceFiles
79  writeObjects.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef functionObjects_writeObjects_H
84 #define functionObjects_writeObjects_H
85 
86 #include "functionObject.H"
87 #include "writeObjectsBase.H"
88 #include "NamedEnum.H"
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 
95 namespace functionObjects
96 {
97 
98 /*---------------------------------------------------------------------------*\
99  Class writeObjects Declaration
100 \*---------------------------------------------------------------------------*/
101 
102 class writeObjects
103 :
104  public functionObject,
105  public writeObjectsBase
106 {
107 public:
108 
109  // Public data types
110 
111  //- Re-enumeration defining the write options, based on the original
112  // ones at IOobject::writeOption
113  enum writeOption
114  {
115  AUTO_WRITE,
116  NO_WRITE,
117  ANY_WRITE
118  };
119 
120  static const NamedEnum<writeOption, 3> writeOptionNames_;
121 
122 private:
123 
124  // Private data
125 
126  //- To only write objects of defined writeOption
127  writeOption writeOption_;
128 
129 
130  // Private Member Functions
131 
132  //- Write the requested registered IO object
133  virtual void writeObject(const regIOobject& obj);
134 
135  //- Disallow default bitwise copy construct
136  writeObjects(const writeObjects&);
137 
138  //- Disallow default bitwise assignment
139  void operator=(const writeObjects&);
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("writeObjects");
148  // Constructors
149 
150  //- Construct from Time and dictionary
152  (
153  const word& name,
154  const Time& runTime,
155  const dictionary& dict
156  );
157 
158 
159  //- Destructor
160  virtual ~writeObjects();
161 
162 
163  // Member Functions
164 
165  //- Read the writeObjects data
166  virtual bool read(const dictionary&);
167 
168  //- Do nothing
169  virtual bool execute();
170 
171  //- Write the registered objects
172  virtual bool write();
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:137
static const NamedEnum< writeOption, 3 > writeOptionNames_
Definition: writeObjects.H:151
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:144
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:133
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.