File: MPICommWrapper.h

package info (click to toggle)
fenics-dolfinx 1%3A0.10.0.post4-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,028 kB
  • sloc: cpp: 36,535; python: 25,391; makefile: 226; sh: 171; xml: 55
file content (40 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (4)
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
// Copyright (C) 2017 Tormod Landet
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier:    LGPL-3.0-or-later

#pragma once

#include <dolfinx/common/MPI.h>

namespace dolfinx_wrappers
{
/// This class wraps the MPI_Comm type for use in the nanobind
/// generation of python wrappers. MPI_Comm is either a pointer or an
/// int (MPICH vs OpenMPI) and this cannot be wrapped in a type safe way
/// with nanobind

class MPICommWrapper
{
public:
  MPICommWrapper() : _comm(MPI_COMM_NULL) {}

  /// Wrap a MPI_Comm object
  MPICommWrapper(MPI_Comm comm) : _comm(comm) {}

  /// Assignment operator
  MPICommWrapper& operator=(const MPI_Comm comm)
  {
    this->_comm = comm;
    return *this;
  }

  /// Get the underlying MPI communicator
  MPI_Comm get() const { return _comm; }

private:
  // The underlying communicator
  MPI_Comm _comm;
};
} // namespace dolfinx_wrappers