Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
moab::ProcessSet Class Reference

Represent a set of processes using a bit vector. More...

#include <ProcessSet.hpp>

Public Types

enum  { SHARED_PROC_BYTES = ( MAX_SHARING_PROCS / 8 + ( MAX_SHARING_PROCS % 8 ? 1 : 0 ) ) }

Public Member Functions

 ProcessSet ()
 ProcessSet (const unsigned char *psetbits)
 ~ProcessSet ()
void unite (const ProcessSet &other)
void intersect (const ProcessSet &other)
void clear ()
void set_process_member (int i)
 Add a process to this process set.
void set_process_members (const std::vector< int > &procs)
 Add each process in the input vector to this process set.
bool get_process_members (int rank, std::vector< int > &procs)
 Retrieve a vector containing processes in this set.
bool is_process_member (int i) const
const unsigned char * data () const
bool operator< (const ProcessSet &other) const

Protected Attributes

unsigned char processes [SHARED_PROC_BYTES]

Friends

std::ostream & operator<< (std::ostream &os, const ProcessSet &pset)

Detailed Description

Represent a set of processes using a bit vector.

This is used by the mesh refiner when determining where to record split vertices so that labeling can be inferred across process boundaries without communicating anything other than the number of entities in a given partition.

Definition at line 35 of file ProcessSet.hpp.


Member Enumeration Documentation

anonymous enum
Enumerator:
SHARED_PROC_BYTES 

Definition at line 38 of file ProcessSet.hpp.

    {
        SHARED_PROC_BYTES = ( MAX_SHARING_PROCS / 8 + ( MAX_SHARING_PROCS % 8 ? 1 : 0 ) )
    };

Constructor & Destructor Documentation

Definition at line 8 of file ProcessSet.cpp.

References clear().

{
    this->clear();
}
moab::ProcessSet::ProcessSet ( const unsigned char *  psetbits)

Definition at line 13 of file ProcessSet.cpp.

References processes, and SHARED_PROC_BYTES.

{
    for( int i = 0; i < SHARED_PROC_BYTES; ++i )
        this->processes[i] = psetbits[i];
}

Definition at line 19 of file ProcessSet.cpp.

{}

Member Function Documentation

Definition at line 37 of file ProcessSet.cpp.

References processes, and SHARED_PROC_BYTES.

Referenced by moab::RefinerTagManager::get_common_processes(), and ProcessSet().

{
    memset( this->processes, 0, SHARED_PROC_BYTES );
}
const unsigned char * moab::ProcessSet::data ( ) const

Definition at line 114 of file ProcessSet.cpp.

References processes.

{
    return this->processes;
}
bool moab::ProcessSet::get_process_members ( int  rank,
std::vector< int > &  procs 
)

Retrieve a vector containing processes in this set.

Parameters:
[in]rankThe rank of the local process. This integer will not be included in the output list.
[out]procsThe vector in which the list of sharing processes is listed.
Returns:
True when rank is the owning process and false otherwise.

Definition at line 75 of file ProcessSet.cpp.

References MAX_SHARING_PROCS, processes, and SHARED_PROC_BYTES.

Referenced by moab::RefinerTagManager::set_sharing().

{
    int i = 0;
    assert( rank >= 0 );
    procs.clear();
    bool rank_owner = false;
    for( int byte = 0; byte < SHARED_PROC_BYTES; ++byte )
    {
        i = byte * 8;
        for( unsigned char val = this->processes[byte]; val; ++i, val >>= 1 )
        {
            if( val & 0x1 )
            {
                if( i != rank )
                {
                    // std::cout << " " << i;
                    procs.push_back( i );
                }
                else if( !procs.size() )
                {
                    rank_owner = true;
                }
            }
        }
    }
    for( i = procs.size(); i < MAX_SHARING_PROCS; ++i )
    {
        procs.push_back( -1 );  // pad with invalid values
    }
    return rank_owner;
}
void moab::ProcessSet::intersect ( const ProcessSet other)

Definition at line 29 of file ProcessSet.cpp.

References processes, and SHARED_PROC_BYTES.

Referenced by moab::RefinerTagManager::get_common_processes().

{
    for( int i = 0; i < SHARED_PROC_BYTES; ++i )
    {
        this->processes[i] &= other.processes[i];
    }
}
bool moab::ProcessSet::is_process_member ( int  i) const

Definition at line 107 of file ProcessSet.cpp.

References processes.

Referenced by moab::operator<<().

{
    int byte    = i / 8;
    int bitmask = 1 << ( i % 8 );
    return ( this->processes[byte] & bitmask ) ? true : false;
}
bool moab::ProcessSet::operator< ( const ProcessSet other) const

Definition at line 119 of file ProcessSet.cpp.

References processes, and SHARED_PROC_BYTES.

{
    for( int i = 0; i < SHARED_PROC_BYTES; ++i )
    {
        if( this->processes[i] < other.processes[i] )
            return true;
        else if( this->processes[i] > other.processes[i] )
            return false;
    }
    return false;  // equality
}

Add a process to this process set.

This does not verify that proc is within the range [0,MAX_SHARING_PROCS[ . You are responsible for that.

Definition at line 47 of file ProcessSet.cpp.

References processes.

Referenced by moab::RefinerTagManager::get_common_processes(), and set_process_members().

{
    int byte    = proc / 8;
    int bitmask = 1 << ( proc % 8 );
    this->processes[byte] |= bitmask;
}
void moab::ProcessSet::set_process_members ( const std::vector< int > &  procs)

Add each process in the input vector to this process set.

This is a convenience routine that calls set_process_member() for each entry in the vector. This does not verify that proc is within the range [0,MAX_SHARING_PROCS[ . You are responsible for that.

Definition at line 60 of file ProcessSet.cpp.

References set_process_member().

Referenced by moab::RefinerTagManager::get_common_processes().

{
    for( std::vector< int >::const_iterator it = procs.begin(); it != procs.end() && *it != -1; ++it )
    {
        this->set_process_member( *it );
    }
}
void moab::ProcessSet::unite ( const ProcessSet other)

Definition at line 21 of file ProcessSet.cpp.

References processes, and SHARED_PROC_BYTES.

Referenced by moab::RefinerTagManager::get_common_processes().

{
    for( int i = 0; i < SHARED_PROC_BYTES; ++i )
    {
        this->processes[i] |= other.processes[i];
    }
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ProcessSet pset 
) [friend]

Definition at line 131 of file ProcessSet.cpp.

{
    for( int i = 0; i < MAX_SHARING_PROCS; ++i )
    {
        os << ( pset.is_process_member( i ) ? "1" : "0" );
    }
    return os;
}

Member Data Documentation

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