| 1 |
// Copyright (C) 2017 Tormod Landet |
| 2 |
// |
| 3 |
// This file is part of DOLFIN. |
| 4 |
// |
| 5 |
// DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU Lesser General Public License as published by |
| 7 |
// the Free Software Foundation, either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// DOLFIN is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU Lesser General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU Lesser General Public License |
| 16 |
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#ifndef __MPI_COMM_WRAPPER_H |
| 19 |
#define __MPI_COMM_WRAPPER_H |
| 20 |
|
| 21 |
#include <dolfin/common/MPI.h> |
| 22 |
|
| 23 |
namespace dolfin_wrappers |
| 24 |
{ |
| 25 |
|
| 26 |
/// This class wraps the MPI_Comm type for use in the pybind11 |
| 27 |
/// generation of python wrappers. MPI_Comm is either a pointer or |
| 28 |
/// an int (MPICH vs OpenMPI) and this cannot be wrapped in a type |
| 29 |
/// safe way with pybind11. |
| 30 |
|
| 31 |
class MPICommWrapper |
| 32 |
{ |
| 33 |
public: |
| 34 |
|
| 35 |
MPICommWrapper(); |
| 36 |
|
| 37 |
/// Wrap a MPI_Comm object |
| 38 |
MPICommWrapper(MPI_Comm comm); |
| 39 |
|
| 40 |
/// Assignment operator |
| 41 |
MPICommWrapper& operator=(const MPI_Comm comm); |
| 42 |
|
| 43 |
/// Get the underlying MPI communicator |
| 44 |
MPI_Comm get() const; |
| 45 |
|
| 46 |
private: |
| 47 |
|
| 48 |
// The underlying communicator |
| 49 |
MPI_Comm _comm; |
| 50 |
|
| 51 |
}; |
| 52 |
} |
| 53 |
|
| 54 |
#endif |