[petsc-users] Combine DM and FFTW

Matthew Knepley knepley at gmail.com
Sat Sep 11 13:49:37 CDT 2021


On Fri, Sep 10, 2021 at 2:26 PM Gerhard Ungersbäck via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hello,
>
>
> I want to solve a time dependent differential equation in 3D (Scalar field
> theory in Hamilton formulation) .
>
> The crucial part is that at some time steps I need to FFT the 3D grid.
>
>
> I have written a sequential code without petsc and now I would like to use
> petsc to get a parallel version.
>
> I worked through the examples and now I understand DMDACreate and also the
> FFTW examples.
>
>
> What is missing though is how I combine both!
>
> DMDACreate takes care of ghost points and periodic boundary conditions. As
> far as I know FFTW requires each process to have a slab of the grid to
> work. I know how to create this grid with DMDACreate. Normally I would
> proceed by creating a global vector by DMCreateGlobalVector. But this
> vector needs then to be linked with fftw arrays. How does this work?
>
> Or should I first allocate local memory for fftw and then somehow stitch
> them together to form a global petsc vector?
>

It would be great if we had worked through an example with this, but I can
only find a serial example:

  https://gitlab.com/petsc/petsc/-/blob/main/src/dm/tests/ex27.c

I think you can use

  https://petsc.org/main/docs/manualpages/Mat/VecScatterFFTWToPetsc.html

to go between FFTW and Petsc vectors, but I have not tried in parallel. Is
the example
in the right direction?

  Thanks,

     Matt


> Thanks
>
> best, gerhard
>
>

-- 
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/20210911/d84e7245/attachment.html>


More information about the petsc-users mailing list