[petsc-users] Moving data between two Vecs managed using different DMDAs
Matthew Knepley
knepley at gmail.com
Tue Jul 21 14:54:30 CDT 2026
On Tue, Jul 21, 2026 at 3:45 PM Constantine Khrulev via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Hello,
>
> I would like to move data between two Vecs managed by DMDAs. The DMDAs
> involved may use the same MPI Communicator or possibly different
> (possibly disjoint) MPI communicators. Crucially, Vecs may have
> different parallel decompositions but the same global size, so
> interpolation is not needed.
>
> In other words, I would like to set up data exchange to couple
> components of our model (PISM). All components use DMDA but may use
> different communicators, domain decomposition, etc, but the same global
> grid dimensions.
>
> Would it be reasonable to use PETSc's tools for this? And if it is, do
> you have any advice for me? I think I can accomplish this using
> DMDACreatePatchIS and VecScatter, or maybe using PetscSF.
>
Let's do it in stges. Suppose the DMDAs use the same communicator. Then you
could just
setup a VecScatter to move the unknowns from the source global numbering to
the target
global numbering.
However, it might be complicated to come up with that VecScatter. Since the
DMDAs are the
same size you could get the VecScatter that does GlobalToNatural from the
source and target,
and apply the first FORWARD and the second BACKWARD.
You might want to optimize that. You could extract the PetscSF (VecScatter
is implemented by
PetscSF) and use
https://urldefense.us/v3/__https://petsc.org/main/manualpages/PetscSF/PetscSFComposeInverse/__;!!G_uCfscf7eWS!djXX5UM6u6XCpGFg6ZfWtmm-XkiTSLRuP8ozVfAiN2Hiyep8dBksiziFVtgDfuqY_95uNsJBMOpbTGUB3Z-d$ .
Lastly, you might have different communicators. Then you would have to a)
have a common
supercomm, perhaps PETSC_COMM_WORLD, and b) pull the two vectors into the
common
comm, c) rewrite the PetscSF with the new rank values. This is all doable,
but involves some
programming. We have never had anyone ask for this.
Thanks,
Matt
> Thank you!
>
> --
> Constantine
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djXX5UM6u6XCpGFg6ZfWtmm-XkiTSLRuP8ozVfAiN2Hiyep8dBksiziFVtgDfuqY_95uNsJBMOpbTKmskYsu$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djXX5UM6u6XCpGFg6ZfWtmm-XkiTSLRuP8ozVfAiN2Hiyep8dBksiziFVtgDfuqY_95uNsJBMOpbTCGLS5r-$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260721/6545a20b/attachment.html>
More information about the petsc-users
mailing list