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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
 * storing and accessing finite element mesh data.
 *
 * Copyright 2004 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_PROC_CONFIG_HPP
#define MOAB_PROC_CONFIG_HPP

#include "moab_mpi.h"

#include "moab/Types.hpp"
#include "moab/Range.hpp"
#include "moab/gs.hpp"

namespace moab
{

class Interface;

/**\brief Multi-CPU information for parallel MOAB */
class ProcConfig
{
  public:
    ProcConfig( MPI_Comm proc_comm );

    ~ProcConfig();

    //! Get the current processor number
    unsigned proc_rank() const
    {
        return procRank;
    }

    //! Get the number of processors
    unsigned proc_size() const
    {
        return procSize;
    }

    //! get a crystal router for this parallel job
    gs_data::crystal_data* crystal_router( bool construct_if_missing = true );

    //! get/set the communicator for this proc config
    MPI_Comm proc_comm() const
    {
        return procComm;
    }
    void proc_comm( MPI_Comm this_comm )
    {
        procComm = this_comm;
    }

    //! set rank/size; USED FOR TESTING ONLY!
    void proc_rank( unsigned r )
    {
        procRank = r;
    }
    void proc_size( unsigned s )
    {
        procSize = s;
    }

  private:
    //! MPI communicator set for this instance
    MPI_Comm procComm;

    //! rank of this processor
    unsigned procRank;

    //! number of processors
    unsigned procSize;

    //! crystal router for this parallel job
    gs_data::crystal_data* crystalData;
};

}  // namespace moab

#endif