Exemple #1
0
Part * PartRepository::declare_part( const std::string & arg_name , EntityRank arg_rank, bool force_no_induce )
{
  Part * p = get_part_by_name( arg_name );

  if ( p == NULL ) {
    p = declare_part_impl( arg_name, arg_rank, force_no_induce );
  }
  else {
    p->m_partImpl.set_primary_entity_rank(arg_rank);
    p->m_partImpl.set_force_no_induce(force_no_induce);
  }

  return p;
}
Exemple #2
0
Part * PartRepository::declare_part( const std::string & arg_name , EntityRank arg_rank )
{
  Trace_("stk_classic::mesh::impl::PartRepository::declare_part");

  const PartVector & all_parts = get_all_parts();
  Part * p = find( all_parts, arg_name );

  if ( p == NULL ) {
    p = declare_part_impl( arg_name, arg_rank );
  }
  else {
    p->m_partImpl.set_primary_entity_rank(arg_rank);
  }

  return p;
}
Part * PartRepository::declare_part( const std::string & arg_name , EntityRank arg_rank )
{
    const PartVector & all_parts = m_universal_part->subsets();
    Part * p = find( all_parts, arg_name );

    if ( p == NULL ) {
        p = declare_part_impl( arg_name, arg_rank );
    }

    if ( p->primary_entity_rank() != arg_rank ) {
        std::ostringstream msg;
        msg << "stk::mesh::Part[ " << arg_name ;
        msg << ",rank(" << p->primary_entity_rank() << ")" ;
        msg << "] : FAILED to declare part; " ;
        msg << "Part of name '" << arg_name ;
        msg << "' of rank " << p->primary_entity_rank() ;
        msg << " already exists";
        msg << " User cannot redeclare " << arg_name ;
        msg << " with different rank, " << arg_rank ;
        throw std::runtime_error ( msg.str() );
    }

    return p;
}
Exemple #4
0
Part * PartRepository::declare_part( const PartVector & part_intersect )
{
  static const char method[] = "stk_classic::mesh::impl::PartRepository::declare_part" ;
  Trace_(method);

  PartVector pset_clean ;

  for ( PartVector::const_iterator
        i = part_intersect.begin() ; i != part_intersect.end() ; ++i ) {
    Part * const p = *i ;
    assert_superset( *m_universal_part, *p , method );

    // If 'p' is a superset of another member
    // then it is redundant in this intersection.
    // Only keep non-redundant intersections.

    PartVector::const_iterator j = part_intersect.begin();
    for ( ; j != part_intersect.end() &&
            ! contain( (*j)->supersets() , *p ) ; ++j );
    if ( j == part_intersect.end() ) {
      pset_clean.push_back( p );
    }
  }

  // Sort and unique the intersection
  order( pset_clean );

  Part * p = NULL ;
  if ( 1 == pset_clean.size() ) {
    // Only one remaining part, it is the subset.
    p = pset_clean[0] ;
  }
  else {
    const char separator[] = "^" ;
    // Generate a name and rank reflecting the intersection.
    // Rank is the minimum rank of the intersection members.

    std::string p_name ;
    EntityRank p_rank = InvalidEntityRank;

    p_name.assign("{");
    for ( PartVector::iterator
          i = pset_clean.begin() ; i != pset_clean.end() ; ++i ) {
      if ( i != pset_clean.begin() ) { p_name.append( separator ); }
      p_name.append( (*i)->name() );
      if ( (*i)->primary_entity_rank() < p_rank ) {
        p_rank = (*i)->primary_entity_rank();
      }
    }
    p_name.append("}");

    const PartVector & all_parts = get_all_parts();
    p = find( all_parts, p_name );
    if ( p == NULL ) {
      // Create the part:

      p = declare_part_impl( p_name , p_rank );

      // Define the part to be an intersection of the given parts:

      p->m_partImpl.set_intersection_of( pset_clean );

      for ( PartVector::iterator
            i = pset_clean.begin() ; i != pset_clean.end() ; ++i ) {
        declare_subset( **i, *p );
      }
    }
    else {
      // This error is "inconceivable" and is
      // only possible by heroic malicious abuse.
      ThrowInvalidArgMsgIf( pset_clean != p->intersection_of(),
                            p_name << " FAILED FROM MALICIOUS ABUSE" );
    }
  }

  return p ;
}