[cig-commits] r14313 - in short/3D/PyLith/branches/pylith-swig: . libsrc/bc libsrc/feassemble libsrc/problems modulesrc/bc modulesrc/feassemble pylith/bc pylith/feassemble pylith/meshio unittests/libtests/bc unittests/pytests/bc

brad at geodynamics.org brad at geodynamics.org
Fri Mar 13 12:06:59 PDT 2009


Author: brad
Date: 2009-03-13 12:06:58 -0700 (Fri, 13 Mar 2009)
New Revision: 14313

Added:
   short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i
Modified:
   short/3D/PyLith/branches/pylith-swig/TODO
   short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.hh
   short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i
   short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Makefile.am
   short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i
   short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityImplicit.i
   short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Integrator.i
   short/3D/PyLith/branches/pylith-swig/pylith/bc/Neumann.py
   short/3D/PyLith/branches/pylith-swig/pylith/feassemble/Constraint.py
   short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManager.py
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestNeumann.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/testbc.py
Log:
Updated SWIG stuff to use Jacobian. More work on Python tests for bc.

Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/TODO	2009-03-13 19:06:58 UTC (rev 14313)
@@ -11,9 +11,6 @@
   Cleanup error checking on PETSc calls. Use PetscError as in
   Jacobian.
 
-  C++ testing of Jacobian
-  Python testing of Jacobian
-
   TestMesh.test_view()
   TestMesh.test_checkMaterialIds()
   

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc	2009-03-13 19:06:58 UTC (rev 14313)
@@ -326,6 +326,7 @@
  				       const double t,
  				       topology::SolutionFields* const fields)
 { // integrateJacobian
+  _needNewJacobian = false;
 } // integrateJacobian
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh	2009-03-13 19:06:58 UTC (rev 14313)
@@ -33,7 +33,6 @@
 #include "spatialdata/spatialdb/spatialdbfwd.hh" // USES GravityField
 #include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
 
-#include "pylith/utils/petscfwd.h" // USES PetscMat
 #include "pylith/utils/array.hh" // HASA double_array
 
 // Integrator -----------------------------------------------------------

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.cc	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.cc	2009-03-13 19:06:58 UTC (rev 14313)
@@ -18,6 +18,7 @@
 #include "pylith/topology/SubMesh.hh" // USES Quadrature<SubMesh>
 #include "pylith/feassemble/Quadrature.hh" // USES Integrator<Quadrature>
 #include "pylith/feassemble/Integrator.hh" // USES Integrator
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
 
 #include <cassert> // USES assert()
 
@@ -128,7 +129,7 @@
 // Reform system Jacobian.
 void
 pylith::problems::Formulation::reformJacobian(
-				     PetscMat* jacobian,
+				     topology::Jacobian* jacobian,
 				     topology::SolutionFields* const fields,
 				     const double t,
 				     const double dt)
@@ -137,7 +138,7 @@
   assert(0 != fields);
 
   // Set residual to zero.
-  MatZeroEntries(*jacobian);
+  jacobian->zero();
 
   // Add in contributions that do not require assembly.
   int numIntegrators = _meshIntegrators.size();
@@ -148,13 +149,7 @@
     _submeshIntegrators[i]->integrateJacobianAssembled(jacobian, t, fields);
 
   // Assemble residual.
-  PetscErrorCode err = 0;
-  err = MatAssemblyBegin(*jacobian, MAT_FLUSH_ASSEMBLY);
-  if (0 != err)
-    throw std::runtime_error("Assembly of matrix failed.");
-  err = MatAssemblyEnd(*jacobian, MAT_FLUSH_ASSEMBLY);
-  if (0 != err)
-    throw std::runtime_error("Assembly of matrix failed.");
+  jacobian->assemble("flush_assembly");
 
   // Add in contributions that require assembly.
   numIntegrators = _meshIntegrators.size();
@@ -165,12 +160,7 @@
     _submeshIntegrators[i]->integrateJacobian(jacobian, t, fields);
   
   // Assemble residual.
-  err = MatAssemblyBegin(*jacobian, MAT_FINAL_ASSEMBLY);
-  if (0 != err)
-    throw std::runtime_error("Assembly of matrix failed.");
-  err = MatAssemblyEnd(*jacobian, MAT_FINAL_ASSEMBLY);
-  if (0 != err)
-    throw std::runtime_error("Assembly of matrix failed.");
+  jacobian->assemble("final_assembly");
 } // reformJacobian
 
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.hh	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Formulation.hh	2009-03-13 19:06:58 UTC (rev 14313)
@@ -25,7 +25,6 @@
 #include "pylith/feassemble/feassemblefwd.hh" // USES Integrator
 #include "pylith/topology/topologyfwd.hh" // USES Mesh, Field, SolutionFields
 #include "pylith/utils/array.hh" // USES std::vector
-#include "pylith/utils/petscfwd.h" // USES PetscMat
 
 // Formulation ----------------------------------------------------------
 class pylith::problems::Formulation
@@ -45,7 +44,7 @@
   
   struct ArgsJacobian {
     Formulation* object;
-    PetscMat* jacobian;
+    topology::Jacobian* jacobian;
     topology::SolutionFields* const fields;
     double t;
     double dt;
@@ -117,7 +116,7 @@
    * @param t Current time.
    * @param dt Current time step (t -> t+dt).
    */
-  void reformJacobian(PetscMat* jacobian,
+  void reformJacobian(topology::Jacobian* jacobian,
 		      topology::SolutionFields* const fields,
 		      const double t,
 		      const double dt);

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i	2009-03-13 19:06:58 UTC (rev 14313)
@@ -60,7 +60,7 @@
        * @param t Current time
        * @param fields Solution fields
        */
-      void integrateJacobian(PetscMat* mat,
+      void integrateJacobian(pylith::topology::Jacobian* mat,
 			     const double t,
 			     pylith::topology::SolutionFields* const fields);
       

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Makefile.am	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Makefile.am	2009-03-13 19:06:58 UTC (rev 14313)
@@ -23,6 +23,7 @@
 	DirichletBC.i \
 	DirichletBoundary.i \
 	AbsorbingDampers.i \
+	Neumann.i \
 	../feassemble/Constraint.i \
 	../feassemble/Quadrature.i \
 	../feassemble/Integrator.i

Added: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i	2009-03-13 19:06:58 UTC (rev 14313)
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/Neumann.i
+ *
+ * @brief Python interface to C++ Neumann object.
+ */
+
+%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >;
+
+namespace pylith {
+  namespace bc {
+
+    class Neumann : public BoundaryCondition, 
+		    public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >
+    { // class Neumann
+      friend class TestNeumann; // unit testing
+
+      // PUBLIC METHODS /////////////////////////////////////////////////
+    public :
+
+      /// Default constructor.
+      Neumann(void);
+
+      /// Destructor.
+      ~Neumann(void);
+
+      /** Initialize boundary condition.
+       *
+       * @param mesh Finite-element mesh.
+       * @param upDir Direction perpendicular to horizontal surface tangent 
+       *   direction that is not collinear with surface normal.
+       */
+      void initialize(const pylith::topology::Mesh& mesh,
+		      const double upDir[3]);
+
+      /** Integrate contributions to residual term (r) for operator.
+       *
+       * @param residual Field containing values for residual.
+       * @param t Current time.
+       * @param fields Solution fields.
+       */
+      void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+			     const double t,
+			     pylith::topology::SolutionFields* const fields);
+
+      /** Integrate contributions to Jacobian matrix (A) associated with
+       * operator.
+       *
+       * @param jacobian Sparse matrix for Jacobian of system.
+       * @param t Current time
+       * @param fields Solution fields
+       */
+      void integrateJacobian(pylith::topology::Jacobian* jacobian,
+			     const double t,
+			     pylith::topology::SolutionFields* const fields);
+      
+      /** Verify configuration is acceptable.
+       *
+       * @param mesh Finite-element mesh
+       */
+      void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+      
+      /** Get boundary mesh.
+       *
+       * @returns Boundary mesh.
+       */
+      const pylith::topology::SubMesh& boundaryMesh(void) const;
+      
+      /** Get cell field with BC information.
+       *
+       * @param fieldType Type of field.
+       * @param name Name of field.
+       * @param mesh Finite-element mesh.
+       * @param fields Solution fields.
+       *
+       * @returns Traction vector at integration points.
+       */
+      const pylith::topology::Field<pylith::topology::SubMesh>&
+      cellField(const char* name,
+		pylith::topology::SolutionFields* const fields);
+
+    }; // class Neumann
+
+  } // bc
+} // pylith
+
+
+// End of file 

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i	2009-03-13 19:06:58 UTC (rev 14313)
@@ -19,6 +19,7 @@
 #include "pylith/bc/DirichletBC.hh"
 #include "pylith/bc/DirichletBoundary.hh"
 #include "pylith/bc/AbsorbingDampers.hh"
+#include "pylith/bc/Neumann.hh"
 %}
 
 %include "exception.i"
@@ -51,6 +52,7 @@
 %include "DirichletBC.i"
 %include "DirichletBoundary.i"
 %include "AbsorbingDampers.i"
+%include "Neumann.i"
 
 // End of file
 

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityImplicit.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityImplicit.i	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityImplicit.i	2009-03-13 19:06:58 UTC (rev 14313)
@@ -76,7 +76,7 @@
        * @param t Current time
        * @param fields Solution fields
        */
-      void integrateJacobian(PetscMat* jacobian,
+      void integrateJacobian(pylith::topology::Jacobian* jacobian,
 			     const double t,
 			     pylith::topology::SolutionFields* const fields);
   

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Integrator.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Integrator.i	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Integrator.i	2009-03-13 19:06:58 UTC (rev 14313)
@@ -108,7 +108,7 @@
        * @param fields Solution fields
        */
       virtual
-      void integrateJacobian(PetscMat* jacobian,
+      void integrateJacobian(pylith::topology::Jacobian* jacobian,
 			     const double t,
 			     pylith::topology::SolutionFields* const fields);
 
@@ -133,7 +133,7 @@
        * @param fields Solution fields
        */
       virtual
-      void integrateJacobianAssembled(PetscMat* jacobian,
+      void integrateJacobianAssembled(pylith::topology::Jacobian* jacobian,
 				      const double t,
 				      pylith::topology::SolutionFields* const fields);
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/bc/Neumann.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/Neumann.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/Neumann.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -18,9 +18,10 @@
 
 from BoundaryCondition import BoundaryCondition
 from pylith.feassemble.Integrator import Integrator
+from bc import Neumann as ModuleNeumann
 
 # Neumann class
-class Neumann(BoundaryCondition, Integrator):
+class Neumann(BoundaryCondition, Integrator, ModuleNeumann):
   """
   Python object for managing traction boundary conditions.
 
@@ -46,8 +47,9 @@
 
     import pyre.inventory
 
-    from pylith.feassemble.quadrature.Quadrature import Quadrature
-    quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
+    from pylith.feassemble.Quadrature import SubMeshQuadrature
+    quadrature = pyre.inventory.facility("quadrature",
+                                         factory=SubMeshQuadrature)
     quadrature.meta['tip'] = "Quadrature object for numerical integration."
 
     from pylith.meshio.OutputNeumann import OutputNeumann
@@ -81,7 +83,8 @@
     """
     BoundaryCondition.preinitialize(self, mesh)
     Integrator.preinitialize(self, mesh)
-    self.quadrature.preinitialize()
+    self.bcQuadrature.preinitialize(mesh.coordsys().spaceDim())
+    self.quadrature(self.bcQuadrature)
     self.output.preinitialize(self)
     return
 
@@ -95,12 +98,12 @@
 
     BoundaryCondition.verifyConfiguration(self)
     Integrator.verifyConfiguration(self)
-    if self.quadrature.cellDim != self.mesh.dimension()-1:
+    if self.bcQuadrature.cellDim != self.mesh.dimension()-1:
         raise ValueError, \
               "Quadrature scheme and mesh are incompatible.\n" \
               "Dimension for quadrature: %d\n" \
               "Dimension of mesh boundary '%s': %d" % \
-              (self.quadrature.cellDim,
+              (self.bcQuadrature.cellDim,
                self.label, self.mesh.dimension()-1)    
     self.output.verifyConfiguration(self.mesh)
 
@@ -116,18 +119,16 @@
     self._logger.eventBegin(logEvent)
     
     Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
-    
-    self.cppHandle.quadrature = self.quadrature.cppHandle
     BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
 
-    from pylith.topology.Mesh import Mesh
-    self.boundaryMesh = Mesh()
-    self.boundaryMesh.initialize(self.mesh.coordsys)
-    self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
+    #from pylith.topology.Mesh import Mesh
+    #self.boundaryMesh = Mesh()
+    #self.boundaryMesh.initialize(self.mesh.coordsys)
+    #self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
 
-    if None != self.output:
-      self.output.initialize(normalizer, self.quadrature)
-      self.output.writeInfo()
+    #if None != self.output:
+    #  self.output.initialize(normalizer, self.quadrature)
+    #  self.output.writeInfo()
 
     self._logger.eventEnd(logEvent)
     return
@@ -145,10 +146,9 @@
     Get vertex field.
     """
     if None == fields:
-      (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle)
+      (field, fieldType) = self.cellField(name)
     else:
-      (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle,
-                                                    fields.cppHandle)
+      (field, fieldType) = self.cellField(name, fields)
     return (field, fieldType)
 
 
@@ -159,18 +159,17 @@
     Setup members using inventory.
     """
     BoundaryCondition._configure(self)
-    self.quadrature = self.inventory.quadrature
+    self.bcQuadrature = self.inventory.quadrature
     self.output = self.inventory.output
     return
 
 
-  def _createCppHandle(self):
+  def _createModuleObj(self):
     """
     Create handle to corresponding C++ object.
     """
-    if None == self.cppHandle:
-      import pylith.bc.bc as bindings
-      self.cppHandle = bindings.Neumann()    
+    if None == self.this:
+      ModuleNeumann.__init__(self)
     return
   
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/feassemble/Constraint.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/feassemble/Constraint.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/pylith/feassemble/Constraint.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -24,7 +24,6 @@
   required = ["preinitialize",
               "verifyConfiguration",
               "initialize",
-              "timeStep",
               "setConstraintSizes",
               "setConstraints",
               "useSolnIncr",
@@ -33,6 +32,7 @@
               "finalize"]
   for attr in required:
     if not attr in available:
+      print "Missing method '%s'." % attr
       result = False
   return result
 
@@ -62,6 +62,13 @@
     return
 
 
+  def poststep(self, t, dt, totalTime, fields):
+    """
+    Hook for doing stuff after advancing time step.
+    """
+    return
+  
+
   def finalize(self):
     """
     Cleanup.

Modified: short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManager.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManager.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -382,7 +382,7 @@
 
     from pylith.utils.EventLogger import EventLogger
     logger = EventLogger()
-    logger.setClassName("FE Output")
+    logger.className("FE Output")
     logger.initialize()
 
     events = ["init",

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc	2009-03-13 19:06:58 UTC (rev 14313)
@@ -23,6 +23,7 @@
 #include "pylith/topology/SubMesh.hh" // USES SubMesh
 #include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
 #include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
 #include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -204,21 +205,13 @@
   const ALE::Obj<RealSection>& solutionSection = solution.section();
   CPPUNIT_ASSERT(!solutionSection.isNull());
 
-  PetscMat jacobian;
-  //sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default", solutionSection)->view("Global Order");
-  PetscErrorCode err = MeshCreateMatrix(sieveMesh, solutionSection, 
-					MATMPIBAIJ, &jacobian);
-  CPPUNIT_ASSERT(0 == err);
+  topology::Jacobian jacobian(fields);
 
   const double t = 1.0;
   bc.integrateJacobian(&jacobian, t, &fields);
   CPPUNIT_ASSERT_EQUAL(false, bc.needNewJacobian());
+  jacobian.assemble("final_assembly");
 
-  err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
-  CPPUNIT_ASSERT(0 == err);
-  err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
-  CPPUNIT_ASSERT(0 == err);
-
   CPPUNIT_ASSERT(!sieveMesh->depthStratum(0).isNull());
 
   const double* valsE = _data->valsJacobian;
@@ -226,15 +219,16 @@
   const int nrowsE = totalNumVertices * _data->spaceDim;
   const int ncolsE = totalNumVertices * _data->spaceDim;
 
+  const PetscMat* jacobianMat = jacobian.matrix();
   int nrows = 0;
   int ncols = 0;
-  MatGetSize(jacobian, &nrows, &ncols);
+  MatGetSize(*jacobianMat, &nrows, &ncols);
   CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
   CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
 
   PetscMat jDense;
   PetscMat jSparseAIJ;
-  MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+  MatConvert(*jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
   MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
 
   double_array vals(nrows*ncols);

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -24,15 +24,6 @@
   Unit testing of AbsorbingDampers object.
   """
 
-  def test_constructor(self):
-    """
-    Test constructor.
-    """
-    from pylith.bc.AbsorbingDampers import AbsorbingDampers
-    bc = AbsorbingDampers()
-    return
-
-
   def test_implementsIntegrator(self):
     """
     Test to make sure AbsorbingDampers satisfies integrator requirements.
@@ -43,6 +34,15 @@
     return
     
 
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    from pylith.bc.AbsorbingDampers import AbsorbingDampers
+    bc = AbsorbingDampers()
+    return
+
+
   def test_initialize(self):
     """
     Test initialize().
@@ -123,9 +123,9 @@
 
     (mesh, bc, fields) = self._initialize()
 
-    jacobian = mesh.createMatrix(fields.get("residual"))
-    import pylith.utils.petsc as petsc
-    petsc.mat_setzero(jacobian)
+    from pylith.topology.Jacobian import Jacobian
+    jacobian = Jacobian(fields)
+    jacobian.zero()
     t = 0.24
     bc.integrateJacobian(jacobian, t, fields)
     self.assertEqual(False, bc.needNewJacobian())

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -39,6 +39,7 @@
     """
     bc = DirichletBC()
     from pylith.feassemble.Constraint import implementsConstraint
+    print dir(bc)
     self.failUnless(implementsConstraint(bc))
     return
     

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestNeumann.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestNeumann.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestNeumann.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -53,10 +53,7 @@
 
     (mesh, bc, fields) = self._initialize()
 
-    self.assertNotEqual(None, bc.cppHandle)
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly    
+    # No testing of result.
     return
 
 
@@ -108,12 +105,11 @@
     """
     (mesh, bc, fields) = self._initialize()
 
-    residual = fields.getReal("residual")
+    residual = fields.get("residual")
     t = 0.02
     bc.integrateResidual(residual, t, fields)
 
-    # We should really add something here to check to make sure things
-    # actually initialized correctly    
+    # No testing of result.
     return
 
 
@@ -126,12 +122,14 @@
 
     (mesh, bc, fields) = self._initialize()
 
-    jacobian = mesh.createMatrix(fields.getReal("residual"))
-    import pylith.utils.petsc as petsc
-    petsc.mat_setzero(jacobian)
+    from pylith.topology.Jacobian import Jacobian
+    jacobian = Jacobian(fields)
+    jacobian.zero()
     t = 0.24
     bc.integrateJacobian(jacobian, t, fields)
+    self.assertEqual(False, bc.needNewJacobian())
 
+    # No testing of result.
     return
 
 
@@ -149,8 +147,7 @@
     totalTime = 5
     bc.poststep(t, dt, totalTime, fields)
 
-    # We should really add something here to check to make sure things
-    # actually initialized correctly    
+    # No testing of result.
     return
   
 
@@ -164,8 +161,7 @@
     (mesh, bc, fields) = self._initialize()
     bc.finalize()
 
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
+    # No testing of result.
     return
 
 
@@ -175,44 +171,49 @@
     """
     Initialize Neumann boundary condition.
     """
-    from pylith.bc.Neumann import Neumann
-    bc = Neumann()
-    bc._configure()
-    bc.output._configure()
-    bc.output.writer._configure()
-    bc.label = "bc"
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    db = SimpleDB()
+    db._configure()
+    db.inventory.label = "TestNeumann tri3"
+    db.inventory.iohandler.inventory.filename = "data/tri3-tractions.spatialdb"
+    db.inventory.iohandler._configure()
+    db._configure()
 
     from pylith.feassemble.FIATSimplex import FIATSimplex
     cell = FIATSimplex()
-    cell.shape = "line"
-    cell.degree = 1
-    cell.order = 1
-    from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
-    quadrature = Quadrature1Din2D()
+    cell.inventory.shape = "line"
+    cell.inventory.degree = 1
+    cell.inventory.order = 1
+    cell._configure()
+    from pylith.feassemble.Quadrature import SubMeshQuadrature
+    quadrature = SubMeshQuadrature()
+    quadrature.inventory.cell = cell
     quadrature._configure()
-    quadrature.cell = cell
-    bc.quadrature = quadrature
+    
+    from pylith.bc.Neumann import Neumann
+    bc = Neumann()
+    bc.inventory.quadrature = quadrature
+    bc.inventory.db = db
+    bc.inventory.label = "bc"
+    bc.inventory.output.inventory.writer._configure()
+    bc.inventory.output._configure()
+    bc._configure()
 
-    from spatialdata.spatialdb.SimpleDB import SimpleDB
-    db = SimpleDB()
-    db._configure()
-    db.label = "TestNeumann tri3"
-    db.iohandler.filename = "data/tri3-tractions.spatialdb"
-    db.initialize()
-    bc.db = db
 
     from spatialdata.geocoords.CSCart import CSCart
     cs = CSCart()
-    cs.spaceDim = 2
+    cs.inventory.spaceDim = 2
+    cs._configure()
 
     from spatialdata.units.Nondimensional import Nondimensional
     normalizer = Nondimensional()
-    normalizer.initialize()
+    normalizer._configure()
 
     from pylith.meshio.MeshIOAscii import MeshIOAscii
     importer = MeshIOAscii()
-    importer.filename = "data/tri3.mesh"
-    importer.coordsys = cs
+    importer.inventory.filename = "data/tri3.mesh"
+    importer.inventory.coordsys = cs
+    importer._configure()
     mesh = importer.read(normalizer, debug=False, interpolate=False)
     
     bc.preinitialize(mesh)
@@ -220,17 +221,19 @@
     bc.timeStep(0.01)
 
     # Setup fields
-    from pylith.topology.FieldsManager import FieldsManager
-    fields = FieldsManager(mesh)
-    fields.addReal("residual")
-    fields.addReal("dispTBctpdt")
-    fields.addReal("dispIncr")
-    fields.setFiberDimension("residual", cs.spaceDim)
-    fields.allocate("residual")
+    from pylith.topology.SolutionFields import SolutionFields
+    fields = SolutionFields(mesh)
+    fields.add("residual")
+    fields.add("disp(t), bc(t+dt)")
+    fields.add("dispIncr")
+    fields.solutionName("dispIncr")
+
+    residual = fields.get("residual")
+    residual.newSection(residual.VERTICES_FIELD, cs.spaceDim())
+    residual.allocate()
+    residual.zero()
+
     fields.copyLayout("residual")
-
-    import pylith.topology.topology as bindings
-    bindings.zeroRealSection(fields.getReal("dispIncr"))
     
     return (mesh, bc, fields)
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/testbc.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/testbc.py	2009-03-13 01:33:18 UTC (rev 14312)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/testbc.py	2009-03-13 19:06:58 UTC (rev 14313)
@@ -65,8 +65,8 @@
     from TestAbsorbingDampers import TestAbsorbingDampers
     suite.addTest(unittest.makeSuite(TestAbsorbingDampers))
 
-    #from TestNeumann import TestNeumann
-    #suite.addTest(unittest.makeSuite(TestNeumann))
+    from TestNeumann import TestNeumann
+    suite.addTest(unittest.makeSuite(TestNeumann))
 
     return suite
 



More information about the CIG-COMMITS mailing list