本文整理汇总了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();
}
}
}
}
}
}