1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2007-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "scalarRanges.H"
27 #include "DynamicList.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 Foam::scalarRanges::scalarRanges()
38 Foam::scalarRanges::scalarRanges(Istream& is)
42 DynamicList<scalarRange> lst;
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 bool Foam::scalarRanges::selected(const scalar value) const
63 if (operator[](i).selected(value))
73 Foam::List<bool> Foam::scalarRanges::selected
75 const List<scalar>& values
78 List<bool> lst(values.size(), false);
83 if (selected(values[i]))
89 // check specific values
92 if (operator[](rangeI).isExact())
94 scalar target = operator[](rangeI).value();
96 int nearestIndex = -1;
97 scalar nearestDiff = Foam::GREAT;
99 forAll(values, timeIndex)
101 scalar diff = fabs(values[timeIndex] - target);
102 if (diff < nearestDiff)
105 nearestIndex = timeIndex;
109 if (nearestIndex >= 0)
111 lst[nearestIndex] = true;
120 Foam::List<Foam::scalar> Foam::scalarRanges::select
122 const List<scalar>& values
125 return subset(selected(values), values);
129 void Foam::scalarRanges::inplaceSelect
134 inplaceSubset(selected(values), values);
138 // ************************************************************************* //