9 #ifndef stk_mesh_EntityComm_hpp 10 #define stk_mesh_EntityComm_hpp 17 #include <stk_util/parallel/ParallelComm.hpp> 18 #include <stk_mesh/base/Types.hpp> 19 #include <stk_mesh/base/Ghosting.hpp> 21 #include <boost/unordered_map.hpp> 31 typedef boost::unordered_map<EntityKey, EntityCommInfoVector> map_type;
37 bool insert(
const EntityKey & key,
const EntityCommInfo & val );
38 bool erase(
const EntityKey & key,
const EntityCommInfo & val );
39 bool erase(
const EntityKey & key,
const Ghosting & ghost );
40 void comm_clear_ghosting(
const EntityKey & key );
41 void comm_clear(
const EntityKey & key );
42 void comm_swap(
const EntityKey & key1,
const EntityKey & key2);
50 map_type::const_iterator it = m_comm_map.find(key);
51 if (it == m_comm_map.cend()) {
54 const EntityCommInfoVector & m_comm = it->second;
56 EntityCommInfoVector::const_iterator i = m_comm.begin();
57 EntityCommInfoVector::const_iterator e = m_comm.end();
59 e = std::lower_bound( i , e , EntityCommInfo(1,
68 map_type::const_iterator it = m_comm_map.find(key);
69 if (it == m_comm_map.cend()) {
72 const EntityCommInfoVector & m_comm = it->second;
76 inline PairIterEntityComm EntityComm::comm(
const EntityKey & key,
const Ghosting & sub )
const 78 map_type::const_iterator it = m_comm_map.find(key);
79 if (it == m_comm_map.cend()) {
82 const EntityCommInfoVector & m_comm = it->second;
84 const EntityCommInfo s_begin( sub.ordinal() , 0 );
85 const EntityCommInfo s_end( sub.ordinal() + 1 , 0 );
87 EntityCommInfoVector::const_iterator i = m_comm.begin();
88 EntityCommInfoVector::const_iterator e = m_comm.end();
90 i = std::lower_bound( i , e , s_begin );
91 e = std::lower_bound( i , e , s_end );
98 TraceIfWatching(
"stk_classic::mesh::EntityComm::insert", LOG_ENTITY, key());
99 EntityCommInfoVector & m_comm = m_comm_map[key];
101 std::vector< EntityCommInfo >::iterator i =
102 std::lower_bound( m_comm.begin() , m_comm.end() , val );
104 const bool result = ((i == m_comm.end()) || (val != *i));
107 m_comm.insert( i , val );
113 inline bool EntityComm::erase(
const EntityKey & key,
const EntityCommInfo & val )
115 TraceIfWatching(
"stk_classic::mesh::EntityComm::erase(comm)", LOG_ENTITY, key());
116 EntityCommInfoVector & m_comm = m_comm_map[key];
118 std::vector< EntityCommInfo >::iterator i =
119 std::lower_bound( m_comm.begin() , m_comm.end() , val );
121 const bool result = ( (i != m_comm.end()) && (val == *i) ) ;
130 inline bool EntityComm::erase(
const EntityKey & key,
const Ghosting & ghost )
132 TraceIfWatching(
"stk_classic::mesh::EntityComm::erase(ghost)", LOG_ENTITY, key());
133 EntityCommInfoVector & m_comm = m_comm_map[key];
135 const EntityCommInfo s_begin( ghost.ordinal() , 0 );
136 const EntityCommInfo s_end( ghost.ordinal() + 1 , 0 );
138 EntityCommInfoVector::iterator i = m_comm.begin();
139 EntityCommInfoVector::iterator e = m_comm.end();
141 i = std::lower_bound( i , e , s_begin );
142 e = std::lower_bound( i , e , s_end );
144 const bool result = i != e ;
147 m_comm.erase( i , e );
153 inline void EntityComm::comm_clear_ghosting(
const EntityKey & key)
155 TraceIfWatching(
"stk_classic::mesh::EntityComm::comm_clear_ghosting", LOG_ENTITY, key());
156 EntityCommInfoVector & m_comm = m_comm_map[key];
158 std::vector< EntityCommInfo >::iterator j = m_comm.begin();
159 while ( j != m_comm.end() && j->ghost_id == 0 ) { ++j ; }
160 m_comm.erase( j , m_comm.end() );
163 inline void EntityComm::comm_clear(
const EntityKey & key)
165 TraceIfWatching(
"stk_classic::mesh::EntityComm::comm_clear", LOG_ENTITY, key());
166 EntityCommInfoVector& commvec = m_comm_map[key];
170 inline void EntityComm::comm_swap(
const EntityKey & key1,
const EntityKey & key2)
172 map_type::iterator it1 = m_comm_map.find(key1);
173 map_type::iterator it2 = m_comm_map.find(key2);
175 if (it1 == m_comm_map.cend() && it2 == m_comm_map.cend()) {
179 EntityCommInfoVector & comm1 = it1 == m_comm_map.cend() ? m_comm_map[key1] : it1->second;
180 EntityCommInfoVector & comm2 = it2 == m_comm_map.cend() ? m_comm_map[key2] : it2->second;
186 bool in_shared(
const Entity & entity );
189 bool in_shared(
const Entity & entity ,
unsigned proc );
192 bool in_receive_ghost(
const Entity & entity );
195 bool in_receive_ghost(
const Ghosting & ghost ,
const Entity & entity );
198 bool in_send_ghost(
const Entity & entity );
201 bool in_send_ghost(
const Entity & entity ,
unsigned proc );
204 bool in_ghost(
const Ghosting & ghost ,
const Entity & entity ,
unsigned p );
209 bool in_owned_closure(
const Entity & entity ,
unsigned proc );
212 void comm_procs(
const Entity & entity , std::vector<unsigned> & procs );
215 void comm_procs(
const Ghosting & ghost ,
216 const Entity & entity , std::vector<unsigned> & procs );
220 void pack_entity_info( CommBuffer & buf ,
const Entity & entity );
222 void unpack_entity_info(
224 const BulkData & mesh ,
228 std::vector<Relation> & relations );
231 void pack_field_values( CommBuffer & , Entity & );
234 bool unpack_field_values( CommBuffer & , Entity & , std::ostream & error_msg );
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
PairIter< std::vector< EntityCommInfo >::const_iterator > PairIterEntityComm
Span of ( communication-subset-ordinal , process-rank ) pairs for the communication of an entity...
bool insert(PartVector &v, Part &part)
Insert a part into a properly ordered collection of parts. Returns true if this is a new insertion...