version 0.4.1
boundarypatch.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <dune/common/bitsetvector.hh>
7#include <dune/python/pybind11/eigen.h>
8#include <dune/python/pybind11/functional.h>
9#include <dune/python/pybind11/pybind11.h>
10#include <dune/python/pybind11/stl.h>
11
12namespace Ikarus::Python {
13
14// Python wrapper for the BoundaryPatch C++ class
15template <class BoundaryPatch, class... options>
16void registerBoundaryPatch(pybind11::handle scope, pybind11::class_<BoundaryPatch, options...> cls) {
17 using pybind11::operator""_a;
18
19 using GridView = typename BoundaryPatch::GridView;
20
21 cls.def(pybind11::init([](const GridView& gv, Eigen::Ref<Eigen::VectorX<bool>> vec) {
22 Dune::BitSetVector<1> bitSetVector;
23 bitSetVector.resize(vec.size());
24 for (size_t i = 0; i < vec.size(); ++i)
25 bitSetVector[i] = vec[i];
26 return new BoundaryPatch(gv, bitSetVector);
27 }),
28 pybind11::keep_alive<1, 2>(), pybind11::keep_alive<1, 3>());
29
30 cls.def("gridView", &BoundaryPatch::gridView);
31}
32
33} // namespace Ikarus::Python
void init(int argc, char **argv, bool enableFileLogger=true)
Initializes the Ikarus framework.
Definition: init.hh:82
Definition: flatassembler.hh:21
void registerBoundaryPatch(pybind11::handle scope, pybind11::class_< BoundaryPatch, options... > cls)
Definition: boundarypatch.hh:16