subCycleTime.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-2014 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::subCycleTime
28 
29 Description
30  A class for managing sub-cycling times
31 
32 SourceFiles
33  subCycleTime.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef subCycleTime_H
38 #define subCycleTime_H
39 
40 #include "Time.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class subCycleTime Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class subCycleTime
52 {
53  // Private data
54 
55  //- Reference to the underlying time
56  Time& time_;
57 
58  //- Current index in the sub-cycle
59  label index_;
60 
61  //- Total number of cycles in the sub-cycle
62  label total_;
63 
64 
65 public:
66 
67  // Constructors
68 
69  //- Construct referencing the original time and number of sub-cycles
70  subCycleTime(Time& runTime, const label nCycle);
71 
72 
73  //- Destructor
74  ~subCycleTime();
75 
76 
77  // Member functions
78 
79  //- Return the current sub-cycle index
80  inline label index() const
81  {
82  return index_;
83  }
84 
85  //- Return the total number of sub-cycles
86  inline label nSubCycles() const
87  {
88  return total_;
89  }
90 
91  //- True if the sub-cycle is active.
92  bool status() const;
93 
94  //- Return true if the number of sub-cycles has been reached
95  bool end() const;
96 
97  //- End the sub-cycling and reset the time-state
98  void endSubCycle();
99 
100  //- True if looping is active, increments the index.
101  // Example usage,
102  // \code
103  // while (subcycle.loop())
104  // {
105  // solve;
106  // }
107  // \endcode
108  bool loop();
109 
110 
111  // Member operators
112 
113  //- Prefix increment
115 
116  //- Postfix increment, this is identical to the prefix increment
117  subCycleTime& operator++(int);
118 };
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::subCycleTime::end
bool end() const
Return true if the number of sub-cycles has been reached.
Definition: subCycleTime.C:62
Foam::subCycleTime
A class for managing sub-cycling times.
Definition: subCycleTime.H:50
Foam::subCycleTime::subCycleTime
subCycleTime(Time &runTime, const label nCycle)
Construct referencing the original time and number of sub-cycles.
Definition: subCycleTime.C:32
Foam::subCycleTime::~subCycleTime
~subCycleTime()
Destructor.
Definition: subCycleTime.C:48
Foam::subCycleTime::nSubCycles
label nSubCycles() const
Return the total number of sub-cycles.
Definition: subCycleTime.H:85
Foam::subCycleTime::endSubCycle
void endSubCycle()
End the sub-cycling and reset the time-state.
Definition: subCycleTime.C:68
Foam::subCycleTime::index
label index() const
Return the current sub-cycle index.
Definition: subCycleTime.H:79
Foam::subCycleTime::loop
bool loop()
True if looping is active, increments the index.
Definition: subCycleTime.C:81
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Time.H
Foam::subCycleTime::status
bool status() const
True if the sub-cycle is active.
Definition: subCycleTime.C:56
Foam::subCycleTime::operator++
subCycleTime & operator++()
Prefix increment.
Definition: subCycleTime.C:96