[cig-commits] r15090 - in short/3D/PyLith/trunk: . libsrc/topology libsrc/utils modulesrc/topology unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Sat May 30 14:42:32 PDT 2009


Author: brad
Date: 2009-05-30 14:42:31 -0700 (Sat, 30 May 2009)
New Revision: 15090

Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc
   short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh
   short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
   short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh
   short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc
Log:
Added block flag to Jacobian constructor. Added hasField() unit tests. Added missing include to EventLogger.

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/TODO	2009-05-30 21:42:31 UTC (rev 15090)
@@ -7,17 +7,18 @@
   field split
 
 Brad
+  symmetric matrix
+  full-scale testing
+  cleanup
   Questions for Matt:
     How to use symmetric matrix (updateOperator)?
-  cleanup
-  full-scale testing
   test uniform refinement
 
+  PointForce
   time-dependent BC
 
 Charles
   3-D Power-law rheology
-    C++
     libtests
     Python
     pytests
@@ -84,9 +85,6 @@
 
     libtests/topology/TestMesh::testNondimensionalize()
 
-    libtests/topology/TestFields::testHasField()
-    pytests/topology/TestFields.test_hasField()
-
     libtests/topology/Field add constraints to field in unit tests
       copy
       +=

Modified: short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc	2009-05-30 21:42:31 UTC (rev 15090)
@@ -23,15 +23,20 @@
 // ----------------------------------------------------------------------
 // Default constructor.
 pylith::topology::Jacobian::Jacobian(const SolutionFields& fields,
-				     const char* matrixType) :
+				     const char* matrixType,
+				     const bool blockOkay) :
   _fields(fields),
   _matrix(0)
 { // constructor
   const ALE::Obj<Mesh::SieveMesh>& sieveMesh = fields.mesh().sieveMesh();
   const ALE::Obj<Mesh::RealSection>& solnSection = fields.solution().section();
 
+  // Set blockFlag to -1 if okay to set block size equal to fiber
+  // dimension, otherwise use a block size of 1.
+  const int blockFlag = (blockOkay) ? -1 : 1;
+
   PetscErrorCode err = MeshCreateMatrix(sieveMesh, solnSection, 
-					matrixType, &_matrix);
+					matrixType, &_matrix, blockFlag);
   CHECK_PETSC_ERROR_MSG(err, "Could not create PETSc sparse matrix "
 			"associated with system Jacobian.");
 } // constructor

Modified: short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh	2009-05-30 21:42:31 UTC (rev 15090)
@@ -36,9 +36,12 @@
    *
    * @param fields Fields associated with mesh and solution of the problem.
    * @param matrixType Type of PETSc sparse matrix.
+   * @param blockOkay True if okay to use block size equal to fiberDim
+   * (all or none of the DOF at each point are constrained).
    */
   Jacobian(const SolutionFields& fields,
-	   const char* matrixType ="aij");
+	   const char* matrixType ="aij",
+	   const bool blockOkay =false);
 
   /// Destructor.
   ~Jacobian(void);

Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh	2009-05-30 21:42:31 UTC (rev 15090)
@@ -27,6 +27,7 @@
 #include <string> // USES std::string
 #include <map> // USES std::map
 
+#include "petsc.h"
 #include "petsclog.h" // USES PetscLogEventBegin/End() in inline methods
 
 // EventLogger ----------------------------------------------------------

Modified: short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i	2009-05-30 21:42:31 UTC (rev 15090)
@@ -29,9 +29,12 @@
        *
        * @param fields Fields associated with mesh and solution of the problem.
        * @param matrixType Type of PETSc sparse matrix.
+       * @param blockOkay True if okay to use block size equal to fiberDim
+       * (all or none of the DOF at each point are constrained).
        */
       Jacobian(const SolutionFields& fields,
-	       const char* matrixType ="aij");
+	       const char* matrixType ="aij",
+	       const bool blockOkay =false);
       
       /// Destructor.
       ~Jacobian(void);

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc	2009-05-30 21:42:31 UTC (rev 15090)
@@ -151,6 +151,28 @@
 } // testGetConst
 
 // ----------------------------------------------------------------------
+// Test hasField().
+void
+pylith::topology::TestFieldsMesh::testHasField(void)
+{ // testHasField
+  CPPUNIT_ASSERT(0 != _mesh);
+  FieldsMesh fields(*_mesh);
+
+  fields.add("field A", "velocity");
+  
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field B"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+  fields.add("field B", "displacement");
+
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field B"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+} // testHasField
+
+// ----------------------------------------------------------------------
 // Test copyLayout().
 void
 pylith::topology::TestFieldsMesh::testCopyLayout(void)

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh	2009-05-30 21:42:31 UTC (rev 15090)
@@ -46,6 +46,7 @@
   CPPUNIT_TEST( testDelete );
   CPPUNIT_TEST( testGet );
   CPPUNIT_TEST( testGetConst );
+  CPPUNIT_TEST( testHasField );
   CPPUNIT_TEST( testCopyLayout );
 
   CPPUNIT_TEST_SUITE_END();
@@ -77,6 +78,9 @@
   /// Test get() for const Fields.
   void testGetConst(void);
 
+  /// Test hasField().
+  void testHasField(void);
+
   /// Test copyLayout(domain).
   void testCopyLayout(void);
 

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc	2009-05-30 21:42:31 UTC (rev 15090)
@@ -153,6 +153,28 @@
 } // testGetConst
 
 // ----------------------------------------------------------------------
+// Test hasField().
+void
+pylith::topology::TestFieldsSubMesh::testHasField(void)
+{ // testHasField
+  CPPUNIT_ASSERT(0 != _submesh);
+  FieldsSubMesh fields(*_submesh);
+
+  fields.add("field A", "velocity");
+  
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field B"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+  fields.add("field B", "displacement");
+
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field A"));
+  CPPUNIT_ASSERT_EQUAL(true, fields.hasField("field B"));
+  CPPUNIT_ASSERT_EQUAL(false, fields.hasField("field C"));
+
+} // testHasField
+
+// ----------------------------------------------------------------------
 // Test copyLayout().
 void
 pylith::topology::TestFieldsSubMesh::testCopyLayout(void)

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh	2009-05-30 21:42:31 UTC (rev 15090)
@@ -47,6 +47,7 @@
   CPPUNIT_TEST( testDelete );
   CPPUNIT_TEST( testGet );
   CPPUNIT_TEST( testGetConst );
+  CPPUNIT_TEST( testHasField );
   CPPUNIT_TEST( testCopyLayout );
 
   CPPUNIT_TEST_SUITE_END();
@@ -78,6 +79,9 @@
   /// Test get() for const Fields.
   void testGetConst(void);
 
+  /// Test hasField().
+  void testHasField(void);
+
   /// Test copyLayout(domain).
   void testCopyLayout(void);
 

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc	2009-05-30 17:54:21 UTC (rev 15089)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc	2009-05-30 21:42:31 UTC (rev 15090)
@@ -36,6 +36,9 @@
   Jacobian jacobian(fields);
 
   Jacobian jacobianB(fields, "baij");
+  Jacobian jacobianC(fields, "baij", true);
+  Jacobian jacobianD(fields, "sbaij");
+  Jacobian jacobianE(fields, "sbaij", true);
 } // testConstructor
  
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list