|
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_SetOwners_hpp 00010 #define stk_mesh_SetOwners_hpp 00011 00012 #include <set> 00013 #include <map> 00014 00015 #include <stk_mesh/base/BulkData.hpp> 00016 00017 namespace stk_classic { 00018 namespace mesh { 00019 00020 typedef std::less<unsigned> LowestRankSharingProcOwns; 00021 typedef std::greater<unsigned> HighestRankSharingProcOwns; 00022 00027 template<class OwnershipRule> 00028 void set_owners(BulkData& mesh_bulk_data) 00029 { 00030 typedef std::set<unsigned,OwnershipRule> ProcSet ; 00031 00032 const unsigned local_proc = mesh_bulk_data.parallel_rank(); 00033 00034 std::vector<EntityProc> entity_new_owners; 00035 00036 const std::vector<Entity*>& entity_comm = mesh_bulk_data.entity_comm(); 00037 00038 for ( size_t i=0; i<entity_comm.size(); ++i) { 00039 Entity * const entity = entity_comm[i] ; 00040 00041 const PairIterEntityComm sharing = entity->sharing(); 00042 00043 if ( ! sharing.empty() && entity->owner_rank() == local_proc ) { 00044 ProcSet proc_set ; 00045 00046 proc_set.insert( local_proc ); 00047 00048 for ( size_t j = 0 ; j < sharing.size() ; ++j ) { 00049 proc_set.insert( sharing[j].proc ); 00050 } 00051 00052 const unsigned new_owner_proc = *proc_set.begin(); 00053 00054 entity_new_owners.push_back(std::make_pair( entity, new_owner_proc ) ); 00055 } 00056 } 00057 00058 mesh_bulk_data.modification_begin(); 00059 00060 mesh_bulk_data.change_entity_owner( entity_new_owners ); 00061 00062 mesh_bulk_data.modification_end(); 00063 } 00064 00065 }//namespace mesh 00066 }//namespace stk_classic 00067 00068 #endif // stk_mesh_SetOwner_hpp 00069