diff --git a/CMakeLists.txt b/CMakeLists.txt index 14eca8625e989d3e44b55fedf8f1a0ddfea17b1a..73083d29f17734f7e1e76889c042119b084c1bfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,3 +3,4 @@ add_python_targets(geometry _referenceelements quadpy ) +dune_add_pybind11_module(NAME _geometry) diff --git a/__init__.py b/__init__.py index 67e19d2d885476ec2b7bdb5aedbbbc8d36425b0e..857d92734bbf56d26b6b6159244301794d3fdf4a 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ -from .._geometry import * +from ._geometry import * from ._referenceelements import * import numpy diff --git a/_geometry.cc b/_geometry.cc new file mode 100644 index 0000000000000000000000000000000000000000..defba1f4b21dbc5856a5597b76af675e9bd56806 --- /dev/null +++ b/_geometry.cc @@ -0,0 +1,25 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#include <dune/python/geometry/type.hh> +#include <dune/python/pybind11/pybind11.h> + +PYBIND11_MODULE( _geometry, module ) +{ + Dune::Python::registerGeometryType( module ); + + // register geometry type contuctors + module.def( "simplex", [] ( int dim ) { return Dune::GeometryTypes::simplex( dim ); } ); + module.def( "cube", [] ( int dim ) { return Dune::GeometryTypes::cube( dim ); } ); + module.def( "none", [] ( int dim ) { return Dune::GeometryTypes::none( dim ); } ); + + // register predefined geometry types + module.attr( "vertex" ) = Dune::GeometryTypes::vertex; + module.attr( "line" ) = Dune::GeometryTypes::line; + module.attr( "triangle" ) = Dune::GeometryTypes::triangle; + module.attr( "quadrilateral" ) = Dune::GeometryTypes::quadrilateral; + module.attr( "tetrahedron" ) = Dune::GeometryTypes::tetrahedron; + module.attr( "pyramid" ) = Dune::GeometryTypes::pyramid; + module.attr( "prism" ) = Dune::GeometryTypes::prism; + module.attr( "hexahedron" ) = Dune::GeometryTypes::hexahedron; +}