static char help[] = "Solves the 1-dimensional wave equation.\n\n"; #include #include #include int main(int argc,char **argv) { PetscMPIInt rank,size; PetscInt M = 60,time_steps = 100, localsize,j,i,mybase,myend,width,xbase,*localnodes = NULL; DM da; PetscViewer viewer,viewer_private; PetscDraw draw; Vec local,global; PetscScalar *localptr,*globalptr; PetscReal a,h,k; PetscBool flg = PETSC_FALSE; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-time",&time_steps,NULL)); /* Test putting two nodes on each processor, exact last processor gets the rest */ PetscCall(PetscOptionsGetBool(NULL,NULL,"-distribute",&flg,NULL)); if (flg) { PetscCall(PetscMalloc1(size,&localnodes)); for (i=0; i