// python wrapper for vtkRungeKutta45 // #define VTK_WRAPPING_CXX #define VTK_STREAMS_FWD_ONLY #include "vtkPythonArgs.h" #include "vtkPythonOverload.h" #include "vtkConfigure.h" #include #include #include "vtkVariant.h" #include "vtkIndent.h" #include "vtkRungeKutta45.h" extern "C" { VTK_ABI_EXPORT void PyVTKAddFile_vtkRungeKutta45(PyObject *); } extern "C" { VTK_ABI_EXPORT PyObject *PyvtkRungeKutta45_ClassNew(); } #ifndef DECLARED_PyvtkInitialValueProblemSolver_ClassNew extern "C" { PyObject *PyvtkInitialValueProblemSolver_ClassNew(); } #define DECLARED_PyvtkInitialValueProblemSolver_ClassNew #endif static const char *PyvtkRungeKutta45_Doc = "vtkRungeKutta45 - Integrate an initial value problem using 5th order\nRunge-Kutta method with adaptive stepsize control.\n\n" "Superclass: vtkInitialValueProblemSolver\n\n" "This is a concrete sub-class of vtkInitialValueProblemSolver. It uses\n" "a 5th order Runge-Kutta method with stepsize control to obtain the\n" "values of a set of functions at the next time step. The stepsize is\n" "adjusted by calculating an estimated error using an embedded 4th\n" "order Runge-Kutta formula: Press, W. H. et al., 1992, Numerical\n" "Recipes in Fortran, Second Edition, Cambridge University Press Cash,\n" "J.R. and Karp, A.H. 1990, ACM Transactions on Mathematical Software,\n" "vol 16, pp 201-222\n\n" "@sa\n" "vtkInitialValueProblemSolver vtkRungeKutta4 vtkRungeKutta2\n" "vtkFunctionSet\n\n"; static PyObject * PyvtkRungeKutta45_IsTypeOf(PyObject *, PyObject *args) { vtkPythonArgs ap(args, "IsTypeOf"); char *temp0 = nullptr; PyObject *result = nullptr; if (ap.CheckArgCount(1) && ap.GetValue(temp0)) { int tempr = vtkRungeKutta45::IsTypeOf(temp0); if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_IsA(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "IsA"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); char *temp0 = nullptr; PyObject *result = nullptr; if (op && ap.CheckArgCount(1) && ap.GetValue(temp0)) { int tempr = (ap.IsBound() ? op->IsA(temp0) : op->vtkRungeKutta45::IsA(temp0)); if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_SafeDownCast(PyObject *, PyObject *args) { vtkPythonArgs ap(args, "SafeDownCast"); vtkObjectBase *temp0 = nullptr; PyObject *result = nullptr; if (ap.CheckArgCount(1) && ap.GetVTKObject(temp0, "vtkObjectBase")) { vtkRungeKutta45 *tempr = vtkRungeKutta45::SafeDownCast(temp0); if (!ap.ErrorOccurred()) { result = ap.BuildVTKObject(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_NewInstance(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "NewInstance"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); PyObject *result = nullptr; if (op && ap.CheckArgCount(0)) { vtkRungeKutta45 *tempr = (ap.IsBound() ? op->NewInstance() : op->vtkRungeKutta45::NewInstance()); if (!ap.ErrorOccurred()) { result = ap.BuildVTKObject(tempr); if (result && PyVTKObject_Check(result)) { PyVTKObject_GetObject(result)->UnRegister(0); PyVTKObject_SetFlag(result, VTK_PYTHON_IGNORE_UNREGISTER, 1); } } } return result; } static PyObject * PyvtkRungeKutta45_ComputeNextStep_s1(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "ComputeNextStep"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); int size0 = ap.GetArgSize(0); vtkPythonArgs::Array store0(2*size0); double *temp0 = store0.Data(); double *save0 = (size0 == 0 ? nullptr : temp0 + size0); int size1 = ap.GetArgSize(1); vtkPythonArgs::Array store1(2*size1); double *temp1 = store1.Data(); double *save1 = (size1 == 0 ? nullptr : temp1 + size1); double temp2; double temp3; double temp4; double temp5; PyObject *result = nullptr; if (op && ap.CheckArgCount(6) && ap.GetArray(temp0, size0) && ap.GetArray(temp1, size1) && ap.GetValue(temp2) && ap.GetValue(temp3) && ap.GetValue(temp4) && ap.GetValue(temp5)) { ap.SaveArray(temp0, save0, size0); ap.SaveArray(temp1, save1, size1); int tempr = (ap.IsBound() ? op->ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5) : op->vtkRungeKutta45::ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5)); if (ap.ArrayHasChanged(temp0, save0, size0) && !ap.ErrorOccurred()) { ap.SetArray(0, temp0, size0); } if (ap.ArrayHasChanged(temp1, save1, size1) && !ap.ErrorOccurred()) { ap.SetArray(1, temp1, size1); } if (!ap.ErrorOccurred()) { ap.SetArgValue(3, temp3); } if (!ap.ErrorOccurred()) { ap.SetArgValue(5, temp5); } if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_ComputeNextStep_s2(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "ComputeNextStep"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); int size0 = ap.GetArgSize(0); vtkPythonArgs::Array store0(2*size0); double *temp0 = store0.Data(); double *save0 = (size0 == 0 ? nullptr : temp0 + size0); int size1 = ap.GetArgSize(1); vtkPythonArgs::Array store1(2*size1); double *temp1 = store1.Data(); double *save1 = (size1 == 0 ? nullptr : temp1 + size1); int size2 = ap.GetArgSize(2); vtkPythonArgs::Array store2(2*size2); double *temp2 = store2.Data(); double *save2 = (size2 == 0 ? nullptr : temp2 + size2); double temp3; double temp4; double temp5; double temp6; PyObject *result = nullptr; if (op && ap.CheckArgCount(7) && ap.GetArray(temp0, size0) && ap.GetArray(temp1, size1) && ap.GetArray(temp2, size2) && ap.GetValue(temp3) && ap.GetValue(temp4) && ap.GetValue(temp5) && ap.GetValue(temp6)) { ap.SaveArray(temp0, save0, size0); ap.SaveArray(temp1, save1, size1); ap.SaveArray(temp2, save2, size2); int tempr = (ap.IsBound() ? op->ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6) : op->vtkRungeKutta45::ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6)); if (ap.ArrayHasChanged(temp0, save0, size0) && !ap.ErrorOccurred()) { ap.SetArray(0, temp0, size0); } if (ap.ArrayHasChanged(temp1, save1, size1) && !ap.ErrorOccurred()) { ap.SetArray(1, temp1, size1); } if (ap.ArrayHasChanged(temp2, save2, size2) && !ap.ErrorOccurred()) { ap.SetArray(2, temp2, size2); } if (!ap.ErrorOccurred()) { ap.SetArgValue(4, temp4); } if (!ap.ErrorOccurred()) { ap.SetArgValue(6, temp6); } if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_ComputeNextStep_s3(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "ComputeNextStep"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); int size0 = ap.GetArgSize(0); vtkPythonArgs::Array store0(2*size0); double *temp0 = store0.Data(); double *save0 = (size0 == 0 ? nullptr : temp0 + size0); int size1 = ap.GetArgSize(1); vtkPythonArgs::Array store1(2*size1); double *temp1 = store1.Data(); double *save1 = (size1 == 0 ? nullptr : temp1 + size1); double temp2; double temp3; double temp4; double temp5; double temp6; double temp7; double temp8; PyObject *result = nullptr; if (op && ap.CheckArgCount(9) && ap.GetArray(temp0, size0) && ap.GetArray(temp1, size1) && ap.GetValue(temp2) && ap.GetValue(temp3) && ap.GetValue(temp4) && ap.GetValue(temp5) && ap.GetValue(temp6) && ap.GetValue(temp7) && ap.GetValue(temp8)) { ap.SaveArray(temp0, save0, size0); ap.SaveArray(temp1, save1, size1); int tempr = (ap.IsBound() ? op->ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8) : op->vtkRungeKutta45::ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8)); if (ap.ArrayHasChanged(temp0, save0, size0) && !ap.ErrorOccurred()) { ap.SetArray(0, temp0, size0); } if (ap.ArrayHasChanged(temp1, save1, size1) && !ap.ErrorOccurred()) { ap.SetArray(1, temp1, size1); } if (!ap.ErrorOccurred()) { ap.SetArgValue(3, temp3); } if (!ap.ErrorOccurred()) { ap.SetArgValue(4, temp4); } if (!ap.ErrorOccurred()) { ap.SetArgValue(8, temp8); } if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_ComputeNextStep_s4(PyObject *self, PyObject *args) { vtkPythonArgs ap(self, args, "ComputeNextStep"); vtkObjectBase *vp = ap.GetSelfPointer(self, args); vtkRungeKutta45 *op = static_cast(vp); int size0 = ap.GetArgSize(0); vtkPythonArgs::Array store0(2*size0); double *temp0 = store0.Data(); double *save0 = (size0 == 0 ? nullptr : temp0 + size0); int size1 = ap.GetArgSize(1); vtkPythonArgs::Array store1(2*size1); double *temp1 = store1.Data(); double *save1 = (size1 == 0 ? nullptr : temp1 + size1); int size2 = ap.GetArgSize(2); vtkPythonArgs::Array store2(2*size2); double *temp2 = store2.Data(); double *save2 = (size2 == 0 ? nullptr : temp2 + size2); double temp3; double temp4; double temp5; double temp6; double temp7; double temp8; double temp9; PyObject *result = nullptr; if (op && ap.CheckArgCount(10) && ap.GetArray(temp0, size0) && ap.GetArray(temp1, size1) && ap.GetArray(temp2, size2) && ap.GetValue(temp3) && ap.GetValue(temp4) && ap.GetValue(temp5) && ap.GetValue(temp6) && ap.GetValue(temp7) && ap.GetValue(temp8) && ap.GetValue(temp9)) { ap.SaveArray(temp0, save0, size0); ap.SaveArray(temp1, save1, size1); ap.SaveArray(temp2, save2, size2); int tempr = (ap.IsBound() ? op->ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9) : op->vtkRungeKutta45::ComputeNextStep(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9)); if (ap.ArrayHasChanged(temp0, save0, size0) && !ap.ErrorOccurred()) { ap.SetArray(0, temp0, size0); } if (ap.ArrayHasChanged(temp1, save1, size1) && !ap.ErrorOccurred()) { ap.SetArray(1, temp1, size1); } if (ap.ArrayHasChanged(temp2, save2, size2) && !ap.ErrorOccurred()) { ap.SetArray(2, temp2, size2); } if (!ap.ErrorOccurred()) { ap.SetArgValue(4, temp4); } if (!ap.ErrorOccurred()) { ap.SetArgValue(5, temp5); } if (!ap.ErrorOccurred()) { ap.SetArgValue(9, temp9); } if (!ap.ErrorOccurred()) { result = ap.BuildValue(tempr); } } return result; } static PyObject * PyvtkRungeKutta45_ComputeNextStep(PyObject *self, PyObject *args) { int nargs = vtkPythonArgs::GetArgCount(self, args); switch(nargs) { case 6: return PyvtkRungeKutta45_ComputeNextStep_s1(self, args); case 7: return PyvtkRungeKutta45_ComputeNextStep_s2(self, args); case 9: return PyvtkRungeKutta45_ComputeNextStep_s3(self, args); case 10: return PyvtkRungeKutta45_ComputeNextStep_s4(self, args); } vtkPythonArgs::ArgCountError(nargs, "ComputeNextStep"); return nullptr; } static PyMethodDef PyvtkRungeKutta45_Methods[] = { {"IsTypeOf", PyvtkRungeKutta45_IsTypeOf, METH_VARARGS, "V.IsTypeOf(string) -> int\nC++: static vtkTypeBool IsTypeOf(const char *type)\n\nReturn 1 if this class type is the same type of (or a subclass\nof) the named class. Returns 0 otherwise. This method works in\ncombination with vtkTypeMacro found in vtkSetGet.h.\n"}, {"IsA", PyvtkRungeKutta45_IsA, METH_VARARGS, "V.IsA(string) -> int\nC++: vtkTypeBool IsA(const char *type) override;\n\nReturn 1 if this class is the same type of (or a subclass of) the\nnamed class. Returns 0 otherwise. This method works in\ncombination with vtkTypeMacro found in vtkSetGet.h.\n"}, {"SafeDownCast", PyvtkRungeKutta45_SafeDownCast, METH_VARARGS, "V.SafeDownCast(vtkObjectBase) -> vtkRungeKutta45\nC++: static vtkRungeKutta45 *SafeDownCast(vtkObjectBase *o)\n\n"}, {"NewInstance", PyvtkRungeKutta45_NewInstance, METH_VARARGS, "V.NewInstance() -> vtkRungeKutta45\nC++: vtkRungeKutta45 *NewInstance()\n\n"}, {"ComputeNextStep", PyvtkRungeKutta45_ComputeNextStep, METH_VARARGS, "V.ComputeNextStep([float, ...], [float, ...], float, float, float,\n float) -> int\nC++: int ComputeNextStep(double *xprev, double *xnext, double t,\n double &delT, double maxError, double &error) override;\nV.ComputeNextStep([float, ...], [float, ...], [float, ...], float,\n float, float, float) -> int\nC++: int ComputeNextStep(double *xprev, double *dxprev,\n double *xnext, double t, double &delT, double maxError,\n double &error) override;\nV.ComputeNextStep([float, ...], [float, ...], float, float, float,\n float, float, float, float) -> int\nC++: int ComputeNextStep(double *xprev, double *xnext, double t,\n double &delT, double &delTActual, double minStep,\n double maxStep, double maxError, double &error) override;\nV.ComputeNextStep([float, ...], [float, ...], [float, ...], float,\n float, float, float, float, float, float) -> int\nC++: int ComputeNextStep(double *xprev, double *dxprev,\n double *xnext, double t, double &delT, double &delTActual,\n double minStep, double maxStep, double maxError,\n double &error) override;\n\nGiven initial values, xprev , initial time, t and a requested\ntime interval, delT calculate values of x at t+delTActual\n(xnext). Possibly delTActual != delT. This may occur because this\nsolver supports adaptive stepsize control. It tries to change to\nstepsize such that the (estimated) error of the integration is\nless than maxError. The solver will not set the stepsize smaller\nthan minStep or larger than maxStep (note that maxStep and\nminStep should both be positive, whereas delT can be negative).\nAlso note that delT is an in/out argument. vtkRungeKutta45 will\nmodify delT to reflect the best (estimated) size for the next\nintegration step. An estimated value for the error is returned\n(by reference) in error. This is the norm of the error vector if\nthere are more than one function to be integrated. This method\nreturns an error code representing the nature of the failure:\nOutOfDomain = 1, NotInitialized = 2, Une ...\n [Truncated]\n"}, {nullptr, nullptr, 0, nullptr} }; static PyTypeObject PyvtkRungeKutta45_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "vtkCommonMathPython.vtkRungeKutta45", // tp_name sizeof(PyVTKObject), // tp_basicsize 0, // tp_itemsize PyVTKObject_Delete, // tp_dealloc 0, // tp_print nullptr, // tp_getattr nullptr, // tp_setattr nullptr, // tp_compare PyVTKObject_Repr, // tp_repr nullptr, // tp_as_number nullptr, // tp_as_sequence nullptr, // tp_as_mapping nullptr, // tp_hash nullptr, // tp_call PyVTKObject_String, // tp_str PyObject_GenericGetAttr, // tp_getattro PyObject_GenericSetAttr, // tp_setattro &PyVTKObject_AsBuffer, // tp_as_buffer Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE, // tp_flags PyvtkRungeKutta45_Doc, // tp_doc PyVTKObject_Traverse, // tp_traverse nullptr, // tp_clear nullptr, // tp_richcompare offsetof(PyVTKObject, vtk_weakreflist), // tp_weaklistoffset nullptr, // tp_iter nullptr, // tp_iternext nullptr, // tp_methods nullptr, // tp_members PyVTKObject_GetSet, // tp_getset nullptr, // tp_base nullptr, // tp_dict nullptr, // tp_descr_get nullptr, // tp_descr_set offsetof(PyVTKObject, vtk_dict), // tp_dictoffset nullptr, // tp_init nullptr, // tp_alloc PyVTKObject_New, // tp_new PyObject_GC_Del, // tp_free nullptr, // tp_is_gc nullptr, // tp_bases nullptr, // tp_mro nullptr, // tp_cache nullptr, // tp_subclasses nullptr, // tp_weaklist VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED }; static vtkObjectBase *PyvtkRungeKutta45_StaticNew() { return vtkRungeKutta45::New(); } PyObject *PyvtkRungeKutta45_ClassNew() { PyVTKClass_Add( &PyvtkRungeKutta45_Type, PyvtkRungeKutta45_Methods, "vtkRungeKutta45", &PyvtkRungeKutta45_StaticNew); PyTypeObject *pytype = &PyvtkRungeKutta45_Type; if ((pytype->tp_flags & Py_TPFLAGS_READY) != 0) { return (PyObject *)pytype; } #if !defined(VTK_PY3K) && PY_VERSION_HEX >= 0x02060000 pytype->tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER; #endif pytype->tp_base = (PyTypeObject *)PyvtkInitialValueProblemSolver_ClassNew(); PyType_Ready(pytype); return (PyObject *)pytype; } void PyVTKAddFile_vtkRungeKutta45( PyObject *dict) { PyObject *o; o = PyvtkRungeKutta45_ClassNew(); if (o && PyDict_SetItemString(dict, "vtkRungeKutta45", o) != 0) { Py_DECREF(o); } }