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