| 1 |
// Copyright (C) 2017 Garth N. Wells |
| 2 |
// |
| 3 |
// This file is part of FFC. |
| 4 |
// |
| 5 |
// FFC 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 |
// FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#include <memory> |
| 19 |
#include <pybind11/pybind11.h> |
| 20 |
#include <ufc.h> |
| 21 |
|
| 22 |
namespace py = pybind11; |
| 23 |
|
| 24 |
namespace ufc_wrappers |
| 25 |
{ |
| 26 |
void finite_element(py::module& m); |
| 27 |
void dofmap(py::module& m); |
| 28 |
} |
| 29 |
|
| 30 |
//PYBIND11_MODULE(ffc_factory, m) |
| 31 |
PYBIND11_PLUGIN(ffc_factory) |
| 32 |
{ |
| 33 |
pybind11::module m("ffc_factory", "Factory for wrapping FFC JIT-compiled objects"); |
| 34 |
|
| 35 |
// Create finite_element submodule |
| 36 |
py::module finite_element = m.def_submodule("finite_element", |
| 37 |
"UFC finite_element"); |
| 38 |
ufc_wrappers::finite_element(finite_element); |
| 39 |
|
| 40 |
// Create dofmap submodule |
| 41 |
py::module dofmap = m.def_submodule("dofmap", "UFC dofmap"); |
| 42 |
ufc_wrappers::dofmap(dofmap); |
| 43 |
|
| 44 |
// Factory functions |
| 45 |
m.def("make_ufc_finite_element", |
| 46 |
[](std::uintptr_t e) |
| 47 |
{ |
| 48 |
ufc::finite_element * p = reinterpret_cast<ufc::finite_element *>(e); |
| 49 |
return std::shared_ptr<const ufc::finite_element>(p); |
| 50 |
}); |
| 51 |
m.def("make_ufc_dofmap", |
| 52 |
[](std::uintptr_t e) |
| 53 |
{ |
| 54 |
ufc::dofmap * p = reinterpret_cast<ufc::dofmap *>(e); |
| 55 |
return std::shared_ptr<const ufc::dofmap>(p); |
| 56 |
}); |
| 57 |
|
| 58 |
return m.ptr(); |
| 59 |
} |