Debian Codegraph @

dune/python/istl/matrixindexset.hh

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 #ifndef DUNE_PYTHON_ISTL_BCRSMATRIX_HH
4 #define DUNE_PYTHON_ISTL_BCRSMATRIX_HH
5
6 #include <cstdint>
7 #include <memory>
8 #include <stdexcept>
9 #include <string>
10 #include <tuple>
11
12 #include <dune/common/fmatrix.hh>
13 #include <dune/common/fvector.hh>
14
15 #include <dune/istl/matrixindexset.hh>
16
17 #include <dune/python/pybind11/pybind11.h>
18 #include <dune/python/pybind11/stl.h>
19
20 namespace Dune
21 {
22
23 namespace Python
24 {
25
26 // registermatrixindexset
27 // ------------------
28
29 template <class MatrixIndexSet, class... options>
30 void registerMatrixIndexSet(pybind11::handle scope,
31 pybind11::class_<MatrixIndexSet, options...> cls)
32 {
33 using size_type = Dune::MatrixIndexSet::size_type;
34
35 // two different possible constructors
36 cls.def( pybind11::init( [] () { return new MatrixIndexSet(); } ) );
37 cls.def( pybind11::init( [] (size_type rows, size_type cols) { return new MatrixIndexSet(rows,cols); } ) );
38
39 cls.def ( "add", [] (MatrixIndexSet &self, size_type i, size_type j) {self.add(i,j); } );
40
41 cls.def( "exportIdx<BCRSMatrix etc...>", [] (MatrixIndexSet &self) { } );
42 }
43
44 template< class MatrixIndexSet >
45 pybind11::class_< MatrixIndexSet > registerMatrixIndexSet ( pybind11::handle scope, const char *clsName = "MatrixIndexSet" )
46 {
47 pybind11::class_< MatrixIndexSet > cls( scope, clsName );
48 registerMatrixIndexSet( scope, cls );
49 return cls;
50 }
51
52 } // namespace Python
53
54 } // namespace Dune
55
56 #endif // #ifndef DUNE_PYTHON_ISTL_BCRSMATRIX_HH