Exemplo n.º 1
0
void BulkData::require_good_rank_and_id(EntityRank ent_rank, EntityId ent_id) const
{
  const size_t rank_count = m_mesh_meta_data.entity_rank_count();
  const bool ok_id   = entity_id_valid(ent_id);
  const bool ok_rank = ent_rank < rank_count ;

  ThrowRequireMsg( ok_rank,
                   "Bad key rank: " << ent_rank << " for id " << ent_id );

  ThrowRequireMsg( ok_id, "Bad key id for key: " <<
      print_entity_key(m_mesh_meta_data, EntityKey(ent_rank, ent_id) ) );
}
Exemplo n.º 2
0
void test_shift_ring( RingFixture& ring, bool generate_aura=true )
{
  MetaData& meta = ring.m_meta_data;
  BulkData& bulk = ring.m_bulk_data;

  const int p_rank     = bulk.parallel_rank();
  const int p_size     = bulk.parallel_size();
  const unsigned nPerProc   = ring.m_num_element_per_proc ;
  const unsigned id_total   = nPerProc * p_size ;
  const unsigned id_begin   = nPerProc * p_rank ;
  const unsigned id_end     = nPerProc * ( p_rank + 1 );
  const unsigned nLocalNode = nPerProc + ( 1 < p_size ? 1 : 0 );
  const unsigned nLocalElement = nPerProc ;

  const unsigned p_send  = ( p_rank + 1 ) % p_size ;
  const unsigned id_send = id_end - 2 ;
  const unsigned id_recv = ( id_begin + id_total - 2 ) % id_total ;

  Selector select_used = meta.locally_owned_part() |
                         meta.globally_shared_part();

  std::vector<unsigned> local_count ;
  std::vector<EntityProc> change ;

  Entity send_element_1 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_send ] );
  Entity send_element_2 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_send + 1 ] );

  Entity send_node_1 = *(bulk.begin_nodes(send_element_1) + 1);
  Entity send_node_2 = *(bulk.begin_nodes(send_element_2) + 1);

  Entity recv_element_1 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_recv ] );
  Entity recv_element_2 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_recv + 1 ] );

  ASSERT_TRUE( bulk.is_valid(send_element_1) && p_rank == bulk.parallel_owner_rank(send_element_1) );
  ASSERT_TRUE( bulk.is_valid(send_element_2) && p_rank == bulk.parallel_owner_rank(send_element_2) );
  ASSERT_TRUE( !bulk.is_valid(recv_element_1) || p_rank != bulk.parallel_owner_rank(recv_element_1) );
  ASSERT_TRUE( !bulk.is_valid(recv_element_2) || p_rank != bulk.parallel_owner_rank(recv_element_2) );

  if ( p_rank == bulk.parallel_owner_rank(send_node_1) ) {
    EntityProc entry( send_node_1 , p_send );
    change.push_back( entry );
  }
  if ( p_rank == bulk.parallel_owner_rank(send_node_2) ) {
    EntityProc entry( send_node_2 , p_send );
    change.push_back( entry );
  }
  {
    EntityProc entry( send_element_1 , p_send );
    change.push_back( entry );
  }
  {
    EntityProc entry( send_element_2 , p_send );
    change.push_back( entry );
  }

  send_element_1 = Entity();
  send_element_2 = Entity();
  send_node_1 = Entity();
  send_node_2 = Entity();
  recv_element_1 = Entity();
  recv_element_2 = Entity();

  ASSERT_TRUE( bulk.modification_begin() );
  bulk.change_entity_owner( change );
  ASSERT_TRUE( stk::unit_test::modification_end_wrapper( bulk , generate_aura ) );

  send_element_1 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_send ] );
  send_element_2 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_send + 1 ] );
  recv_element_1 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_recv ] );
  recv_element_2 = bulk.get_entity( stk::topology::ELEMENT_RANK , ring.m_element_ids[ id_recv + 1 ] );

  ASSERT_TRUE( !bulk.is_valid(send_element_1) || p_rank != bulk.parallel_owner_rank(send_element_1) );
  ASSERT_TRUE( !bulk.is_valid(send_element_2) || p_rank != bulk.parallel_owner_rank(send_element_2) );
  ASSERT_TRUE( bulk.is_valid(recv_element_1) && p_rank == bulk.parallel_owner_rank(recv_element_1) );
  ASSERT_TRUE( bulk.is_valid(recv_element_2) && p_rank == bulk.parallel_owner_rank(recv_element_2) );

  stk::mesh::count_entities( select_used , bulk , local_count );
  ASSERT_EQ( local_count[stk::topology::NODE_RANK] , nLocalNode );
  ASSERT_EQ( local_count[stk::topology::ELEMENT_RANK] , nLocalElement );

  unsigned count_shared = 0 ;
  for ( stk::mesh::EntityCommListInfoVector::const_iterator
        i = bulk.comm_list().begin() ;
        i != bulk.comm_list().end() ; ++i )
  {
    if ( bulk.in_shared( i->key ) ) { ++count_shared ; }
  }
  ASSERT_EQ( count_shared , 2u );

  {
    const EntityKey node_recv = EntityKey(NODE_RANK , ring.m_node_ids[id_recv]);
    const EntityKey node_send = EntityKey(NODE_RANK , ring.m_node_ids[id_send]);

    ASSERT_EQ( bulk.entity_comm_map_shared(node_recv).size(), 1u );
    ASSERT_EQ( bulk.entity_comm_map_shared(node_send).size() , 1u );
  }
}
Exemplo n.º 3
0
 bool operator()(const EntityCommListInfo& comm) const
 {
   return comm.key == EntityKey();
 }
Exemplo n.º 4
0
 bool operator()( const EntityProc & lhs, const EntityKey & rhs) const
 {
   const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
   return lhs_key < rhs ;
 }
Exemplo n.º 5
0
 bool operator()( const EntityProc & lhs, const EntityProc & rhs) const
 {
   const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
   const EntityKey rhs_key = rhs.first ? rhs.first->key() : EntityKey() ;
   return lhs_key != rhs_key ? lhs_key < rhs_key : lhs.second < rhs.second ;
 }
Exemplo n.º 6
0
 bool operator()(const Entity* lhs, const EntityKey & rhs) const
 {
   const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ;
   return lhs_key < rhs ;
 }
Exemplo n.º 7
0
 bool operator()(const Entity& lhs, const Entity* rhs) const
 {
   const EntityKey rhs_key = rhs ? rhs->key() : EntityKey();
   return lhs.key() < rhs_key ;
 }