moab
moab::ParallelData Class Reference

Parallel data in MOAB. More...

#include <ParallelData.hpp>

List of all members.

Public Member Functions

 ParallelData (Interface *impl, ParallelComm *pcomm=NULL)
ErrorCode get_partition_sets (Range &part_sets, const char *tag_name=NULL)
ErrorCode get_interface_sets (std::vector< EntityHandle > &iface_sets, std::vector< int > &iface_procs)

Private Attributes

InterfacembImpl
 interface instance to which this instance corresponds
ParallelCommparallelComm
 ParallelComm object to which this is bound.

Detailed Description

Parallel data in MOAB.

Author:
Tim Tautges

This class implements methods to retrieve information about the parallel mesh from MOAB. Most of this data can be retrieved directly from MOAB as sets and tags; this class provides convenience methods implemented on top of other MOAB functions.

Definition at line 22 of file ParallelData.hpp.


Constructor & Destructor Documentation

moab::ParallelData::ParallelData ( Interface impl,
ParallelComm pcomm = NULL 
) [inline]

constructor; if non-null parallelcomm, that is used to determine rank, otherwise rank is taken from impl

Definition at line 51 of file ParallelData.hpp.

    : mbImpl(impl), parallelComm(pcomm) 
{}

Member Function Documentation

ErrorCode moab::ParallelData::get_interface_sets ( std::vector< EntityHandle > &  iface_sets,
std::vector< int > &  iface_procs 
)

get communication interface sets and the processors with which this processor communicates; sets are sorted by processor

Definition at line 35 of file ParallelData.cpp.

{
#define CONTINUE {result = tmp_result; continue;}
  iface_sets.clear();
  iface_procs.clear();
  
  Tag proc_tag = 0, procs_tag = 0;
  ErrorCode result = MB_SUCCESS;
  int my_rank;
  if (parallelComm) 
    my_rank = parallelComm->proc_config().proc_rank();
  else 
    return MB_FAILURE;

  std::multimap<int, EntityHandle> iface_data;

  for (int i = 0; i < 2; i++) {
    ErrorCode tmp_result;
    
    if (0 == i)
      tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROC_TAG_NAME, 
                                      1, MB_TYPE_INTEGER, proc_tag);
    else
      tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROCS_TAG_NAME, 
                                      MAX_SHARING_PROCS, MB_TYPE_INTEGER, proc_tag);
    if (MB_SUCCESS != tmp_result) CONTINUE;

    int tsize;
    tmp_result = mbImpl->tag_get_length(proc_tag, tsize);
    if (0 == tsize || MB_SUCCESS != tmp_result) CONTINUE;
    
    Range proc_sets;
    tmp_result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, 
                                                  &proc_tag, NULL, 1,
                                                  proc_sets, Interface::UNION);
    if (MB_SUCCESS != tmp_result) CONTINUE;
    
    if (proc_sets.empty()) CONTINUE;
      
    std::vector<int> proc_tags(proc_sets.size()*tsize);
    tmp_result = mbImpl->tag_get_data(procs_tag, proc_sets, &proc_tags[0]);
    if (MB_SUCCESS != tmp_result) CONTINUE;
    int k;
    Range::iterator rit;
    
    for (k = 0, rit = proc_sets.begin(); rit != proc_sets.end(); rit++, k++) {
      for (int j = 0; j < tsize; j++) {
        if (my_rank != proc_tags[2*k+j] && proc_tags[2*k+j] >= 0)
          iface_data.insert(std::pair<int,EntityHandle>(proc_tags[2*k+j], *rit));
      }
    }
  }

    // now get the results in sorted order
  std::multimap<int,EntityHandle>::iterator mit;
  for (mit = iface_data.begin(); mit != iface_data.end(); mit++)
    iface_procs.push_back((*mit).first),
      iface_sets.push_back((*mit).second);
    
  return result;
}
ErrorCode moab::ParallelData::get_partition_sets ( Range part_sets,
const char *  tag_name = NULL 
)

return partition sets; if tag_name is input, gets sets with that tag name, otherwise uses PARALLEL_PARTITION tag

Definition at line 12 of file ParallelData.cpp.

{
  Tag part_tag = 0;
  ErrorCode result;
  
  if (NULL != tag_name) 
    result = mbImpl->tag_get_handle(tag_name, 1, MB_TYPE_INTEGER, part_tag);
  else
    result = mbImpl->tag_get_handle(PARALLEL_PARTITION_TAG_NAME, 1, MB_TYPE_INTEGER, part_tag);
    
  if (MB_SUCCESS != result) return result;
  else if (0 == part_tag) return MB_TAG_NOT_FOUND;
  
  result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &part_tag, 
                                                NULL, 1, part_sets,
                                                Interface::UNION);
  return result;
}

Member Data Documentation

interface instance to which this instance corresponds

Definition at line 44 of file ParallelData.hpp.

ParallelComm object to which this is bound.

Definition at line 47 of file ParallelData.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines