<div dir="ltr"><div>Dear all,<br>I'm solving a system using petsc and I get a global Vec, say X . It uses DMDA with 4 dofs (3 velocity + 1 pressure). X contains velocity at the cell faces since I solve using staggered grid.<br>Now I'd like to create one array for velocity with values at cell centers and another array for pressure (not the Vec so that I can send the pointer to the array to other part of the code that does not use Petsc).<br><br></div><div>Currently what I do is :<br>------ Vec               X, X_local;<br>------ PetscScalar  *X_array;<br><br>// Scatter X to X_local and then use:<br><br>------- VecGetArray(X_local, &X_array) <br></div><div><br>And then have a function, say <br>getVelocityAt(x, y, z, component) {<br></div><div>// interpolate velocity at (x,y,z) cell center using X_array<br></div><div>}<br><br>The function getVelocityAt() gets called from outside petsc in a loop over all (x,y,z) positions.<br></div><div>This is not done in parallel.<br></div><div><br>Now, how do I use Petsc to instead interpolate the cell center velocities in parallel and store it<br>in an array say<br>PetscScalar *X_array_cellCenter;<br>?<br></div><div>This would need to have size one less along each axis compared to the orginal DMDA size.<br></div><div>This way I intend to return X_array_cellCenter to the code outside Petsc.<br><br><br></div></div>