Sierra Toolkit  Version of the Day
EntityKey.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 
10 #include <sstream>
11 #include <stdexcept>
12 
13 #include <stk_util/util/StaticAssert.hpp>
14 
15 #include <stk_util/environment/ReportHandler.hpp>
16 
17 #include <stk_mesh/base/EntityKey.hpp>
18 
19 namespace stk_classic {
20 namespace mesh {
21 
23  EntityKey::raw_key_type entity_id )
24  : key( ( raw_key_type(entity_rank) << id_digits ) | entity_id )
25 {
26  enum { OK = StaticAssert< sizeof(EntityKey) ==
27  sizeof(EntityKey::raw_key_type) >::OK };
28 
29  ThrowAssertMsg( rank() == entity_rank,
30  "entity_rank out of range, entity_rank= " << entity_rank << " rank() = " << rank() << " entity_id= " << entity_id << " id() = " << id() );
31 
32  ThrowAssertMsg( id() == entity_id,
33  "entity_id out of range, entity_rank= " << entity_rank << " rank() = " << rank() << " entity_id= " << entity_id << " id() = " << id() );
34 }
35 
36 
37 }
38 }
39 
Compile-time assertionIf the compile-time expression is true then defines.
EntityId entity_id(const EntityKey &key)
Given an entity key, return the identifier for the entity.
Sierra Toolkit.
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).