Sierra Toolkit Version of the Day
Ghosting.cpp
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 
00010 #include <stk_mesh/base/Ghosting.hpp>
00011 #include <stk_mesh/base/BulkData.hpp>
00012 #include <stk_mesh/base/EntityComm.hpp>
00013 
00014 namespace stk {
00015 namespace mesh {
00016 
00017 void Ghosting::send_list( std::vector< EntityProc > & v ) const
00018 {
00019   for ( std::vector<Entity*>::const_iterator
00020         i =  m_mesh.entity_comm().begin() ;
00021         i != m_mesh.entity_comm().end() ; ++i ){
00022     Entity * const entity = *i ;
00023     if ( entity->owner_rank() == m_mesh.parallel_rank() ) {
00024       for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
00025         if ( ec->ghost_id == m_ordinal ) {
00026           v.push_back( EntityProc( entity , ec->proc ) );
00027         }
00028       }
00029     }
00030   }
00031 }
00032 
00033 void Ghosting::receive_list( std::vector< Entity * > & v ) const
00034 {
00035   for ( std::vector<Entity*>::const_iterator
00036         i =  m_mesh.entity_comm().begin() ;
00037         i != m_mesh.entity_comm().end() ; ++i ){
00038     Entity * const entity = *i ;
00039     if ( entity->owner_rank() != m_mesh.parallel_rank() ) {
00040       for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
00041         if ( ec->ghost_id == m_ordinal ) {
00042           v.push_back( entity );
00043         }
00044       }
00045     }
00046   }
00047 }
00048 
00049 std::ostream& Ghosting::operator<<(std::ostream& out) const
00050 {
00051   out << "Ghosting object: name: " << name()
00052       << ", ordinal: " << ordinal() << "\n";
00053 
00054   out << "  Locally owned entities ghosted on other processors (send list):\n";
00055 
00056   for ( std::vector<Entity*>::const_iterator
00057         i =  m_mesh.entity_comm().begin() ;
00058         i != m_mesh.entity_comm().end() ; ++i ){
00059     Entity * const entity = *i ;
00060     if ( entity->owner_rank() == m_mesh.parallel_rank() ) {
00061       for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
00062         if ( ec->ghost_id == m_ordinal ) {
00063           out << "    ";
00064           print_entity_key( out, MetaData::get(m_mesh), entity->key() );
00065           out << ", sending ghost to " << ec->proc << ", status is: "
00066               << entity->log_query() << "\n";
00067         }
00068       }
00069     }
00070   }
00071 
00072   out << "  Entities ghosted on this processor from the owner (recv list):\n";
00073   for ( std::vector<Entity*>::const_iterator
00074         i =  m_mesh.entity_comm().begin() ;
00075         i != m_mesh.entity_comm().end() ; ++i ){
00076     Entity * const entity = *i ;
00077     if ( entity->owner_rank() != m_mesh.parallel_rank() ) {
00078       for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
00079         if ( ec->ghost_id == m_ordinal ) {
00080           out << "    ";
00081           print_entity_key( out, MetaData::get(m_mesh), entity->key() );
00082           out << ", owner of ghost is " << entity->owner_rank()
00083               << ", status is: " << entity->log_query() << "\n";
00084         }
00085       }
00086     }
00087   }
00088   return out;
00089 }
00090 
00091 std::ostream& operator<<(std::ostream& out, const Ghosting& rhs)
00092 {
00093   return rhs.operator<<(out);
00094 }
00095 
00096 }
00097 }
00098 
00099 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends