[cig-commits] r13952 - short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Sun Jan 25 15:10:32 PST 2009


Author: brad
Date: 2009-01-25 15:10:32 -0800 (Sun, 25 Jan 2009)
New Revision: 13952

Modified:
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldUniform.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.hh
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMeshOps.cc
Log:
Improved Mesh object- added communicator and debug flag as members; added createSieveMesh().

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-25 23:10:17 UTC (rev 13951)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-25 23:10:32 UTC (rev 13952)
@@ -48,6 +48,7 @@
 pylith::topology::TestField::testConstructor(void)
 { // testConstructor
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   CPPUNIT_ASSERT(!field._mesh.isNull());
@@ -59,6 +60,7 @@
 pylith::topology::TestField::testSection(void)
 { // testSection
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   const ALE::Obj<SieveMesh::real_section_type>& section = field.section();
@@ -74,6 +76,7 @@
 pylith::topology::TestField::testName(void)
 { // testName
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   CPPUNIT_ASSERT_EQUAL(std::string("unknown"), std::string(field.name()));
@@ -89,6 +92,7 @@
 pylith::topology::TestField::testVectorFieldType(void)
 { // testVectorFieldType
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   CPPUNIT_ASSERT_EQUAL(Field::OTHER, field.vectorFieldType());
@@ -103,7 +107,7 @@
 void
 pylith::topology::TestField::testSpaceDim(void)
 { // testSpaceDim
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   Field field(mesh.sieveMesh());
 
@@ -118,6 +122,7 @@
 pylith::topology::TestField::testScale(void)
 { // testScale
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   CPPUNIT_ASSERT_EQUAL(1.0, field.scale());
@@ -133,6 +138,7 @@
 pylith::topology::TestField::testAddDimensionOkay(void)
 { // testAddDimensionOkay
   Mesh mesh;
+  mesh.createSieveMesh();
   Field field(mesh.sieveMesh());
 
   CPPUNIT_ASSERT_EQUAL(false, field.addDimensionOkay());
@@ -155,7 +161,7 @@
     0, 1, 2,  // 3
   };
     
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -198,7 +204,7 @@
 void
 pylith::topology::TestField::testClear(void)
 { // testClear
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh(_TestField::cellDim);
   Field field(mesh.sieveMesh());
 
   field.scale(2.0);
@@ -226,7 +232,7 @@
     1.4, 2.5, 3.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -280,7 +286,7 @@
     1.4, 2.5, 3.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -336,7 +342,7 @@
     1.4, 2.5, 3.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -413,7 +419,7 @@
     10.4, 20.5, 30.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -496,7 +502,7 @@
     1.4, 2.5, 3.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   Field field(sieveMesh);
@@ -554,7 +560,7 @@
     1.4, 2.5, 3.6,
   };
 
-  Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -590,6 +596,7 @@
 { // _buildMesh
   assert(0 != mesh);
 
+  mesh->createSieveMesh(_TestField::cellDim);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
 
   ALE::Obj<SieveMesh::sieve_type> sieve = 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldUniform.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldUniform.cc	2009-01-25 23:10:17 UTC (rev 13951)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldUniform.cc	2009-01-25 23:10:32 UTC (rev 13952)
@@ -49,6 +49,7 @@
 pylith::topology::TestFieldUniform::testConstructor(void)
 { // testConstructor
   Mesh mesh;
+  mesh.createSieveMesh();
   const int fiberDim = 4;
   FieldUniform field(mesh.sieveMesh(), fiberDim);
 
@@ -63,7 +64,7 @@
 { // testCreateSectionPoints
   const int fiberDim = 3;
     
-  Mesh mesh(PETSC_COMM_WORLD, _TestFieldUniform::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -86,7 +87,7 @@
 { // testCreateSectionChart
   const int fiberDim = 2;
     
-  Mesh mesh(PETSC_COMM_WORLD, _TestFieldUniform::cellDim);
+  Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -120,6 +121,7 @@
 { // _buildMesh
   assert(0 != mesh);
 
+  mesh->createSieveMesh(_TestFieldUniform::cellDim);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
 
   ALE::Obj<SieveMesh::sieve_type> sieve = 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.cc	2009-01-25 23:10:17 UTC (rev 13951)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.cc	2009-01-25 23:10:32 UTC (rev 13952)
@@ -26,16 +26,48 @@
 pylith::topology::TestMesh::testConstructor(void)
 { // testConstructor
   Mesh mesh;
+  CPPUNIT_ASSERT(mesh._mesh.isNull());
+  CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+  CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
+  CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+  
+  Mesh mesh2(2);
+  CPPUNIT_ASSERT(!mesh2._mesh.isNull());
+  CPPUNIT_ASSERT_EQUAL(2, mesh2.dimension());
+  CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh2.comm());
+
+  Mesh mesh3(1, PETSC_COMM_SELF);
+  CPPUNIT_ASSERT(!mesh3._mesh.isNull());
+  CPPUNIT_ASSERT_EQUAL(1, mesh3.dimension());
+  CPPUNIT_ASSERT_EQUAL(PETSC_COMM_SELF, mesh3.comm());
 } // testConstructor
 
 // ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestMesh::testCreateSieveMesh(void)
+{ // testCreateSieveMesh
+  Mesh mesh;
+  CPPUNIT_ASSERT(mesh._mesh.isNull());
+
+  int dim = 2;
+  mesh.createSieveMesh(dim);
+  CPPUNIT_ASSERT(!mesh._mesh.isNull());
+  CPPUNIT_ASSERT_EQUAL(dim, mesh.dimension());
+
+  dim = 1;
+  mesh.createSieveMesh(dim);
+  CPPUNIT_ASSERT(!mesh._mesh.isNull());
+  CPPUNIT_ASSERT_EQUAL(dim, mesh.dimension());
+} // testCreateMeshSieve
+
+// ----------------------------------------------------------------------
 // Test sieveMesh().
 void
 pylith::topology::TestMesh::testSieveMesh(void)
 { // testSieveMesh
   const int dim = 2;
-
-  Mesh mesh(PETSC_COMM_WORLD, dim);
+  Mesh mesh(dim);
   
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   CPPUNIT_ASSERT(!sieveMesh.isNull());
@@ -63,7 +95,6 @@
 pylith::topology::TestMesh::testDebug(void)
 { // testDebug
   Mesh mesh;
-
   CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
 
   mesh.debug(true);
@@ -75,10 +106,12 @@
 void
 pylith::topology::TestMesh::testDimension(void)
 { // testDimension
+  Mesh mesh;
+  CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+
   const int dim = 2;
-  Mesh mesh(PETSC_COMM_WORLD, dim);
-
-  CPPUNIT_ASSERT_EQUAL(dim, mesh.dimension());
+  Mesh mesh2(dim);
+  CPPUNIT_ASSERT_EQUAL(dim, mesh2.dimension());
 } // testDimension
 
 // ----------------------------------------------------------------------
@@ -86,8 +119,10 @@
 void
 pylith::topology::TestMesh::testComm(void)
 { // testComm
-  Mesh mesh(PETSC_COMM_SELF);
+  Mesh mesh;
+  CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
 
+  mesh.comm(PETSC_COMM_SELF);
   CPPUNIT_ASSERT_EQUAL(PETSC_COMM_SELF, mesh.comm());
 } // testComm
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.hh	2009-01-25 23:10:17 UTC (rev 13951)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMesh.hh	2009-01-25 23:10:32 UTC (rev 13952)
@@ -41,6 +41,7 @@
   CPPUNIT_TEST_SUITE( TestMesh );
 
   CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testCreateSieveMesh );
   CPPUNIT_TEST( testSieveMesh );
   CPPUNIT_TEST( testCoordsys );
   CPPUNIT_TEST( testDebug );
@@ -56,6 +57,9 @@
   /// Test constructor.
   void testConstructor(void);
 
+  /// Test createSieveMesh().
+  void testCreateSieveMesh(void);
+
   /// Test sieveMesh().
   void testSieveMesh(void);
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMeshOps.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMeshOps.cc	2009-01-25 23:10:17 UTC (rev 13951)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestMeshOps.cc	2009-01-25 23:10:32 UTC (rev 13952)
@@ -27,8 +27,7 @@
 void
 pylith::topology::TestMeshOps::testCheckMaterialIds(void)
 { // testCheckMaterialIds
-  const int dim = 2;
-  Mesh mesh(PETSC_COMM_WORLD, dim);
+  Mesh mesh;
 
   meshio::MeshIOAscii iohandler;
   iohandler.filename("data/tri3.mesh");



More information about the CIG-COMMITS mailing list