[petsc-users] DMSWARM with DMDA and KSP

Dave May dave.mayhem23 at gmail.com
Mon May 1 21:51:12 CDT 2023


On Mon 1. May 2023 at 18:57, Matthew Young <myoung.space.science at gmail.com>
wrote:

> Thanks for the suggestion to keep DMs separate, and for pointing me toward
> that example. I now have a DM for the particle quantities (i.e., density
> and flux) and another for the potential. I'm hoping to use
> KSPSetComputeOperators with PCGAMG, so I packed the density DM into the
> application context and set the potential DM on the KSP, but I'm not sure
> how to communicate changes in the KSP DM (e.g., coarsening) to the density
> DM inside my operator function.
>

I don’t think you need to.

GAMG only requires the fine grid operator - this will be the matrix
assembled from KSPSetComputeOperators. Hence density DM and potential DM
fields only need to be managed by you on the finest level.

However, if you wanted to use PCMG with rediscretized operators on every
level, then you would need the density DM field defined on each level of
your geometric multigrid hierarchy. This could be done (possibly less than
ideally) by calling DMCreateInterpolation() and then using the Mat to
interpolate the density from the  finest level to next coarsest level (and
so on).

Thanks,
Dave


>
> --Matt
> ==========================
> Matthew Young, PhD (he/him)
> Research Scientist II
> Space Science Center
> University of New Hampshire
> Matthew.Young at unh.edu
> ==========================
>
>
> On Sun, Apr 30, 2023 at 1:52 PM Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Sun, Apr 30, 2023 at 1:12 PM Matthew Young <
>> myoung.space.science at gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I am developing a particle-in-cell code that models ions as particles
>>> and electrons as an inertialess fluid. I use a PIC DMSWARM for the ions,
>>> which I gather into density and flux before solving a linear system for the
>>> electrostatic potential (phi). I currently have one DMDA with 5 degrees of
>>> freedom -- one each for density, 3 flux components, and phi.
>>>
>>> When setting up the linear system to solve for phi, I've been following
>>> examples like KSP ex34.c and ex42.c when writing the KSP operator and RHS
>>> functions but I'm not sure I have the right approach, since 4 of the DOFs
>>> are known and 1 is unknown.
>>>
>>> I saw this thread
>>> <https://lists.mcs.anl.gov/pipermail/petsc-users/2016-November/031031.html>
>>> that recommended using DMDAGetReducedDMDA, which I gather has been
>>> deprecated in favor of DMDACreateCompatibleDMDA. Is that a good approach
>>> for managing a regular grid with known and unknown quantities on each node?
>>> Could a composite DM be useful? Has anyone else worked on a problem like
>>> this?
>>>
>>
>> I recommend making a different DM for each kind of solve you want.
>> DMDACreateCompatibleDMDA() should be the implementation of DMClone(), but
>> we have yet to harmonize all things for all DMs. I would create one DM for
>> your Vlasov components and one for the Poisson.
>> We follow this strategy in our Vlasov-Poisson test for Landau damping:
>> https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/swarm/tests/ex9.c
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>> --Matt
>>> ==========================
>>> Matthew Young, PhD (he/him)
>>> Research Scientist II
>>> Space Science Center
>>> University of New Hampshire
>>> Matthew.Young at unh.edu
>>> ==========================
>>>
>>
>>
>> --
>> 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://www.cse.buffalo.edu/~knepley/
>> <http://www.cse.buffalo.edu/~knepley/>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230501/4818bcdb/attachment.html>


More information about the petsc-users mailing list