#ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef DUNE_NICE_FUNCTION_MODULE_PATH #error DUNE_NICE_FUNCTION_MODULE_PATH unset #endif #ifndef HAVE_PYTHON #error Python is necessary #else #define EMBEDDED_PYTHON 1 #endif #include <Python.h> #include <dune/common/exceptions.hh> #include <dune/common/stdstreams.hh> #include <dune/fufem/dunepython.hh> #include <dune/fufem/sharedpointermap.hh> int main() { typedef Dune::VirtualFunction<double, double> Function; typedef SharedPointerMap<std::string, Function> FunctionMap; FunctionMap functions; try { Python::start(); Python::run("import sys"); std::string importString("sys.path.append('"); importString += DUNE_NICE_FUNCTION_MODULE_PATH; importString += "')"; Python::run(importString.c_str()); Python::Reference module = Python::import("nicefunction"); Python::Reference funcRef = module.get("Functions"); funcRef.toC<FunctionMap::Base>(functions); double const in(2.0); Function const &foo = functions.get("sampleFunction"); double out; foo.evaluate(in, out); Python::stop(); } catch (Dune::Exception &e) { Dune::derr << "Dune reported error: " << e << std::endl; } }