コード例 #1
0
ファイル: CellIntervalTest.cpp プロジェクト: lssfau/walberla
inline void testCI( const CellInterval & ci )
{
   WALBERLA_CHECK( !ci.empty() );

   Cell minCorner = ci.min();
   Cell maxCorner = ci.max();

   WALBERLA_CHECK_EQUAL( minCorner.x(), ci.xMin() );
   WALBERLA_CHECK_EQUAL( minCorner.y(), ci.yMin() );
   WALBERLA_CHECK_EQUAL( minCorner.z(), ci.zMin() );
   WALBERLA_CHECK_EQUAL( maxCorner.x(), ci.xMax() );
   WALBERLA_CHECK_EQUAL( maxCorner.y(), ci.yMax() );
   WALBERLA_CHECK_EQUAL( maxCorner.z(), ci.zMax() );

   WALBERLA_CHECK_EQUAL( ci.positiveIndicesOnly(), minCorner.positiveIndicesOnly() && maxCorner.positiveIndicesOnly() );

   WALBERLA_CHECK_EQUAL( ci, ci );
   WALBERLA_CHECK( !( ci != ci ) );
   WALBERLA_CHECK( ci.overlaps(ci) );

   WALBERLA_CHECK_EQUAL( ci.xSize(), ci.xMax() - ci.xMin() + 1 );
   WALBERLA_CHECK_EQUAL( ci.ySize(), ci.yMax() - ci.yMin() + 1 );
   WALBERLA_CHECK_EQUAL( ci.zSize(), ci.zMax() - ci.zMin() + 1 );

   WALBERLA_CHECK_EQUAL( ci.numCells(), ci.xSize() * ci.ySize() * ci.zSize() );

   CellInterval ci_copied( ci );
   CellInterval ci_assigned;
   ci_assigned = ci;

   WALBERLA_CHECK_EQUAL( ci, ci_copied );
   WALBERLA_CHECK_EQUAL( ci, ci_assigned );

   std::stringstream ss;
   const int forty_two = 42;
   const int twenty_three = 23;
   ss << forty_two << ci << twenty_three;
   CellInterval rci;
   int i0, i1;
   ss >> i0 >> rci >> i1;
   WALBERLA_CHECK_EQUAL( ci, rci );
   WALBERLA_CHECK_EQUAL( i0, forty_two );
   WALBERLA_CHECK_EQUAL( i1, twenty_three );
   WALBERLA_CHECK( !ss.bad() );
   WALBERLA_CHECK( ss.eof() );
}
コード例 #2
0
ファイル: CellIntervalTest.cpp プロジェクト: lssfau/walberla
void testIterators( const CellInterval & ci )
{
   uint_t ctr = 0;
   auto it = ci.begin();
   for( cell_idx_t z = ci.zMin(); z <= ci.zMax(); ++z)
      for( cell_idx_t y = ci.yMin(); y <= ci.yMax(); ++y)
         for( cell_idx_t x = ci.xMin(); x <= ci.xMax(); ++x, ++it)
         {
            WALBERLA_CHECK( ci.contains( *it ) );

            WALBERLA_CHECK_EQUAL( x, it->x() );
            WALBERLA_CHECK_EQUAL( y, it->y() );
            WALBERLA_CHECK_EQUAL( z, it->z() );

            ++ctr;
         }

   WALBERLA_CHECK_EQUAL( it, ci.end() );
   WALBERLA_CHECK_EQUAL( ctr, ci.numCells() );
   WALBERLA_CHECK_EQUAL( std::distance( ci.begin(), ci.end() ), ci.numCells() );

   ctr = 0;
   auto it2 = ci.end();
   --it2;
   for( cell_idx_t z = ci.zMax(); z >= ci.zMin(); --z)
      for( cell_idx_t y = ci.yMax(); y >= ci.yMin(); --y)
         for( cell_idx_t x = ci.xMax(); x >= ci.xMin(); --x, --it2)
         {
            WALBERLA_CHECK( ci.contains( *it2 ) );

            WALBERLA_CHECK_EQUAL( x, it2->x() );
            WALBERLA_CHECK_EQUAL( y, it2->y() );
            WALBERLA_CHECK_EQUAL( z, it2->z() );

            ++ctr;
         }

         WALBERLA_CHECK_EQUAL( ctr, ci.numCells() );
         WALBERLA_CHECK_EQUAL( it2, --ci.begin() );
}
コード例 #3
0
ファイル: JacobiTest.cpp プロジェクト: Haider-BA/walberla
void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDataID & srcId, const BlockDataID & dstId )
{
   for( auto block = blocks->begin(); block != blocks->end(); ++block )
   {
      if( blocks->atDomainYMaxBorder( *block ) )
      {
         PdeField_T * src = block->getData< PdeField_T >( srcId );
         PdeField_T * dst = block->getData< PdeField_T >( dstId );
         CellInterval xyz = src->xyzSizeWithGhostLayer();
         xyz.yMin() = xyz.yMax();
         for( auto cell = xyz.begin(); cell != xyz.end(); ++cell )
         {
            const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell );
            src->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] );
            dst->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] );
         }
      }
   }
}