[cig-commits] r17045 - in short/3D/PyLith/branches/v1.5-stable: libsrc/problems modulesrc/problems pylith/problems

brad at geodynamics.org brad at geodynamics.org
Thu Jul 15 09:48:41 PDT 2010


Author: brad
Date: 2010-07-15 09:48:41 -0700 (Thu, 15 Jul 2010)
New Revision: 17045

Modified:
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.cc
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.hh
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.cc
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.hh
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.cc
   short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.hh
   short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Explicit.i
   short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Formulation.i
   short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Implicit.i
   short/3D/PyLith/branches/v1.5-stable/pylith/problems/Explicit.py
   short/3D/PyLith/branches/v1.5-stable/pylith/problems/ExplicitLumped.py
   short/3D/PyLith/branches/v1.5-stable/pylith/problems/Formulation.py
   short/3D/PyLith/branches/v1.5-stable/pylith/problems/Implicit.py
Log:
BUGFIX: Cleanup of creating velocity and acceleration fields. Move to Python and set scales (scales were set to length scale).

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.cc
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.cc	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.cc	2010-07-15 16:48:41 UTC (rev 17045)
@@ -114,31 +114,5 @@
   PetscLogFlops(vertices->size() * 6*spaceDim);
 } // calcRateFields
 
-// ----------------------------------------------------------------------
-// Setup rate fields.
-void
-pylith::problems::Explicit::_setupRateFields(void)
-{ // _setupRateFields
-  assert(0 != _fields);
- 
-  topology::Field<topology::Mesh>& dispIncr = _fields->get("dispIncr(t->t+dt)");
 
-  if (!_fields->hasField("velocity(t)")) {
-    _fields->add("velocity(t)", "velocity");
-    topology::Field<topology::Mesh>& velocity = _fields->get("velocity(t)");
-    velocity.cloneSection(dispIncr);
-    velocity.zero();
-  } // if
-
-  if (!_fields->hasField("acceleration(t)")) {
-    _fields->add("acceleration(t)", "acceleration");
-    topology::Field<topology::Mesh>& acceleration = 
-      _fields->get("acceleration(t)");
-    acceleration.cloneSection(dispIncr);
-    acceleration.zero();
-  } // if
-} // _setupRateFields
-
-
-
 // End of file

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.hh
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.hh	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Explicit.hh	2010-07-15 16:48:41 UTC (rev 17045)
@@ -44,12 +44,6 @@
   /// Compute rate fields (velocity and/or acceleration) at time t.
   void calcRateFields(void);
 
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
-
-  /// Setup rate fields.
-  void _setupRateFields(void);
-
 // NOT IMPLEMENTED //////////////////////////////////////////////////////
 private :
 

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.cc
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.cc	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.cc	2010-07-15 16:48:41 UTC (rev 17045)
@@ -152,28 +152,6 @@
 } // preconditioner
 
 // ----------------------------------------------------------------------
-// Initialize formulation.
-void
-pylith::problems::Formulation::initialize(void)
-{ // initialize
-
-  // Determine whether we need to compute velocity
-  _isJacobianSymmetric = false;
-  int numIntegrators = _meshIntegrators.size();
-  for (int i=0; i < numIntegrators; ++i) {
-    assert(0 != _meshIntegrators[i]);
-    if (_meshIntegrators[i]->isJacobianSymmetric())
-      _isJacobianSymmetric = true;
-  } // fpr
-  numIntegrators = _submeshIntegrators.size();
-  for (int i=0; i < numIntegrators; ++i) {
-    assert(0 != _submeshIntegrators[i]);
-    if (_submeshIntegrators[i]->isJacobianSymmetric())
-      _isJacobianSymmetric = true;
-  } // for
-} // initialize
-
-// ----------------------------------------------------------------------
 // Update handles and parameters for reforming the Jacobian and
 // residual.
 void
@@ -190,8 +168,6 @@
   _fields = fields;
   _t = t;
   _dt = dt;
-
-  _setupRateFields();
 } // updateSettings
 
 // ----------------------------------------------------------------------
@@ -211,8 +187,6 @@
   _fields = fields;
   _t = t;
   _dt = dt;
-
-  _setupRateFields();
 } // updateSettings
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.hh
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.hh	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Formulation.hh	2010-07-15 16:48:41 UTC (rev 17045)
@@ -113,10 +113,6 @@
    */
   void customPCMatrix(PetscMat& mat);
 
-  /// Initialize formulation.
-  virtual
-  void initialize(void);
-
   /** Update handles and parameters for reforming the Jacobian and
    *  residual.
    *
@@ -187,13 +183,6 @@
 // PROTECTED MEMBERS ////////////////////////////////////////////////////
 protected :
 
-  /// Setup rate fields.
-  virtual
-  void _setupRateFields(void) = 0;
-
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
-
   double _t; ///< Current time (nondimensional).
   double _dt; ///< Current time step (nondimensional).
   topology::Jacobian* _jacobian; ///< Handle to Jacobian of system.

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.cc
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.cc	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.cc	2010-07-15 16:48:41 UTC (rev 17045)
@@ -82,21 +82,5 @@
 
 } // calcRateFields
 
-// ----------------------------------------------------------------------
-// Setup rate fields.
-void
-pylith::problems::Implicit::_setupRateFields(void)
-{ // _setupRateFields
-  assert(0 != _fields);
- 
-  topology::Field<topology::Mesh>& dispIncr = _fields->get("dispIncr(t->t+dt)");
 
-  if (!_fields->hasField("velocity(t)")) {
-    _fields->add("velocity(t)", "velocity");
-    topology::Field<topology::Mesh>& velocity = _fields->get("velocity(t)");
-    velocity.cloneSection(dispIncr);
-    velocity.zero();
-  } // if
-} // _setupRateFields
-
 // End of file

Modified: short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.hh
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.hh	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/libsrc/problems/Implicit.hh	2010-07-15 16:48:41 UTC (rev 17045)
@@ -44,12 +44,6 @@
   /// Compute rate fields (velocity and/or acceleration) at time t.
   void calcRateFields(void);
 
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
-
-  /// Setup rate fields.
-  void _setupRateFields(void);
-
 // NOT IMPLEMENTED //////////////////////////////////////////////////////
 private :
 

Modified: short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Explicit.i
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Explicit.i	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Explicit.i	2010-07-15 16:48:41 UTC (rev 17045)
@@ -34,12 +34,6 @@
       /// Compute rate fields (velocity and/or acceleration) at time t.
       void calcRateFields(void);
 
-      // PROTECTED MEMBERS //////////////////////////////////////////////
-      protected :
-
-      /// Setup rate fields.
-      void _setupRateFields(void);
-
     }; // Explicit
 
   } // problems

Modified: short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Formulation.i
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Formulation.i	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Formulation.i	2010-07-15 16:48:41 UTC (rev 17045)
@@ -88,10 +88,6 @@
       void submeshIntegrators(pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >** integrators,
 			      const int numIntegrators);
       
-	  /// Initialize formulation.
-	  virtual
-	  void initialize(void);
-
       /** Update handles and parameters for reforming the Jacobian and
        *  residual.
        *
@@ -149,13 +145,6 @@
       virtual
       void calcRateFields(void) = 0;
 
-      // PROTECTED MEMBERS //////////////////////////////////////////////
-      protected :
-
-      /// Setup rate fields.
-      virtual
-      void _setupRateFields(void) = 0;
-
     }; // Formulation
 
   } // problems

Modified: short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Implicit.i
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Implicit.i	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/modulesrc/problems/Implicit.i	2010-07-15 16:48:41 UTC (rev 17045)
@@ -34,12 +34,6 @@
       /// Compute rate fields (velocity and/or acceleration) at time t.
       void calcRateFields(void);
 
-      // PROTECTED MEMBERS //////////////////////////////////////////////
-      protected :
-
-      /// Setup rate fields.
-      void _setupRateFields(void);
-
     }; // Implicit
 
   } // problems

Modified: short/3D/PyLith/branches/v1.5-stable/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/pylith/problems/Explicit.py	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/pylith/problems/Explicit.py	2010-07-15 16:48:41 UTC (rev 17045)
@@ -77,6 +77,8 @@
     # Allocate other fields, reusing layout from dispIncr
     self._info.log("Creating other fields.")
     self.fields.add("disp(t-dt)", "displacement")
+    self.fields.add("velocity(t)", "velocity")
+    self.fields.add("acceleration(t)", "acceleration")
     self.fields.copyLayout("dispIncr(t->t+dt)")
     self._debug.log(resourceUsageString())
 
@@ -88,6 +90,19 @@
     residual = self.fields.get("residual")
     residual.zero()
     residual.createVector()
+
+    lengthScale = normalizer.lengthScale()
+    timeScale = normalizer.timeScale()
+    velocityScale = lengthScale / timeScale
+    velocityT = self.fields.get("velocity(t)")
+    velocityT.scale(velocityScale.value)
+    velocityT.zero()
+
+    accelerationScale = velocityScale / timeScale
+    accelerationT = self.fields.get("acceleration(t)")
+    accelerationT.scale(accelerationScale.value)
+    accelerationT.zero()
+
     self._debug.log(resourceUsageString())
     logger.stagePop()
 

Modified: short/3D/PyLith/branches/v1.5-stable/pylith/problems/ExplicitLumped.py
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/pylith/problems/ExplicitLumped.py	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/pylith/problems/ExplicitLumped.py	2010-07-15 16:48:41 UTC (rev 17045)
@@ -94,6 +94,8 @@
     # Allocate other fields, reusing layout from dispIncr
     self._info.log("Creating other fields.")
     self.fields.add("disp(t-dt)", "displacement")
+    self.fields.add("velocity(t)", "velocity")
+    self.fields.add("acceleration(t)", "acceleration")
     self.fields.copyLayout("dispIncr(t->t+dt)")
     self._debug.log(resourceUsageString())
 
@@ -105,6 +107,19 @@
     residual = self.fields.get("residual")
     residual.zero()
     residual.createVector()
+
+    lengthScale = normalizer.lengthScale()
+    timeScale = normalizer.timeScale()
+    velocityScale = lengthScale / timeScale
+    velocityT = self.fields.get("velocity(t)")
+    velocityT.scale(velocityScale.value)
+    velocityT.zero()
+
+    accelerationScale = velocityScale / timeScale
+    accelerationT = self.fields.get("acceleration(t)")
+    accelerationT.scale(accelerationScale.value)
+    accelerationT.zero()
+
     self._debug.log(resourceUsageString())
     logger.stagePop()
 

Modified: short/3D/PyLith/branches/v1.5-stable/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/pylith/problems/Formulation.py	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/pylith/problems/Formulation.py	2010-07-15 16:48:41 UTC (rev 17045)
@@ -440,7 +440,6 @@
       integrator.initialize(totalTime, numTimeSteps, normalizer)
     ModuleFormulation.meshIntegrators(self, self.integratorsMesh)
     ModuleFormulation.submeshIntegrators(self, self.integratorsSubMesh)
-    ModuleFormulation.initialize(self)
     self._debug.log(resourceUsageString())
 
     self._info.log("Initializing constraints.")
@@ -485,7 +484,7 @@
 
     memoryLogger.stagePop()
 
-    # This creates a global order
+    # This also creates a global order.
     solution.createVector()
     solution.createScatter()
 

Modified: short/3D/PyLith/branches/v1.5-stable/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/branches/v1.5-stable/pylith/problems/Implicit.py	2010-07-15 16:47:40 UTC (rev 17044)
+++ short/3D/PyLith/branches/v1.5-stable/pylith/problems/Implicit.py	2010-07-15 16:48:41 UTC (rev 17045)
@@ -119,6 +119,7 @@
 
     # Allocate other fields, reusing layout from dispIncr
     self._info.log("Creating other fields.")
+    self.fields.add("velocity(t)", "velocity")
     self.fields.copyLayout("dispIncr(t->t+dt)")
 
     # Setup fields and set to zero
@@ -127,6 +128,14 @@
     residual = self.fields.get("residual")
     residual.zero()
     residual.createVector()
+
+    lengthScale = normalizer.lengthScale()
+    timeScale = normalizer.timeScale()
+    velocityScale = lengthScale / timeScale
+    velocityT = self.fields.get("velocity(t)")
+    velocityT.scale(velocityScale.value)
+    velocityT.zero()
+
     self._debug.log(resourceUsageString())
     memoryLogger.stagePop()
 



More information about the CIG-COMMITS mailing list