1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "GatherBase.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 Type GatherBase::flatten(const List<Type> lst)
42 sum += lst[lstI].size();
51 const Type& sub = lst[lstI];
55 result[index++] = sub[subI];
63 template <class DataType, class IndexType, class AddOp>
64 IndexType GatherBase::offset
66 const List<DataType>& values,
67 const List<IndexType>& indices,
71 if (values.size() != indices.size())
75 "GatherBase::offset(const List<DataType>&, "
76 "const List<IndexType>&, AddOp)"
77 ) << "Input data and indices lists not equal size." << endl
78 << "data size:" << values.size()
79 << " indices:" << indices.size()
88 sum += indices[lstI].size();
91 IndexType result(sum);
99 const IndexType& sub = indices[lstI];
103 result[index++] = aop(sub[subI], offset);
105 offset += values[lstI].size();
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 } // End namespace Foam
116 // ************************************************************************* //