<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  Something like <div class=""><br class=""></div><div class="">  DMDASetComputeGhostBoundary(DM dm, s(DM,Vec,Vec,void*),d(void*))</div><div class=""><br class=""></div><div class="">where </div><div class=""><br class=""></div><div class="">s(DM dm, Vec g, Vec l, void*ctx) {</div><div class="">  User code that fills in appropriate places in l. </div><div class=""><br class=""></div><div class="">d(void* ctx) {</div><div class="">Optional: Destroys optional user context when DM is destroyed.</div><div class="">}</div><div class=""><br class=""></div><div class="">and s() gets called inside of DMGlobalToLocalEnd() just before it returns? </div><div class=""><br class=""></div><div class="">Yes, this seems doable. But I note that you can simply perform your s() function on the local vector immediately after you call DMGlobalToLocalEnd() and get the same affect.</div><div class=""><br class=""></div><div class="">Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 15, 2022, at 4:02 AM, David Scott <<a href="mailto:d.scott@epcc.ed.ac.uk" class="">d.scott@epcc.ed.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
  
  <div class="">
    <br class="">
    <br class="">
    <div class="moz-cite-prefix">On 12/08/2022 18:15, Matthew Knepley
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:CAMYG4GmzzvfqPuXRBE9n1ZFZ5sCU=Ao95KNNPtPCvD4O7_4ZrQ@mail.gmail.com" class="">
      
      <div style="background-color:#fff2e6; border:2px dotted #ff884d" class=""><span style="font-size: 12pt; font-family: sans-serif; font-weight: bold; padding: 0.2em;" class="">This email was sent to you by
          someone outside the University.</span>
        <div style="font-size:10pt; font-family: sans-serif;
          font-style:normal; padding:.2em" class=""> You should only click on
          links or attachments if you are certain that the email is
          genuine and the content is safe.</div>
      </div>
      <div class="">
        <div dir="ltr" class="">
          <div dir="ltr" class="">On Fri, Aug 12, 2022 at 9:27 AM David Scott
            <<a href="mailto:d.scott@epcc.ed.ac.uk" moz-do-not-send="true" class="moz-txt-link-freetext">d.scott@epcc.ed.ac.uk</a>>
            wrote:<br class="">
          </div>
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div class="">
                <div class="">On 12/08/2022 11:26, Matthew Knepley wrote:<br class="">
                </div>
                <blockquote type="cite" class="">
                  <div style="background-color:rgb(255,242,230);border:2px
                    dotted rgb(255,136,77)" class=""> <span style="font-size: 12pt; font-family: sans-serif; font-weight: bold; padding: 0.2em;" class="">This
                      email was sent to you by someone outside the
                      University.</span>
                    <div style="font-size:10pt;font-family:sans-serif;font-style:normal;padding:0.2em" class="">You
                      should only click on links or attachments if you
                      are certain that the email is genuine and the
                      content is safe.</div>
                  </div>
                  <div class="">
                    <div dir="ltr" class="">
                      <div dir="ltr" class="">On Fri, Aug 12, 2022 at 2:21 AM
                        Quynh Nguyen <<a href="mailto:nguyenquynh9537@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">nguyenquynh9537@gmail.com</a>>
                        wrote:<br class="">
                      </div>
                      <div class="gmail_quote">
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex">
                          <div dir="ltr" class="">Dear petsc developers and
                            users,
                            <div class=""><br class="">
                            </div>
                            <div class="">I am a new petsc user ^_^.</div>
                            <div class="">I have some questions about using
                              DMDA_BOUNDARY_GHOSTED.</div>
                            <div class=""><br class="">
                            </div>
                            <div class="">1. I have 2D Poisson code with domain
                              (nx, ny), and I used  DMDA_BOUNDARY_NONE,
                              then the size of the matrix is
                              (nx*ny)X(nx*ny). <b class=""><i class="">what is the size
                                  of the matrix if I used 
                                  DMDA_BOUNDARY_GHOSTED? is it the same
                                  size as DMDA_BOUNDARY_NONE</i></b>?</div>
                          </div>
                        </blockquote>
                        <div class=""><br class="">
                        </div>
                        <div class="">Yes, the matrix should be the same size,
                          but local vectors have extra ghost node slots.</div>
                        <div class=""> <br class="">
                        </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="ltr" class="">
                            <div class="">
                              <div class="">2. if the matrix size of
                                DMDA_BOUNDARY_GHOSTED isn't the same as
                                DMDA_BOUNDARY_NONE, <b class=""><i class="">how i can
                                    view the matrix including ghost
                                    points</i></b>? I ask this one
                                because I used MatView(P,
                                PETSC_VIEWER_STDOUT_WORLD) to show the
                                matrix but excluded ghost points.</div>
                            </div>
                          </div>
                        </blockquote>
                        <div class=""><br class="">
                        </div>
                        <div class="">Ghost nodes are there so that stencil
                          operations on local vectors work at
                          boundaries. You fill in the slots with
                          boundary information.</div>
                        <div class=""><br class="">
                        </div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                I can see how this works if you are writing your own
                solver but can it be used with a KSP? In the case of
                periodic boundary conditions the boundary values are
                "filled in" for you by PETSc. Is there any way for a
                user to supply boundary information to a PETSc solver
                when using DMDA_BOUNDARY_GHOSTED?<br class="">
              </div>
            </blockquote>
            <div class=""><br class="">
            </div>
            <div class="">Right now, there is not. This is mainly due to the lack
              of consensus for boundary condition specification.
              Periodic conditions are simple in this respect.</div>
            <div class=""><br class="">
            </div>
            <div class="">For example, Plex has such a thing</div>
            <div class=""><br class="">
            </div>
            <div class="">  <a href="https://petsc.org/main/docs/manualpages/DM/DMAddBoundary/" moz-do-not-send="true" class="moz-txt-link-freetext">https://petsc.org/main/docs/manualpages/DM/DMAddBoundary/</a></div>
            <div class=""><br class="">
            </div>
            <div class="">that can be used to fill in these constrained spots</div>
            <div class=""><br class="">
            </div>
            <div class="">  <a href="https://petsc.org/main/docs/manualpages/DMPLEX/DMPlexInsertBoundaryValues/" moz-do-not-send="true" class="moz-txt-link-freetext">https://petsc.org/main/docs/manualpages/DMPLEX/DMPlexInsertBoundaryValues/</a></div>
            <div class=""><br class="">
            </div>
            <div class="">But there have been many complaints about this
              interface (and I suspect any interface we choose).</div>
            <div class=""><br class="">
            </div>
            <div class="">Maybe there is something that we could write that would
              make it easier for you with DMDA?</div>
            <div class=""><br class="">
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    The way I had imagined it working was that for each dimension the
    user could register a function to be to be called at the start of
    every iteration (in a similar fashion to adding a monitor). Not all
    of the dimensions would have to be specified as
    DMDA_BOUNDARY_GHOSTED and thus require a function to be registered.
    This function would have access to the DMDA and the local vector so
    it could determine if ghost locations were present and, if so, set
    appropriate values. Does this make sense?<br class="">
    <br class="">
    Thanks,<br class="">
    <br class="">
    David<br class="">
    <br class="">
    <blockquote type="cite" cite="mid:CAMYG4GmzzvfqPuXRBE9n1ZFZ5sCU=Ao95KNNPtPCvD4O7_4ZrQ@mail.gmail.com" class="">
      <div class="">
        <div dir="ltr" class="">
          <div class="gmail_quote">
            <div class=""> </div>
            <div class="">  Thanks,</div>
            <div class=""><br class="">
            </div>
            <div class="">     Matt</div>
            <div class=""> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div class="">Thanks,<br class="">
                <br class="">
                David<br class="">
                <br class="">
                <blockquote type="cite" class="">
                  <div class="">
                    <div dir="ltr" class="">
                      <div class="gmail_quote">
                        <div class="">  Thanks,</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">     Matt</div>
                        <div class=""> </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="ltr" class="">
                            <div class="">
                              <div class="">I hope someone can explain my wonder
                                :)</div>
                              <div class=""><br class="">
                              </div>
                              <div class="">P/S: maybe, those question is
                                simple and a bit stupid ^_^. </div>
                              <div class=""><br class="">
                              </div>
                              <div class="">Have a nice day,</div>
                              <div class=""><br class="">
                              </div>
                              -- <br class="">
                              <div dir="ltr" class="">
                                <div dir="ltr" class="">
                                  <div dir="ltr" class="">
                                    <div dir="ltr" class="">
                                      <div dir="ltr" class="">
                                        <div dir="ltr" class="">
                                          <div dir="ltr" class="">
                                            <div dir="ltr" class="">
                                              <div class=""><span class="">Quynh Nguyen</span><br class="">
                                              </div>
                                              <div class=""><font face="times new
                                                  roman, serif" color="#3d85c6" class=""><span style="font-size:12.8px" class="">Graduate student, Ocean Engineering.</span></font></div>
                                              <div class=""><font face="times new
                                                  roman, serif" color="#3d85c6" class=""><span style="font-size:12.8px" class="">School of Naval Architecture and Ocean
                                                    Engineering,
                                                    University of Ulsan.</span></font></div>
                                              <div class="">
                                                <div class=""><font face="times
                                                    new roman, serif" color="#3d85c6" class="">-----------------------------------------------------------------------------------------</font></div>
                                                <div class=""><font face="times
                                                    new roman, serif" color="#3d85c6" class="">Mobile:
                                                    (+82) 010-9394-5595 </font></div>
                                                <div class=""><font face="times
                                                    new roman, serif" color="#3d85c6" class="">Email:
                                                    <a href="mailto:nguyenquynh9537@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">nguyenquynh9537@gmail.com</a>; <a href="mailto:nguyenthiquynhb_t58@hus.edu.vn" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">nguyenthiquynhb_t58@hus.edu.vn</a></font></div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      <br clear="all" class="">
                      <div class=""><br class="">
                      </div>
                      -- <br class="">
                      <div dir="ltr" class="">
                        <div dir="ltr" class="">
                          <div class="">
                            <div dir="ltr" class="">
                              <div class="">
                                <div dir="ltr" class="">
                                  <div class="">What most experimenters take for
                                    granted before they begin their
                                    experiments is infinitely more
                                    interesting than any results to
                                    which their experiments lead.<br class="">
                                    -- Norbert Wiener</div>
                                  <div class=""><br class="">
                                  </div>
                                  <div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" moz-do-not-send="true" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                <br class="">
                The University of Edinburgh is a charitable body,
                registered in Scotland, with registration number
                SC005336. Is e buidheann carthannais a th’ ann an
                Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh
                clàraidh SC005336. </div>
            </blockquote>
          </div>
          <br clear="all" class="">
          <div class=""><br class="">
          </div>
          -- <br class="">
          <div dir="ltr" class="gmail_signature">
            <div dir="ltr" class="">
              <div class="">
                <div dir="ltr" class="">
                  <div class="">
                    <div dir="ltr" class="">
                      <div class="">What most experimenters take for granted
                        before they begin their experiments is
                        infinitely more interesting than any results to
                        which their experiments lead.<br class="">
                        -- Norbert Wiener</div>
                      <div class=""><br class="">
                      </div>
                      <div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" moz-do-not-send="true" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br class="">
  </div>

</div></blockquote></div><br class=""></div></body></html>