1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
 * storing and accessing finite element mesh data.
 *
 * Copyright 2007 Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
 * retains certain rights in this software.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 */

#ifndef MOAB_PROCESS_SET_HPP
#define MOAB_PROCESS_SET_HPP

#include "moab/Types.hpp"
#include "moab/ParallelComm.hpp"

#include <iostream>
#include <vector>

namespace moab
{

/**\brief 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.
 */
class ProcessSet
{
  public:
    enum
    {
        SHARED_PROC_BYTES = ( MAX_SHARING_PROCS / 8 + ( MAX_SHARING_PROCS % 8 ? 1 : 0 ) )
    };

    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 );
    void set_process_members( const std::vector< int >& procs );

    bool get_process_members( int rank, std::vector< int >& procs );
    bool is_process_member( int i ) const;

    const unsigned char* data() const;

    bool operator<( const ProcessSet& other ) const;

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

  protected:
    unsigned char processes[SHARED_PROC_BYTES];
};

}  // namespace moab

#endif /* MOAB_PROCESS_SET_HPP */