[cig-commits] r21701 - in short/3D/PyLith/trunk/libsrc/pylith: faults topology

brad at geodynamics.org brad at geodynamics.org
Tue Apr 2 18:01:02 PDT 2013


Author: brad
Date: 2013-04-02 18:01:02 -0700 (Tue, 02 Apr 2013)
New Revision: 21701

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/VisitorSubMesh.icc
Log:
Fixed some memory leaks.

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-04-03 00:54:29 UTC (rev 21700)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-04-03 01:01:02 UTC (rev 21701)
@@ -188,6 +188,7 @@
     }
     err = PetscFree(renum);CHECK_PETSC_ERROR(err);
     err = DMPlexSetSubpointMap(dm, subpointMap);CHECK_PETSC_ERROR(err);
+    err = DMLabelDestroy(&subpointMap);CHECK_PETSC_ERROR(err);
     renumbering.clear();
     faultMesh->setDMMesh(dm);
   }

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-04-03 00:54:29 UTC (rev 21700)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-04-03 01:01:02 UTC (rev 21701)
@@ -59,10 +59,12 @@
       err = DMGetDefaultSection(coordDM, &coordSection);CHECK_PETSC_ERROR(err);
       err = PetscSectionClone(coordSection, &newCoordSection);CHECK_PETSC_ERROR(err);
       err = DMSetDefaultSection(newCoordDM, newCoordSection);CHECK_PETSC_ERROR(err);
+      err = PetscSectionDestroy(&newCoordSection);CHECK_PETSC_ERROR(err);
       err = DMSetCoordinatesLocal(_dm, coordVec);CHECK_PETSC_ERROR(err);
     }
     err = PetscSectionCreate(mesh.comm(), &s);CHECK_PETSC_ERROR(err);
     err = DMSetDefaultSection(_dm, s);CHECK_PETSC_ERROR(err);
+    err = PetscSectionDestroy(&s);CHECK_PETSC_ERROR(err);
   } else {
     _dm = NULL;
   }
@@ -157,6 +159,7 @@
     err = DMGetDefaultSection(coordDM, &coordSection);CHECK_PETSC_ERROR(err);
     err = PetscSectionClone(coordSection, &newCoordSection);CHECK_PETSC_ERROR(err);
     err = DMSetDefaultSection(newCoordDM, newCoordSection);CHECK_PETSC_ERROR(err);
+    err = PetscSectionDestroy(&newCoordSection);CHECK_PETSC_ERROR(err);
     err = DMSetCoordinatesLocal(_dm, coordVec);CHECK_PETSC_ERROR(err);
   } // if
   _globalVec = NULL;
@@ -508,6 +511,7 @@
   assert(_dm);
   err = PetscSectionClone(section, &newSection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultSection(_dm, newSection);CHECK_PETSC_ERROR(err);
+  err = PetscSectionDestroy(&newSection);CHECK_PETSC_ERROR(err);
   err = DMCreateGlobalVector(_dm, &_globalVec);CHECK_PETSC_ERROR(err);
   err = DMCreateLocalVector(_dm, &_localVec);CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject) _globalVec, _metadata["default"].label.c_str());CHECK_PETSC_ERROR(err);
@@ -1060,6 +1064,7 @@
   err = DMGetDefaultSection(_dm, &section);CHECK_PETSC_ERROR(err);
   err = PetscSectionClone(section, &newSection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultSection(sinfo.dm, newSection);CHECK_PETSC_ERROR(err);
+  err = PetscSectionDestroy(&newSection);CHECK_PETSC_ERROR(err);
   err = DMGetPointSF(sinfo.dm, &sf);CHECK_PETSC_ERROR(err);
   err = PetscSectionCreateGlobalSection(section, sf, PETSC_TRUE, &gsection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultGlobalSection(sinfo.dm, gsection);CHECK_PETSC_ERROR(err);
@@ -1159,6 +1164,7 @@
   err = DMPlexClone(_dm, &sinfo.dm);CHECK_PETSC_ERROR(err);
   err = PetscSectionClone(section, &newSection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultSection(sinfo.dm, newSection);CHECK_PETSC_ERROR(err);
+  err = PetscSectionDestroy(&newSection);CHECK_PETSC_ERROR(err);
   err = DMGetPointSF(sinfo.dm, &sf);CHECK_PETSC_ERROR(err);
   if (labelName.empty()) {
     err = PetscSectionCreateGlobalSectionCensored(section, sf, PETSC_TRUE, numExcludes, excludeRanges, &gsection);CHECK_PETSC_ERROR(err);

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc	2013-04-03 00:54:29 UTC (rev 21700)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc	2013-04-03 01:01:02 UTC (rev 21701)
@@ -73,6 +73,7 @@
 
   delete _coordsys; _coordsys = 0;
   _mesh.destroy();
+  PetscErrorCode err = DMDestroy(&_newMesh);CHECK_PETSC_ERROR(err);
 
   PYLITH_METHOD_END;
 } // deallocate
@@ -164,6 +165,7 @@
   } // if
 
   /* TODO: Add creation of pointSF for submesh */
+  err = DMDestroy(&_newMesh);CHECK_PETSC_ERROR(err);
   err = DMPlexCreateSubmesh(dmMesh, label, &_newMesh);CHECK_PETSC_ERROR(err);
 
   // Set data from mesh.

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/VisitorSubMesh.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/VisitorSubMesh.icc	2013-04-03 00:54:29 UTC (rev 21700)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/VisitorSubMesh.icc	2013-04-03 01:01:02 UTC (rev 21701)
@@ -191,6 +191,11 @@
 pylith::topology::MatVisitorSubMesh::~MatVisitorSubMesh(void)
 { // destructor
   clear();
+  
+  PetscErrorCode err;
+  err = PetscSectionDestroy(&_subsection);assert(!_subsection);
+  err = PetscSectionDestroy(&_globalSubsection);assert(!_globalSubsection);
+  err = PetscSectionDestroy(&_globalSection);assert(!_globalSection);
 } // destructor
 
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list