[cig-commits] r8899 - in short/3D/PyLith/trunk/unittests/libtests/bc: . data

willic3 at geodynamics.org willic3 at geodynamics.org
Tue Dec 18 10:35:31 PST 2007


Author: willic3
Date: 2007-12-18 10:35:30 -0800 (Tue, 18 Dec 2007)
New Revision: 8899

Added:
   short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.hh
   short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.hh
   short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4-tractions.spatialdb
Modified:
   short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/data/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4.mesh
Log:
Finished unit tests for Neumann (traction) BC.
Final test was linearly-varying traction applied along an edge of a
quad4 mesh.



Modified: short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am	2007-12-18 18:35:30 UTC (rev 8899)
@@ -40,6 +40,7 @@
 	TestNeumann.cc \
 	TestNeumannLine2.cc \
 	TestNeumannTri3.cc \
+	TestNeumannQuad4.cc \
 	TestNeumannTet4.cc \
 	TestNeumannHex8.cc \
 	test_bc.cc
@@ -64,6 +65,7 @@
 	TestNeumann.hh \
 	TestNeumannLine2.hh \
 	TestNeumannTri3.hh \
+	TestNeumannQuad4.hh \
 	TestNeumannTet4.hh \
 	TestNeumannHex8.hh
 
@@ -87,6 +89,7 @@
 	data/NeumannData.cc \
 	data/NeumannDataLine2.cc \
 	data/NeumannDataTri3.cc \
+	data/NeumannDataQuad4.cc \
 	data/NeumannDataTet4.cc \
 	data/NeumannDataHex8.cc
 
@@ -109,6 +112,7 @@
 	data/NeumannData.hh \
 	data/NeumannDataLine2.hh \
 	data/NeumannDataTri3.hh \
+	data/NeumannDataQuad4.hh \
 	data/NeumannDataTet4.hh \
 	data/NeumannDataHex8.hh
 

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc	2007-12-18 18:35:30 UTC (rev 8899)
@@ -142,10 +142,12 @@
 			    &tractionsCell[0], tractionsCell.size());
 
     // std::cout << "Tractions at quadrature points: " << std::endl;
+    // std::cout << "Computed    Expected" << std::endl;
     for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
       for (int iDim =0; iDim < spaceDim; ++iDim) {
-        // std::cout << "  " << tractionsCell[iQuad*spaceDim+iDim];
-	CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->tractionsCell[index],
+	const double tractionsCellData = _data->tractionsCell[index];
+        // std::cout << "  " << tractionsCell[iQuad*spaceDim+iDim] << "   " << tractionsCellData << std::endl;
+	CPPUNIT_ASSERT_DOUBLES_EQUAL(tractionsCellData,
 				     tractionsCell[iQuad*spaceDim+iDim],
 				     tolerance);
 	++index;

Added: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc	2007-12-18 18:35:30 UTC (rev 8899)
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestNeumannQuad4.hh" // Implementation of class methods
+
+#include "data/NeumannDataQuad4.hh" // USES NeumannDataQuad4
+
+#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestNeumannQuad4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestNeumannQuad4::setUp(void)
+{ // setUp
+  _data = new NeumannDataQuad4();
+  _quadrature = new feassemble::Quadrature1Din2D();
+  CPPUNIT_ASSERT(0 != _quadrature);
+  feassemble::GeometryLine2D geometry;
+  _quadrature->refGeometry(&geometry);
+} // setUp
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.hh	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.hh	2007-12-18 18:35:30 UTC (rev 8899)
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestNeumannQuad4.hh
+ *
+ * @brief C++ TestNeumann object.
+ *
+ * C++ unit testing for Neumann for mesh with 2-D quad cells.
+ */
+
+#if !defined(pylith_bc_testneumannquad4_hh)
+#define pylith_bc_testneumannquad4_hh
+
+#include "TestNeumann.hh" // ISA TestNeumann
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace bc {
+    class TestNeumannQuad4;
+  } // bc
+} // pylith
+
+/// C++ unit testing for Neumann for mesh with 2-D quad cells.
+class pylith::bc::TestNeumannQuad4 : public TestNeumann
+{ // class TestNeumann
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUB_SUITE( TestNeumannQuad4, TestNeumann );
+  CPPUNIT_TEST( testInitialize );
+  CPPUNIT_TEST( testIntegrateResidual );
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Setup testing data.
+  void setUp(void);
+
+}; // class TestNeumannQuad4
+
+#endif // pylith_bc_neumannquad4_hh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/Makefile.am	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/Makefile.am	2007-12-18 18:35:30 UTC (rev 8899)
@@ -22,6 +22,7 @@
 	elasticplanestrain.spatialdb \
 	quad4.mesh \
 	quad4.spatialdb \
+	quad4-tractions.spatialdb \
 	tet4.mesh \
 	tet4.spatialdb \
 	tet4-tractions.spatialdb \

Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.cc	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.cc	2007-12-18 18:35:30 UTC (rev 8899)
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/* Mesh: quad4.mesh
+ *
+ * Neumann BC on edge defined by vertices 0, 2, 4.
+ * A linear variation in the normal traction is specified, ranging from
+ * a value of zero at x = -1 (vertex 0) to one at x = 1 (vertex 4).
+ * The traction values at the integration points should be:
+ * cell 0:  -0.1056624327, -0.3943375673
+ * cell 1:  -0.6056624327, -0.8943375673
+ * The Jacobian determinant along the element edges is 1/4.
+ * The shape function values at the two element integration points are:
+ * 0.21132486541, 0.78867513459
+ * Integrating over the cell edges, the nodal forces (y-direction)
+ * should be:
+ * vertex 0:  -0.08333333333
+ * vertex 2:  -0.5
+ * vertex 4:  -0.41666666667
+ *
+ */
+
+#include "NeumannDataQuad4.hh"
+
+const char* pylith::bc::NeumannDataQuad4::_meshFilename = 
+  "data/quad4.mesh";
+
+const int pylith::bc::NeumannDataQuad4::_numBasis = 2;
+const int pylith::bc::NeumannDataQuad4::_numQuadPts = 2;
+const double pylith::bc::NeumannDataQuad4::_quadPts[] = {
+  -0.57735027,
+   0.57735027,
+};
+const double pylith::bc::NeumannDataQuad4::_quadWts[] = {
+  1.0,
+  1.0,
+};
+const double pylith::bc::NeumannDataQuad4::_basis[] = {
+  0.78867513459,
+  0.21132486541,
+  0.21132486541,
+  0.78867513459,
+};
+const double pylith::bc::NeumannDataQuad4::_basisDerivRef[] = {
+ -0.5,
+  0.5,
+ -0.5,
+  0.5,
+};
+
+const char* pylith::bc::NeumannDataQuad4::_spatialDBFilename =
+  "data/quad4-tractions.spatialdb";
+const int pylith::bc::NeumannDataQuad4::_id = 0;
+const char* pylith::bc::NeumannDataQuad4::_label = "bc3";
+
+const int pylith::bc::NeumannDataQuad4::_spaceDim = 2;
+const int pylith::bc::NeumannDataQuad4::_cellDim = 1;
+
+const int pylith::bc::NeumannDataQuad4::_numBoundaryVertices = 3;
+const int pylith::bc::NeumannDataQuad4::_numBoundaryCells = 2;
+const int pylith::bc::NeumannDataQuad4::_numCorners = 2;
+const double pylith::bc::NeumannDataQuad4::_cellVertices[] = {-1.0,-1.0,
+							      0.0,-1.0,
+							      0.0,-1.0,
+							      1.0,-1.0};
+const double pylith::bc::NeumannDataQuad4::_tractionsCell[] = {
+  0.0, -0.1056624327,
+  0.0, -0.3943375673,
+  0.0, -0.6056624327,
+  0.0, -0.8943375673,
+};
+const double pylith::bc::NeumannDataQuad4::_valsResidual[] = {
+  0.0, -0.08333333333,
+  0.0,  0.0,
+  0.0, -0.5,
+  0.0,  0.0,
+  0.0, -0.41666666667,
+  0.0,  0.0,
+};
+
+
+pylith::bc::NeumannDataQuad4::NeumannDataQuad4(void)
+{ // constructor
+  meshFilename = const_cast<char*>(_meshFilename);
+
+  numBasis = _numBasis;
+  numQuadPts = _numQuadPts;
+  quadPts = const_cast<double*>(_quadPts);
+  quadWts = const_cast<double*>(_quadWts);
+  basis = const_cast<double*>(_basis);
+  basisDerivRef = const_cast<double*>(_basisDerivRef);
+
+  spatialDBFilename = const_cast<char*>(_spatialDBFilename);
+  id = _id;
+  label = const_cast<char*>(_label);
+
+  spaceDim = _spaceDim;
+  cellDim = _cellDim;
+  numBoundaryVertices = _numBoundaryVertices;
+  numBoundaryCells = _numBoundaryCells;
+  numCorners = _numCorners;
+
+  cellVertices = const_cast<double*>(_cellVertices);
+  tractionsCell = const_cast<double*>(_tractionsCell);
+  valsResidual = const_cast<double*>(_valsResidual);
+
+} // constructor
+
+pylith::bc::NeumannDataQuad4::~NeumannDataQuad4(void)
+{}
+
+
+// End of file

Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.hh	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannDataQuad4.hh	2007-12-18 18:35:30 UTC (rev 8899)
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_bc_neumanndataquad4_hh)
+#define pylith_bc_neumanndataquad4_hh
+
+#include "NeumannData.hh"
+
+namespace pylith {
+  namespace bc {
+     class NeumannDataQuad4;
+  } // pylith
+} // bc
+
+class pylith::bc::NeumannDataQuad4 : public NeumannData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public: 
+
+  /// Constructor
+  NeumannDataQuad4(void);
+
+  /// Destructor
+  ~NeumannDataQuad4(void);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private:
+
+  static const char* _meshFilename;
+
+  // Quadrature information
+  static const int _numBasis;
+  static const int _numQuadPts;
+  static const double _quadPts[];
+  static const double _quadWts[];
+  static const double _basis[];
+  static const double _basisDerivRef[];
+
+  // BC information
+  static const char* _spatialDBFilename;
+  static const int _id;
+  static const char* _label;
+
+  // Mesh information
+  static const int _spaceDim;
+  static const int _cellDim;
+  static const int _numBoundaryVertices;
+  static const int _numBoundaryCells;
+  static const int _numCorners;
+  static const double _cellVertices[];
+
+  // Calculated values.
+  static const double _tractionsCell[];
+  static const double _valsResidual[];
+
+};
+
+#endif // pylith_bc_neumanndataquad4_hh
+
+// End of file

Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4-tractions.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4-tractions.spatialdb	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4-tractions.spatialdb	2007-12-18 18:35:30 UTC (rev 8899)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 2
+  value-names =  shear-traction normal-traction
+  value-units =  Pa  Pa
+  num-locs = 2
+  data-dim = 1
+  space-dim = 2
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 2
+  }
+}
+-1.0  0.0    0.0  0.0
+ 1.0  0.0    0.0  1.0

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4.mesh	2007-12-18 05:05:05 UTC (rev 8898)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/quad4.mesh	2007-12-18 18:35:30 UTC (rev 8899)
@@ -57,4 +57,12 @@
       0  1  4  5
     }
   }
+  group = {
+    name = bc3
+    type = vertices
+    count = 3
+    indices = {
+      0  2  4
+    }
+  }
 }



More information about the cig-commits mailing list