version 0.4.1
python/basis/basis.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
9#pragma once
10
11#include <dune/functions/functionspacebases/lagrangebasis.hh>
12#include <dune/functions/functionspacebases/powerbasis.hh>
13#include <dune/grid/yaspgrid.hh>
14#include <dune/python/common/typeregistry.hh>
15#include <dune/python/pybind11/eigen.h>
16#include <dune/python/pybind11/functional.h>
17#include <dune/python/pybind11/pybind11.h>
18#include <dune/python/pybind11/stl.h>
19
21#include <ikarus/utils/basis.hh>
22
23namespace Ikarus::Python {
24
36template <class BasisHandler, class... options>
37void registerBasisHandler(pybind11::handle scope, pybind11::class_<BasisHandler, options...> cls) {
38 using pybind11::operator""_a;
39
40 using GridView = typename BasisHandler::GridView;
41 using PreBasis = typename BasisHandler::PreBasis;
42 using UntouchedBasis = typename BasisHandler::UntouchedBasis;
43 using FlatBasis = typename BasisHandler::FlatBasis;
44
45 cls.def(pybind11::init([](const UntouchedBasis& gb) { return new BasisHandler(gb.preBasis()); }));
46
47 cls.def("flat", [](BasisHandler& self) { return self.flat(); }, pybind11::return_value_policy::reference);
48
49 cls.def("untouched", [](BasisHandler& self) { return self.untouched(); }, pybind11::return_value_policy::reference);
50}
51
52} // namespace Ikarus::Python
Definition of the LinearElastic class for finite element mechanics computations.
void registerBasisHandler(pybind11::handle scope, pybind11::class_< BasisHandler, options... > cls)
Register a Python wrapper for an Ikarus basis class.
Definition: python/basis/basis.hh:37
void init(int argc, char **argv, bool enableFileLogger=true)
Initializes the Ikarus framework.
Definition: init.hh:82
Definition: flatassembler.hh:21
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:30
auto & flat()
Returns a reference to the flat version of the basis.
Definition: utils/basis.hh:55
decltype(Dune::Functions::DefaultGlobalBasis(std::declval< PreBasis >())) UntouchedBasis
The type of the untouched basis.
Definition: utils/basis.hh:35
decltype(Dune::Functions::DefaultGlobalBasis(Ikarus::flatPreBasis(std::declval< PreBasis >()))) FlatBasis
The type of the flattened basis.
Definition: utils/basis.hh:37
auto & untouched()
Returns a reference to the untouched version of the basis.
Definition: utils/basis.hh:62
typename PreBasis::GridView GridView
The type of the grid view.
Definition: utils/basis.hh:33
PB PreBasis
The type of the untouched pre basis.
Definition: utils/basis.hh:32
Wrapper around Dune-functions global basis.