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


C++ DB::findParticleIndx方法代码示例

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


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

示例1: main

int main() {
  const char * Pname = "Ar";

  typedef chimp::RuntimeDB<> DB;
  DB db;
  db.addParticleType(Pname);

  std::cout << "Accessed with string index, each property individually:\n";
  std::cout << "\tp.name:  "   << db[Pname].name::value << std::endl;
  std::cout << "\tp.mass:  "   << db[Pname].mass::value << std::endl;
  std::cout << "\tp.charge:  " << db[Pname].charge::value << std::endl;

  int i = db.findParticleIndx(Pname);
  std::cout << "Accessed with integer index, each property individually:\n";
  std::cout << "\tp.name:  "   << db[i].name::value << std::endl;
  std::cout << "\tp.mass:  "   << db[i].mass::value << std::endl;
  std::cout << "\tp.charge:  " << db[i].charge::value << std::endl;

  std::cout << "Accessed with const reference:\n";
  const DB::Properties & p = db[Pname];
  std::cout << "Printing all properties by using stream insertion:\n";
  std::cout << "\t{" << p << '}' << std::endl;

  return 0;
}
开发者ID:hpcdev,项目名称:chimp,代码行数:25,代码来源:getProperties.cpp

示例2: check_table

   void check_table( const DB & db, unsigned int cross_species_num ) {
     int i87Rb = db.findParticleIndx("87Rb");
     int i85Rb = db.findParticleIndx("85Rb");
 
     {/* 87Rb * 87Rb */
       const typename DB::Set & set = db(i87Rb,i87Rb);
 
       BOOST_CHECK_EQUAL( set.rhs.size(), 1u );
 
       typedef typename DB::Set::Equation::list::const_iterator EIter;
 
       {
         std::ostringstream estr;
         for ( EIter i = set.rhs.begin(); i != set.rhs.end(); ++i ) {
           i->print( estr, db ) << '\n';
           BOOST_CHECK_EQUAL( i->interaction->getLabel(), "elastic" );
         }
 
         BOOST_CHECK_EQUAL( estr.str(), "2 87Rb  -->  2 87Rb\n" );
       }
     }/* 87Rb * 87Rb */
 
     {/* 85Rb * 85Rb */
       const typename DB::Set & set = db(i85Rb,i85Rb);
 
       BOOST_CHECK_EQUAL( set.rhs.size(), 1u );
 
       typedef typename DB::Set::Equation::list::const_iterator EIter;
 
       {
         std::ostringstream estr;
         for ( EIter i = set.rhs.begin(); i != set.rhs.end(); ++i ) {
           i->print( estr, db ) << '\n';
           BOOST_CHECK_EQUAL( i->interaction->getLabel(), "elastic" );
         }
 
         BOOST_CHECK_EQUAL( estr.str(), "2 85Rb  -->  2 85Rb\n" );
       }
     }/* 85Rb * 85Rb */
 
     {/* 87Rb * 85Rb */
       const typename DB::Set & set = db(i85Rb,i87Rb);
 
       // These if-else statements are just to make error reports easier to
       // read
       if ( cross_species_num == 0u )
         BOOST_CHECK_EQUAL( set.rhs.size(), 0u );
       else if ( cross_species_num == 1u )
         BOOST_CHECK_EQUAL( set.rhs.size(), 1u );
       else
         BOOST_CHECK_EQUAL( set.rhs.size(), cross_species_num );
     }/* 85Rb * 85Rb */
   }
开发者ID:hpcdev,项目名称:chimp,代码行数:53,代码来源:RuntimeDB.cpp


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