void Foam::GAMGAgglomeration::restrictField ( gpuField<Type>& cf, const gpuField<Type>& ff, const labelgpuList& sort, const labelgpuList& target, const labelgpuList& targetStart ) const { cf = pTraits<Type>::zero; thrust::transform ( targetStart.begin(), targetStart.end()-1, targetStart.begin()+1, thrust::make_permutation_iterator ( cf.begin(), target.begin() ), GAMGAgglomerationRestrictFunctor<Type> ( ff.data(), sort.data() ) ); }
void Foam::GAMGAgglomeration::createTarget ( const labelgpuList& list, const labelgpuList& sort, labelgpuList& target, labelgpuList& targetStart ) { labelgpuList ones(list.size(),1); labelgpuList tmpTarget(list.size()); labelgpuList tmpSum(list.size()); labelgpuList listSort(list.size()); thrust::copy ( thrust::make_permutation_iterator ( list.begin(), sort.begin() ), thrust::make_permutation_iterator ( list.begin(), sort.end() ), listSort.begin() ); target = listSort; label targetSize = thrust::unique ( target.begin(), target.end() ) - target.begin(); target.setSize(targetSize); targetStart.setSize(list.size()); thrust::reduce_by_key ( listSort.begin(), listSort.end(), ones.begin(), tmpTarget.begin(), tmpSum.begin() ); thrust::exclusive_scan ( tmpSum.begin(), tmpSum.end(), targetStart.begin() ); targetStart.setSize(targetSize+1); targetStart.set(targetSize,list.size()); }