<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 28, 2017 at 2:36 AM, neok m4700 <span dir="ltr"><<a href="mailto:neok.m4700@gmail.com" target="_blank">neok.m4700@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Barry,<div><br></div><div>Thank you for answering.</div><div><br></div><div>I quote the DMDA webpage:</div><div>"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." </div><div><br></div><div>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 ?</div><div><br></div><div>I that possible in PETSc or should I stick to the nodal representation of my problem ?</div></div></blockquote><div><br></div><div>With periodic problems, you must think of the input sizes as being vertices.</div><div><br></div><div>  Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>thanks.</div><div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-27 20:03 GMT+02:00 Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_8478283647055825801m_2473249144130670842gmail-"><br>
> On Apr 27, 2017, at 12:43 PM, neok m4700 <<a href="mailto:neok.m4700@gmail.com" target="_blank">neok.m4700@gmail.com</a>> wrote:<br>
><br>
> Hi Matthew,<br>
><br>
> Thank you for the clarification, however, it is unclear why there is an additional unknown in the case of periodic bcs.<br>
><br>
> 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.<br>
<br>
</span>   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.<br>
<br>
   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.<br>
<br>
    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<br>
<br>
   if (bx == DM_BOUNDARY_PERIODIC) hx = (xmax-xmin)/M;<br>
    else hx = (xmax-xmin)/(M-1);<br>
    ierr = VecGetArray(xcoor,&coors);CHKE<wbr>RRQ(ierr);<br>
    for (i=0; i<isize; i++) {<br>
      coors[i] = xmin + hx*(i+istart);<br>
    }<br>
<br>
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<br>
<br>
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".<br>
<br>
   There is no contradiction between what you are saying and what we are saying.<br>
<br>
   Barry<br>
<div><div class="m_8478283647055825801m_2473249144130670842gmail-h5"><br>
><br>
> 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.<br>
><br>
> Hope I was clear enough,<br>
> thanks<br>
><br>
><br>
> 2017-04-27 16:15 GMT+02:00 Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>:<br>
> On Thu, Apr 27, 2017 at 3:46 AM, neok m4700 <<a href="mailto:neok.m4700@gmail.com" target="_blank">neok.m4700@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I am trying to change my problem to using periodic boundary conditions.<br>
><br>
> However, when I use DMDASetUniformCoordinates on the DA, the spacing changes.<br>
><br>
> This is due to an additional point e.g. in dm/impls/da/gr1.c<br>
><br>
> else if (dim == 2) {<br>
>     if (bx == DM_BOUNDARY_PERIODIC) hx = (xmax-xmin)/(M);<br>
>     else hx = (xmax-xmin)/(M-1);<br>
>     if (by == DM_BOUNDARY_PERIODIC) hy = (ymax-ymin)/(N);<br>
>     else hy = (ymax-ymin)/(N-1);<br>
><br>
> 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 ?<br>
><br>
> Could someone clarify or point to a reference ?<br>
><br>
> Just do a 1D example with 3 vertices. With a normal domain, you have 2 cells<br>
><br>
>   1-----2-----3<br>
><br>
> 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<br>
><br>
>   1-----2-----3-----1<br>
><br>
> and each is 1/3 of the domain.<br>
><br>
>    Matt<br>
><br>
> Thanks<br>
><br>
><br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
><br>
</div></div>> <1D.pdf><br>
<br>
</blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>