[petsc-users] DM misuse causes massive memory leak?

Ferrand, Jesus A. FERRANJ2 at my.erau.edu
Wed Dec 29 16:12:53 CST 2021


Dear PETSc Team:

I have a question about DM and PetscSection. Say I import a mesh (for FEM purposes) and create a DMPlex for it. I then use PetscSections to set degrees of freedom per "point" (by point I mean vertices, lines, faces, and cells). I then use PetscSectionGetStorageSize() to get the size of the global stiffness matrix (K) needed for my FEM problem. One last detail, this K I populate inside a rather large loop using an element stiffness matrix function of my own. Instead of using DMCreateMatrix(), I manually created a Mat using MatCreate(), MatSetType(), MatSetSizes(), and MatSetUp(). I come to find that said loop is painfully slow when I use the manually created matrix, but 20x faster when I use the Mat coming out of DMCreateMatrix().

My question is then: Is the manual Mat a noob mistake and is it somehow creating a memory leak with K? Just in case it's something else I'm attaching the code. The loop that populates K is between lines 221 and 278. Anything related to DM, DMPlex, and PetscSection is between lines 117 and 180.

Machine Type: HP Laptop
C-compiler: Gnu C
OS: Ubuntu 20.04
PETSc version: 3.16.0
MPI Implementation: MPICH

Hope you all had a Merry Christmas and that you will have a happy and productive New Year. :D


Sincerely:

J.A. Ferrand

Embry-Riddle Aeronautical University - Daytona Beach FL

M.Sc. Aerospace Engineering | May 2022

B.Sc. Aerospace Engineering

B.Sc. Computational Mathematics



Sigma Gamma Tau

Tau Beta Pi

Honors Program



Phone: (386)-843-1829

Email(s): ferranj2 at my.erau.edu

    jesus.ferrand at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211229/db5d4a19/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmshBACKUP2.c
Type: text/x-csrc
Size: 34421 bytes
Desc: gmshBACKUP2.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211229/db5d4a19/attachment-0001.bin>


More information about the petsc-users mailing list