[petsc-users] How to free SieveMesh memory?

Matthew Knepley knepley at gmail.com
Fri Jun 1 10:26:48 CDT 2012


On Fri, Jun 1, 2012 at 5:24 AM, fdkong <fd.kong at siat.ac.cn> wrote:

> Hi guys,
>
> In directory: /src//src/dm/impls/mesh/, we can find a file named "mesh.c",
> where a function called "DMDestroy_Mesh(DM dm)", which has the following
> code:
>
> PetscErrorCode DMDestroy_Mesh(DM dm)
>  {
>    DM_Mesh       *mesh = (DM_Mesh *) dm->data;
>
>    mesh->m = PETSC_NULL;
>    VecScatterDestroy(&mesh->globalScatter);
>     return(0);
>  }
>
> When we destroy SieveMesh,  this function will be called. In this
> function, we just set "mesh->m = PETSC_NULL", Whether memory occupied by
> SieveMesh will be free? I don't think so!
>

1) It will be freed because it is allocated in C++, and the destructor is
automatically called by
    the smart pointer when it is set to NULL

2) This is my old code. It works, but you should seriously consider using
the new revision which
    is all in C and easier to understand, and better integrated with the
solvers. See


http://www.mcs.anl.gov/petsc/petsc-dev/src/snes/examples/tutorials/ex62.c.html

   for the Stokes problem on an unstructured grid.

      Matt


> Thus, there are anyone who have an idea on how to free SieveMesh memory.
>
> Regards,
> **
> ------------------
> Fande Kong
> ShenZhen Institutes of Advanced Technology
> Chinese Academy of Sciences
> **
>
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120601/bcc0c302/attachment-0001.html>


More information about the petsc-users mailing list