[petsc-users] Moving data between two Vecs managed using different DMDAs

Junchao Zhang junchao.zhang at gmail.com
Thu Jul 23 10:04:36 CDT 2026


For the case with different communicators, you may have a look at
src/vec/is/sf/tests/ex9.c, in which the sub2sub case shows VecScatter on
two disjoint communicators.

If you have an example showing the various DMDA cases in your code, we
might have better solutions.

Thanks,
--Junchao Zhang


On Tue, Jul 21, 2026 at 2:54 PM Matthew Knepley <knepley at gmail.com> wrote:

> 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!ciUIcdwj23Gjmgsk57icDGCdiCH--D0P38NaCBc2ueqa_ZKDzRS_qbu5yZ76kg_M7GcObufq-85rQLQc6yWl53eFMhxa$ 
> <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!ciUIcdwj23Gjmgsk57icDGCdiCH--D0P38NaCBc2ueqa_ZKDzRS_qbu5yZ76kg_M7GcObufq-85rQLQc6yWl506OdbJ5$ 
> <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/20260723/c7a09426/attachment.html>


More information about the petsc-users mailing list