PETSc version 3.16.6
Fix/Edit manual page

DMSwarmSortGetAccess

Setups up a DMSwarm point sort context for efficient traversal of points within a cell

Synopsis

PETSC_EXTERN PetscErrorCode DMSwarmSortGetAccess(DM dm)
Not collective

Input parameter

dm - a DMSwarm object

Calling DMSwarmSortGetAccess() creates a list which enables easy identification of all points contained in a given cell. This method does not explicitly sort the data within the DMSwarm based on the cell index associated with a DMSwarm point.

The sort context is valid only for the DMSwarm points defined at the time when DMSwarmSortGetAccess() was called. For example, suppose the swarm contained NP points when DMSwarmSortGetAccess() was called. If the user subsequently adds 10 additional points to the swarm, the sort context is still valid, but only for the first NP points. The indices associated with the 10 new additional points will not be contained within the sort context. This means that the user can still safely perform queries via DMSwarmSortGetPointsPerCell() and DMSwarmSortGetPointsPerCell(), however the results return will be based on the first NP points.

If any DMSwam re-sizing method is called after DMSwarmSortGetAccess() which modifies any of the first NP entries in the DMSwarm, the sort context will become invalid. Currently there are no guards to prevent the user from invalidating the sort context. For this reason, we highly recommend you do not use DMSwarmRemovePointAtIndex() in between calls to DMSwarmSortGetAccess() and DMSwarmSortRestoreAccess().

To facilitate safe removal of points using the sort context, we suggest a "two pass" strategy in which the first pass "marks" points for removal, and the second pass actually removes the points from the DMSwarm.

Notes

- You must call DMSwarmSortGetAccess() before you can call DMSwarmSortGetPointsPerCell() or DMSwarmSortGetNumberOfPointsPerCell() - The sort context may become invalid if any re-sizing methods are applied which alter the first NP points within swarm at the time DMSwarmSortGetAccess() was called. - You must call DMSwarmSortRestoreAccess() when you no longer need access to the sort context

See Also

DMSwarmSetType(), DMSwarmSortRestoreAccess()

Level

advanced

Location

src/dm/impls/swarm/swarmpic_sort.c

Examples

src/dm/tutorials/ex20.c.html
src/ksp/ksp/tutorials/ex70.c.html

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