本文整理汇总了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;
}
示例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 */
}