|
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 #ifndef stk_mesh_EntityImpl_hpp 00010 #define stk_mesh_EntityImpl_hpp 00011 00012 //#include <utility> 00013 00014 #include <stk_mesh/base/Types.hpp> 00015 00016 //#include <stk_util/util/NamedPair.hpp> 00017 #include <stk_util/util/PairIter.hpp> 00018 #include <stk_mesh/base/Types.hpp> 00019 //#include <stk_mesh/base/Bucket.hpp> 00020 #include <stk_mesh/base/Relation.hpp> 00021 00022 #include <cassert> 00023 00024 namespace stk { 00025 namespace mesh { 00026 namespace impl { 00027 00032 class EntityImpl { 00033 public: 00034 00035 ~EntityImpl(); 00036 EntityImpl( const EntityKey & arg_key ); 00037 00038 // Exposed in external interface: 00039 EntityRank entity_rank() const { return stk::mesh::entity_rank( m_key ); } 00040 EntityId identifier() const { return stk::mesh::entity_id( m_key ); } 00041 const EntityKey & key() const { return m_key ; } 00042 PairIterRelation relations() const { return PairIterRelation( m_relation ); } 00043 PairIterRelation relations( unsigned type ) const ; 00044 PairIterEntityComm comm() const { return PairIterEntityComm( m_comm ); } 00045 PairIterEntityComm sharing() const ; 00046 PairIterEntityComm comm( const Ghosting & sub ) const ; 00047 Bucket & bucket() const { 00048 assert(m_bucket); //don't want to return a reference to a null bucket 00049 return *m_bucket ; 00050 } 00051 Bucket* bucket_ptr() const { 00052 return m_bucket; // allow for NULL return value 00053 } 00054 bool is_bucket_valid() const { return m_bucket != NULL; } 00055 unsigned bucket_ordinal() const { return m_bucket_ord ; } 00056 unsigned owner_rank() const { return m_owner_rank ; } 00057 size_t synchronized_count() const { return m_sync_count ; } 00058 00059 // The two relation methods below need to be called symmetically, ideally 00060 // through EntityRepository which will enforce the symmetry. 00061 00062 bool destroy_relation( Entity & e_to); 00063 bool declare_relation( Entity & e_to, 00064 const unsigned local_id, 00065 unsigned sync_count, 00066 bool is_converse = false); 00067 00068 // Communication info access: 00069 bool insert( const EntityCommInfo & ); 00070 bool erase( const EntityCommInfo & ); 00071 bool erase( const Ghosting & ); 00072 void comm_clear_ghosting(); 00073 void comm_clear(); 00074 00075 void set_bucket_and_ordinal( Bucket * bucket, unsigned ordinal ) { 00076 m_bucket = bucket; 00077 m_bucket_ord = ordinal; 00078 } 00079 00080 // return true if entity was actually modified 00081 bool set_owner_rank( unsigned owner_rank ) { 00082 if ( owner_rank != m_owner_rank ) { 00083 m_owner_rank = owner_rank; 00084 return true; 00085 } 00086 return false; 00087 } 00088 00089 void set_sync_count( size_t sync_count ) { 00090 m_sync_count = sync_count; 00091 } 00092 00093 // Change log access: 00094 EntityModificationLog log_query() const { return m_mod_log ; } 00095 00096 void log_clear() { 00097 m_mod_log = EntityLogNoChange; 00098 } 00099 00104 void log_modified() { 00105 if ( EntityLogNoChange == m_mod_log ) { 00106 m_mod_log = EntityLogModified; 00107 } 00108 } 00109 00110 void log_deleted() { 00111 m_mod_log = EntityLogDeleted; 00112 } 00113 00118 void log_resurrect(); 00119 00121 void log_created_parallel_copy(); 00122 00123 bool marked_for_destruction() const; 00124 00125 private: 00126 00127 const EntityKey m_key ; 00128 RelationVector m_relation ; 00129 EntityCommInfoVector m_comm ; 00130 Bucket * m_bucket ; 00131 unsigned m_bucket_ord ; 00132 unsigned m_owner_rank ; 00133 size_t m_sync_count ; 00134 EntityModificationLog m_mod_log ; 00135 00136 private: 00137 EntityImpl(); 00138 EntityImpl( const EntityImpl & ); 00139 EntityImpl & operator = ( const EntityImpl & ); 00140 00141 }; 00142 00143 //---------------------------------------------------------------------- 00144 00147 } // namespace impl 00148 } // namespace mesh 00149 } // namespace stk 00150 00151 //---------------------------------------------------------------------- 00152 //---------------------------------------------------------------------- 00153 00154 #endif /* stk_mesh_EntityImpl_hpp */ 00155