void Ghosting::send_list( std::vector< EntityProc > & v ) const { for ( EntityCommListInfoVector::const_iterator i = m_mesh.internal_comm_list().begin() ; i != m_mesh.internal_comm_list().end() ; ++i ){ if ( i->owner == m_mesh.parallel_rank() ) { for ( PairIterEntityComm ec = m_mesh.internal_entity_comm_map(i->key) ; ! ec.empty() ; ++ec ) { if ( ec->ghost_id == m_ordinal ) { v.push_back( EntityProc( i->entity , ec->proc ) ); } } } } }
// Parallel collective call: void distribute_gear_across_processors(Gear & gear, GearsFixture::CylindricalField & cylindrical_coord_field) { BulkData & bulk_data = gear.bulk_data; const unsigned p_size = bulk_data.parallel_size(); const unsigned p_rank = bulk_data.parallel_rank(); EntityProcVec elements_to_change_owner; Selector locally_owned = gear.meta_data.locally_owned_part(); if (p_rank == 0) { BucketVector all_elements; stk::mesh::get_buckets(locally_owned,bulk_data.buckets(gear.meta_data.element_rank()),all_elements); std::set<Entity *> node_set; // First come first serve nodal movement. for (BucketVector::iterator it = all_elements.begin() ; it != all_elements.end() ; ++it) { Bucket & b = **it; for (size_t i=0 ; i<b.size() ; ++i) { Entity * element = &b[i]; double radius = 0.0; double angle = 0.0; double height = 0.0; select_nodal_data(cylindrical_coord_field, *element,radius,angle,height); unsigned destination_processor_rank = destination_processor(gear,radius,angle,height,p_rank,p_size); elements_to_change_owner.push_back(EntityProc(element,destination_processor_rank)); // Now add all related nodes to list to move to this processor: PairIterRelation node_relations = element->relations(stk::mesh::fem::FEMMetaData::NODE_RANK); for ( ; node_relations.first != node_relations.second ; ++(node_relations.first) ) { Entity * node = node_relations.first->entity(); if (node_set.count(node)==0) { elements_to_change_owner.push_back(EntityProc(node,destination_processor_rank)); node_set.insert(node); } } } } } // Parallel collective call: bulk_data.modification_begin(); bulk_data.change_entity_owner(elements_to_change_owner); // Parallel collective call: bulk_data.modification_end(); // Print out how many ended up on each processor: //{ // BucketVector local_elements; // stk::mesh::get_buckets(locally_owned,bulk_data.buckets(Element),local_elements); // BucketVector local_nodes; // stk::mesh::get_buckets(locally_owned,bulk_data.buckets(Node),local_nodes); // size_t element_count = 0; // for (BucketVector::iterator it = local_elements.begin() ; it != local_elements.end() ; ++it) { // Bucket & b = **it; // element_count += b.size(); // } // size_t node_count = 0; // for (BucketVector::iterator it = local_nodes.begin() ; it != local_nodes.end() ; ++it) { // Bucket & b = **it; // node_count += b.size(); // } // std::cout << "Proc " << p_rank << ": element count = " << element_count << " node count = " << node_count << std::endl; //} }