Actual source code: pyvistaviewer.c
1: #include <petsc/private/viewerimpl.h>
3: /*@
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(PetscViewerSetFromOptions(viewer));
30: PetscCallNull(PetscObjectRegisterDestroy((PetscObject)viewer));
31: PetscFunctionReturn(viewer);
32: }
34: /*MC
35: PETSCVIEWERPYVISTA - A PyVista viewer implemented using Python code
37: Level: beginner
39: Notes:
40: Currently the `DM` viewer only supports `DMPLEX` meshes.
42: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerCreate()`, `VecView()`, `DMView()`, `DMPLEX`
43: M*/
44: PETSC_EXTERN PetscErrorCode PetscViewerCreate_PyVista(PetscViewer viewer)
45: {
46: PetscFunctionBegin;
47: PetscCall(PetscPythonInitialize(NULL, NULL));
48: PetscCall(PetscViewerSetType(viewer, PETSCVIEWERPYTHON));
49: PetscCall(PetscObjectChangeTypeName((PetscObject)viewer, PETSCVIEWERPYVISTA));
50: PetscCall(PetscViewerPythonSetType(viewer, "petsc4py.lib._pytypes.viewer.petscpyvista.PetscPyVista"));
51: PetscFunctionReturn(PETSC_SUCCESS);
52: }