static char help[] = "Example program demonstrating projection between particle and finite element spaces\n\n"; #include "petscdmplex.h" #include "petscds.h" #include "petscdmswarm.h" #include "petscksp.h" static PetscErrorCode crd_func(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf_dummy, PetscScalar *u, void *actx) { PetscInt i; PetscFunctionBeginUser; for (i = 0; i < dim; ++i) u[i] = x[i]; PetscFunctionReturn(0); } int main(int argc, char **argv) { DM dm, crddm, sw; PetscFE fe; KSP ksp; Mat M_p, M; Vec f, rho, rhs, crd_vec; PetscInt dim = 2, Nc = 1, timestep = 0, N, i, idx[3]; PetscInt Np = 10, p, field = 0, zero = 0, bs, cells[] = {40, 20, 20}; PetscReal time = 0.0, norm; PetscBool removePoints = PETSC_TRUE, flg; const PetscReal *xx, *vv; PetscReal *wq, *coords, lo[] = {-1,-1,-1}, hi[]={1,1,1}, h[3]; PetscDataType dtype; PetscBool interpolate = PETSC_TRUE; PetscErrorCode ierr; PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal [], PetscInt, PetscScalar [], void *); ierr = PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr; /* get options */ ierr = PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "Options for Fokker-Plank collision operator", "none");CHKERRQ(ierr); ierr = PetscOptionsRangeInt("-dim", "dim (2 or 3)", "ex1.c", dim, &dim, NULL,2,3);CHKERRQ(ierr); i = dim; ierr = PetscOptionsIntArray("-dm_plex_box_faces", "Number of cells of grid", "ex1.c", cells, &i, &flg);CHKERRQ(ierr); i = dim; ierr = PetscOptionsRealArray("-dm_plex_box_lower", "Low corner of grid", "ex1.c", lo, &i, &flg);CHKERRQ(ierr); i = dim; ierr = PetscOptionsRealArray("-dm_plex_box_upper", "High corner of grid", "ex1.c", hi, &i, &flg);CHKERRQ(ierr); for (i=0;i