예제 #1
0
void BulkData::destroy_relation( Entity & e1 , Entity & e2 , unsigned kind )
{
  // When removing a relationship may need to
  // remove part membership and set field relation pointer to NULL

  PartSet del ;
  bool to_e1 = false ;

  std::vector<Relation>::iterator i ;

  for ( i = e1.m_relation.end() ; i != e1.m_relation.begin() ; ) {
    --i ;
    if ( i->entity() == & e2 && i->kind() == kind ) {
      if ( i->forward() ) {
        clear_field_relations( e1 , i->entity_type() ,
                                    i->identifier() ,
                                    i->kind() );
        deduce_part_relations( e1, e2, i->identifier(), i->kind(), del );
      }
      i = e1.m_relation.erase( i );
    }
  }

  for ( i = e2.m_relation.end() ; i != e2.m_relation.begin() ; ) {
    --i ;
    if ( i->entity() == & e1 && i->kind() == kind ) {
      if ( i->forward() ) {
        clear_field_relations( e2 , i->entity_type() ,
                                    i->identifier() ,
                                    i->kind() );
        deduce_part_relations( e2, e1, i->identifier(), i->kind(), del );
        to_e1 = true ;
      }
      i = e2.m_relation.erase( i );
    }
  }

  Entity & e_to = to_e1 ? e1 : e2 ;

  {
    PartSet keep ;

    deduce_part_relations( e_to , keep );

    if ( ! keep.empty() ) {
      // Eliminate the 'keep' from the accumulated 'del'

      for ( PartSet::iterator j = del.end() ; j != del.begin() ; ) {
        --j ;
        if ( contain( keep , **j ) ) { j = del.erase( j ); }
      }
    }
  }

  if ( ! del.empty() ) {
    PartSet add ;
    internal_change_entity_parts( e_to , add , del );
  }
}
예제 #2
0
void BulkData::destroy_relation( Entity & e_from , Entity & e_to )
{
  static const char method[]= "stk::mesh::BulkData::destroy_relation" ;

  assert_ok_to_modify( method );

  assert_valid_relation( method , *this , e_from , e_to );


  //------------------------------
  // When removing a relationship may need to
  // remove part membership and set field relation pointer to NULL

  PartVector del , keep ;

  for ( PairIterRelation i = e_to.relations() ; i.first != i.second ; ++(i.first) ) {

    if ( !( i.first->entity() == & e_from )  &&
        ( e_to.entity_rank() < i.first->entity_rank() ) )
    {
      induced_part_membership( * i.first->entity(), del, e_to.entity_rank(),
                               i.first->identifier(), keep );
    }
  }

  for ( PairIterRelation i = e_from.relations() ; i.first != i.second ; ++(i.first) ) {
    if ( i.first->entity() == & e_to ) {

      induced_part_membership( e_from, keep, e_to.entity_rank(),
                               i.first->identifier(), del );

      clear_field_relations( e_from , e_to.entity_rank() ,
                             i.first->identifier() );
    }
  }

  //------------------------------
  // 'keep' contains the parts deduced from kept relations
  // 'del'  contains the parts deduced from deleted relations
  //        that are not in 'keep'
  // Only remove these part memberships the entity is not shared.
  // If the entity is shared then wait until modificaton_end_synchronize.
  //------------------------------

  if ( ! del.empty() && (parallel_size() < 2 || e_to.sharing().empty()) ) {
    PartVector add ;
    internal_change_entity_parts( e_to , add , del );
  }

  //delete relations from the entities
  m_entity_repo.destroy_relation( e_from, e_to);

}