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 private:
00116 
00117   impl::EntityImpl m_entityImpl;
00118 
00119   ~Entity();
00120   explicit Entity( const EntityKey & arg_key );
00121 
00122   Entity(); 
00123   Entity( const Entity & ); 
00124   Entity & operator = ( const Entity & ); 
00125 
00126 #ifndef DOXYGEN_COMPILE
00127   friend class impl::EntityRepository ;
00128   friend class impl::EntityImpl ;
00129 
00130 #endif /* DOXYGEN_COMPILE */
00131 };
00132 
00134 class EntityLess {
00135 public:
00136   ~EntityLess() {}
00137   EntityLess() {}
00138   EntityLess( const EntityLess & ) {}
00139   EntityLess & operator = ( const EntityLess & ) { return *this ; }
00140 
00142   bool operator()(const Entity& lhs, const Entity& rhs) const
00143   { return lhs.key() < rhs.key(); }
00144 
00145   bool operator()(const Entity& lhs, const EntityKey & rhs) const
00146   { return lhs.key() < rhs ; }
00147 
00149   bool operator()(const Entity* lhs, const Entity* rhs) const
00150   {
00151     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ;
00152     const EntityKey rhs_key = rhs ? rhs->key() : EntityKey() ;
00153     return lhs_key < rhs_key ;
00154   }
00155 
00156   bool operator()(const Entity* lhs, const Entity& rhs) const
00157   {
00158     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey();
00159     return lhs_key < rhs.key() ;
00160   }
00161 
00162   bool operator()(const Entity& lhs, const Entity* rhs) const
00163   {
00164     const EntityKey rhs_key = rhs ? rhs->key() : EntityKey();
00165     return lhs.key() < rhs_key ;
00166   }
00167 
00168   bool operator()(const Entity* lhs, const EntityKey & rhs) const
00169   {
00170     const EntityKey lhs_key = lhs ? lhs->key() : EntityKey() ;
00171     return lhs_key < rhs ;
00172   }
00173 
00174   bool operator()( const EntityProc & lhs, const EntityProc & rhs) const
00175   {
00176     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00177     const EntityKey rhs_key = rhs.first ? rhs.first->key() : EntityKey() ;
00178     return lhs_key != rhs_key ? lhs_key < rhs_key : lhs.second < rhs.second ;
00179   }
00180 
00181   bool operator()( const EntityProc & lhs, const Entity & rhs) const
00182   {
00183     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00184     return lhs_key < rhs.key();
00185   }
00186 
00187   bool operator()( const EntityProc & lhs, const Entity * rhs) const
00188   {
00189     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00190     const EntityKey rhs_key = rhs       ? rhs->key() : EntityKey() ;
00191     return lhs_key < rhs_key ;
00192   }
00193 
00194   bool operator()( const EntityProc & lhs, const EntityKey & rhs) const
00195   {
00196     const EntityKey lhs_key = lhs.first ? lhs.first->key() : EntityKey() ;
00197     return lhs_key < rhs ;
00198   }
00199 
00200 }; //class EntityLess
00201 
00202 class EntityEqual
00203 {
00204 public:
00205   bool operator()(const stk::mesh::Entity* lhs, const stk::mesh::Entity* rhs) const
00206   {
00207     const stk::mesh::EntityKey lhs_key = lhs ? lhs->key() : stk::mesh::EntityKey();
00208     const stk::mesh::EntityKey rhs_key = rhs ? rhs->key() : stk::mesh::EntityKey();
00209     return lhs_key == rhs_key;
00210   }
00211 
00212   bool operator()(const stk::mesh::Entity& lhs, const stk::mesh::Entity& rhs) const
00213   {
00214     const stk::mesh::EntityKey lhs_key = lhs.key();
00215     const stk::mesh::EntityKey rhs_key = rhs.key();
00216     return lhs_key == rhs_key;
00217   }
00218 };
00219 
00220 std::string print_entity_key(const Entity& entity);
00221 
00222 std::string print_entity_key(const Entity* entity);
00223 
00224 //----------------------------------------------------------------------
00225 
00228 } // namespace mesh
00229 } // namespace stk
00230 
00231 //----------------------------------------------------------------------
00232 //----------------------------------------------------------------------
00233 
00234 #endif /* stk_mesh_base_Entity_hpp */
00235 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends