[petsc-users] explanations on DM_BOUNDARY_PERIODIC

Barry Smith bsmith at mcs.anl.gov
Fri Apr 28 11:26:13 CDT 2017


> On Apr 28, 2017, at 2:36 AM, neok m4700 <neok.m4700 at gmail.com> wrote:
> 
> Hello Barry,
> 
> Thank you for answering.
> 
> I quote the DMDA webpage:
> "The vectors can be thought of as either cell centered or vertex centered on the mesh. But some variables cannot be cell centered and others vertex centered." 
> 
> So If I use this, then when creating the DMDA the overall size will be the number of nodes, with nodal coordinates, and by setting DMDA_Q0 interp together with DM_BOUNDARY_PERIODIC I should be able to recover the solution at cell centers ?
> 
> I that possible in PETSc or should I stick to the nodal representation of my problem ?

  You can use them as cell centered values for your problem. Just keep in mind that the coordinate values in the coordinate array correspond to the vertex locations in the mesh.

   Barry

> 
> thanks.
> 
> 2017-04-27 20:03 GMT+02:00 Barry Smith <bsmith at mcs.anl.gov>:
> 
> > On Apr 27, 2017, at 12:43 PM, neok m4700 <neok.m4700 at gmail.com> wrote:
> >
> > Hi Matthew,
> >
> > Thank you for the clarification, however, it is unclear why there is an additional unknown in the case of periodic bcs.
> >
> > Please see attached to this email what I'd like to achieve, the number of unknowns does not change when switching to the periodic case for e.g. a laplace operator.
> 
>    So here you are thinking in terms of cell-centered discretizations. You are correct in that case that the number of "unknowns" is the same for both Dirichlet or periodic boundary conditions.
> 
>    DMDA was originally written in support of vertex centered coordinates, then this was extended somewhat with DMDASetInterpolationType() where DMDA_Q1 represents piecewise linear vertex centered while DMDA_Q0 represents piecewise constatant cell-centered.
> 
>     If you look at the source code for DMDASetUniformCoordinates() it is written in the context of vertex centered where the coordinates are stored for each vertex
> 
>    if (bx == DM_BOUNDARY_PERIODIC) hx = (xmax-xmin)/M;
>     else hx = (xmax-xmin)/(M-1);
>     ierr = VecGetArray(xcoor,&coors);CHKERRQ(ierr);
>     for (i=0; i<isize; i++) {
>       coors[i] = xmin + hx*(i+istart);
>     }
> 
> Note that in the periodic case say domain [0,1) vertex centered with 3 grid points (in the global problem) the coordinates for the vertices are 0, 1/3, 2/3 If you are using cell-centered and have 3 cells, the coordinates of the vertices are again 0, 1/3, 2/3
> 
> Note that in the cell centered case we are storing in each location of the vector the coordinates of a vertex, not the coordinates of the cell center so it is a likely "wonky".
> 
>    There is no contradiction between what you are saying and what we are saying.
> 
>    Barry
> 
> >
> > And in the case of dirichlet or neumann bcs, the extremum cell add information to the RHS, they do not appear in the matrix formulation.
> >
> > Hope I was clear enough,
> > thanks
> >
> >
> > 2017-04-27 16:15 GMT+02:00 Matthew Knepley <knepley at gmail.com>:
> > On Thu, Apr 27, 2017 at 3:46 AM, neok m4700 <neok.m4700 at gmail.com> wrote:
> > Hi,
> >
> > I am trying to change my problem to using periodic boundary conditions.
> >
> > However, when I use DMDASetUniformCoordinates on the DA, the spacing changes.
> >
> > This is due to an additional point e.g. in dm/impls/da/gr1.c
> >
> > else if (dim == 2) {
> >     if (bx == DM_BOUNDARY_PERIODIC) hx = (xmax-xmin)/(M);
> >     else hx = (xmax-xmin)/(M-1);
> >     if (by == DM_BOUNDARY_PERIODIC) hy = (ymax-ymin)/(N);
> >     else hy = (ymax-ymin)/(N-1);
> >
> > I don't understand the logic here, since xmin an xmax refer to the physical domain, how does changing to a periodic BC change the discretization ?
> >
> > Could someone clarify or point to a reference ?
> >
> > Just do a 1D example with 3 vertices. With a normal domain, you have 2 cells
> >
> >   1-----2-----3
> >
> > so each cell is 1/2 of the domain. In a periodic domain, the last vertex is connected to the first, so we have 3 cells
> >
> >   1-----2-----3-----1
> >
> > and each is 1/3 of the domain.
> >
> >    Matt
> >
> > Thanks
> >
> >
> >
> > --
> > 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
> >
> > <1D.pdf>
> 
> 



More information about the petsc-users mailing list