void Foam::lduAddressing::calcLosort() const
{
    if (losortPtr_)
    {
        FatalErrorIn("lduAddressing::calcLosort() const")
            << "losort already calculated"
            << abort(FatalError);
    }

    // Scan the neighbour list to find out how many times the cell
    // appears as a neighbour of the face. Done this way to avoid guessing
    // and resizing list
    labelList nNbrOfFace(size(), 0);

    const labelUList& nbr = upperAddr();

    forAll(nbr, nbrI)
    {
        nNbrOfFace[nbr[nbrI]]++;
    }

    // Create temporary neighbour addressing
    labelListList cellNbrFaces(size());

    forAll(cellNbrFaces, cellI)
    {
        cellNbrFaces[cellI].setSize(nNbrOfFace[cellI]);
    }
示例#2
0
void Foam::lduAddressing::calcLosort() const
{
    if (losortPtr_)
    {
        FatalErrorIn("lduAddressing::calcLosort() const")
            << "losort already calculated"
            << abort(FatalError);
    }

    const labelgpuList& nbr = upperAddr();
    losortPtr_ = new labelgpuList(nbr.size());

    labelgpuList& lst = *losortPtr_;

    labelgpuList nbrTmp(nbr);

    thrust::counting_iterator<label> first(0);
    thrust::copy
    (
        first,
        first+nbr.size(),
        lst.begin()
    );

    thrust::stable_sort_by_key
    (
        nbrTmp.begin(),
        nbrTmp.end(),
        lst.begin()
    );                
}
示例#3
0
Foam::Tuple2<Foam::label, Foam::scalar> Foam::lduAddressing::band() const
{
    const labelgpuList& owner = lowerAddr();
    const labelgpuList& neighbour = upperAddr();

    labelgpuList cellBandwidth(size(), 0);
    labelgpuList diffs(neighbour.size(),0);

    thrust::transform
    (
        neighbour.begin(),
        neighbour.end(),
        owner.begin(),
        diffs.begin(),
        subtractOperatorFunctor<label,label,label>()
    );

    thrust::transform
    (
        diffs.begin(),
        diffs.end(),
        thrust::make_permutation_iterator
        (
            cellBandwidth.begin(),
            neighbour.begin()
        ),
        thrust::make_permutation_iterator
        (
            cellBandwidth.begin(),
            neighbour.begin()
        ),
        maxBinaryFunctionFunctor<label,label,label>()
    );

    label bandwidth = max(cellBandwidth);

    // Do not use field algebra because of conversion label to scalar
    scalar profile = 
        thrust::reduce
        (
            cellBandwidth.begin(),
            cellBandwidth.end()
        );

    return Tuple2<label, scalar>(bandwidth, profile);
}
示例#4
0
void Foam::lduAddressing::calcLosortStart() const
{
    if (losortStartPtr_)
    {
        FatalErrorIn("lduAddressing::calcLosortStart() const")
            << "losort start already calculated"
            << abort(FatalError);
    }

    const labelgpuList& nbr = upperAddr();

    const labelgpuList& lsrt = losortAddr();

    losortStartPtr_ = new labelgpuList(size() + 1, nbr.size());

    labelgpuList& lsrtStart = *losortStartPtr_;

    labelgpuList ones(nbr.size()+size(),1);
    labelgpuList tmpCell(size());
    labelgpuList tmpSum(size());

    labelgpuList nbrSort(nbr.size()+size());

    thrust::copy
    (
        thrust::make_permutation_iterator
        (
            nbr.begin(),
            lsrt.begin()
        ),
        thrust::make_permutation_iterator
        (
            nbr.begin(),
            lsrt.end()
        ),
        nbrSort.begin()
    );
                 
    thrust::copy
    (
        thrust::make_counting_iterator(0),
        thrust::make_counting_iterator(0)+size(),
        nbrSort.begin()+nbr.size()
    );
                 
    thrust::fill
    (
        ones.begin()+nbr.size(),
        ones.end(),
        0
    );
                 

    thrust::stable_sort_by_key
    (
        nbrSort.begin(),
        nbrSort.end(),
        ones.begin()
    );     

    thrust::reduce_by_key
    (
        nbrSort.begin(),
        nbrSort.end(),
        ones.begin(),
        tmpCell.begin(),
        tmpSum.begin()
    );

    thrust::exclusive_scan
    (
        tmpSum.begin(),
        tmpSum.begin()+size(),
        lsrtStart.begin()
    );
}