moab
|
00001 #include "SplitVertices.hpp" 00002 #include "RefinerTagManager.hpp" 00003 00004 #include "MBParallelConventions.h" 00005 00006 namespace moab { 00007 00008 SplitVerticesBase::SplitVerticesBase( RefinerTagManager* tag_mgr ) 00009 { 00010 this->tag_manager = tag_mgr; 00011 this->mesh_out = tag_mgr->get_output_mesh(); 00012 } 00013 00014 SplitVerticesBase::~SplitVerticesBase() 00015 { 00016 } 00017 00018 EntitySource::EntitySource( int nc, RefinerTagManager* tag_mgr ) 00019 { 00020 this->tag_manager = tag_mgr; 00021 this->mesh_out = tag_mgr->get_output_mesh(); 00022 this->num_corners = nc; 00023 } 00024 00025 EntitySource::~EntitySource() 00026 { 00027 } 00028 00029 bool EntitySource::create_element( 00030 EntityType etyp, int nconn, const EntityHandle* elem_verts, EntityHandle& elem_handle, 00031 std::map<ProcessSet,int>& proc_partition_counts ) 00032 { 00033 // Get the global IDs of the input vertices 00034 //int stat; 00035 proc_partition_counts[this->tag_manager->get_element_procs()]++; 00036 if ( this->mesh_out->create_element( etyp, elem_verts, nconn, elem_handle ) != MB_SUCCESS ) 00037 { 00038 return false; 00039 } 00040 this->push_back( EntitySourceRecord( this->num_corners, elem_handle, this->tag_manager->get_element_procs() ) ); 00041 this->tag_manager->set_sharing( elem_handle, this->tag_manager->get_element_procs() ); 00042 return true; 00043 } 00044 00045 void EntitySource::assign_global_ids( std::map<ProcessSet,int>& gids ) 00046 { 00047 std::vector<EntityHandle> adjacencies; 00048 adjacencies.resize( this->num_corners ); 00049 std::vector<EntitySourceRecord>::iterator it; 00050 for ( it = this->begin(); it != this->end(); ++ it ) 00051 { 00052 int num_nodes; 00053 const EntityHandle* conn; 00054 this->mesh_out->get_connectivity( it->handle, conn, num_nodes ); 00055 this->tag_manager->get_output_gids( this->num_corners, conn, it->ids ); 00056 std::sort( it->ids.begin(), it->ids.end() ); 00057 } 00058 std::sort( this->begin(), this->end() ); 00059 for ( it = this->begin(); it != this->end(); ++ it ) 00060 { 00061 int gid = gids[it->process_set] ++; 00062 this->tag_manager->set_gid( it->handle, gid ); 00063 #ifdef MB_DEBUG 00064 std::cout << "Assigning entity: " << it->handle << " GID: " << gid << "\n"; 00065 #endif // MB_DEBUG 00066 } 00067 } 00068 00069 } // namespace moab