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  It has similar functionality as the main time database through the
38  \c writeControl setting:
39  - timeStep
40  - writeTime
41  - adjustableRunTime
42  - runTime
43  - clockTime
44  - cpuTime
45 
46  It also has the ability to write the selected objects that were defined
47  with the respective write mode for the requested \c writeOption, namely:
48  \vartable
49  autoWrite | objects set to write at output time
50  noWrite | objects set to not write by default
51  anyWrite | any option of the previous two
52  \endvartable
53 
54 Usage
55  Example of function object specification:
56  \verbatim
57  writeObjects1
58  {
59  type writeObjects;
60  libs (utilityFunctionObjects);
61  ...
62  objects (obj1 obj2);
63  writeOption anyWrite;
64  }
65  \endverbatim
66 
67  Where the entries comprise:
68  \table
69  Property | Description | Required | Default value
70  type | type name: writeObjects | yes |
71  objects | objects to write | yes |
72  writeOption | only those with this write option | no | anyWrite
73  \endtable
74 
75  Note: Regular expressions can also be used in \c objects.
76 
77 See also
78  Foam::functionObject
79  Foam::functionObjects::timeControl
80 
81 SourceFiles
82  writeObjects.C
83 
84 \*---------------------------------------------------------------------------*/
85 
86 #ifndef functionObjects_writeObjects_H
87 #define functionObjects_writeObjects_H
88 
89 #include "functionObject.H"
90 #include "wordRes.H"
91 #include "Enum.H"
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 namespace Foam
96 {
97 
98 // Forward declaration of classes
99 class objectRegistry;
100 
101 namespace functionObjects
102 {
103 
104 /*---------------------------------------------------------------------------*\
105  Class functionObjects::writeObjects Declaration
106 \*---------------------------------------------------------------------------*/
107 
108 class writeObjects
109 :
110  public functionObject
111 {
112 public:
113 
114  // Public data types
115 
116  //- Re-enumeration defining the write options, based on the original
117  // ones at IOobject::writeOption
118  enum writeOption
119  {
120  AUTO_WRITE,
121  NO_WRITE,
122  ANY_WRITE
123  };
124 
125  static const Enum<writeOption> writeOptionNames_;
126 
127 private:
128 
129  // Private data
130 
131  //- Reference to registry
132  const objectRegistry& obr_;
133 
134  //- To only write objects of defined writeOption
135  writeOption writeOption_;
136 
137  //- Names of objects to control
138  wordRes objectNames_;
139 
140 
141  // Private Member Functions
142 
143  //- No copy construct
144  writeObjects(const writeObjects&) = delete;
145 
146  //- No copy assignment
147  void operator=(const writeObjects&) = delete;
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("writeObjects");
154 
155 
156  // Constructors
157 
158  //- Construct from Time and dictionary
160  (
161  const word& name,
162  const Time& runTime,
163  const dictionary& dict
164  );
165 
166 
167  //- Destructor
168  virtual ~writeObjects() = default;
169 
170 
171  // Member Functions
172 
173  //- Read the writeObjects data
174  virtual bool read(const dictionary&);
175 
176  //- Do nothing
177  virtual bool execute();
178 
179  //- Write the registered objects
180  virtual bool write();
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
wordRes.H
Foam::functionObjects::writeObjects::write
virtual bool write()
Write the registered objects.
Definition: writeObjects.C:125
Foam::Enum< writeOption >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::writeObjects::writeOptionNames_
static const Enum< writeOption > writeOptionNames_
Definition: writeObjects.H:156
Foam::functionObject
Abstract base-class for Time/database function objects.
Definition: functionObject.H:332
Foam::functionObjects::writeObjects::writeOption
writeOption
Re-enumeration defining the write options, based on the original.
Definition: writeObjects.H:149
Foam::functionObjects::writeObjects::TypeName
TypeName("writeObjects")
Runtime type information.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::writeObjects::execute
virtual bool execute()
Do nothing.
Definition: writeObjects.C:119
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::writeObjects::~writeObjects
virtual ~writeObjects()=default
Destructor.
Foam::functionObjects::writeObjects::ANY_WRITE
Definition: writeObjects.H:153
Foam::functionObjects::writeObjects::NO_WRITE
Definition: writeObjects.H:152
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::writeObjects::read
virtual bool read(const dictionary &)
Read the writeObjects data.
Definition: writeObjects.C:90
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
functionObject.H
Foam::functionObjects::writeObjects::AUTO_WRITE
Definition: writeObjects.H:151
Foam::functionObjects::writeObjects
Allows specification of different writing frequency of objects registered to the database.
Definition: writeObjects.H:139
Enum.H