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


C++ Site::isLegalToSpawn方法代码示例

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


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

示例1: initialize_diamondSquareSurface


//.........这里部分代码省略.........
            Top(i, j)    = std::round((_Top.at(i).at(j) - topMin)/topSpan*maxSpan);


        }
    }

    _Bottom.clear();
    _Top.clear();


    //calculate how many percent of the total z = z' surface is populated

    vec occupancyBottom(maxSpan, fill::zeros);
    vec occupancyTop   (maxSpan, fill::zeros);

    for (uint i = 0; i < solver->NX(); ++i)
    {
        for (uint j = 0; j < solver->NY(); ++j)
        {

            for (uint z = 0; z < Bottom(i, j); ++z)
            {
                occupancyBottom(z)++;
            }

            for (uint z = 0; z < Top(i, j); ++z)
            {
                occupancyTop(z)++;
            }

        }
    }

    uint area = solver->NX()*solver->NY();

    occupancyBottom /= area;
    occupancyTop    /= area;


    //Going from top to bottom, ending when the population is lower than
    //the given treshold.

    uint bottomCutoff = 0;
    while (occupancyTop(bottomCutoff) > occupancyTreshold)
    {
        bottomCutoff++;
    }

    uint topCutoff = 0;
    while (occupancyTop(topCutoff) > occupancyTreshold)
    {
        topCutoff++;
    }


    //calculate the new box height

    uint newNZ = 2*maxSpan - (topCutoff + bottomCutoff) + clearing;

    solver->setBoxSize({NX, NY, newNZ});


    Site * currentSite;

    for (uint x = 0; x < solver->NX(); ++x)
    {
        for (uint y = 0; y < solver->NY(); ++y)
        {

            uint bottomEnd = Bottom(x, y);
            uint topEnd    = Top(x, y);

            //Points below the cutoff are filtered out. Avoiding uints going to negative values (overflow)
            uint bottomSurface = (bottomEnd > bottomCutoff) ? (     (bottomEnd - bottomCutoff)) : 0;
            uint topSurface    =    (topEnd > topCutoff)    ? (newNZ - (topEnd - topCutoff)) : newNZ;

            for (uint z = 1; z < newNZ - 1; ++z)
            {
                currentSite = solver->getSite(x, y, z);

                //Fill in crystals below the bottom and above the top surface
                if ((z < bottomSurface) || (z >= topSurface))
                {
                    currentSite->spawnAsCrystal();
                }

                //Fill the cavity with solution
                else if (currentSite->isLegalToSpawn())
                {
                    if (KMC_RNG_UNIFORM() < solver->targetSaturation())
                    {
                        currentSite->activate();
                    }
                }

            }
        }

    }
}
开发者ID:joebradly,项目名称:kMC,代码行数:101,代码来源:diamondSquareSurfacemain.cpp


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