Sierra Toolkit  Version of the Day
Ghosting.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 
10 #include <stk_mesh/base/Ghosting.hpp>
11 #include <stk_mesh/base/BulkData.hpp>
12 #include <stk_mesh/base/EntityComm.hpp>
13 
14 namespace stk_classic {
15 namespace mesh {
16 
17 void Ghosting::send_list( std::vector< EntityProc > & v ) const
18 {
19  for ( std::vector<Entity*>::const_iterator
20  i = m_mesh.entity_comm().begin() ;
21  i != m_mesh.entity_comm().end() ; ++i ){
22  Entity * const entity = *i ;
23  if ( entity->owner_rank() == m_mesh.parallel_rank() ) {
24  for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
25  if ( ec->ghost_id == m_ordinal ) {
26  v.push_back( EntityProc( entity , ec->proc ) );
27  }
28  }
29  }
30  }
31 }
32 
33 void Ghosting::receive_list( std::vector< Entity * > & v ) const
34 {
35  for ( std::vector<Entity*>::const_iterator
36  i = m_mesh.entity_comm().begin() ;
37  i != m_mesh.entity_comm().end() ; ++i ){
38  Entity * const entity = *i ;
39  if ( entity->owner_rank() != m_mesh.parallel_rank() ) {
40  for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
41  if ( ec->ghost_id == m_ordinal ) {
42  v.push_back( entity );
43  }
44  }
45  }
46  }
47 }
48 
49 std::ostream& Ghosting::operator<<(std::ostream& out) const
50 {
51  out << "Ghosting object: name: " << name()
52  << ", ordinal: " << ordinal() << "\n";
53 
54  out << " Locally owned entities ghosted on other processors (send list):\n";
55 
56  for ( std::vector<Entity*>::const_iterator
57  i = m_mesh.entity_comm().begin() ;
58  i != m_mesh.entity_comm().end() ; ++i ){
59  Entity * const entity = *i ;
60  if ( entity->owner_rank() == m_mesh.parallel_rank() ) {
61  for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
62  if ( ec->ghost_id == m_ordinal ) {
63  out << " ";
64  print_entity_key( out, MetaData::get(m_mesh), entity->key() );
65  out << ", sending ghost to " << ec->proc << ", status is: "
66  << entity->log_query() << "\n";
67  }
68  }
69  }
70  }
71 
72  out << " Entities ghosted on this processor from the owner (recv list):\n";
73  for ( std::vector<Entity*>::const_iterator
74  i = m_mesh.entity_comm().begin() ;
75  i != m_mesh.entity_comm().end() ; ++i ){
76  Entity * const entity = *i ;
77  if ( entity->owner_rank() != m_mesh.parallel_rank() ) {
78  for ( PairIterEntityComm ec = entity->comm() ; ! ec.empty() ; ++ec ) {
79  if ( ec->ghost_id == m_ordinal ) {
80  out << " ";
81  print_entity_key( out, MetaData::get(m_mesh), entity->key() );
82  out << ", owner of ghost is " << entity->owner_rank()
83  << ", status is: " << entity->log_query() << "\n";
84  }
85  }
86  }
87  }
88  return out;
89 }
90 
91 std::ostream& operator<<(std::ostream& out, const Ghosting& rhs)
92 {
93  return rhs.operator<<(out);
94 }
95 
96 }
97 }
98 
99 
const std::vector< Entity * > & entity_comm() const
All entities with communication information.
Definition: BulkData.hpp:367
Data for ghosting mesh entities.
Definition: Ghosting.hpp:28
std::pair< Entity *, unsigned > EntityProc
Pairing of an entity with a processor rank.
Definition: Types.hpp:111
std::ostream & operator<<(std::ostream &s, const Bucket &k)
Print the part names for which this bucket is a subset.
Definition: Bucket.cpp:239
void receive_list(std::vector< Entity * > &) const
Entities ghosted on this processor from the owner.
Definition: Ghosting.cpp:33
std::ostream & operator<<(std::ostream &out) const
Print the details of this object for debugging.
Definition: Ghosting.cpp:49
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Definition: Entity.hpp:120
Sierra Toolkit.
const std::string & name() const
Text name for printing purposes only.
Definition: Ghosting.hpp:32
unsigned ordinal() const
Ordinal to identify the ghosting subset.
Definition: Ghosting.hpp:35
void send_list(std::vector< EntityProc > &) const
Locally owned entities ghosted on other processors.
Definition: Ghosting.cpp:17
unsigned parallel_rank() const
Rank of the parallel machine&#39;s local processor.
Definition: BulkData.hpp:85