当前位置: 首页>>代码示例>>C++>>正文


C++ Box2D::getNy方法代码示例

本文整理汇总了C++中Box2D::getNy方法的典型用法代码示例。如果您正苦于以下问题:C++ Box2D::getNy方法的具体用法?C++ Box2D::getNy怎么用?C++ Box2D::getNy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Box2D的用法示例。


在下文中一共展示了Box2D::getNy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: saveFull

void saveFull( MultiBlock2D& multiBlock, FileName fName, IndexOrdering::OrderingT ordering )
{
    global::profiler().start("io");
    SparseBlockStructure2D blockStructure(multiBlock.getBoundingBox());
    Box2D bbox = multiBlock.getBoundingBox();
    if (ordering==IndexOrdering::forward) {
        plint nBlocks = std::min(bbox.getNx(), (plint)global::mpi().getSize());
        std::vector<std::pair<plint,plint> > ranges;
        util::linearRepartition(bbox.x0, bbox.x1, nBlocks, ranges);
        for (pluint iRange=0; iRange<ranges.size(); ++iRange) {
            blockStructure.addBlock (
                    Box2D( ranges[iRange].first, ranges[iRange].second,
                           bbox.y0, bbox.y1 ),
                    iRange );
        }
    }
    else if (ordering==IndexOrdering::backward) {
        plint nBlocks = std::min(bbox.getNy(), (plint)global::mpi().getSize());
        std::vector<std::pair<plint,plint> > ranges;
        util::linearRepartition(bbox.y0, bbox.y1, nBlocks, ranges);
        for (pluint iRange=0; iRange<ranges.size(); ++iRange) {
            blockStructure.addBlock (
                    Box2D( bbox.x0, bbox.x1, ranges[iRange].first, ranges[iRange].second ),
                    iRange );
        }
    }
    else {
        // Sparse ordering not defined.
        PLB_ASSERT( false );
    }
    plint envelopeWidth=1;
    MultiBlockManagement2D adjacentMultiBlockManagement (
            blockStructure, new OneToOneThreadAttribution, envelopeWidth );
    MultiBlock2D* multiAdjacentBlock = multiBlock.clone(adjacentMultiBlockManagement);
    
    std::vector<plint> offset;
    std::vector<plint> myBlockIds;
    std::vector<std::vector<char> > data;

    bool dynamicContent = false;
    dumpData(*multiAdjacentBlock, dynamicContent, offset, myBlockIds, data);
    if (ordering==IndexOrdering::backward && myBlockIds.size()==1) {
        PLB_ASSERT( data.size()==1 );
        Box2D domain;
        blockStructure.getBulk(myBlockIds[0], domain);
        plint sizeOfCell = multiAdjacentBlock->sizeOfCell();
        PLB_ASSERT( domain.nCells()*sizeOfCell == (plint)data[0].size() );
        transposeToBackward( sizeOfCell, domain, data[0] );
    }

    plint totalSize = offset[offset.size()-1];
    writeOneBlockXmlSpec(*multiAdjacentBlock, fName, totalSize, ordering);
    writeRawData(fName, myBlockIds, offset, data);
    delete multiAdjacentBlock;
    global::profiler().stop("io");
}
开发者ID:Longlonc,项目名称:palabos,代码行数:56,代码来源:multiBlockWriter2D.cpp

示例2: transposeToBackward

void transposeToBackward(plint sizeOfCell, Box2D const& domain, std::vector<char>& data) {
    plint nx = domain.getNx();
    plint ny = domain.getNy();
    std::vector<char> transp(data.size());

    for (plint iX=0; iX<nx; ++iX) {
        for (plint iY=0; iY<ny; ++iY) {
            plint iForward = sizeOfCell*(iY + ny*iX);
            plint iBackward = sizeOfCell*(iX + nx*iY);
            for (plint iByte=0; iByte<sizeOfCell; ++iByte) {
                transp[iBackward+iByte] = data[iForward+iByte];
            }
        }
    }
    transp.swap(data);
}
开发者ID:Longlonc,项目名称:palabos,代码行数:16,代码来源:multiBlockWriter2D.cpp

示例3:

plint Parallelizer2D::computeCost(std::vector<std::vector<Box2D> > const& originalBlocks, Box2D box){
    plint totalCost = 0;
    plint numLevels = originalBlocks.size();
    
    for (plint iLevel=(plint)originalBlocks.size()-1; iLevel>=0; --iLevel){
        // convert the box to the current level
        Box2D levelBox = global::getDefaultMultiScaleManager().scaleBox(box,iLevel-(numLevels-1));
        for (pluint iComp=0; iComp<originalBlocks[iLevel].size(); ++iComp){
            Box2D currentBox;
            if (intersect(originalBlocks[iLevel][iComp], levelBox, currentBox)){
                plint volume = currentBox.getNx()*currentBox.getNy();
                totalCost += (plint) util::twoToThePower(iLevel) * volume;
            }
        }
    }
    
    return totalCost;
}
开发者ID:Longlonc,项目名称:palabos,代码行数:18,代码来源:parallelizer2D.cpp


注:本文中的Box2D::getNy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。