MOAB: Mesh Oriented datABase  (version 5.3.1)
moab::ParallelData Class Reference

Parallel data in MOAB. More...

#include <ParallelData.hpp>

+ Collaboration diagram for moab::ParallelData:

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 45 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 34 of file ParallelData.cpp.

References moab::Range::begin(), CONTINUE, moab::Range::empty(), moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_type_and_tag(), MAX_SHARING_PROCS, MB_SUCCESS, MB_TYPE_INTEGER, MBENTITYSET, mbImpl, PARALLEL_SHARED_PROC_TAG_NAME, PARALLEL_SHARED_PROCS_TAG_NAME, parallelComm, moab::ParallelComm::proc_config(), moab::ProcConfig::proc_rank(), moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::Interface::tag_get_length(), and moab::Interface::UNION.

{
#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 13 of file ParallelData.cpp.

References ErrorCode, moab::Interface::get_entities_by_type_and_tag(), MB_SUCCESS, MB_TAG_NOT_FOUND, MB_TYPE_INTEGER, MBENTITYSET, mbImpl, PARALLEL_PARTITION_TAG_NAME, moab::Interface::tag_get_handle(), and moab::Interface::UNION.

{
    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 39 of file ParallelData.hpp.

Referenced by get_interface_sets(), and get_partition_sets().

ParallelComm object to which this is bound.

Definition at line 42 of file ParallelData.hpp.

Referenced by get_interface_sets().

List of all members.


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