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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::writeObjects
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
34  Allows specification of different writing frequency of objects registered
35  to the database.
36 
37 Usage
38  Minimal example by using \c system/controlDict.functions:
39  \verbatim
40  writeObjects1
41  {
42  // Mandatory entries
43  type writeObjects;
44  libs (utilityFunctionObjects);
45 
46  // Optional entries
47  writeOption <word>;
48 
49  // Conditional entries
50 
51  // Option-1
52  field <word>;
53 
54  // Option-2
55  fields (<wordRes>);
56 
57  // Option-3
58  objects (<wordRes>);
59 
60  // Inherited entries
61  ...
62  }
63  \endverbatim
64 
65  where the entries mean:
66  \table
67  Property | Description | Type | Reqd | Deflt
68  type | Type name: writeObjects | word | yes | -
69  libs | Library name: utilityFunctionObjects | word | yes | -
70  writeOption | Select objects with the specified write mode | no | anyWrite
71  field | Name of field to write | word | no | -
72  fields | Names of fields to write | wordRes | no | -
73  objects | Names of objects to write | wordRes | no | -
74  \endtable
75 
76  Options for the \c writeOption entry:
77  \vartable
78  autoWrite | Objects set to write at output time
79  noWrite | Objects set to not write by default
80  anyWrite | Any option of the previous two
81  log | Only report registered objects without writing objects
82  \endvartable
83 
84  The inherited entries are elaborated in:
85  - \link functionObject.H \endlink
86 
87 SourceFiles
88  writeObjects.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef Foam_functionObjects_writeObjects_H
93 #define Foam_functionObjects_writeObjects_H
94 
95 #include "functionObject.H"
96 #include "wordRes.H"
97 #include "Enum.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 
104 // Forward declaration of classes
105 class objectRegistry;
106 
107 namespace functionObjects
108 {
109 
110 /*---------------------------------------------------------------------------*\
111  Class functionObjects::writeObjects Declaration
112 \*---------------------------------------------------------------------------*/
113 
114 class writeObjects
115 :
116  public functionObject
117 {
118 public:
119 
120  // Public Data Types
121 
122  //- Re-enumeration defining the write options,
123  //- Naming based on the IOobjectOption::writeOption
124  enum writeOption
125  {
126  NO_WRITE,
127  AUTO_WRITE,
128  ANY_WRITE,
129  LOG
130  };
131 
132  //- Names for writeOption
133  static const Enum<writeOption> writeOptionNames_;
134 
135 private:
136 
137  // Private Data
138 
139  //- Reference to registry
140  const objectRegistry& obr_;
141 
142  //- To only write objects of defined writeOption
143  writeOption writeOption_;
144 
145  //- Names of objects to control
146  wordRes objectNames_;
147 
148 
149  // Private Member Functions
150 
151  //- No copy construct
152  writeObjects(const writeObjects&) = delete;
153 
154  //- No copy assignment
155  void operator=(const writeObjects&) = delete;
156 
157 
158 public:
159 
160  //- Runtime type information
161  TypeName("writeObjects");
162 
163 
164  // Constructors
165 
166  //- Construct from Time and dictionary
168  (
169  const word& name,
170  const Time& runTime,
171  const dictionary& dict
172  );
173 
174 
175  //- Destructor
176  virtual ~writeObjects() = default;
177 
179  // Member Functions
181  //- Read the writeObjects data
182  virtual bool read(const dictionary&);
184  //- Do nothing
185  virtual bool execute();
186 
187  //- Write the registered objects
188  virtual bool write();
189 };
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 } // End namespace functionObjects
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
dictionary dict
virtual bool write()
Write the registered objects.
Definition: writeObjects.C:132
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
const word & name() const noexcept
Return the name of this functionObject.
TypeName("writeObjects")
Runtime type information.
virtual ~writeObjects()=default
Destructor.
A class for handling words, derived from Foam::string.
Definition: word.H:63
writeOption
Re-enumeration defining the write options, Naming based on the IOobjectOption::writeOption.
Definition: writeObjects.H:178
static const Enum< writeOption > writeOptionNames_
Names for writeOption.
Definition: writeObjects.H:189
Allows specification of different writing frequency of objects registered to the database.
Definition: writeObjects.H:166
virtual bool execute()
Do nothing.
Definition: writeObjects.C:126
virtual bool read(const dictionary &)
Read the writeObjects data.
Definition: writeObjects.C:94
Namespace for OpenFOAM.