On Tue, May 17, 2011 at 4:53 PM, Tabrez Ali <span dir="ltr">&lt;<a href="mailto:stali@geology.wisc.edu">stali@geology.wisc.edu</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<u></u>

  
    
    
  
  <div text="#000000" bgcolor="#ffffff">
    Matt<br>
    <br>
    Any linear 2/3d element would do. A linear tetrahedron would be good
    to start with.<br></div></blockquote><div><br></div><div>I have finally gotten to this. Sorry about the wait. You must have petsc-dev. I have added</div><div><br></div><div>  src/dm/impls/mesh/examples/tutorials/ex4f90.F</div>
<div><br></div><div>I coded it using the Fortran datatypes option. If you do not use his, just change</div><div><br></div><div>  type(Mat) --&gt; Mat</div><div><br></div><div>and so on. It should work fine. It reads in an ExodusII mesh (I attach the one I used),</div>
<div>and then defines a linear element. It prints out the properly allocated matrix. Let me know</div><div>if this helps.</div><div><br></div><div>  Thanks,</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 text="#000000" bgcolor="#ffffff">
    Thanks<br><font color="#888888">
    Tabrez</font><div><div></div><div class="h5"><br>
    <br>
    On 05/17/2011 11:21 AM, Matthew Knepley wrote:
    <blockquote type="cite">On Tue, May 17, 2011 at 9:36 AM, Tabrez Ali <span dir="ltr">&lt;<a href="mailto:stali@geology.wisc.edu" target="_blank">stali@geology.wisc.edu</a>&gt;</span>
      wrote:<br>
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
          <div text="#000000" bgcolor="#ffffff"> Matt<br>
            <br>
            An example which reads an unstructured mesh (ascii or
            exodus), partitions it and sets up Mat (with the right
            preallocation) would be great. If it is in Fortran then that
            would be perfect. Btw my problem also has Lagrange
            multiplier constraints.<br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>Yes, I should have been more specific. What element?</div>
        <div><br>
        </div>
        <div>  Thanks,</div>
        <div><br>
        </div>
        <div>     Matt</div>
        <div> </div>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
          <div text="#000000" bgcolor="#ffffff"> Thanks<br>
            <font color="#888888"> Tabrez</font>
            <div>
              <div><br>
                <br>
                On 05/17/2011 08:25 AM, Matthew Knepley wrote:
                <blockquote type="cite">On Mon, May 2, 2011 at 8:16 AM,
                  Tabrez Ali <span dir="ltr">&lt;<a href="mailto:stali@geology.wisc.edu" target="_blank">stali@geology.wisc.edu</a>&gt;</span>
                  wrote:<br>
                  <div class="gmail_quote">
                    <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
                      <div text="#000000" bgcolor="#ffffff"> Is there a
                        way I can use this and other mesh routines from
                        Fortran? The manual doesn&#39;t say much on this.</div>
                    </blockquote>
                    <div><br>
                    </div>
                    <div>Yes, but you are right that nothing is in the
                      manual. DMMESH (in petsc-dev) now obeys the full
                      DM interface,</div>
                    <div>so that DMGetMatrix() will return you a
                      properly allocated Mat. So what is the problem? Of
                      course, it is that</div>
                    <div>Petsc has no good way to specify what finite
                      element you are dealing with.</div>
                    <div><br>
                    </div>
                    <div>The way I was doing this is to encode it using
                      some C++ classes. This turns out to be a bad way
                      to do things.</div>
                    <div> I am currently reworking it so that this
                      information is stored in a simple C struct that
                      you can produce. Should</div>
                    <div>have this done soon.</div>
                    <div><br>
                    </div>
                    <div>Can you mail me a description of an example you
                      would like to run?</div>
                    <div><br>
                    </div>
                    <div>  Thanks,</div>
                    <div><br>
                    </div>
                    <div>     Matt</div>
                    <div> </div>
                    <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
                      <div text="#000000" bgcolor="#ffffff"> <font color="#888888"><br>
                          Tabrez</font>
                        <div>
                          <div><br>
                            <br>
                            On 05/01/2011 09:53 AM, Matthew Knepley
                            wrote:
                            <blockquote type="cite">On Sat, Apr 30, 2011
                              at 12:58 PM, Tabrez Ali <span dir="ltr">&lt;<a href="mailto:stali@geology.wisc.edu" target="_blank">stali@geology.wisc.edu</a>&gt;</span>
                              wrote:<br>
                              <div class="gmail_quote">
                                <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"> Petsc
                                  Developers/Users<br>
                                  <br>
                                  I having some performance issues with
                                  preallocation in a fully unstructured
                                  FE code. It would be very helpful if
                                  those using FE codes can comment.<br>
                                  <br>
                                  For a problem of size 100K nodes and
                                  600K tet elements (on 1 cpu)<br>
                                  <br>
                                  1. If I calculate the _exact_ number
                                  of non-zeros per row (using a running
                                  list in Fortran) by looping over nodes
                                  &amp; elements, the code takes 17 mins
                                  (to calculate nnz&#39;s/per row, assemble
                                  and solve).<br>
                                  2. If I dont use a running list and
                                  simply get the average of the max
                                  number of nodes a node might be
                                  connected to (again by looping over
                                  nodes &amp; elements but not using a
                                  running list) then it takes 8 mins<br>
                                  3. If I just magically guess the right
                                  value calculated in 2 and use that as
                                  average nnz per row then it only takes
                                  25 secs.<br>
                                  <br>
                                  Basically in all cases Assembly and
                                  Solve are very fast (few seconds) but
                                  the nnz calculation itself (in 2 and
                                  3) takes a long time. How can this be
                                  cut down? Is there a heuristic way to
                                  estimate the number (as done in 3)
                                  even if it slightly overestimates the
                                  nnz&#39;s per row or are efficient ways to
                                  do step 1 or 2. Right now I have do
                                  i=1,num_nodes; do j=1,num_elements ...
                                  which obviously is slow for large
                                  number of nodes/elements.<br>
                                </blockquote>
                                <div><br>
                                </div>
                                <div>If you want to see my code doing
                                  this, look at</div>
                                <div><br>
                                </div>
                                <div>  include/petscdmmesh.hh:preallocateOperatorNew()</div>
                                <div><br>
                                </div>
                                <div>which handles the determination of
                                  nonzero structure for a FEM operator.
                                  It should look mostly</div>
                                <div>like your own code.</div>
                                <div><br>
                                </div>
                                <div>    Matt</div>
                                <div> </div>
                                <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"> Thanks in
                                  advance<br>
                                  <font color="#888888"> Tabrez<br>
                                  </font></blockquote>
                              </div>
                              <br>
                              <br clear="all">
                              <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>
                            </blockquote>
                            <br>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <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>
                </blockquote>
                <br>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <br clear="all">
      <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>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br><br clear="all"><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>