Beispiel #1
0
MultiDataDistribution2D createXSlicedDataDistribution2D (
        CellTypeField2D const& cellTypeField,
        int numBlocks,
        int envelopeWidth )
{
    int nX = cellTypeField.getNx();
    int nY = cellTypeField.getNy();
    
    std::vector<int> numActivePerSlice;
    int numActiveTotal = 0;
    for(int iX=0; iX<nX; iX++) {
        int numActiveCurrentSlice = 0;
        for (int iY=0; iY<nY; iY++) {
            if (cellTypeField.get(iX,iY) > 0) numActiveCurrentSlice++;
        }
        numActivePerSlice.push_back(numActiveCurrentSlice);
        numActiveTotal += numActiveCurrentSlice;
    }
    int numActivePerBlock = numActiveTotal / numBlocks;
    
    MultiDataDistribution2D dataDistribution(nX, nY);
    
    int iX=0;
    for (int iBlock=0; iBlock<numBlocks; ++iBlock) {
        int posX = iX;
        int numActiveCurrentBlock = 0;
        while (numActiveCurrentBlock<numActivePerBlock && iX<nX) {
            numActiveCurrentBlock += numActivePerSlice[iX];
            iX++;
        }
        dataDistribution.addBlock(posX, iX-1, 0, nY-1, envelopeWidth, iBlock);
    }
    return dataDistribution;
}
Beispiel #2
0
MultiDataDistribution3D createRegularDataDistribution (
        int nx, int ny, int nz, int numBlocksX, int numBlocksY, int numBlocksZ,
        int envelopeWidth )
{
    MultiDataDistribution3D dataDistribution(nx, ny, nz);
    int posX = 0;
    int iBlock = 0;
    for (int iBlockX=0; iBlockX<numBlocksX; ++iBlockX) {
        int lx = nx / numBlocksX;
        if (iBlockX < nx%numBlocksX) ++lx;
        int posY = 0;
        for (int iBlockY=0; iBlockY<numBlocksY; ++iBlockY) {
            int ly = ny / numBlocksY;
            if (iBlockY < ny%numBlocksY) ++ly;
            int posZ = 0;
            for (int iBlockZ=0; iBlockZ<numBlocksZ; ++iBlockZ) {
                int lz = nz / numBlocksZ;
                if (iBlockZ < nz%numBlocksZ) ++lz;
                dataDistribution.addBlock(posX, posX+lx-1, posY, posY+ly-1, posZ, posZ+lz-1,
                                          envelopeWidth, iBlock++);
                posZ += lz;
            }
            posY += ly;
        }
        posX += lx;
    }
    return dataDistribution;
}
Beispiel #3
0
MultiDataDistribution2D createRegularDataDistribution (
        int nx, int ny, int numBlocksX, int numBlocksY,
        int envelopeWidth )
{
    MultiDataDistribution2D dataDistribution(nx, ny);
    int posX = 0;
    int iBlock = 0;
    for (int iBlockX=0; iBlockX<numBlocksX; ++iBlockX) {
        int lx = nx / numBlocksX;
        if (iBlockX < nx%numBlocksX) ++lx;
        int posY = 0;
        for (int iBlockY=0; iBlockY<numBlocksY; ++iBlockY) {
             int ly = ny / numBlocksY;
             if (iBlockY < ny%numBlocksY) ++ly;
             dataDistribution.addBlock(posX, posX+lx-1, posY, posY+ly-1, envelopeWidth, iBlock);
             iBlock++;
             posY += ly;
        }
        posX += lx;
    }
    return dataDistribution;
}
Beispiel #4
0
MultiDataDistribution3D createZSlicedDataDistribution3D (
        CellTypeField3D const& cellTypeField,
        int numBlocks,
        int envelopeWidth )
{
    int nX = cellTypeField.getNx();
    int nY = cellTypeField.getNy();
    int nZ = cellTypeField.getNz();
    
    std::vector<int> numActivePerSlice;
    int numActiveTotal = 0;
    for(int iZ=0; iZ<nZ; iZ++) {
        int numActiveCurrentSlice = 0;
        for(int iX=0; iX<nX; iX++) {
            for (int iY=0; iY<nY; iY++) {
                if (cellTypeField.get(iX,iY,iZ) > 0) numActiveCurrentSlice++;
            }
        }
        numActivePerSlice.push_back(numActiveCurrentSlice);
        numActiveTotal += numActiveCurrentSlice;
    }
    int numActivePerBlock = numActiveTotal / numBlocks;    
    
    MultiDataDistribution3D dataDistribution(nX, nY, nZ);
    
    int iZ=0;
    for (int iBlock=0; iBlock<numBlocks; ++iBlock) {
        int posZ = iZ;
        int numActiveCurrentBlock = 0;
        while (numActiveCurrentBlock<numActivePerBlock && iZ<nZ) {
            numActiveCurrentBlock += numActivePerSlice[iZ];
            iZ++;
        }
        dataDistribution.addBlock( 0, nX-1, 0, nY-1, posZ, iZ-1, envelopeWidth, iBlock);
    }
    return dataDistribution;
}