<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Manuel,</p>
    <p>you might consider useful taking a look at this code
      <a class="moz-txt-link-freetext" href="https://bitbucket.org/bkaus/lamem">https://bitbucket.org/bkaus/lamem</a>, which is a multi-DMDA staggered
      grid implementation.</p>
    <p>Also, as Matt pointed out, there is a direct PETSc support for
      staggered grids (DMSTAG), recently contributed by Patrick Sanan.<br>
    </p>
    <p>Thanks,</p>
    <p>Anton<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 15.10.2018 23:22, Manuel Valera
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPzU9WV5-OPh0wiBdUGm8-cHukbDMBeKPNUX3m-zzVZ9hF9ijQ@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr"><br>
        Thanks Matthew, i have made some progress but i am still unsure
        on how to proceed to make the DMDAs work as intended, i will try
        to lay out what i am trying now:
        <div><br>
        </div>
        <div>I was able to port the interpolation into the DMDA model
          but it works only in serial runs, and it becomes unstable for
          more than one processor running,</div>
        <div><br>
        </div>
        <div>What i do is roughly this:</div>
        <div>
          <ul>
            <li style="margin-left:15px">Calculate density at a
              cell-centered DMDA object, using a local vector so i can
              access the ghost rows (indices -1 and max+1)</li>
            <li style="margin-left:15px">Interpolate into a
              face-centered DMDA object for velocities, using also a
              local vector.</li>
          </ul>
          <div>Doing this i get the right results using the same
            interpolation i used for my non-petsc implementation of the
            model, as long as i use only one processor but the doubts i
            have are:</div>
        </div>
        <div>
          <ul>
            <li style="margin-left:15px">How to use the local vectors
              properly: Is operating on them the recommended course in
              this case? </li>
            <li style="margin-left:15px">How can i access the ghost
              indices in the global vector so i can then communicate
              GlobalToLocal? would this be a better strategy?</li>
            <li style="margin-left:15px">I feel is wrong to interpolate
              a cell-centered based vector into a face-centered based
              vector, using the indices of the latter, what strategy
              would work best in this case?</li>
          </ul>
          <div>I also tried opening a global vector with a different DA
            layout than the one created (opening global density on the
            velocities DMDA layout) and this introduced an error in the
            GlobalToLocal, LocalToLocal, LocalToGlobal communication,
            something didn't happen if i used the local versions of
            these vectors instead,</div>
        </div>
        <div><br>
        </div>
        <div>Thanks for your help,</div>
        <div><br>
        </div>
        <div>Manuel </div>
        <div class="gmail_quote">
          <div dir="ltr"><br>
          </div>
          <div dir="ltr">
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr">On Sat, Oct 6, 2018 at 4:45 AM Matthew
              Knepley <<a href="mailto:knepley@gmail.com"
                target="_blank" moz-do-not-send="true">knepley@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">
                <div dir="ltr">
                  <div class="gmail_quote">
                    <div dir="ltr">On Fri, Oct 5, 2018 at 6:49 PM Manuel
                      Valera <<a href="mailto:mvalera-w@sdsu.edu"
                        target="_blank" moz-do-not-send="true">mvalera-w@sdsu.edu</a>>
                      wrote:<br>
                    </div>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px 0.8ex;border-left:1px solid
                      rgb(204,204,204);padding-left:1ex">
                      <div dir="auto">Hello,
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto">I'm trying to do a simple
                          variable interpolation, from a cell center to
                          a face in a staggered grid, my model data
                          management is done with DMDAs, with two
                          different DMs one for each cell position, </div>
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto">I already did this task on a
                          fortran only version of the model using the 4
                          closest neighbors of the scalars (cell center)
                          to be interpolated at the velocity site (cell
                          face), i did it using a loop over the domain,
                          somehow this easy task is not translating into
                          the DMDA framework, </div>
                      </div>
                    </blockquote>
                    <div><br>
                    </div>
                    <div>Its not clear to me what problem you are
                      having. We have done this before. For example, </div>
                    <div><br>
                    </div>
                    <div>  <a
href="https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex30.c.html"
                        target="_blank" moz-do-not-send="true">https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex30.c.html</a></div>
                    <div><br>
                    </div>
                    <div>I would note that the development version of
                      PETSc now has DMStag which supports staggered grid
                      discretizations directly.</div>
                    <div><br>
                    </div>
                    <div>  Thanks,</div>
                    <div><br>
                    </div>
                    <div>    Matt</div>
                    <div> </div>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px 0.8ex;border-left:1px solid
                      rgb(204,204,204);padding-left:1ex">
                      <div dir="auto">
                        <div dir="auto">I'm not sure what I'm doing
                          wrong or not aware of a easier way Petsc may
                          have for this task, if you could point out an
                          easier strategy or an example I would be
                          grateful, </div>
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto">Thanks, </div>
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto"><br>
                        </div>
                        <div dir="auto"><br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  <div dir="ltr"
                    class="m_-4086939011740966609m_8651859862473364093gmail_signature">
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr">
                              <div>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><br>
                              </div>
                              <div><a
                                  href="http://www.cse.buffalo.edu/%7Eknepley/"
                                  target="_blank" moz-do-not-send="true">https://www.cse.buffalo.edu/~knepley/</a><br>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>