1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Perform a subCycleTime on a field
30 \*---------------------------------------------------------------------------*/
35 #include "subCycleTime.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 /*---------------------------------------------------------------------------*\
43 Class subCycleField Declaration
44 \*---------------------------------------------------------------------------*/
46 template<class GeometricField>
51 //- Reference to the field being sub-cycled
54 //- Reference to the field old-time field being sub-cycled
55 // Needed to avoid calls to oldTime() which may cause
56 // unexpected updates of the old-time field
59 //- Copy of the "real" old-time value of the field
67 //- Construct field and number of sub-cycles
68 subCycleField(GeometricField& gf)
72 gf_0_(gf0_.name() + "_", gf0_)
79 // Reset the old-time field
82 // Correct the time index of the field to correspond to the global time
83 gf_.timeIndex() = gf_.time().timeIndex();
84 gf0_.timeIndex() = gf_.time().timeIndex();
88 //- Correct the time index of the field to correspond to
89 // the sub-cycling time.
91 // The time index is incremented to protect the old-time value from
92 // being updated at the beginning of the time-loop in the case of
94 void updateTimeIndex()
96 gf_.timeIndex() = gf_.time().timeIndex() + 1;
97 gf0_.timeIndex() = gf_.time().timeIndex() + 1;
102 /*---------------------------------------------------------------------------*\
103 Class subCycle Declaration
104 \*---------------------------------------------------------------------------*/
106 template<class GeometricField>
109 public subCycleField<GeometricField>,
112 // Private Member Functions
114 //- Disallow default bitwise copy construct
115 subCycle(const subCycle<GeometricField>&);
117 //- Disallow default bitwise assignment
118 void operator=(const subCycle<GeometricField>&);
125 //- Construct field and number of sub-cycles
126 subCycle(GeometricField& gf, const label nSubCycles)
128 subCycleField<GeometricField>(gf),
129 subCycleTime(const_cast<Time&>(gf.time()), nSubCycles)
131 // Update the field time index to correspond to the sub-cycle time
132 this->updateTimeIndex();
137 // End the subCycleTime, which restores the time state
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 // ************************************************************************* //