SparseBlockStructure3D createZSlicedDistribution3D (
        CellTypeField3D const& cellTypeField,
        plint numBlocks )
{
    plint nX = cellTypeField.getNx();
    plint nY = cellTypeField.getNy();
    plint nZ = cellTypeField.getNz();
    
    std::vector<plint> numActivePerSlice;
    plint numActiveTotal = 0;
    for(plint iZ=0; iZ<nZ; iZ++) {
        plint numActiveCurrentSlice = 0;
        for(plint iX=0; iX<nX; iX++) {
            for (plint iY=0; iY<nY; iY++) {
                if (cellTypeField.get(iX,iY,iZ) > 0) numActiveCurrentSlice++;
            }
        }
        numActivePerSlice.push_back(numActiveCurrentSlice);
        numActiveTotal += numActiveCurrentSlice;
    }
    plint numActivePerBlock = numActiveTotal / numBlocks;    
    
    SparseBlockStructure3D dataGeometry(nX, nY, nZ);
    
    plint iZ=0;
    for (plint iBlock=0; iBlock<numBlocks; ++iBlock) {
        plint posZ = iZ;
        plint numActiveCurrentBlock = 0;
        while (numActiveCurrentBlock<numActivePerBlock && iZ<nZ) {
            numActiveCurrentBlock += numActivePerSlice[iZ];
            iZ++;
        }
        dataGeometry.addBlock (
                Box3D(0, nX-1, 0, nY-1, posZ, iZ-1),
                dataGeometry.nextIncrementalId() );
    }
    return dataGeometry;
}
Exemple #2
0
MultiDataDistribution3D createXSlicedDataDistribution3D (
        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 iX=0; iX<nX; iX++) {
        int numActiveCurrentSlice = 0;
        for (int iY=0; iY<nY; iY++) {
            for (int iZ=0; iZ<nZ; iZ++) {
                if (cellTypeField.get(iX,iY,iZ) > 0) numActiveCurrentSlice++;
            }
        }
        numActivePerSlice.push_back(numActiveCurrentSlice);
        numActiveTotal += numActiveCurrentSlice;
    }
    int numActivePerBlock = numActiveTotal / numBlocks;
    
    MultiDataDistribution3D dataDistribution(nX, nY, nZ);
    
    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, 0, nZ-1, envelopeWidth, iBlock);
    }
    return dataDistribution;
}