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()
        )
    );
}
Foam::tmp<Foam::labelgpuField> Foam::regionCoupledFvPatch::internalFieldTransfer
(
    const Pstream::commsTypes commsType,
    const labelgpuList& iF
) const
{
    if (neighbFvPatch().sameRegion())
    {
        return neighbFvPatch().patchInternalField(iF);
    }
    else
    {
        /*
        WarningIn
        (
            "regionCoupledFvPatch::internalFieldTransfer"
            "( const Pstream::commsTypes, const labelUList&)"
            " the internal field can not be transfered "
            " as the neighbFvPatch are in different meshes "
        );
        */
        return tmp<labelgpuField>(new labelgpuField(iF.size(), 0));

    }
}
Exemplo n.º 3
0
void Foam::GAMGAgglomeration::createSort
(
    const labelgpuList& list, 
    labelgpuList& sort
)
{
    sort.setSize(list.size());

    thrust::copy
    (
        thrust::make_counting_iterator(0),
        thrust::make_counting_iterator(0)+list.size(),
        sort.begin()
    );

    labelgpuList listTmp(list);
    thrust::stable_sort_by_key
    (
        listTmp.begin(),
        listTmp.end(),
        sort.begin()
    );
}
Foam::tmp<Foam::labelgpuField> Foam::regionCoupledWallFvPatch::
internalFieldTransfer
(
    const Pstream::commsTypes commsType,
    const labelgpuList& iF
) const
{
    if (neighbFvPatch().sameRegion())
    {
        return neighbFvPatch().patchInternalField(iF);
    }
    else
    {
        return tmp<labelgpuField>(new labelgpuField(iF.size(), 0));
    }
}
Exemplo n.º 5
0
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());
}