:orphan:
# PetscViewerGLVisSetFields
Sets the required information to visualize different fields from a vector.
## Synopsis
```
#include "petscviewer.h"
#include "petscsys.h"
PetscErrorCode PetscViewerGLVisSetFields(PetscViewer viewer, PetscInt nf, const char *fec_type[], PetscInt dim[], PetscErrorCode (*g2l)(PetscObject, PetscInt, PetscObject[], void *), PetscObject Vfield[], void *ctx, PetscErrorCode (*destroyctx)(void *))
```
Logically Collective
## Input Parameters
- ***viewer -*** the `PetscViewer` of type `PETSCVIEWERGLVIS`
- ***nf -*** number of fields to be visualized
- ***fec_type -*** the type of finite element to be used to visualize the data (see FiniteElementCollection::Name() in MFEM)
- ***dim -*** array of space dimension for field vectors (used to initialize the scene)
- ***g2lfields -*** User routine to compute the local field vectors to be visualized; PetscObject is used in place of Vec on the prototype
- ***Vfield -*** array of work vectors, one for each field
- ***ctx -*** User context to store the relevant data to apply g2lfields
- ***destroyctx -*** Destroy function for userctx
## Notes
`g2lfields` is called on the vector V to be visualized in order to extract the relevant dofs to be put in `Vfield`, as
```none
g2lfields((PetscObject)V,nfields,(PetscObject*)Vfield[],ctx).
```
For vector spaces, the block size of `Vfield`[i] represents the vector dimension.
The names of the `Vfield` vectors will be displayed in the window title.
## See Also
[](sec_viewers), `PETSCVIEWERGLVIS`, `PetscViewerGLVisOpen()`, `PetscViewerCreate()`, `PetscViewerSetType()`, `PetscObjectSetName()`
## Level
intermediate
## Location
src/sys/classes/viewer/impls/glvis/glvis.c
## Examples
src/ksp/ksp/tutorials/ex43.c
## Implementations
PetscViewerGLVisSetFields_GLVis(PetscViewer viewer, PetscInt nfields, const char *fec_type[], PetscInt dim[], PetscErrorCode (*g2l)(PetscObject, PetscInt, PetscObject[], void *), PetscObject Vfield[], void *ctx, PetscErrorCode (*destroyctx) in src/sys/classes/viewer/impls/glvis/glvis.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/viewer/impls/glvis/glvis.c)
[Index of all Viewer routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)