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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "timeClusterList.H"
27 #include "objectRegistry.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 const char* const Foam::timeCluster::typeName = "timeCluster";
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::timeCluster::timeCluster()
39 Foam::timeCluster::timeCluster
41 const instantList& times,
42 const scalar globalOffset,
43 const label globalIndex,
44 const label superLoop,
45 const word& solverDomainName,
46 const word& preConName
50 globalOffset_(globalOffset),
51 globalIndex_(globalIndex),
52 superLoop_(superLoop),
53 solverDomainName_(solverDomainName),
54 preConName_(preConName)
57 Foam::timeCluster::timeCluster
59 const timeCluster& tc,
63 instantList(1, tc[index]),
64 globalOffset_(tc.globalOffset_),
65 globalIndex_(tc.globalIndex_),
66 superLoop_(tc.superLoop_),
67 solverDomainName_(tc.solverDomainName_),
68 preConName_(tc.preConName_)
72 Foam::timeCluster::timeCluster(const Foam::scalar t)
74 instantList(1, instant(0)),
78 solverDomainName_(word::null),
79 preConName_(word::null)
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 Foam::scalar Foam::timeCluster::globalValue(const label& index) const
87 return this->operator[](index).value() + globalOffset_;
90 Foam::scalar Foam::timeCluster::globalMinValue() const
92 return this->localMinValue() + globalOffset_;
96 Foam::scalar Foam::timeCluster::globalMaxValue() const
98 return this->localMaxValue() + globalOffset_;
102 Foam::label Foam::timeCluster::globalMinIndex() const
104 return this->localMinIndex();
108 Foam::label Foam::timeCluster::globalMaxIndex() const
110 return this->localMaxIndex();
114 Foam::scalar Foam::timeCluster::globalFindClosestTimeValue
116 const scalar timeValue
119 return this->operator[]
121 Foam::Time::findClosestTimeIndex
123 this->times(), timeValue - globalOffset_
125 ).value() + globalOffset_;
129 Foam::label Foam::timeCluster::globalFindClosestTimeIndex
131 const scalar timeValue
134 return Foam::Time::findClosestTimeIndex
136 this->times(), timeValue - globalOffset_
141 Foam::scalar Foam::timeCluster::localValue(const label& index) const
143 return this->operator[](index).value();
147 Foam::scalar Foam::timeCluster::localMinValue() const
149 return this->operator[](this->localMinIndex()).value();
153 Foam::scalar Foam::timeCluster::localMaxValue() const
155 return this->operator[](this->localMaxIndex()).value();
159 Foam::label Foam::timeCluster::localMinIndex() const
165 if (this->operator[](i).value() < min)
167 min = this->operator[](i).value();
175 Foam::label Foam::timeCluster::localMaxIndex() const
181 if (this->operator[](i).value() > max)
183 max = this->operator[](i).value();
191 Foam::scalar Foam::timeCluster::localFindClosestTimeValue
193 const scalar timeValue
196 return this->operator[]
198 Foam::Time::findClosestTimeIndex
200 this->times(), timeValue
206 Foam::label Foam::timeCluster::localFindClosestTimeIndex
208 const scalar timeValue
211 return Foam::Time::findClosestTimeIndex
213 this->times(), timeValue
218 Foam::timeCluster Foam::timeCluster::operator()(const Foam::label index) const
220 return timeCluster(*this, index);
224 // * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * //
226 Foam::Istream& Foam::operator>>(Istream& is, timeCluster& I)
228 return is >> I.globalOffset_
231 >> I.solverDomainName_
237 Foam::Ostream& Foam::operator<<(Ostream& os, const timeCluster& I)
239 return os << "/* globalOffset: */\t" << I.globalOffset_ << nl
240 << "/* globalIndex: */\t" << I.globalIndex_ << nl
241 << "/* superLoop: */\t" << I.superLoop_ << nl
242 << "/* solverDomain: */\t" << I.solverDomainName_ << nl
243 << "/* preConName: */\t" << I.preConName_ << nl
244 << "/* Instant list: */\t" << I.times();
247 // ************************************************************************* //