9 #ifndef stk_mesh_baseImpl_EntityRepository_hpp 10 #define stk_mesh_baseImpl_EntityRepository_hpp 12 #include <stk_mesh/base/Trace.hpp> 15 #if defined(__PGI) || defined(__PATHSCALE__) 16 #define STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 0 18 #define STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 0 21 #if STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 22 #include <tr1/unordered_map> 27 #include <stk_mesh/base/Entity.hpp> 30 #include <boost/pool/pool_alloc.hpp> 36 class EntityRepository {
38 #if STK_MESH_ENTITYREPOSITORY_MAP_TYPE_TR1 39 struct stk_entity_rep_hash :
public std::unary_function< EntityKey, std::size_t >
42 operator()(
const EntityKey& x)
const 44 return (std::size_t)(x.raw_key());
48 typedef std::tr1::unordered_map<EntityKey, Entity*, stk_entity_rep_hash, std::equal_to<EntityKey> > EntityMap;
50 typedef std::map<EntityKey,Entity*> EntityMap;
55 typedef EntityMap::const_iterator iterator;
57 EntityRepository(
bool use_pool)
58 : m_entities(), m_use_pool(use_pool) {}
62 Entity * get_entity(
const EntityKey &key )
const;
64 iterator begin()
const {
return m_entities.begin(); }
65 iterator end()
const {
return m_entities.end(); }
73 std::pair<Entity*,bool>
74 internal_create_entity(
const EntityKey & key );
79 void log_created_parallel_copy( Entity & e );
87 inline void log_modified(Entity & e)
const;
89 inline void set_entity_owner_rank( Entity & e,
unsigned owner_rank);
90 inline void set_entity_sync_count( Entity & e,
size_t count);
92 inline void comm_clear( Entity & e)
const;
93 inline void comm_clear_ghosting( Entity & e)
const;
95 bool erase_ghosting( Entity & e,
const Ghosting & ghosts)
const;
96 bool erase_comm_info( Entity & e,
const EntityCommInfo & comm_info)
const;
98 bool insert_comm_info( Entity & e,
const EntityCommInfo & comm_info)
const;
100 void change_entity_bucket( Bucket & b, Entity & e,
unsigned ordinal);
101 Bucket * get_entity_bucket ( Entity & e )
const;
102 void destroy_later( Entity & e, Bucket* nil_bucket );
104 bool destroy_relation( Entity & e_from,
106 const RelationIdentifier local_id);
108 void declare_relation( Entity & e_from,
110 const RelationIdentifier local_id,
111 unsigned sync_count );
113 void update_entity_key(EntityKey key, Entity & entity);
116 void internal_expunge_entity( EntityMap::iterator i);
118 Entity* internal_allocate_entity(EntityKey entity_key);
119 Entity* allocate_entity(
bool use_pool);
121 EntityMap m_entities;
125 EntityRepository(
const EntityRepository &);
126 EntityRepository & operator =(
const EntityRepository &);
131 void EntityRepository::set_entity_sync_count( Entity & e,
size_t count)
133 TraceIfWatching(
"stk_classic::mesh::impl::EntityRepository::set_entity_sync_count", LOG_ENTITY, e.key());
135 e.m_entityImpl.set_sync_count(count);
138 void EntityRepository::set_entity_owner_rank( Entity & e,
unsigned owner_rank)
140 TraceIfWatching(
"stk_classic::mesh::impl::EntityRepository::set_entity_owner_rank", LOG_ENTITY, e.key());
141 DiagIfWatching(LOG_ENTITY, e.key(),
"new owner: " << owner_rank);
143 bool changed = e.m_entityImpl.set_owner_rank(owner_rank);
145 e.m_entityImpl.log_modified_and_propagate();
149 void EntityRepository::comm_clear( Entity & e)
const 151 TraceIfWatching(
"stk_classic::mesh::impl::EntityRepository::comm_clear", LOG_ENTITY, e.key());
153 e.m_entityImpl.comm_clear();
156 void EntityRepository::comm_clear_ghosting( Entity & e)
const 158 TraceIfWatching(
"stk_classic::mesh::impl::EntityRepository::comm_clear_ghosting", LOG_ENTITY, e.key());
160 e.m_entityImpl.comm_clear_ghosting();
163 void EntityRepository::log_modified( Entity & e )
const 165 TraceIfWatching(
"stk_classic::mesh::impl::EntityRepository::log_modified", LOG_ENTITY, e.key());
167 e.m_entityImpl.log_modified_and_propagate();
174 #endif // stk_mesh_baseImpl_EntityRepository_hpp