Actual source code: pythonsnes.c

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

      3: /*@
      4:    SNESPythonSetType - Initialize a `SNES` object implemented in Python.

      6:    Collective

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

     12:    Options Database Key:
     13: .  -snes_python_type <pyname> - python class

     15:    Level: intermediate

     17: .seealso: [](ch_snes), `SNES`, `SNESCreate()`, `SNESSetType()`, `SNESPYTHON`, `PetscPythonInitialize()`, `SNESPythonGetType()`
     18: @*/
     19: PetscErrorCode SNESPythonSetType(SNES snes, const char pyname[])
     20: {
     21:   PetscFunctionBegin;
     23:   PetscAssertPointer(pyname, 2);
     24:   PetscTryMethod(snes, "SNESPythonSetType_C", (SNES, const char[]), (snes, pyname));
     25:   PetscFunctionReturn(PETSC_SUCCESS);
     26: }

     28: /*@
     29:    SNESPythonGetType - Get the type of a `SNES` object implemented in Python set with `SNESPythonSetType()`

     31:    Not Collective

     33:    Input Parameter:
     34: .  snes - the nonlinear solver (`SNES`) context.

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

     39:    Level: intermediate

     41: .seealso: [](ch_snes), `SNES`, `SNESCreate()`, `SNESSetType()`, `SNESPYTHON`, `PetscPythonInitialize()`, `SNESPythonSetType()`
     42: @*/
     43: PetscErrorCode SNESPythonGetType(SNES snes, const char *pyname[])
     44: {
     45:   PetscFunctionBegin;
     47:   PetscAssertPointer(pyname, 2);
     48:   PetscUseMethod(snes, "SNESPythonGetType_C", (SNES, const char *[]), (snes, pyname));
     49:   PetscFunctionReturn(PETSC_SUCCESS);
     50: }