1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | 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::timeClusterList::typeName = "timeClusterList";
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::timeClusterList::timeClusterList()
41 Foam::timeClusterList::timeClusterList(const Foam::label size)
43 List<timeCluster>(size)
47 Foam::timeClusterList::timeClusterList(const timeCluster& tcIn)
49 List<timeCluster>(1, tcIn)
53 Foam::timeClusterList::timeClusterList(const Foam::label size, const Foam::timeCluster& tcIn)
55 List<timeCluster>(size, tcIn)
59 Foam::timeClusterList::timeClusterList(const labelList& subIndices, const timeClusterList& tclIn)
61 List<timeCluster>(subIndices.size())
65 this->operator[](i) = tclIn[subIndices[i]];
70 Foam::timeClusterList::timeClusterList(Foam::Istream& is)
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 void Foam::timeClusterList::globalSort()
80 Foam::sort(*this, timeCluster::less());
83 void Foam::timeClusterList::append(const timeClusterList& tclIn)
85 label wasSize = this->size();
86 this->setSize(tclIn.size() + this->size());
88 for (label i = 0; i < tclIn.size(); i++)
90 this->operator[](i + wasSize) = tclIn[i];
95 void Foam::timeClusterList::append(const timeCluster& tcIn)
97 label wasSize = this->size();
98 this->setSize(this->size() + 1);
100 this->operator[](wasSize) = tcIn;
104 bool Foam::timeClusterList::purgeEmpties()
106 if (!this->size()) return false;
109 for (label i = 0; i < this->size(); i++)
111 if (!this->operator[](i).times().size())
118 this->operator[](i - empties) = this->operator[](i);
123 this->setSize(this->size() - empties);
125 if (!this->size()) return false;
129 Foam::timeClusterList Foam::timeClusterList::selectiveSubList
131 const labelList& indices
134 timeClusterList tcl(indices.size());
138 if (indices[i] > this->size())
140 FatalErrorIn("timeClusterList::selectiveSubList")
141 << "Out of range index passed to this function. Indices "
142 << "passed are: \n" << indices << "\nFailure at index " << i
143 << ", with value " << indices[i] << ".\n This timeClusterList "
144 << "has size " << this->size() << "."
145 << abort(FatalError);
148 tcl[i] = this->operator[](indices[i]);
153 // ************************************************************************* //