diff --git a/src/OpenFOAM/containers/Lists/BinSum/BinSum.C b/src/OpenFOAM/containers/Lists/BinSum/BinSum.C index 6854597644a9a06d5fe8e86ea9812463b0eaa4d4..1e099613269d7f7582ace01f2f436e13b1c5aef3 100644 --- a/src/OpenFOAM/containers/Lists/BinSum/BinSum.C +++ b/src/OpenFOAM/containers/Lists/BinSum/BinSum.C @@ -44,6 +44,31 @@ Foam::BinSum<IndexType, List, CombineOp>::BinSum {} +template<class IndexType, class List, class CombineOp> +Foam::BinSum<IndexType, List, CombineOp>::BinSum +( + const IndexType min, + const IndexType max, + const IndexType delta, + const UList<IndexType>& indexVals, + const List& vals, + const CombineOp& cop +) +: + List(ceil((max-min)/delta), pTraits<typename List::value_type>::zero), + min_(min), + max_(max), + delta_(delta), + lowSum_(pTraits<typename List::value_type>::zero), + highSum_(pTraits<typename List::value_type>::zero) +{ + forAll(indexVals, i) + { + add(indexVals[i], vals[i], cop); + } +} + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // template<class IndexType, class List, class CombineOp> @@ -70,4 +95,19 @@ void Foam::BinSum<IndexType, List, CombineOp>::add } +template<class IndexType, class List, class CombineOp> +void Foam::BinSum<IndexType, List, CombineOp>::add +( + const UList<IndexType>& indexVals, + const List& vals, + const CombineOp& cop +) +{ + forAll(indexVals, i) + { + add(indexVals[i], vals[i], cop); + } +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/BinSum/BinSum.H b/src/OpenFOAM/containers/Lists/BinSum/BinSum.H index 6e0195a780fc850840ef881f7690d63706fea000..3cf09bc3a7752bb1479df39d5fbc2c97e358be77 100644 --- a/src/OpenFOAM/containers/Lists/BinSum/BinSum.H +++ b/src/OpenFOAM/containers/Lists/BinSum/BinSum.H @@ -84,6 +84,17 @@ public: const IndexType delta ); + //- Construct given min, max, delta and data + BinSum + ( + const IndexType min, + const IndexType max, + const IndexType delta, + const UList<IndexType>& indexVals, + const List& vals, + const CombineOp& cop = plusEqOp<typename List::value_type>() + ); + // Access @@ -111,6 +122,13 @@ public: const typename List::const_reference val, const CombineOp& cop = plusEqOp<typename List::value_type>() ); + + void add + ( + const UList<IndexType>& indexVals, + const List& vals, + const CombineOp& cop = plusEqOp<typename List::value_type>() + ); };