:orphan:
# DMSwarmComputeLocalSize
Compute the local number and distribution of particles based upon a density function 
## Synopsis
```
#include "petscdmswarm.h"   
PetscErrorCode DMSwarmComputeLocalSize(DM sw, PetscInt N, PetscProbFunc density)
```
Not Collective


## Input Parameters

- ***sw      -*** The `DMSWARM`
- ***N       -*** The target number of particles
- ***density -*** The density field for the particle layout, normalized to unity





## Note
One particle will be created for each species.


## See Also
 `DMSWARM`, `DMSwarmComputeLocalSizeFromOptions()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/swarm/swarmpic.c.html#DMSwarmComputeLocalSize">src/dm/impls/swarm/swarmpic.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/impls/swarm/swarmpic.c)


[Index of all DMSwarm routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
