Debian Codegraph @

python/dune/istl/_istl.cc

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 // -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #include <dune/common/fmatrix.hh>
6
7 #include <dune/istl/bcrsmatrix.hh>
8 #include <dune/istl/bvector.hh>
9
10 #include <dune/python/common/fvector.hh>
11 #include <dune/python/istl/bcrsmatrix.hh>
12 #include <dune/python/istl/bvector.hh>
13 #include <dune/python/istl/operators.hh>
14 #include <dune/python/istl/preconditioners.hh>
15 #include <dune/python/istl/solvers.hh>
16
17 #include <dune/python/pybind11/pybind11.h>
18
19 #include <dune/python/common/typeregistry.hh>
20
21 PYBIND11_MODULE( _istl, module )
22 {
23 // export solver category
24 pybind11::enum_< Dune::SolverCategory::Category > solverCategory( module, "SolverCategory" );
25 solverCategory.value( "sequential", Dune::SolverCategory::sequential );
26 solverCategory.value( "nonoverlapping", Dune::SolverCategory::nonoverlapping );
27 solverCategory.value( "overlapping", Dune::SolverCategory::overlapping );
28
29 // export block vector with block size 1
30 typedef Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector;
31 Dune::Python::registerBlockVector< Vector >( module );
32
33 // export linear operator, preconditioners, and solvers for blockvectors with block size 1
34 pybind11::class_< Dune::LinearOperator< Vector, Vector > > clsLinearOperator( module, "LinearOperator" );
35 Dune::Python::registerLinearOperator( clsLinearOperator );
36 Dune::Python::registerPreconditioners( module, clsLinearOperator );
37 Dune::Python::registerSolvers( module, clsLinearOperator );
38
39 // export BCRS matrix with block size 1x1
40 typedef Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix;
41
42 // register the BCRS matrix of size 1-1 in the type registry
43 Dune::Python::registerBCRSMatrix< Matrix >( module );
44
45 // export buildmode
46 using BuildMode = Matrix::BuildMode;
47 pybind11::enum_< BuildMode > buildMode( module, "BuildMode" );
48 buildMode.value( "row_wise", BuildMode::row_wise );
49 buildMode.value( "random", BuildMode::random );
50 buildMode.value( "implicit", BuildMode::implicit );
51 buildMode.value( "unknown", BuildMode::unknown );
52
53
54 // export matrix-based preconditioners for BCRS matrix with block size 1x1
55 Dune::Python::registerMatrixPreconditioners< Matrix >( module, clsLinearOperator );
56 }