Actual source code: pythontao.c

      1: #include <petsc/private/taoimpl.h>

      3: /*@
      4:    TaoPythonSetType - Initialize a `Tao` object implemented in Python.

      6:    Collective

      8:    Input Parameters:
      9: +  tao - the optimization solver (`Tao`) context.
     10: -  pyname - full dotted Python name [package].module[.{class|function}]

     12:    Options Database Key:
     13: .  -tao_python_type pyname - python class

     15:    Level: intermediate

     17: .seealso: `TaoCreate()`, `TaoSetType()`, `TAOPYTHON`, `PetscPythonInitialize()`
     18: @*/
     19: PetscErrorCode TaoPythonSetType(Tao tao, const char pyname[])
     20: {
     21:   PetscFunctionBegin;
     23:   PetscAssertPointer(pyname, 2);
     24:   PetscTryMethod(tao, "TaoPythonSetType_C", (Tao, const char[]), (tao, pyname));
     25:   PetscFunctionReturn(PETSC_SUCCESS);
     26: }

     28: /*@
     29:    TaoPythonGetType - Get the type of a `Tao` object implemented in Python.

     31:    Not Collective

     33:    Input Parameter:
     34: .  tao - the optimization solver (`Tao`) context.

     36:    Output Parameter:
     37: .  pyname - full dotted Python name [package].module[.{class|function}]

     39:    Level: intermediate

     41: .seealso: `TaoCreate()`, `TaoSetType()`, `TAOPYTHON`, `PetscPythonInitialize()`, `TaoPythonSetType()`
     42: @*/
     43: PetscErrorCode TaoPythonGetType(Tao tao, const char *pyname[])
     44: {
     45:   PetscFunctionBegin;
     47:   PetscAssertPointer(pyname, 2);
     48:   PetscUseMethod(tao, "TaoPythonGetType_C", (Tao, const char *[]), (tao, pyname));
     49:   PetscFunctionReturn(PETSC_SUCCESS);
     50: }

     52: /*MC
     53:    TAOPYTHON - a `TAOType` that is implemented as a Python class using `TaoPythonSetType()`

     55:    Level: intermediate

     57: .seealso: [](ch_snes), `Tao`, `TaoCreate()`, `TAOSHELL`, `TaoSetType()`, `PetscPythonInitialize()`, `TaoPythonSetType()`,
     58:           `TaoPythonGetType()`, `TSPYTHON`, `SNESPYTHON`
     59: M*/