// Copyright (C) 2017 Chris Richardson and Garth N. Wells // // This file is part of DOLFIN. // // DOLFIN is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // DOLFIN is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with DOLFIN. If not, see . #include #include #include #include #include #include #include #include #include #include namespace py = pybind11; namespace dolfin_wrappers { void ts(py::module& m) { #ifdef HAS_SUNDIALS // CVode trampoline class for allowing overloading of virtual functions class PyCVode : public dolfin::CVode { public: using dolfin::CVode::CVode; void derivs(double t, std::shared_ptr u, std::shared_ptr udot) { PYBIND11_OVERLOAD_NAME(void, dolfin::CVode, "derivs", derivs, t, u, udot); } int jacobian(std::shared_ptr v, std::shared_ptr Jv, double t, std::shared_ptr y, std::shared_ptr fy) { PYBIND11_OVERLOAD_NAME(int, dolfin::CVode, "jacobian", jacobian, v, Jv, t, y, fy); } int psolve(double t, std::shared_ptr y, std::shared_ptr fy, std::shared_ptr r, std::shared_ptr z, double gamma, double delta, int lr) { PYBIND11_OVERLOAD_NAME(int, dolfin::CVode, "psolve", psolve, t, y, fy, r, z, gamma, delta, lr); } }; py::class_>cvode(m,"CVode"); //dolfin::CVode cvode .def(py::init()) .def("init", &dolfin::CVode::init, py::arg("u0"), py::arg("atol"), py::arg("rtol"), py::arg("mxsteps")=0) .def("set_time", &dolfin::CVode::set_time, py::arg("t0")) .def("get_time", &dolfin::CVode::get_time) .def("step", &dolfin::CVode::step, py::arg("dt")) .def("statistics", &dolfin::CVode::statistics) .def("derivs", &dolfin::CVode::derivs) .def("jacobian", &dolfin::CVode::jacobian) .def("psolve", &dolfin::CVode::psolve); py::enum_(cvode,"LMM") .value("CV_BDF", dolfin::CVode::LMM::cv_bdf) .value("CV_ADAMS", dolfin::CVode::LMM::cv_adams); py::enum_(cvode,"ITER") .value("CV_FUNCTIONAL", dolfin::CVode::ITER::cv_functional) .value("CV_NEWTON", dolfin::CVode::ITER::cv_newton); #endif } }