[petsc-users] [petsc-maint] DMSwarm with periodic B.C.

Mark Adams mfadams at lbl.gov
Wed Apr 12 10:31:45 CDT 2023


First, you don't want a DMShell. Just use da_swarm.
See src/dm/tutorials/ex20.c

You can run this test with
> cd src/dm/tutorials
> make ex20
> ./ex20
or
> ./ex20 -mode 1
See the end of ex20.c for these (lack of) arguments

Now change that code to one periodic direction and test.

This could be a bug. This code is not well tested.

Thanks,
Mark




On Wed, Apr 12, 2023 at 4:02 AM Joauma Marichal <
joauma.marichal at uclouvain.be> wrote:

> Hello,
>
>
>
> I am using petsc DMSwarm library for some Lagrangian particle tracking.
> Until now, I was working in a closed box and was therefore initializing my
> swarm object as:
>
>
>
> // Create a DMDA staggered and without ghost cells (for DMSwarm to work)
>
> DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,
> DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,M,N,P,m,n,p,1,1,lx,ly,lz,da_swarm);
>
>
>
> DMSetFromOptions(*da_swarm);
>
> DMSetUp(*da_swarm);
>
> PetscScalar xmin, xmax, ymin, ymax, zmin, zmax;
>
> xmin = ymin = zmin = 0.;
>
> xmax = ymax = zmax = 1.;
>
> DMDASetUniformCoordinates(*da_swarm,xmin, xmax, ymin, ymax, zmin, zmax);
>
> //SetNonUniform3DCoordinates(*da_swarm, cornp, gridp, rank);
>
>
>
> /* Create a DMShell for point location purposes */
>
> DMShellCreate(PETSC_COMM_WORLD,dmcell);
>
> DMSetApplicationContext(*dmcell,*da_swarm);
>
> (*dmcell)->ops->locatepoints = DMLocatePoints_DMDARegular;
>
> (*dmcell)->ops->getneighbors = DMGetNeighbors_DMDARegular;
>
>
>
> // Create a Swarm DMDA
>
> DMCreate(PETSC_COMM_WORLD,swarm);
>
> DMSetType(*swarm,DMSWARM);
>
> DMSetDimension(*swarm,3);
>
> DMSwarmSetType(*swarm,DMSWARM_PIC);
>
> DMSwarmSetCellDM(*swarm,*dmcell);
>
>
>
> I am now trying to work with periodic boundary conditions. I tried
> replacing DM_BOUNDARY_NONE by DM_BOUNDARY_PERIODIC but it does not work…
> I checked for examples using periodic B.C. but have not found any. Is it
> possible? And if yes, how can I make it work?
>
>
>
> Thanks a lot for your answer.
>
> Best regards,
>
>
>
> Joauma
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230412/3da74ca0/attachment.html>


More information about the petsc-users mailing list