[cig-commits] r7119 - in short/3D/PyLith/trunk: libsrc/faults unittests/libtests/faults unittests/libtests/faults/data

brad at geodynamics.org brad at geodynamics.org
Fri Jun 8 21:40:34 PDT 2007


Author: brad
Date: 2007-06-08 21:40:33 -0700 (Fri, 08 Jun 2007)
New Revision: 7119

Modified:
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc
Log:
Fixed some bugs in FaultCohesiveKin and corresponding C++ unit tests.

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2007-06-09 04:40:33 UTC (rev 7119)
@@ -23,6 +23,7 @@
 
 #include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
 
+#include <math.h> // USES pow(), sqrt()
 #include <assert.h> // USES assert()
 #include <sstream> // USES std::ostringstream
 #include <stdexcept> // USES std::runtime_error
@@ -106,9 +107,8 @@
   } // for
 
   // Create orientation section for constraint vertices
-  const int cohesiveDim = mesh->getDimension()-1;
   const int spaceDim = cs->spaceDim();
-  const int orientationSize = (cohesiveDim > 0) ? cohesiveDim*spaceDim : 1;
+  const int orientationSize = spaceDim*spaceDim;
   _orientation = new real_section_type(mesh->comm(), mesh->debug());
   assert(!_orientation.isNull());
   const std::set<Mesh::point_type>::const_iterator vertCohesiveBegin = 
@@ -129,6 +129,7 @@
   assert(!coordinates.isNull());
 
   // Set orientation function
+  const int cohesiveDim = mesh->getDimension()-1;
   assert(cohesiveDim == _quadrature->cellDim());
   assert(spaceDim == _quadrature->spaceDim());
   orient_fn_type orientFn;
@@ -152,7 +153,7 @@
   const int numBasis = _quadrature->numBasis();
   const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
   const double_array& verticesRef = _quadrature->vertices();
-  const int jacobianSize = spaceDim * cohesiveDim;
+  const int jacobianSize = (cohesiveDim > 0) ? spaceDim * cohesiveDim : 1;
   double_array jacobian(jacobianSize);
   double jacobianDet = 0;
   double_array vertexOrientation(orientationSize);
@@ -201,14 +202,15 @@
     const real_section_type::value_type* vertexOrient = 
       _orientation->restrictPoint(*v_iter);
     
-    assert(cohesiveDim*spaceDim == orientationSize);
-    for (int iDim=0, index=0; iDim < cohesiveDim; ++iDim, index+=cohesiveDim) {
+    assert(spaceDim*spaceDim == orientationSize);
+    for (int iDim=0; iDim < spaceDim; ++iDim) {
       double mag = 0;
-      for (int jDim=0; jDim < spaceDim; ++jDim)
-	mag *= vertexOrient[index*cohesiveDim+jDim];
-      for (int jDim=0; jDim < cohesiveDim; ++jDim)
-	vertexDir[index*cohesiveDim+jDim] = 
-	  vertexOrient[index*cohesiveDim+jDim] / mag;
+      for (int jDim=0, index=iDim*spaceDim; jDim < spaceDim; ++jDim)
+	mag += pow(vertexOrient[index+jDim],2);
+      mag = sqrt(mag);
+      for (int jDim=0, index=iDim*spaceDim; jDim < spaceDim; ++jDim)
+	vertexDir[index+jDim] = 
+	  vertexOrient[index+jDim] / mag;
     } // for
     _orientation->updatePoint(*v_iter, &vertexDir[0]);
   } // for
@@ -303,9 +305,8 @@
   const ALE::Obj<real_section_type>& disp = fields->getHistoryItem(1);
   assert(!disp.isNull());  
 
-  const int cohesiveDim = _quadrature->cellDim();
   const int spaceDim = _quadrature->spaceDim();
-  const int orientationSize = cohesiveDim*spaceDim;
+  const int orientationSize = spaceDim*spaceDim;
 
   // Allocate matrix for cell values (if necessary)
   _initCellMatrix();

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2007-06-09 04:40:33 UTC (rev 7119)
@@ -26,10 +26,10 @@
 	TestFault.cc \
 	TestFaultCohesive.cc \
 	TestFaultCohesiveKin.cc \
+	TestFaultCohesiveKinLine2.cc \
 	TestFaultCohesiveKinTri3.cc \
 	test_faults.cc
 
-#	TestFaultCohesiveKinLine2.cc
 
 
 noinst_HEADERS = \

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc	2007-06-09 04:40:33 UTC (rev 7119)
@@ -99,7 +99,7 @@
   int iVertex = 0;
   for (std::set<Mesh::point_type>::const_iterator v_iter=vertConstraintBegin;
        v_iter != vertConstraintEnd;
-       ++v_iter)
+       ++v_iter, ++iVertex)
     CPPUNIT_ASSERT_EQUAL(_data->constraintVertices[iVertex],
 			 *v_iter);
 
@@ -107,7 +107,7 @@
   iVertex = 0;
   const int cellDim = _data->cellDim;
   const int spaceDim = _data->spaceDim;
-  const int orientationSize = (cellDim > 0) ? cellDim*spaceDim : 1;
+  const int orientationSize = spaceDim*spaceDim;
   for (std::set<Mesh::point_type>::const_iterator v_iter=vertConstraintBegin;
        v_iter != vertConstraintEnd;
        ++v_iter) {
@@ -198,7 +198,7 @@
 void
 pylith::faults::TestFaultCohesiveKin::testIntegrateJacobian(void)
 { // testIntegrateJacobian
-
+#if 0
   ALE::Obj<Mesh> mesh;
   FaultCohesiveKin fault;
   _initialize(&mesh, &fault);
@@ -283,6 +283,8 @@
     } // for
   MatDestroy(jDense);
   MatDestroy(jSparseAIJ);
+#endif
+  CPPUNIT_ASSERT(false);
 } // testIntegrateJacobian
 
 // ----------------------------------------------------------------------
@@ -325,6 +327,7 @@
 void
 pylith::faults::TestFaultCohesiveKin::testSetField(void)
 { // testSetField
+#if 0
   ALE::Obj<Mesh> mesh;
   FaultCohesiveKin fault;
   _initialize(&mesh, &fault);
@@ -368,6 +371,8 @@
 	CPPUNIT_ASSERT_DOUBLES_EQUAL(valsE[index], vals[i], tolerance);
     } // for
   } // for
+#endif
+  CPPUNIT_ASSERT(false);
 } // testSetField
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc	2007-06-09 04:40:33 UTC (rev 7119)
@@ -16,8 +16,8 @@
 
 #include "data/CohesiveKinDataLine2.hh" // USES CohesiveKinDataLine2
 
-#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature1D
-#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
+#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature0D
+#include "pylith/feassemble/GeometryPoint1D.hh" // USES GeometryPoint1D
 
 // ----------------------------------------------------------------------
 CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestFaultCohesiveKinLine2 );
@@ -30,7 +30,7 @@
   _data = new CohesiveKinDataLine2();
   _quadrature = new feassemble::Quadrature0D();
   CPPUNIT_ASSERT(0 != _quadrature);
-  feassemble::GeometryLine1D geometry;
+  feassemble::GeometryPoint1D geometry;
   _quadrature->refGeometry(&geometry);
 } // setUp
 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc	2007-06-09 04:40:33 UTC (rev 7119)
@@ -16,8 +16,8 @@
 
 #include "data/CohesiveKinDataTri3.hh" // USES CohesiveKinDataTri3
 
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
-#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
+#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
 
 // ----------------------------------------------------------------------
 CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestFaultCohesiveKinTri3 );
@@ -28,9 +28,9 @@
 pylith::faults::TestFaultCohesiveKinTri3::setUp(void)
 { // setUp
   _data = new CohesiveKinDataTri3();
-  _quadrature = new feassemble::Quadrature1D();
+  _quadrature = new feassemble::Quadrature1Din2D();
   CPPUNIT_ASSERT(0 != _quadrature);
-  feassemble::GeometryLine1D geometry;
+  feassemble::GeometryLine2D geometry;
   _quadrature->refGeometry(&geometry);
 } // setUp
 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc	2007-06-09 02:20:25 UTC (rev 7118)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc	2007-06-09 04:40:33 UTC (rev 7119)
@@ -117,8 +117,8 @@
 const int pylith::faults::CohesiveKinDataTri3::_numConstraintVert = 2;
 
 const double pylith::faults::CohesiveKinDataTri3::_orientation[] = {
-  0.0, 1.0,
-  0.0, 1.0
+  0.0, -1.0,  -1.0, 0.0,
+  0.0, -1.0,  -1.0, 0.0
 };
 
 const int pylith::faults::CohesiveKinDataTri3::_constraintVertices[] = {



More information about the cig-commits mailing list