clockTime.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 OpenFOAM Foundation
9  Copyright (C) 2018 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::clockTime
29 
30 Description
31  Starts timing (using rtc) and returns elapsed time from start.
32  Better resolution (2uSec instead of ~20mSec) than cpuTime.
33 
34 SourceFiles
35  clockTime.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef clockTime_H
40 #define clockTime_H
41 
42 #include "clockValue.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class clockTime Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class clockTime
54 {
55  // Private Data
56 
57  //- The values being used.
58  typedef clockValue value_type;
59 
60  //- Start time, at the time of construction
61  value_type start_;
62 
63  //- Last time when elapsedTime or timeIncrement was called
64  mutable value_type last_;
65 
66 
67 public:
68 
69  // Constructors
70 
71  //- Construct with the current clock time for the starting value
72  clockTime();
73 
74  //- Construct with the given clock value for the starting value
75  clockTime(const clockValue& clockval);
76 
77 
78  // Member Functions
79 
80  //- Reset to use the current time for the start time
81  void resetTime();
82 
83  //- Return time (in seconds) from the start
84  double elapsedTime() const;
85 
86  //- Return time (in seconds) since last call to timeIncrement()
87  double timeIncrement() const;
88 };
89 
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 } // End namespace Foam
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 #endif
98 
99 // ************************************************************************* //
Foam::clockTime::timeIncrement
double timeIncrement() const
Return time (in seconds) since last call to timeIncrement()
Definition: clockTime.C:62
Foam::clockTime::elapsedTime
double elapsedTime() const
Return time (in seconds) from the start.
Definition: clockTime.C:55
clockValue.H
Foam::clockValue
Access to high-resolution clock value with some basic operations.
Definition: clockValue.H:51
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::clockTime::resetTime
void resetTime()
Reset to use the current time for the start time.
Definition: clockTime.C:48
Foam::clockTime::clockTime
clockTime()
Construct with the current clock time for the starting value.
Definition: clockTime.C:32
Foam::clockTime
Starts timing (using rtc) and returns elapsed time from start. Better resolution (2uSec instead of ~2...
Definition: clockTime.H:52