本文整理汇总了C++中stk::mesh::BulkData::entity_comm方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::entity_comm方法的具体用法?C++ BulkData::entity_comm怎么用?C++ BulkData::entity_comm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::entity_comm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_entity_proc_map
void print_entity_proc_map( stk::diag::Writer & writer ,
const stk::mesh::BulkData & mesh )
{
const stk::mesh::MetaData & meta = mesh.mesh_meta_data();
const std::vector<stk::mesh::Entity*> & comm = mesh.entity_comm();
const std::vector<stk::mesh::Ghosting*> & ghost = mesh.ghostings();
size_t counter = 0 ;
for ( size_t ig = 0 ; ig < ghost.size() ; ++ig ) {
const stk::mesh::Ghosting & g = * ghost[ig] ;
writer << "P" << mesh.parallel_rank()
<< " " << g.name() << " Communication:" << std::endl ;
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = comm.begin() ; i != comm.end() ; ++i ) {
const stk::mesh::Entity & entity = **i ;
std::vector<unsigned> procs ;
stk::mesh::comm_procs( g , entity , procs );
if ( ! procs.empty() ) {
writer << "[" << counter << "] "
<< meta.entity_rank_name( entity.entity_rank() )
<< "[" << entity.identifier() << " " ;
if ( entity.owner_rank() != mesh.parallel_rank() ) {
writer << "not_" ;
}
writer << "owned ] {" ;
for ( size_t j = 0 ; j < procs.size() ; ++j ) {
writer << " " << procs[j] ;
}
writer << " }" << std::endl ;
}
}
}
}
示例2: communicate_field_data
void communicate_field_data( const stk::mesh::BulkData & mesh ,
const std::vector< const stk::mesh::FieldBase * > & fields )
{
if ( fields.empty() ) { return; }
const unsigned parallel_size = mesh.parallel_size();
const unsigned parallel_rank = mesh.parallel_rank();
// Sizing for send and receive
const unsigned zero = 0 ;
std::vector<unsigned> send_size( parallel_size , zero );
std::vector<unsigned> recv_size( parallel_size , zero );
std::vector<unsigned> procs ;
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
unsigned size = 0 ;
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
size += stk::mesh::field_data_size( f , e );
}
if ( size ) {
if ( e.owner_rank() == parallel_rank ) {
// owner sends
stk::mesh::comm_procs( e , procs );
for ( std::vector<unsigned>::iterator
ip = procs.begin() ; ip != procs.end() ; ++ip ) {
send_size[ *ip ] += size ;
}
}
else {
// non-owner receives
recv_size[ e.owner_rank() ] += size ;
}
}
}
// Allocate send and receive buffers:
stk::CommAll sparse ;
{
const unsigned * const s_size = & send_size[0] ;
const unsigned * const r_size = & recv_size[0] ;
sparse.allocate_buffers( mesh.parallel(), parallel_size / 4 , s_size, r_size);
}
// Send packing:
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
if ( e.owner_rank() == parallel_rank ) {
stk::mesh::comm_procs( e , procs );
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
const unsigned size = stk::mesh::field_data_size( f , e );
if ( size ) {
unsigned char * ptr =
reinterpret_cast<unsigned char *>(stk::mesh::field_data( f , e ));
for ( std::vector<unsigned>::iterator
ip = procs.begin() ; ip != procs.end() ; ++ip ) {
stk::CommBuffer & b = sparse.send_buffer( *ip );
b.pack<unsigned char>( ptr , size );
}
}
}
}
}
// Communicate:
sparse.communicate();
// Unpack for recv:
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
if ( e.owner_rank() != parallel_rank ) {
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
const unsigned size = stk::mesh::field_data_size( f , e );
//.........这里部分代码省略.........