subCycleTime.C
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) 2011-2019 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 \*---------------------------------------------------------------------------*/
25 
26 #include "subCycleTime.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  time_(t),
33  nSubCycles_(nSubCycles),
34  subCycleIndex_(0)
35 {
36  if (nSubCycles_ > 1)
37  {
38  time_.subCycle(nSubCycles_);
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
44 
46 {
47  endSubCycle();
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
54 {
55  return subCycleIndex_ > nSubCycles_;
56 }
57 
58 
60 {
61  if (nSubCycles_ > 1)
62  {
63  time_.endSubCycle();
64  }
65 }
66 
67 
68 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
69 
71 {
72  if (nSubCycles_ > 1)
73  {
74  time_++;
75  }
76 
77  subCycleIndex_++;
78 
79  return *this;
80 }
81 
82 
84 {
85  return operator++();
86 }
87 
88 
89 // ************************************************************************* //
bool end() const
Return true if the number of sub-cycles has been reached.
Definition: subCycleTime.C:53
~subCycleTime()
Destructor.
Definition: subCycleTime.C:45
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual TimeState subCycle(const label nSubCycles)
Set time to sub-cycle for the given number of steps.
Definition: Time.C:1083
void endSubCycle()
End the sub-cycling and reset the time-state.
Definition: subCycleTime.C:59
subCycleTime(Time &, const label nSubCycles)
Construct from original time and number of sub-cycles.
Definition: subCycleTime.C:30
virtual void endSubCycle()
Reset time after sub-cycling back to previous TimeState.
Definition: Time.C:1097
A class for managing sub-cycling times.
Definition: subCycleTime.H:48
subCycleTime & operator++()
Prefix increment.
Definition: subCycleTime.C:70