[cig-commits] r22027 - in short/3D/PyLith/trunk/libsrc/pylith: bc faults feassemble materials meshio problems topology

brad at geodynamics.org brad at geodynamics.org
Fri May 10 11:42:39 PDT 2013


Author: brad
Date: 2013-05-10 11:42:38 -0700 (Fri, 10 May 2013)
New Revision: 22027

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/bc/DirichletBC.cc
   short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc
   short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc
   short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveTract.cc
   short/3D/PyLith/trunk/libsrc/pylith/feassemble/Integrator.cc
   short/3D/PyLith/trunk/libsrc/pylith/materials/ElasticMaterial.cc
   short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
Log:
Small cleanup of deallocation.

Modified: short/3D/PyLith/trunk/libsrc/pylith/bc/DirichletBC.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/bc/DirichletBC.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/bc/DirichletBC.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -42,6 +42,7 @@
 // Destructor.
 pylith::bc::DirichletBC::~DirichletBC(void)
 { // destructor
+  deallocate();
 } // destructor
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -71,8 +71,7 @@
 
   FaultCohesiveLagrange::deallocate();
 
-  // :TODO: Use shared pointers for amplitudes of impulses
-  _dbImpulseAmp = 0;
+  _dbImpulseAmp = 0; // :TODO: Use shared pointers for amplitudes of impulses
 
   PYLITH_METHOD_END;
 } // deallocate

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -43,7 +43,6 @@
 #include <sstream> // USES std::ostringstream
 #include <stdexcept> // USES std::runtime_error
 
-//#define PRECOMPUTE_GEOMETRY
 //#define DETAILED_EVENT_LOGGING
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveTract.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveTract.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveTract.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -48,8 +48,11 @@
 void 
 pylith::faults::FaultCohesiveTract::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   FaultCohesive::deallocate();
 
+  PYLITH_METHOD_END;
 } // deallocate
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/pylith/feassemble/Integrator.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/feassemble/Integrator.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/feassemble/Integrator.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -47,7 +47,6 @@
 pylith::feassemble::Integrator<quadrature_type>::~Integrator(void)
 { // destructor
   deallocate();
-  _gravityField = 0; /// Memory managed elsewhere :TODO: use shared pointer
 } // destructor
   
 // ----------------------------------------------------------------------
@@ -61,6 +60,7 @@
   delete _quadrature; _quadrature = 0;
   delete _normalizer; _normalizer = 0;
   delete _logger; _logger = 0;
+  _gravityField = 0; /// Memory managed elsewhere :TODO: use shared pointer
 
   PYLITH_METHOD_END;
 } // deallocate
@@ -80,8 +80,7 @@
 void
 pylith::feassemble::Integrator<quadrature_type>::quadrature(const quadrature_type* q)
 { // quadrature
-  delete _quadrature;
-  _quadrature = (q) ? new quadrature_type(*q) : 0;
+  delete _quadrature; _quadrature = (q) ? new quadrature_type(*q) : 0;
 
   // Deallocate cell vector and matrix since size may change
   _cellVector.resize(0);

Modified: short/3D/PyLith/trunk/libsrc/pylith/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/materials/ElasticMaterial.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/materials/ElasticMaterial.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -39,8 +39,6 @@
 #include <stdexcept> // USES std::runtime_error
 #include <sstream> // USES std::ostringstream
 
-//#define PRECOMPUTE_GEOMETRY
-
 // ----------------------------------------------------------------------
 // Default constructor.
 pylith::materials::ElasticMaterial::ElasticMaterial(const int dimension,
@@ -584,11 +582,7 @@
   const PetscInt* cells = materialIS.points();
   const PetscInt numCells = materialIS.size();
 
-#if !defined(PRECOMPUTE_GEOMETRY)
   topology::CoordsVisitor coordsVisitor(dmMesh);
-  PetscScalar *coordsCell = NULL;
-  PetscInt coordsSize = 0;
-#endif
 
   // Create arrays for querying
   const int tensorSize = _tensorSize;
@@ -646,14 +640,13 @@
 
   for(PetscInt c = 0; c < numCells; ++c) {
     const PetscInt cell = cells[c];
+
     // Compute geometry information for current cell
-#if defined(PRECOMPUTE_GEOMETRY)
-    quadrature->retrieveGeometry(*c_iter);
-#else
+    PetscScalar *coordsCell = NULL;
+    PetscInt coordsSize = 0;
     coordsVisitor.getClosure(&coordsCell, &coordsSize, cell);assert(coordsCell);assert(numBasis*spaceDim == coordsSize);
     quadrature->computeGeometry(coordsCell, coordsSize, cell);
     coordsVisitor.restoreClosure(&coordsCell, &coordsSize, cell);
-#endif
 
     // Dimensionalize coordinates for querying
     const scalar_array& quadPtsNonDim = quadrature->quadPts();
@@ -722,11 +715,7 @@
   const PetscInt* cells = materialIS.points();
   const PetscInt numCells = materialIS.size();
 
-#if !defined(PRECOMPUTE_GEOMETRY)
   topology::CoordsVisitor coordsVisitor(dmMesh);
-  PetscScalar* coordsCell = NULL;
-  PetscInt coordsSize = 0;
-#endif
 
   // Create arrays for querying
   const int tensorSize = _tensorSize;
@@ -784,14 +773,13 @@
     
   for(PetscInt c = 0; c < numCells; ++c) {
     const PetscInt cell = cells[c];
+
     // Compute geometry information for current cell
-#if defined(PRECOMPUTE_GEOMETRY)
-    quadrature->retrieveGeometry(*c_iter);
-#else
+    PetscScalar* coordsCell = NULL;
+    PetscInt coordsSize = 0;
     coordsVisitor.getClosure(&coordsCell, &coordsSize, cell);assert(coordsCell);assert(numBasis*spaceDim == coordsSize);
     quadrature->computeGeometry(coordsCell, coordsSize, cell);
     coordsVisitor.restoreClosure(&coordsCell, &coordsSize, cell);
-#endif
 
     // Dimensionalize coordinates for querying
     const scalar_array& quadPtsNonDim = quadrature->quadPts();

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -51,8 +51,6 @@
 template<typename mesh_type, typename field_type>
 pylith::meshio::DataWriterVTK<mesh_type,field_type>::~DataWriterVTK(void)
 { // destructor
-  closeTimeStep(); // Insure time step is closed.
-  close(); // Insure clean up.
   deallocate();
 } // destructor  
 
@@ -64,6 +62,8 @@
 { // deallocate
   PYLITH_METHOD_BEGIN;
 
+  closeTimeStep(); // Insure time step is closed.
+  close(); // Insure clean up.
   DataWriter<mesh_type, field_type>::deallocate();
 
   PYLITH_METHOD_END;

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -43,7 +43,7 @@
 { // calcRateFields
   PYLITH_METHOD_BEGIN;
 
-  assert(0 != _fields);
+  assert(_fields);
 
   // vel(t) = (disp(t+dt) - disp(t)) / dt
   //        = dispIncr(t+dt) / dt

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-05-10 15:31:37 UTC (rev 22026)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2013-05-10 18:42:38 UTC (rev 22027)
@@ -179,7 +179,6 @@
 pylith::topology::Field<mesh_type>::~Field(void)
 { // destructor
   deallocate();
-  PetscErrorCode err = DMDestroy(&_dm);PYLITH_CHECK_ERROR(err);
 } // destructor
 
 // ----------------------------------------------------------------------
@@ -190,25 +189,9 @@
 { // deallocate
   PYLITH_METHOD_BEGIN;
 
-  PetscErrorCode err = 0;
-  
-  const typename scatter_map_type::const_iterator scattersEnd = _scatters.end();
-  for (typename scatter_map_type::iterator s_iter=_scatters.begin();
-       s_iter != scattersEnd;
-       ++s_iter) {
+  clear();
+  PetscErrorCode err = DMDestroy(&_dm);PYLITH_CHECK_ERROR(err);
 
-    err = DMDestroy(&s_iter->second.dm);PYLITH_CHECK_ERROR(err);
-    err = VecDestroy(&s_iter->second.vector);PYLITH_CHECK_ERROR(err);
-
-    if (s_iter->second.scatter) {
-      err = VecScatterDestroy(&s_iter->second.scatter);PYLITH_CHECK_ERROR(err);
-    } // if
-    err = VecDestroy(&s_iter->second.scatterVec);PYLITH_CHECK_ERROR(err);
-  } // for
-  _scatters.clear();
-  err = VecDestroy(&_globalVec);PYLITH_CHECK_ERROR(err);
-  err = VecDestroy(&_localVec);PYLITH_CHECK_ERROR(err);
-
   PYLITH_METHOD_END;
 } // deallocate
 
@@ -586,7 +569,25 @@
 { // clear
   PYLITH_METHOD_BEGIN;
 
-  deallocate();
+  PetscErrorCode err = 0;
+  
+  const typename scatter_map_type::const_iterator scattersEnd = _scatters.end();
+  for (typename scatter_map_type::iterator s_iter=_scatters.begin();
+       s_iter != scattersEnd;
+       ++s_iter) {
+
+    err = DMDestroy(&s_iter->second.dm);PYLITH_CHECK_ERROR(err);
+    err = VecDestroy(&s_iter->second.vector);PYLITH_CHECK_ERROR(err);
+
+    if (s_iter->second.scatter) {
+      err = VecScatterDestroy(&s_iter->second.scatter);PYLITH_CHECK_ERROR(err);
+    } // if
+    err = VecDestroy(&s_iter->second.scatterVec);PYLITH_CHECK_ERROR(err);
+  } // for
+  _scatters.clear();
+  err = VecDestroy(&_globalVec);PYLITH_CHECK_ERROR(err);
+  err = VecDestroy(&_localVec);PYLITH_CHECK_ERROR(err);
+
   _metadata["default"].scale = 1.0;
   _metadata["default"].vectorFieldType = OTHER;
   _metadata["default"].dimsOkay = false;



More information about the CIG-COMMITS mailing list