Sierra Toolkit Version of the Day
Entity.hpp
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 #ifndef stk_mesh_base_Entity_hpp
00010 #define stk_mesh_base_Entity_hpp
00011 
00012 #include <utility>
00013 #include <vector>
00014 #include <iosfwd>
00015 
00016 #include <stk_mesh/base/Types.hpp>
00017 
00018 #include <stk_mesh/baseImpl/EntityImpl.hpp>
00019 
00020 namespace stk {
00021 namespace mesh {
00022 
00023 namespace impl {
00024 
00025 class EntityRepository;
00026 class BucketRepository;
00027 
00028 }
00029 
00034 //----------------------------------------------------------------------
00035 
00036 
00037 
00038 //----------------------------------------------------------------------
00054 class Entity {
00055 public:
00056 
00058   EntityModificationLog log_query() const { return m_entityImpl.log_query(); }
00059 
00061   EntityRank entity_rank() const { return m_entityImpl.entity_rank(); }
00062 
00066   EntityId identifier() const { return m_entityImpl.identifier(); }
00067 
00071   const EntityKey & key() const { return m_entityImpl.key(); }
00072 
00074   Bucket & bucket() const { return m_entityImpl.bucket(); }
00075 
00077   unsigned bucket_ordinal() const { return m_entityImpl.bucket_ordinal(); }
00078 
00086   size_t synchronized_count() const { return m_entityImpl.synchronized_count(); }
00087 
00088   //------------------------------------
00093   PairIterRelation relations() const { return m_entityImpl.relations(); }
00094 
00098   PairIterRelation relations( EntityRank type ) const { return m_entityImpl.relations(type); }
00099   PairIterRelation node_relations() const { return m_entityImpl.node_relations(); }
00100 
00101   //------------------------------------
00103   unsigned owner_rank() const { return m_entityImpl.owner_rank(); }
00104 
00106   PairIterEntityComm sharing() const { return m_entityImpl.sharing(); }
00107 
00109   PairIterEntityComm comm() const { return m_entityImpl.comm(); }
00110 
00112   PairIterEntityComm comm( const Ghosting & sub ) const { return m_entityImpl.comm( sub ); }
00113 
00114   //------------------------------------
00115 #ifdef SIERRA_MIGRATION
00116 
00117   void set_void_ptr(void* vptr) { m_voidptr = vptr; }
00118   void* get_void_ptr() const { return m_voidptr; }
00119 #endif
00120 
00121 private:
00122 
00123 #ifdef SIERRA_MIGRATION
00124 
00125   void* m_voidptr;
00126 #endif
00127 
00128   impl::EntityImpl m_entityImpl;
00129 
00130   ~Entity();
00131   explicit Entity( const EntityKey & arg_key );
00132 
00133   Entity(); 
00134   Entity( const Entity & ); 
00135   Entity & operator = ( const Entity & ); 
00136 
00137 #ifndef DOXYGEN_COMPILE
00138   friend class impl::EntityRepository ;
00139   friend class impl::EntityImpl ;
00140 
00141 #endif /* DOXYGEN_COMPILE */
00142 };
00143 
00145 class EntityLess {
00146 public:
00147   ~EntityLess() {}
00148   EntityLess() {}
00149   EntityLess( const EntityLess & ) {}
00150   EntityLess & operator = ( const EntityLess & ) { return *this ; }
00151 
00153   bool operator()(const Entity& lhs, const Entity& rhs) const
00154   { return lhs.key() < rhs.key(); }
00155 
00156   bool operator()(const Entity& lhs, const EntityKey & rhs) const
00157   { return lhs.key() < rhs ; }
00158 
00160   bool operator()(const Entity* lhs, const Entity* rhs) const
00161   {
00162     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ;
00163     const EntityKey rhs_key = rhs ? rhs->key() : EntityKey() ;
00164     return lhs_key < rhs_key ;
00165   }
00166 
00167   bool operator()(const Entity* lhs, const Entity& rhs) const
00168   {
00169     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey();
00170     return lhs_key < rhs.key() ;
00171   }
00172 
00173   bool operator()(const Entity& lhs, const Entity* rhs) const
00174   {
00175     const EntityKey rhs_key = rhs ? rhs->key() : EntityKey();
00176     return lhs.key() < rhs_key ;
00177   }
00178 
00179   bool operator()(const Entity* lhs, const EntityKey & rhs) const
00180   {
00181     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ;
00182     return lhs_key < rhs ;
00183   }
00184 
00185   bool operator()( const EntityProc & lhs, const EntityProc & rhs) const
00186   {
00187     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00188     const EntityKey rhs_key = rhs.first ? rhs.first->key() : EntityKey() ;
00189     return lhs_key != rhs_key ? lhs_key < rhs_key : lhs.second < rhs.second ;
00190   }
00191 
00192   bool operator()( const EntityProc & lhs, const Entity & rhs) const
00193   {
00194     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00195     return lhs_key < rhs.key();
00196   }
00197 
00198   bool operator()( const EntityProc & lhs, const Entity * rhs) const
00199   {
00200     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00201     const EntityKey rhs_key = rhs       ? rhs->key() : EntityKey() ;
00202     return lhs_key < rhs_key ;
00203   }
00204 
00205   bool operator()( const EntityProc & lhs, const EntityKey & rhs) const
00206   {
00207     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00208     return lhs_key < rhs ;
00209   }
00210 
00211 }; //class EntityLess
00212 
00213 class EntityEqual
00214 {
00215 public:
00216   bool operator()(const stk::mesh::Entity* lhs, const stk::mesh::Entity* rhs) const
00217   {
00218     const stk::mesh::EntityKey lhs_key = lhs ? lhs->key() : stk::mesh::EntityKey();
00219     const stk::mesh::EntityKey rhs_key = rhs ? rhs->key() : stk::mesh::EntityKey();
00220     return lhs_key == rhs_key;
00221   }
00222 
00223   bool operator()(const stk::mesh::Entity& lhs, const stk::mesh::Entity& rhs) const
00224   {
00225     const stk::mesh::EntityKey lhs_key = lhs.key();
00226     const stk::mesh::EntityKey rhs_key = rhs.key();
00227     return lhs_key == rhs_key;
00228   }
00229 };
00230 
00231 std::string print_entity_key(const Entity& entity);
00232 
00233 std::string print_entity_key(const Entity* entity);
00234 
00235 //----------------------------------------------------------------------
00236 
00239 } // namespace mesh
00240 } // namespace stk
00241 
00242 //----------------------------------------------------------------------
00243 //----------------------------------------------------------------------
00244 
00245 #endif /* stk_mesh_base_Entity_hpp */
00246 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends