本文整理汇总了C++中CellList类的典型用法代码示例。如果您正苦于以下问题:C++ CellList类的具体用法?C++ CellList怎么用?C++ CellList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CellList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundary
/*
* Attempt to place an atom.
*/
bool Generator::attemptPlaceAtom(Atom& atom,
const DArray<double>& diameters,
CellList& cellList)
{
// Shift atom position to primary image within boundary
boundary().shift(atom.position());
Vector& pos = atom.position();
// Loop over neighbors, check distance to each.
// Return false immediately if any neighbor is too close.
CellList::NeighborArray neighbors;
cellList.getNeighbors(pos, neighbors);
double di = diameters[atom.typeId()];
double rSq, dj, dSq;
Atom* neighborPtr;
int n = neighbors.size();
for (int j = 0; j < n; ++j) {
neighborPtr = neighbors[j];
rSq = boundary().distanceSq(neighborPtr->position(), pos);
dj = diameters[neighborPtr->typeId()];
dSq = 0.5*(di + dj);
dSq *= dSq;
if (rSq < dSq) {
return false;
}
}
// If all neighbors are allowed, add atom to cellList
cellList.addAtom(atom);
return true;
}
示例2: addRandomDir
void MainWindow::addRandomDir(CellList& list)
{
Cell* cell = list.first();
Cell* ucell = uCell(cell);
Cell* rcell = rCell(cell);
Cell* dcell = dCell(cell);
Cell* lcell = lCell(cell);
typedef QMap<Cell::Dirs, Cell*> CellMap;
CellMap freecells;
if(ucell && ucell->dirs() == Cell::Free)
freecells[Cell::U] = ucell;
if(rcell && rcell->dirs() == Cell::Free)
freecells[Cell::R] = rcell;
if(dcell && dcell->dirs() == Cell::Free)
freecells[Cell::D] = dcell;
if(lcell && lcell->dirs() == Cell::Free)
freecells[Cell::L] = lcell;
if(freecells.isEmpty())
return;
CellMap::ConstIterator it = freecells.constBegin();
for(int i = rand() % freecells.count(); i > 0; --i)
++it;
cell->setDirs(Cell::Dirs(cell->dirs() | it.key()));
it.value()->setDirs(contrdirs[it.key()]);
list.append(it.value());
}
示例3: visitModules
void visitModules() {
// Loop on all modules left to process
// Hitting a cell adds to the appropriate level of this level-sorted list,
// so since cells originally exist top->bottom we process in top->bottom order too.
while (!m_todoModps.empty()) {
LevelModMap::iterator it = m_todoModps.begin();
AstNodeModule* nodep = it->second;
m_todoModps.erase(it);
if (!nodep->user5SetOnce()) { // Process once; note clone() must clear so we do it again
UINFO(4," MOD "<<nodep<<endl);
nodep->iterateChildren(*this);
// Note above iterate may add to m_todoModps
//
// Process interface cells, then non-interface which may ref an interface cell
for (int nonIf=0; nonIf<2; ++nonIf) {
for (CellList::iterator it=m_cellps.begin(); it!=m_cellps.end(); ++it) {
AstCell* nodep = *it;
if ((nonIf==0 && nodep->modp()->castIface())
|| (nonIf==1 && !nodep->modp()->castIface())) {
visitCell(nodep);
}
}
}
m_cellps.clear();
}
}
}
示例4: emit
// Return the list of cells crossed when moving from the start point
// to the end point.
CellList emit()
{
CellList cells;
int gridX = xcell(m_xstart);
int gridY = ycell(m_ystart);
int xlast = xcell(m_xend);
int ylast = ycell(m_yend);
cells.push_back( {gridX, gridY} );
while (gridX != xlast || gridY != ylast)
{
if (m_tMaxX < m_tMaxY)
{
m_tMaxX += m_tDeltaX;
gridX += m_stepX;
}
else
{
m_tMaxY += m_tDeltaY;
gridY += m_stepY;
}
cells.push_back( { gridX, gridY } );
}
return cells;
}
示例5: populate_cell_list_no_sym
/*! \brief populate the Cell-list with particles non symmetric case
*
* \tparam dim dimensionality of the space
* \tparam T type of the space
* \tparam CellList type of cell-list
*
* \param pos vector of positions
* \param cli Cell-list
* \param g_m marker (particle below this marker must be inside the domain, particles outside this marker must be outside the domain)
*
*/
template<unsigned int dim, typename T, typename CellList> void populate_cell_list_no_sym(openfpm::vector<Point<dim,T>> & pos, CellList & cli, size_t g_m)
{
cli.clear();
for (size_t i = 0; i < pos.size() ; i++)
{
cli.add(pos.get(i), i);
}
}
示例6: updateConnections
bool MainWindow::updateConnections()
{
bool newconnection[MasterBoardSize * MasterBoardSize];
for(int i = 0; i < MasterBoardSize * MasterBoardSize; i++)
newconnection[i] = false;
CellList list;
if(!root->isRotated())
{
newconnection[root->index()] = true;
list.append(root);
}
while(!list.isEmpty())
{
Cell* cell = list.first();
Cell* ucell = uCell(cell);
Cell* rcell = rCell(cell);
Cell* dcell = dCell(cell);
Cell* lcell = lCell(cell);
if((cell->dirs() & Cell::U) && ucell && (ucell->dirs() & Cell::D) &&
!newconnection[ucell->index()] && !ucell->isRotated())
{
newconnection[ucell->index()] = true;
list.append(ucell);
}
if((cell->dirs() & Cell::R) && rcell && (rcell->dirs() & Cell::L) &&
!newconnection[rcell->index()] && !rcell->isRotated())
{
newconnection[rcell->index()] = true;
list.append(rcell);
}
if((cell->dirs() & Cell::D) && dcell && (dcell->dirs() & Cell::U) &&
!newconnection[dcell->index()] && !dcell->isRotated())
{
newconnection[dcell->index()] = true;
list.append(dcell);
}
if((cell->dirs() & Cell::L) && lcell && (lcell->dirs() & Cell::R) &&
!newconnection[lcell->index()] && !lcell->isRotated())
{
newconnection[lcell->index()] = true;
list.append(lcell);
}
list.remove(list.begin());
}
bool isnewconnection = false;
for(int i = 0; i < MasterBoardSize * MasterBoardSize; i++)
{
if(!board[i]->isConnected() && newconnection[i])
isnewconnection = true;
board[i]->setConnected(newconnection[i]);
}
return isnewconnection;
}
示例7: cellList
SqlitePage::CellList SqlitePage::cellList() {
CellList cellList;
CellPointers cellPtrs = cellPointers();
for (CellPointers::iterator pos = cellPtrs.begin();
pos != cellPtrs.end(); ++pos) {
CellInfo cellInfo;
cellInfo.offset = *pos;
base::varint_t vint_playload = parseVarint(page_.begin() + *pos, page_.end());
base::varint_t vint_rowid = parseVarint(page_.begin() + *pos + vint_playload.length, page_.end());
cellInfo.length = vint_playload.value + vint_playload.length + vint_rowid.length;
cellList.push_back(cellInfo);
}
return cellList;
}
示例8: filterGraph
SplitState filterGraph(PartitionStack* ps, const GraphType& points,
const CellList& cells, int path_length)
{
// Would not normally go this low level, but it is important this is fast
memset(&(mset.front()), 0, mset.size() * sizeof(mset[0]));
edgesconsidered = 0;
MonoSet monoset(ps->cellCount());
debug_out(3, "EdgeGraph", "filtering: " << cells.size() << " cells out of " << ps->cellCount());
if(path_length == 1) {
for(int c : cells)
{
hashCellSimple(ps, points, monoset, c);
}
}
else
{
MonoSet hitvertices(ps->domainSize());
for(int c : cells)
{
hashRangeDeep(ps, points, monoset, hitvertices, ps->cellRange(c));
}
memset(&(msetspare.front()), 0, msetspare.size() * sizeof(msetspare[0]));
hashRangeDeep2(ps, points, monoset, hitvertices.getMembers());
for(int i : range1(mset.size())) {
mset[i] += msetspare[i] * 71;
}
}
debug_out(3, "EdgeGraph", "filtering " << mset << " : " << monoset);
return filterPartitionStackByFunctionWithCells(ps, SquareBrackToFunction(&mset), monoset);
}
示例9: getSystem
void VerletListTriple::rebuild(){
cutVerlet = cut + getSystem() -> getSkin();
cutsq = cutVerlet * cutVerlet;
vlTriples.clear();
// add particles to adress zone
CellList cl = getSystem()->storage->getRealCells();
LOG4ESPP_DEBUG(theLogger, "local cell list size = " << cl.size());
for (CellListAllTriplesIterator it(cl); it.isValid(); ++it) {
checkTriple(*it->first, *it->second, *it->third);
}
builds++;
LOG4ESPP_DEBUG(theLogger, "rebuilt VerletList (count=" << builds << "), cutsq = " << cutsq
<< " local size = " << vlTriples.size());
}
示例10: makeCellList
CellList* makeCellList(SsProject* proj)
{
// セルデータの出力と、全てセルデータを集約したリストを作る
CellList* cellList = new std::map<const SsCell*, int>();
int cellListIndex = 0;
for (size_t mapIndex = 0; mapIndex < proj->cellmapList.size(); mapIndex++)
{
const SsCellMap* cellMap = proj->cellmapList[mapIndex];
for (size_t cellIndex = 0; cellIndex < cellMap->cells.size(); cellIndex++)
{
const SsCell* cell = cellMap->cells[cellIndex];
cellList->insert(CellList::value_type(cell, cellListIndex++));
}
}
return cellList;
}
示例11:
void ForestTechniqueManager::Cell::bin()
{
// put trees in appropriate cells.
TreeList treesNotAssigned;
for(TreeList::iterator titr=_trees.begin();
titr!=_trees.end();
++titr)
{
Tree* tree = titr->get();
bool assigned = false;
for(CellList::iterator citr=_cells.begin();
citr!=_cells.end() && !assigned;
++citr)
{
if ((*citr)->contains(tree->_position))
{
(*citr)->addTree(tree);
assigned = true;
}
}
if (!assigned) treesNotAssigned.push_back(tree);
}
// put the unassigned trees back into the original local tree list.
_trees.swap(treesNotAssigned);
// prune empty cells.
CellList cellsNotEmpty;
for(CellList::iterator citr=_cells.begin();
citr!=_cells.end();
++citr)
{
if (!((*citr)->_trees.empty()))
{
cellsNotEmpty.push_back(*citr);
}
}
_cells.swap(cellsNotEmpty);
}
示例12:
/*
* Setup cell list for use.
*/
void
Generator::setupCellList(int atomCapacity,
Boundary& boundary,
const DArray<double>& diameters,
CellList& cellList)
{
// Set maximum atom id = atomCapacity - 1, and allocate
// arrays in cellList that are indexed by atom id
cellList.setAtomCapacity(atomCapacity);
// Compute maximum exclusion diameter
double maxDiameter = 0.0;
for (int iType = 0; iType < diameters.capacity(); iType++) {
if (diameters[iType] > maxDiameter) {
maxDiameter = diameters[iType];
}
}
// Setup grid of empty cells
cellList.setup(boundary, maxDiameter);
}
示例13: pageHeader
SqlitePage::BlockAreas SqlitePage::freeBlocks()
{
BlockAreas freeBlockAreaList;
CellList cellList = this->cellList(); // FIXIT
if (cellList.empty()) {
return freeBlockAreaList;
}
BlockArea firstBlock;
PageHeader header = pageHeader();
// FIXIT: 8 is not good
firstBlock.begin = header.numOfCells * 2 + 8;
firstBlock.end = cellList[cellList.size() - 1].offset - 1;
freeBlockAreaList.push_back(firstBlock);
if (cellList.size() > 1) {
// Cell List 是自底向上增长的,所以这里使用反向迭代器遍历
CellList::reverse_iterator rpos;
for (rpos = cellList.rbegin();
rpos != cellList.rend(); ++rpos) {
BlockArea block;
block.begin = rpos->offset;
block.end = rpos->offset + rpos->length;
CellList::reverse_iterator tmp_rpos = rpos + 1;
if (block.end < tmp_rpos->offset - kMinFreeBlockSize &&
block.end < page_.size() - kMinFreeBlockSize) {
freeBlockAreaList.push_back(block);
}
}
}
return freeBlockAreaList;
}
示例14: qFatal
CellList DistanceToAtom::buildCellList(const QVector<QVector3D> &points, float size, float cutoff, float &cellSize)
{
CellList cellList;
cellSize = cutoff;
int numCells = size / cutoff;
cellSize = size / numCells;
cellList.resize(numCells, vector<vector<vector<QVector3D> > >(numCells, vector<vector<QVector3D> >(numCells)));
for(int i=0; i<points.size(); i++) {
const QVector3D &p = points[i];
int ci = p[0] / cellSize;
int cj = p[1] / cellSize;
int ck = p[2] / cellSize;
if(ci==numCells) ci = numCells-1;
if(cj==numCells) cj = numCells-1;
if(ck==numCells) ck = numCells-1;
if(!checkRange<int>(ci, 0, numCells-1) || !checkRange<int>(cj, 0, numCells-1) || !checkRange<int>(ck, 0, numCells-1)) {
qFatal("DistanceToAtom::buildCellList() error: particle %d is out of cell list bounds.", i);
exit(1);
}
cellList[ci][cj][ck].push_back(p);
}
return cellList;
}
示例15: get_system
System get_system()
{
CellList list (1, RVec {0.0, 0.0, 0.0}, RVec {2.0, 2.0, 2.0});
list.add_atom(0.0, 0.0, 0.0);
list.add_atom(0.9, 1.0, 1.1);
list.add_atom(1.9, 1.9, 1.9);
// mean_vx: 3.0, mean_vy: 4.0, mean_vz: 5.0
const vector<double> velocities = {
0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0
};
list.vs = velocities;
const std::string title {"title of system"};
const RVec box_size {2.0, 2.0, 2.0};
System system {title, box_size};
system.cell_lists.push_back(list);
return system;
}