xref: /petsc/src/snes/impls/python/pythonsnes.c (revision d71ae5a4db6382e7f06317b8d368875286fe9008)
1 #include <petsc/private/snesimpl.h> /*I "petscsnes.h" I*/
2 
3 /*@C
4    SNESPythonSetType - Initialize a `SNES` object implemented in Python.
5 
6    Collective on snes
7 
8    Input Parameters:
9 +  snes - the nonlinear solver (`SNES`) context.
10 -  pyname - full dotted Python name [package].module[.{class|function}]
11 
12    Options Database Key:
13 .  -snes_python_type <pyname> - python class
14 
15    Level: intermediate
16 
17 .seealso: `SNESCreate()`, `SNESSetType()`, `SNESPYTHON`, `PetscPythonInitialize()`, `SNESPythonGetType()`
18 @*/
19 PetscErrorCode SNESPythonSetType(SNES snes, const char pyname[])
20 {
21   PetscFunctionBegin;
22   PetscValidHeaderSpecific(snes, SNES_CLASSID, 1);
23   PetscValidCharPointer(pyname, 2);
24   PetscTryMethod(snes, "SNESPythonSetType_C", (SNES, const char[]), (snes, pyname));
25   PetscFunctionReturn(0);
26 }
27 
28 /*@C
29    SNESPythonGetType - Get the type of a `SNES` object implemented in Python.
30 
31    Not collective
32 
33    Input Parameter:
34 .  snes - the nonlinear solver (`SNES`) context.
35 
36    Output Parameter:
37 .  pyname - full dotted Python name [package].module[.{class|function}]
38 
39    Level: intermediate
40 
41 .seealso: `SNESCreate()`, `SNESSetType()`, `SNESPYTHON`, `PetscPythonInitialize()`, `SNESPythonSetType()`
42 @*/
43 PetscErrorCode SNESPythonGetType(SNES snes, const char *pyname[])
44 {
45   PetscFunctionBegin;
46   PetscValidHeaderSpecific(snes, SNES_CLASSID, 1);
47   PetscValidPointer(pyname, 2);
48   PetscUseMethod(snes, "SNESPythonGetType_C", (SNES, const char *[]), (snes, pyname));
49   PetscFunctionReturn(0);
50 }
51