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


C++ VertexEnumerator::overlaps方法代码示例

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


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

示例1: defined

int particles::pidt::mappings::MoveParticles::moveParticlesOfOneVertexWithinCell(
  int                                   vertexIndex,
  const peano::grid::VertexEnumerator&  fineGridVerticesEnumerator
) {
  #if defined(SharedTBB) && !defined(__WIN32__)
  tbb::atomic<int>     numberOfParticlesMoved;
  #elif SharedOMP
    #error not implemented yet
  #else
  int    numberOfParticlesMoved;
  #endif

  numberOfParticlesMoved = 0;

  ParticleHeap::HeapEntries& sourceVertexParticles = ParticleHeap::getInstance().getData(vertexIndex);
  pfor(i,0,static_cast<int>(sourceVertexParticles.size()),200)
    particles::pidt::records::Particle& currentParticle = sourceVertexParticles.at(i);

    const bool particleHasNotBeenMovedYet =
      currentParticle.getMovedParticle() != particles::pidt::records::Particle::Moved;

    const bool particleIsContainedInCell = fineGridVerticesEnumerator.overlaps(
      currentParticle._persistentRecords._x,
      0.0
    );

    if (particleHasNotBeenMovedYet && particleIsContainedInCell) {
      currentParticle._persistentRecords._x             += (_state.getTimeStepSize() * currentParticle._persistentRecords._v);
      currentParticle.setMovedParticle( particles::pidt::records::Particle::Moved );

      reflectParticle(currentParticle);

      numberOfParticlesMoved++;
    }
  endpfor

  return numberOfParticlesMoved;
}
开发者ID:POWER-Morzh,项目名称:particles2,代码行数:38,代码来源:MoveParticles.cpp

示例2: while

int particles::pidt::mappings::MoveParticles::moveParticlesOfOneVertexWithinCellIfTheyAreSorted(
  int                                   vertexIndex,
  const peano::grid::VertexEnumerator&  fineGridVerticesEnumerator
) {
  ParticleHeap::HeapEntries& sourceVertexParticles = ParticleHeap::getInstance().getData(vertexIndex);

  int numberOfParticlesMoved = 0;

  int biggestIndexPointingToUnmovedParticle  = static_cast<int>(sourceVertexParticles.size())-1;
  int smallestIndexPointingToUnmovedParticle = 0;

  while (
    biggestIndexPointingToUnmovedParticle>=0 &&
    sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).getMovedParticle() == particles::pidt::records::Particle::Moved
  ) {
    biggestIndexPointingToUnmovedParticle--;
  }

  #ifdef Asserts
  for (int i=0; i<biggestIndexPointingToUnmovedParticle; i++) {
    assertion3(
      sourceVertexParticles.at(i).getMovedParticle() != particles::pidt::records::Particle::Moved,
      i,
      biggestIndexPointingToUnmovedParticle,
      sourceVertexParticles.at(i).toString()
    );
  }
  #endif

  logDebug(
    "moveParticlesOfOneVertexWithinCellIfTheyAreSorted(...)",
    "moved index from " << static_cast<int>(sourceVertexParticles.size())-1 <<
    " to " << biggestIndexPointingToUnmovedParticle <<
    ": " << sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).toString() <<
    " with first element " << sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle).toString()
  );

  // has to be equals as the two might just have been exchanged
  while (biggestIndexPointingToUnmovedParticle >= smallestIndexPointingToUnmovedParticle) {
    particles::pidt::records::Particle& currentParticle = sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle);

    assertion( biggestIndexPointingToUnmovedParticle>=0 );
    assertion( smallestIndexPointingToUnmovedParticle>=0 );
    assertion( biggestIndexPointingToUnmovedParticle<static_cast<int>(sourceVertexParticles.size()) );
    assertion( smallestIndexPointingToUnmovedParticle<static_cast<int>(sourceVertexParticles.size()) );

    assertion4(
      currentParticle.getMovedParticle() != particles::pidt::records::Particle::Moved ||
      (smallestIndexPointingToUnmovedParticle==biggestIndexPointingToUnmovedParticle),
      smallestIndexPointingToUnmovedParticle,
      biggestIndexPointingToUnmovedParticle,
      sourceVertexParticles.at(smallestIndexPointingToUnmovedParticle).toString(),
      sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle).toString()
    );

    const bool particleIsContainedInCell = fineGridVerticesEnumerator.overlaps(
      currentParticle._persistentRecords._x,
      0.0
    );

    if (particleIsContainedInCell) {
      currentParticle._persistentRecords._x             += (_state.getTimeStepSize() * currentParticle._persistentRecords._v);
      currentParticle.setMovedParticle( particles::pidt::records::Particle::Moved );
      reflectParticle(currentParticle);

      if (smallestIndexPointingToUnmovedParticle!=biggestIndexPointingToUnmovedParticle) {
        particles::pidt::records::Particle tmp                        =  currentParticle;
        currentParticle                                               =  sourceVertexParticles.at(biggestIndexPointingToUnmovedParticle);
        sourceVertexParticles[biggestIndexPointingToUnmovedParticle]  =  tmp;
      }

      numberOfParticlesMoved++;
      biggestIndexPointingToUnmovedParticle--;
    }
    else {
      smallestIndexPointingToUnmovedParticle++;
    }
  }

  return numberOfParticlesMoved;
}
开发者ID:POWER-Morzh,项目名称:particles2,代码行数:81,代码来源:MoveParticles.cpp


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