Skip to main content
`Ctrl`+`K`

# DMSwarmVectorDefineFields

Sets the fields from which to define a `Vec` object when `DMCreateLocalVector()`, or `DMCreateGlobalVector()` is called

## Synopsis

    #include "petscdmswarm.h"
    PetscErrorCode DMSwarmVectorDefineFields(DM sw, PetscInt Nf, const char *fieldnames[])

Collective, No Fortran support

## Input Parameters

- sw - a `DMSWARM`

- Nf - the number of fields

- fieldnames - the textual name given to each registered field

## Notes

Each field with name in `fieldnames` must be defined as having a data type of `PetscScalar`.

This function must be called prior to calling `DMCreateLocalVector()`, `DMCreateGlobalVector()`. Multiple calls to `DMSwarmVectorDefineField()` are permitted.

## See Also

`DM`, `DMSWARM`, `DMSwarmVectorDefineField()`, `DMSwarmVectorGetField()`, `DMSwarmRegisterPetscDatatypeField()`, `DMCreateGlobalVector()`, `DMCreateLocalVector()`

## Level

beginner

## Location

src/dm/impls/swarm/swarm.c

## Examples

src/snes/tutorials/ex63.c

Index of all DMSwarm routines
Table of Contents for all manual pages
Index of all manual pages