Actual source code: btview.c
1: #include <petscsys.h>
2: #include <petscbt.h>
3: #include <petscviewer.h>
5: /*@C
6: PetscBTView - View the contents of a `PetscBT` (bit array) on a `PetscViewer`, one line per bit
8: Collective on `viewer`; No Fortran Support
10: Input Parameters:
11: + m - the number of bits in the array to print
12: . bt - the `PetscBT`
13: - viewer - the `PetscViewer` to print to, or `NULL` to use `PETSC_VIEWER_STDOUT_SELF`
15: Level: developer
17: .seealso: `PetscBT`, `PetscBTCreate()`, `PetscBTLookup()`, `PetscViewer`
18: @*/
19: PetscErrorCode PetscBTView(PetscCount m, const PetscBT bt, PetscViewer viewer)
20: {
21: PetscFunctionBegin;
22: if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PETSC_COMM_SELF, &viewer));
23: PetscCall(PetscViewerASCIIPushSynchronized(viewer));
24: for (PetscCount i = 0; i < m; ++i) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, "%" PetscCount_FMT " %hhu\n", i, PetscBTLookup(bt, i)));
25: PetscCall(PetscViewerFlush(viewer));
26: PetscCall(PetscViewerASCIIPopSynchronized(viewer));
27: PetscFunctionReturn(PETSC_SUCCESS);
28: }