xref: /petsc/src/snes/impls/python/pythonsnes.c (revision a69119a591a03a9d906b29c0a4e9802e4d7c9795)
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()`
18 @*/
19 PetscErrorCode SNESPythonSetType(SNES snes, const char pyname[]) {
20   PetscFunctionBegin;
21   PetscValidHeaderSpecific(snes, SNES_CLASSID, 1);
22   PetscValidCharPointer(pyname, 2);
23   PetscTryMethod(snes, "SNESPythonSetType_C", (SNES, const char[]), (snes, pyname));
24   PetscFunctionReturn(0);
25 }
26 
27 /*@C
28    SNESPythonGetType - Get the type of a SNES object implemented in Python.
29 
30    Not collective
31 
32    Input Parameter:
33 .  snes - the nonlinear solver (SNES) context.
34 
35    Output Parameter:
36 .  pyname - full dotted Python name [package].module[.{class|function}]
37 
38    Level: intermediate
39 
40 .seealso: `SNESCreate()`, `SNESSetType()`, `SNESPYTHON`, `PetscPythonInitialize()`, `SNESPythonSetType()`
41 @*/
42 PetscErrorCode SNESPythonGetType(SNES snes, const char *pyname[]) {
43   PetscFunctionBegin;
44   PetscValidHeaderSpecific(snes, SNES_CLASSID, 1);
45   PetscValidPointer(pyname, 2);
46   PetscUseMethod(snes, "SNESPythonGetType_C", (SNES, const char *[]), (snes, pyname));
47   PetscFunctionReturn(0);
48 }
49