timeFunctionObject.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) 2018-2021 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::time
26 
27 Description
28  Writes run time, CPU time and clock time
29  and optionally the CPU and clock times per time step.
30 
31  Example of function object specification:
32  \verbatim
33  time
34  {
35  type time;
36 
37  libs ("libutilityFunctionObjects.so");
38 
39  writeControl timeStep;
40  writeInterval 1;
41 
42  perTimeStep no;
43  }
44  \endverbatim
45 
46 See also
47  Foam::functionObject
48  Foam::regionFunctionObject
49  Foam::functionObjects::logFiles
50 
51 SourceFiles
52  time.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef timeFunctionObject_H
57 #define timeFunctionObject_H
58 
59 #include "regionFunctionObject.H"
60 #include "logFiles.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 namespace functionObjects
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class time Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 class time
74 :
75  public regionFunctionObject,
76  public logFiles
77 {
78  // Private member data
79 
80  //- Switch to write CPU and clock times per time-step
81  Switch perTimeStep_;
82 
83  //- Previous time-step CPU time
84  scalar cpuTime0_;
85 
86  //- Previous time-step clock time
87  scalar clockTime0_;
88 
89 
90 protected:
91 
92  // Protected Member Functions
93 
94  //- Output file header information
95  virtual void writeFileHeader(const label i);
96 
97 
98 public:
99 
100  //- Runtime type information
101  TypeName("time");
102 
103 
104  // Constructors
105 
106  //- Construct from Time and dictionary
107  time
108  (
109  const word& name,
110  const Time& runTime,
111  const dictionary& dict
112  );
113 
114  //- Disallow default bitwise copy construction
115  time(const time&) = delete;
116 
117 
118  //- Destructor
119  virtual ~time();
120 
121 
122  // Member Functions
123 
124  //- Read the controls
125  virtual bool read(const dictionary&);
126 
127  //- Return the list of fields required
128  virtual wordList fields() const
129  {
130  return wordList::null();
131  }
132 
133  //- Execute, currently does nothing
134  virtual bool execute();
135 
136  //- Write the time
137  virtual bool write();
138 
139 
140  // Member Operators
141 
142  //- Disallow default bitwise assignment
143  void operator=(const time&) = delete;
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace functionObjects
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
dictionary dict
virtual void writeFileHeader(const label i)
Output file header information.
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual ~time()
Destructor.
void operator=(const time &)=delete
Disallow default bitwise assignment.
TypeName("time")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:59
time(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual bool write()
Write the time.
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step...
virtual wordList fields() const
Return the list of fields required.
virtual bool execute()
Execute, currently does nothing.
Namespace for OpenFOAM.
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57
virtual bool read(const dictionary &)
Read the controls.