1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_GRID_PY_PYFUNCTION_HH
#define DUNE_GRID_PY_PYFUNCTION_HH
#warning "The header <dune/python/grid/pygridfunction.hh> is deprecated."
#include <string>
#include <utility>
#include <dune/python/pybind11/pybind11.h>
#include <dune/common/visibility.hh>
namespace Dune
{
namespace Python
{
// PyGridFunction
// --------------
template< class GridFunction >
class DUNE_PRIVATE [[deprecated]] PyGridFunction
{
public:
PyGridFunction ( const GridFunction &impl, pybind11::object pyObj )
: pyObj_( std::move( pyObj ) ), lf_(impl)
{}
PyGridFunction ( const GridFunction &impl )
: pyObj_( pybind11::reinterpret_borrow<pybind11::object>(
pybind11::detail::get_object_handle( &impl, pybind11::detail::get_type_info( typeid( GridFunction ) ) )
) ),
lf_(impl)
{}
template< class Point >
auto evaluate ( const Point &x ) const { return lf_( x ); }
template< class Point >
auto operator() ( const Point &x ) const { return lf_( x ); }
template <class Entity>
void bind(const Entity &entity) { lf_.bind(entity); }
void unbind() { lf_.unbind(); }
// friend PyGridFunction<GridFunction> localFunction ( const PyGridFunction &gf ) { return PyGridFunction( gf ); }
protected:
pybind11::object pyObj_;
typename GridFunction::LocalFunction lf_;
};
// pyGridFunction
// --------------
template< class GridFunction >
inline static PyGridFunction< GridFunction > pyGridFunction ( const GridFunction &gridFunction ) noexcept
{
return PyGridFunction< GridFunction >( gridFunction );
}
template< class GridFunction >
inline static PyGridFunction< GridFunction > pyGridFunction ( const GridFunction &gridFunction, pybind11::object pyObj ) noexcept
{
return PyGridFunction< GridFunction >( gridFunction, std::move( pyObj ) );
}
} // namespace Python
} // namespace Dune
#endif // DUNE_GRID_PY_PYFUNCTION_HH
|