Actual source code: pyvistaviewer.c
1: #include <petsc/private/viewerimpl.h>
3: /*@C
4: PETSC_VIEWER_PYVISTA_ - Creates a PyVista `PetscViewer` shared by all MPI processes in a communicator.
6: Collective
8: Input Parameter:
9: . comm - the MPI communicator to share the `PetscViewer`
11: Level: developer
13: Note:
14: Unlike almost all other PETSc routines, `PETSC_VIEWER_PYVISTA_()` does not return
15: an error code. It is usually used in the form
16: .vb
17: XXXView(XXX object, PETSC_VIEWER_PYVISTA_(comm));
18: .ve
20: .seealso: [](sec_viewers), `PetscViewer`
21: @*/
22: PetscViewer PETSC_VIEWER_PYVISTA_(MPI_Comm comm)
23: {
24: PetscViewer viewer;
26: PetscFunctionBegin;
27: PetscCallNull(PetscViewerCreate(comm, &viewer));
28: PetscCallNull(PetscViewerSetType(viewer, PETSCVIEWERPYVISTA));
29: PetscCallNull(PetscObjectRegisterDestroy((PetscObject)viewer));
30: PetscFunctionReturn(viewer);
31: }
33: /*MC
34: PETSCVIEWERPYVISTA - A PyVista viewer implemented using Python code
36: Level: beginner
38: Notes:
39: Currently the `DM` viewer only supports `DMPLEX` meshes.
41: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerCreate()`, `VecView()`, `DMView()`, `DMPLEX`
42: M*/
43: PETSC_EXTERN PetscErrorCode PetscViewerCreate_PyVista(PetscViewer viewer)
44: {
45: PetscFunctionBegin;
46: PetscCall(PetscPythonInitialize(NULL, NULL));
47: PetscCall(PetscViewerSetType(viewer, PETSCVIEWERPYTHON));
48: PetscCall(PetscObjectChangeTypeName((PetscObject)viewer, PETSCVIEWERPYVISTA));
49: PetscCall(PetscViewerPythonSetType(viewer, "petsc4py.lib._pytypes.viewer.petscpyvista.PetscPyVista"));
50: PetscFunctionReturn(PETSC_SUCCESS);
51: }