<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Thanks, I'll try it.</p>
    <p>Barry<br>
    </p>
    <div class="moz-cite-prefix">On 11/30/18 10:40 PM, Stefano Zampini
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:3C550DA5-0797-4DF1-AE6F-9C0769219B86@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Just to add to what Matt wrote: it seems your question is to get
      the cell numbers  given a node (=vertex) numbering
      <div class="">In general, there are many cells that share the same
        vertex. If you have a vertex id (vertex), you can traverse the
        cells that share that vertex by still using
        DMPlexGetTransitiveClosure, with a PETSC_FALSE argument to get
        the so-called “star” of the point </div>
      <div class=""><br class="">
      </div>
      <div class="">ierr = DMPlexGetHeightStratum(dm, 0, &cStart,
        &cEnd);CHKERRQ(ierr);</div>
      <div class="">ierr = DMPlexGetTransitiveClosure(dm, vertex,
        PETSC_FALSE, &clSize, &closure);CHKERRQ(ierr);</div>
      <div class="">for (cl = 0; cl < clSize*2; cl += 2) {</div>
      <div class="">  const PetscInt point = closure[cl];</div>
      <div class=""><br class="">
      </div>
      <div class="">  if (point >= cStart && point < cEnd)
        {</div>
      <div class="">    <this is a cell></div>
      <div class="">  }</div>
      <div class="">}</div>
      <div class="">ierr = DMPlexRestoreTransitiveClosure(dm, vertex,
        PETSC_FALSE, &clSize, &closure);CHKERRQ(ierr);</div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">
        <div>
          <blockquote type="cite" class="">
            <div class="">On Nov 30, 2018, at 4:28 PM, Matthew Knepley
              <<a href="mailto:knepley@gmail.com" class=""
                moz-do-not-send="true">knepley@gmail.com</a>> wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <div dir="ltr" style="font-family: Helvetica; font-size:
                12px; font-style: normal; font-variant-caps: normal;
                font-weight: normal; letter-spacing: normal; text-align:
                start; text-indent: 0px; text-transform: none;
                white-space: normal; word-spacing: 0px;
                -webkit-text-stroke-width: 0px;" class="">
                <div dir="ltr" class="">
                  <div dir="ltr" class="">
                    <div dir="ltr" class="">
                      <div class="gmail_quote">
                        <div dir="ltr" class="">On Fri, Nov 30, 2018 at
                          8:19 AM barry via petsc-users <<a
                            href="mailto:petsc-users@mcs.anl.gov"
                            class="" moz-do-not-send="true">petsc-users@mcs.anl.gov</a>>
                          wrote:<br class="">
                        </div>
                        <blockquote class="gmail_quote" style="margin:
                          0px 0px 0px 0.8ex; border-left-width: 1px;
                          border-left-style: solid; border-left-color:
                          rgb(204, 204, 204); padding-left: 1ex;">
                          <div bgcolor="#FFFFFF" class="">Sorry for the
                            imprecisely description.
                            <p class="">I have an unstructured grid
                              (DMPLEX) with triangle mesh.</p>
                            <p class="">cell number (2 dim)={0};    line
                              number (1 dim)={1, 2, 3};    node number
                              (0 dim)={4, 5, 6}</p>
                            <div class=""><br
                                class="webkit-block-placeholder">
                            </div>
                          </div>
                        </blockquote>
                        <div class="">So, you have a 2D interpolated
                          simplex mesh in DMPlex, which means it has
                          vertices, edges, and cells.</div>
                        <div class="">If you want the vertices on a
                          given cell, you would get the closure and then
                          filter out any points which are</div>
                        <div class="">not vertices. For example,</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">PetscInt *closure = NULL;</div>
                        <div class="">PetscInt  clSize, cl;</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">
                          <div class="">ierr = DMPlexGetDepthStratum(dm,
                            0, &vStart, &vEnd);CHKERRQ(ierr);</div>
                        </div>
                        <div class="">
                          <div class="">ierr =
                            DMPlexGetTransitiveClosure(dm, cell,
                            PETSC_TRUE, &clSize,
                            &closure);CHKERRQ(ierr);</div>
                        </div>
                        <div class="">for (cl = 0; cl < clSize*2; cl
                          += 2) {</div>
                        <div class="">  const PetscInt point =
                          closure[cl];</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">  if (point >= vStart
                          && point < vEnd) {</div>
                        <div class="">    <this is a vertex></div>
                        <div class="">  }</div>
                        <div class="">}</div>
                        <div class="">
                          <div class="">ierr =
                            DMPlexRestoreTransitiveClosure(dm, cell,
                            PETSC_TRUE, &clSize,
                            &closure);CHKERRQ(ierr);</div>
                        </div>
                        <div class=""><br class="">
                        </div>
                        <div class="">If you do not use edges, then its
                          much easier. Just call DMPlexGetCone(). If you
                          do use edges, but also</div>
                        <div class="">get the vertices all the time, you
                          can make an index for this query, which will
                          speed it up greatly at the</div>
                        <div class="">cost of some memory.</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">  Thanks,</div>
                        <div class=""><br class="">
                        </div>
                        <div class="">     Matt</div>
                        <blockquote class="gmail_quote" style="margin:
                          0px 0px 0px 0.8ex; border-left-width: 1px;
                          border-left-style: solid; border-left-color:
                          rgb(204, 204, 204); padding-left: 1ex;">
                          <div bgcolor="#FFFFFF" class="">
                            <p class="">Thank you,</p>
                            <p class="">Barry<br class="">
                            </p>
                            <div
                              class="gmail-m_-3541176372144564405moz-cite-prefix">On
                              11/30/18 8:33 PM, Stefano Zampini wrote:<br
                                class="">
                            </div>
                            <blockquote type="cite" class="">
                              <div dir="auto" class="">
                                <div class=""><br class="">
                                  <br class="">
                                  <div class="gmail_quote">
                                    <div dir="ltr" class="">Il giorno
                                      Ven 30 Nov 2018, 15:05 Tsung-Hsing
                                      Chen via petsc-users <<a
                                        href="mailto:petsc-users@mcs.anl.gov"
                                        target="_blank" class=""
                                        moz-do-not-send="true">petsc-users@mcs.anl.gov</a>>
                                      ha scritto:<br class="">
                                    </div>
                                    <blockquote class="gmail_quote"
                                      style="margin: 0px 0px 0px 0.8ex;
                                      border-left-width: 1px;
                                      border-left-style: solid;
                                      border-left-color: rgb(204, 204,
                                      204); padding-left: 1ex;">
                                      <div dir="ltr" class="">Hi,
                                        <div class="">Is there any
                                          function that can get cell
                                          number from the given node
                                          number exist already?</div>
                                      </div>
                                    </blockquote>
                                  </div>
                                </div>
                                <div dir="auto" class=""><br class="">
                                </div>
                                <div dir="auto" class="">Cell number of
                                  what? DMPLEX? And what is "node
                                  number"?</div>
                                <div dir="auto" class=""><br class="">
                                </div>
                                <div dir="auto" class="">
                                  <div class="gmail_quote">
                                    <blockquote class="gmail_quote"
                                      style="margin: 0px 0px 0px 0.8ex;
                                      border-left-width: 1px;
                                      border-left-style: solid;
                                      border-left-color: rgb(204, 204,
                                      204); padding-left: 1ex;">
                                      <div dir="ltr" class="">
                                        <div class=""><br class="">
                                        </div>
                                        <div class="">Thank you,</div>
                                        <div class="">Barry</div>
                                      </div>
                                    </blockquote>
                                  </div>
                                </div>
                              </div>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                      <br class="" clear="all">
                      <div class=""><br class="">
                      </div>
                      --<span class="Apple-converted-space"> </span><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" class=""
                                      moz-do-not-send="true">https://www.cse.buffalo.edu/~knepley/</a></div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
  </body>
</html>