DMSwarmProjectFields#
Project a set of swarm fields onto the cell DM
Synopsis#
#include "petscdm.h"
#include "petscdmda.h"
#include "petscdmplex.h"
#include "petscdmswarm.h"
#include "petscksp.h"
PetscErrorCode DMSwarmProjectFields(DM dm, PetscInt nfields, const char *fieldnames[], Vec fields[], ScatterMode mode)
Collective
Input Parameters#
dm - the
DMSWARM
nfields - the number of swarm fields to project
fieldnames - the textual names of the swarm fields to project
fields - an array of Vec’s of length nfields
mode - if SCATTER_FORWARD then map particles to the continuum, and if SCATTER_REVERSE map the continuum to particles
Notes#
Currently, there two available projection methods. The first is conservative projection, used for a DMPLEX
cell DM
. The second is the averaging described below, which is used for a DMDA
cell DM
phi_i = \sum_{p=0}^{np} N_i(x_p) phi_p dJ / \sum_{p=0}^{np} N_i(x_p) dJ
where phi_p is the swarm field at point p,
N_i() is the cell DM basis function at vertex i,
dJ is the determinant of the cell Jacobian and
phi_i is the projected vertex value of the field phi.
The user is responsible for destroying both the array and the individual Vec
objects. For the DMPLEX
case, there is only a single vector, so the field layout in the DMPLEX
must match the requested fields from the DMSwarm
.
For averaging projection, nly swarm fields registered with data type of PETSC_REAL
can be projected onto the cell DM
, and only swarm fields of block size = 1 can currently be projected.
See Also#
KSP: Linear System Solvers, DMSWARM
, DMSwarmSetType()
, DMSwarmSetCellDM()
, DMSwarmType
Level#
beginner
Location#
Examples#
src/dm/impls/swarm/tutorials/ex1.c
src/dm/tutorials/ex21.c
src/ksp/ksp/tutorials/ex70.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages