|
Sierra Toolkit Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 00010 #include <sstream> 00011 #include <stdexcept> 00012 00013 #include <stk_util/util/StaticAssert.hpp> 00014 #include <stk_mesh/base/EntityKey.hpp> 00015 00016 namespace stk { 00017 namespace mesh { 00018 00019 EntityKey::EntityKey( unsigned entity_rank , 00020 EntityKey::raw_key_type entity_id ) 00021 : key( ( raw_key_type(entity_rank) << id_digits ) | entity_id ) 00022 { 00023 enum { OK = StaticAssert< sizeof(EntityKey) == 00024 sizeof(EntityKey::raw_key_type) >::OK }; 00025 00026 const bool error_rank = ( rank() != entity_rank ) ; 00027 const bool error_id = ( id() != entity_id ); 00028 00029 if ( error_rank || error_id ) { 00030 std::ostringstream msg ; 00031 msg << "stk::mesh::EntityKey::EntityKey( " 00032 << entity_rank << " , " << entity_id << " ) FAILED" ; 00033 if ( error_rank ) { 00034 msg << " : RANK OUT OF RANGE" ; 00035 } 00036 if ( error_id ) { 00037 msg << " : ID OUT OF RANGE" ; 00038 } 00039 throw std::runtime_error( msg.str() ); 00040 } 00041 } 00042 00043 00044 } 00045 } 00046