Barry, The PIC and fluid codes are both running on MPI_COMM_WORLD, so it looks like we're doing the initialization correctly. Since my first email, I've identified some other parts in my PETSc solver that could be causing my communicator problems. I'll work on fixing those and come back with specific questions if I have them.
Thanks! -------------------------------------------------------------- Matthew Young Graduate Student Boston University Dept. of Astronomy -------------------------------------------------------------- ________________________________________ From: Barry Smith [[email protected]] Sent: Friday, March 20, 2015 2:11 PM To: Young, Matthew, Adam Cc: [email protected] Subject: Re: [petsc-users] PETSc within a larger simulation > On Mar 20, 2015, at 1:02 PM, Young, Matthew, Adam <[email protected]> wrote: > > I have a PETSc routine that I am trying to use as an electric-field solver > within a particle-in-cell code. The existing PIC code is parallelized with > MPI. The pure PIC code (written many years ago by my advisor) is well-tested > and I am trying to add an option for it to operate as a hybrid fluid/PIC > code. This requires solving Ax=b at every time step but I don't think I > understand how to manage communication between the existing code and my PETSc > solver. Since we may not always run the hybrid version, the code calls > MPI_Init() before PetscInitialize(). Section 14.1 of the manual suggests that > I use PetscSetCommWorld between MPI_Init() and PetscInitialize(), but that > routine appears to not be supported anymore. Is that correct? Can you point > me to examples of simulations that use PETSc within a larger code? Matt, In the standard case where the PIC and fluid code are both running on the same communicator (MPI_COMM_WORLD) you don't need to do anything special, just call the MPI_Init() and then the PetscInitialize(). If the PETSc code runs on a smaller communicator then BEFORE the call to PetscInitialize() you just need to set PETSC_COMM_WORLD = comm (where comm is that smaller communicator). (This replaces the use of the function call PetscSetCommWorld() that once existed.) Barry > > --Matt > > -------------------------------------------------------------- > Matthew Young > Graduate Student > Boston University Dept. of Astronomy > --------------------------------------------------------------
