[cig-commits] r4700 - in short/3D/PyLith/trunk: . modulesrc/feassemble pylith pylith/feassemble pylith/utils unittests unittests/pytests unittests/pytests/feassemble

brad at geodynamics.org brad at geodynamics.org
Wed Oct 4 15:45:46 PDT 2006


Author: brad
Date: 2006-10-04 15:45:45 -0700 (Wed, 04 Oct 2006)
New Revision: 4700

Added:
   short/3D/PyLith/trunk/pylith/utils/testarray.py
   short/3D/PyLith/trunk/unittests/pytests/
   short/3D/PyLith/trunk/unittests/pytests/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/feassemble/
   short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.cc
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py
   short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py
   short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.pyxe
Modified:
   short/3D/PyLith/trunk/configure.ac
   short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am
   short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/feassemble/FIATCell.py
   short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py
   short/3D/PyLith/trunk/pylith/utils/__init__.py
   short/3D/PyLith/trunk/pylith/utils/importing.py
   short/3D/PyLith/trunk/unittests/Makefile.am
Log:
Added testing of Python Quadrature and FIATSimplex. Squashed some small bugs in the process.

Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/configure.ac	2006-10-04 22:45:45 UTC (rev 4700)
@@ -151,6 +151,8 @@
 		unittests/Makefile
 		unittests/libtests/Makefile
 		unittests/libtests/feassemble/Makefile
+		unittests/pytests/Makefile
+		unittests/pytests/feassemble/Makefile
                 doc/Makefile])
 
 #                 libsrc/materials/Makefile

Modified: short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am	2006-10-04 22:45:45 UTC (rev 4700)
@@ -23,7 +23,8 @@
 	feassemble.c feassemble_embed.cpp feassemble_embed.h
 
 feassemblemodule_la_LIBADD = \
-	$(top_builddir)/libsrc/feassemble/libpylithfeassemble.la $(PETSC_LIB)
+	$(top_builddir)/libsrc/feassemble/libpylithfeassemble.la \
+	$(PETSC_LIB)
 
 INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
 

Modified: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe	2006-10-04 22:45:45 UTC (rev 4700)
@@ -96,7 +96,7 @@
             "of type double."
     if numQuadPts != basisDeriv.shape[0] or \
            numCorners != basisDeriv.shape[1] or \
-           cellDim != basisDeriv[2]:
+           cellDim != basisDeriv.shape[2]:
       raise TypeError, \
             "Shape of argument 'basisDeriv' must be (numQuadPts, " \
             "numCorners, cellDim)."
@@ -151,13 +151,13 @@
 
 
   property minJacobian:
-    def __set__(self, min):
+    def __set__(self, value):
       """Set minimum allowable Jacobian."""
       # create shim for method 'minJacobian'
-      #embed{ void Quadrature_minJacobian_set(void* pObj, double min)
-      ((pylith::feassemble::Quadrature*) pObj)->minJacobian(min);
+      #embed{ void Quadrature_minJacobian_set(void* pObj, double value)
+      ((pylith::feassemble::Quadrature*) pObj)->minJacobian(value);
       #}embed
-      Quadrature_minJacobian_set(self.thisptr, min)
+      Quadrature_minJacobian_set(self.thisptr, value)
 
     def __get__(self):
       """Get minimum allowable Jacobian."""

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2006-10-04 22:45:45 UTC (rev 4700)
@@ -15,10 +15,13 @@
 	__init__.py \
 	feassemble/__init__.py \
 	feassemble/Assembler.py \
+	feassemble/FIATCell.py \
+	feassemble/FIATSimplex.py \
 	feassemble/Field.py \
 	feassemble/Integrator.py \
 	feassemble/IntegratorElasticity.py \
 	feassemble/Quadrature.py \
+	feassemble/ReferenceCell.py \
 	materials/__init__.py \
 	materials/ElasticIsotropic3D.py \
 	materials/Homogeneous.py \
@@ -40,8 +43,9 @@
 	topology/MeshGenerator.py \
 	topology/MeshImporter.py \
 	utils/__init__.py \
+	utils/CppData.py \
 	utils/importing.py \
-	utils/CppData.py
+	utils/testarray.py
 
 # version
 # $Id$

Modified: short/3D/PyLith/trunk/pylith/feassemble/FIATCell.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/FIATCell.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/feassemble/FIATCell.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -44,13 +44,15 @@
     
     # Evaluate basis functions at quadrature points
     quadpts = quadrature.get_points()
-    self.basis = numpy.array(basisFns.tabulate(quadpts)).transpose()
+    basis = numpy.array(basisFns.tabulate(quadpts)).transpose()
+    self.basis = numpy.reshape(basis.flatten(), basis.shape)
 
     # Evaluate derivatives of basis functions at quadrature points
     import FIAT.shapes
     dim = FIAT.shapes.dimension(basisFns.base.shape)
-    self.basisDeriv = numpy.array([basisFns.deriv_all(d).tabulate(quadpts) \
-                                   for d in range(dim)]).squeeze().transpose()
+    basisDeriv = numpy.array([basisFns.deriv_all(d).tabulate(quadpts) \
+                              for d in range(dim)]).transpose()
+    self.basisDeriv = numpy.reshape(basisDeriv.flatten(), basisDeriv.shape)
 
     self.quadPts = numpy.array(quadrature.get_points())
     self.quadWts = numpy.array(quadrature.get_weights())

Modified: short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -56,6 +56,7 @@
     Constructor.
     """
     Component.__init__(self, name, facility="quadrature")
+    self.minJacobian = 1.0e-06
     self.cppHandle = None
     self.spaceDim = None
     return
@@ -105,7 +106,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature1D()
     self.spaceDim = 1
@@ -125,7 +126,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature1Din2D()
     self.spaceDim = 2
@@ -145,7 +146,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature1Din3D()
     self.spaceDim = 3
@@ -165,7 +166,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature2D()
     self.spaceDim = 2
@@ -185,7 +186,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature2Din3D()
     self.spaceDim = 3
@@ -195,7 +196,7 @@
 
 # ----------------------------------------------------------------------
 # Quadrature3D class
-class Quadrature2D(Quadrature):
+class Quadrature3D(Quadrature):
   """
   Python object for integrating over 3-D finite-elements in a 3-D
   domain using quadrature.
@@ -205,7 +206,7 @@
     """
     Constructor.
     """
-    Quadrature.__init(self, name)
+    Quadrature.__init__(self, name)
     import pylith.feassemble.feassemble as bindings
     self.cppHandle = bindings.Quadrature3D()
     self.spaceDim = 3

Modified: short/3D/PyLith/trunk/pylith/utils/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/__init__.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/utils/__init__.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -1 +1,15 @@
-all = ['importing']
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ----------------------------------------------------------------------
+#
+
+all = ['CppData', 'testarray', 'importing']
+
+# End of file

Modified: short/3D/PyLith/trunk/pylith/utils/importing.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/importing.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/utils/importing.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -1,8 +1,27 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/utils/importing.py
+
 def importModule(moduleName):
-  '''Import the named module, and return the module object
-  - Works properly for fully qualified names'''
+  """
+  Import the named module, and return the module object
+  - Works properly for fully qualified names.
+  """
   module     = __import__(moduleName)
   components = moduleName.split('.')
   for comp in components[1:]:
     module = getattr(module, comp)
   return module
+
+
+# End of file

Added: short/3D/PyLith/trunk/pylith/utils/testarray.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/testarray.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/pylith/utils/testarray.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+import numpy
+
+def test_double(obj, valuesE, values):
+    """
+    Check whether arrays containing double values match.
+
+    @param obj Test object
+    @valuesE Array of expected values
+    @values Array of values to check
+    """
+
+    # Check shape
+    obj.assertEqual(len(valuesE.shape), len(values.shape))
+    for (dimE, dim) in zip(valuesE.shape, values.shape):
+        obj.assertEqual(dimE, dim)
+
+    # Check values
+    for (vE, v) in zip(numpy.reshape(valuesE, -1),
+                       numpy.reshape(values, -1)):
+        obj.assertAlmostEqual(1.0, v/vE, 6)
+
+    return

Modified: short/3D/PyLith/trunk/unittests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/Makefile.am	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/Makefile.am	2006-10-04 22:45:45 UTC (rev 4700)
@@ -11,6 +11,7 @@
 #
 
 SUBDIRS = \
-	libtests
+	libtests \
+	pytests
 
 # End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/Makefile.am	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/Makefile.am	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,16 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+SUBDIRS = \
+	feassemble
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,52 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = feassemble
+include $(top_srcdir)/subpackage.am
+
+TESTS = testfeassemble.py
+
+check_SCRIPTS = testfeassemble.py
+
+noinst_PYTHON = \
+	TestQuadrature.py \
+	TestFIATSimplex.py
+
+
+# module
+subpkgpyexec_LTLIBRARIES = testfeassemblemodule.la
+
+testfeassemblemodule_la_LDFLAGS = -module
+
+testfeassemblemodule_la_SOURCES = testfeassemble.pyxe
+
+nodist_testfeassemblemodule_la_SOURCES = \
+	testfeassemble.c testfeassemble_embed.cpp testfeassemble_embed.h
+
+testfeassemblemodule_la_LIBADD = \
+	$(PETSC_LIB)
+
+INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+
+testfeassemble.pyx testfeassemble_embed.cpp  testfeassemble_embed.h: testfeassemble.pyxe
+	cp $< . && pyrexembed testfeassemble.pyxe && rm -f testfeassemble.pyxe
+testfeassemble_embed.cpp: testfeassemble_embed.h
+testfeassemble_embed.h: testfeassemble.pyx
+
+.pyx.c:
+	pyrexc $<
+
+CLEANFILES = \
+	testfeassemble.pyx testfeassemble.c *_embed.* \
+	$(am__installdirs)/testfeassemblemodule.*
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/feassemble/TestFIATSimplex.py
+
+## @brief Unit testing of FIATSimplex object.
+
+import unittest
+import numpy
+from pylith.utils.testarray import test_double
+
+# ----------------------------------------------------------------------
+def N0(p):
+  return -0.5*p*(1.0-p)
+
+def N0p(p):
+  return -0.5*(1.0-p) + 0.5*p
+
+def N1(p):
+  return 0.5*p*(1.0+p)
+
+def N1p(p):
+  return +0.5*(1.0+p) + 0.5*p
+
+def N2(p):
+  return (1.0-p**2)
+
+def N2p(p):
+  return -2.0*p
+
+
+# ----------------------------------------------------------------------
+class TestFIATSimplex(unittest.TestCase):
+  """
+  Unit testing of FIATSimplex object.
+  """
+  
+
+  def test_shape(self):
+    """
+    Test _getShape().
+    """
+    from pylith.feassemble.FIATSimplex import FIATSimplex
+    cell = FIATSimplex()
+
+    import FIAT.shapes
+
+    cell.shape = "line"
+    shape = cell._getShape()
+    self.assertEqual(FIAT.shapes.LINE, shape)
+
+    cell.shape = "triangle"
+    shape = cell._getShape()
+    self.assertEqual(FIAT.shapes.TRIANGLE, shape)
+
+    cell.shape = "tetrahedron"
+    shape = cell._getShape()
+    self.assertEqual(FIAT.shapes.TETRAHEDRON, shape)
+    return
+
+
+  def test_initialize(self):
+    """
+    Test initialize().
+    """
+    from pylith.feassemble.FIATSimplex import FIATSimplex
+    cell = FIATSimplex()
+    cell.shape = "line"
+    cell.degree = 2
+    cell.order = 2
+    quadPtsE = numpy.array( [(-1.0/3**0.5,),
+                             (+1.0/3**0.5,)],
+                            dtype=numpy.float64 )
+    quadWtsE = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
+    basis = numpy.zeros( (2, 3), dtype=numpy.Float64)
+    basisDeriv = numpy.zeros( (2, 3, 1), dtype=numpy.Float64)
+    iQuad = 0
+    for q in quadPtsE:
+      basis[iQuad] = numpy.array([N0(q), N1(q), N2(q)],
+                                 dtype=numpy.float64).reshape( (3,) )
+      deriv = numpy.array([[N0p(q)], [N1p(q)], [N2p(q)]],
+                          dtype=numpy.Float64)      
+      basisDeriv[iQuad] = deriv.reshape((3, 1))
+      iQuad += 1
+
+    cell.initialize()
+
+    # Check basic attributes
+    self.assertEqual(1, cell.cellDim)
+    self.assertEqual(3, cell.numCorners)
+    self.assertEqual(2, cell.numQuadPts)
+
+    # Check arrays
+    test_double(self, quadPtsE, cell.quadPts)
+    test_double(self, quadWtsE, cell.quadWts)
+    test_double(self, basis, cell.basis)
+    test_double(self, basisDeriv, cell.basisDeriv)
+
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.cc	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.cc	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,278 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestQuadrature.hh" // Implementation of class methods
+
+// ----------------------------------------------------------------------
+// Test clone
+void
+pylith::feassemble::TestQuadrature::testClone(void)
+{ // testClone
+  // Semi-random values manually set to check cloning
+  const double minJacobian = 1.0;
+  const int cellDim = 1;
+  const int numCorners = 2;
+  const int numQuadPts = 1;
+  const int spaceDim = 1;
+  const double basis[] = { 0.2, 0.4 };
+  const double basisDeriv[] = { 0.8, 1.6 };
+  const double quadPtsRef[] = { 3.2 };
+  const double quadWts[] = { 6.4 };
+  const double quadPts[] = { 12.8 };
+  const double jacobian[] = { 2.56 };
+  const double jacobianInv[] = { 5.12 };
+  const double jacobianDet[] = { 10.24 };
+
+  // Set values
+  Quadrature1D qOrig;
+  qOrig._minJacobian = minJacobian;
+  qOrig._cellDim = cellDim;
+  qOrig._numCorners = numCorners;
+  qOrig._numQuadPts = numQuadPts;
+  qOrig._spaceDim = spaceDim;
+
+  int size = 2;
+  qOrig._basis = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._basis, basis, size*sizeof(double));
+  
+  size = 2;
+  qOrig._basisDeriv = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._basisDeriv, basisDeriv, size*sizeof(double));
+
+  size = 1;
+  qOrig._quadPtsRef = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._quadPtsRef, quadPtsRef, size*sizeof(double));
+
+  size = 1;
+  qOrig._quadWts = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._quadWts, quadWts, size*sizeof(double));
+
+  size = 1;
+  qOrig._quadPts = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._quadPts, quadPts, size*sizeof(double));
+
+  size = 1;
+  qOrig._jacobian = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._jacobian, jacobian, size*sizeof(double));
+
+  size = 1;
+  qOrig._jacobianInv = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._jacobianInv, jacobianInv, size*sizeof(double));
+
+  size = 1;
+  qOrig._jacobianDet = (size > 0) ? new double[size] : 0;
+  memcpy(qOrig._jacobianDet, jacobianDet, size*sizeof(double));
+
+  // Clone
+  const Quadrature* qCopy = qOrig.clone();
+
+  // Check clone
+  CPPUNIT_ASSERT(0 != qCopy);
+
+  CPPUNIT_ASSERT_EQUAL(minJacobian, qCopy->_minJacobian);
+  CPPUNIT_ASSERT_EQUAL(cellDim, qCopy->_cellDim);
+  CPPUNIT_ASSERT_EQUAL(numCorners, qCopy->_numCorners);
+  CPPUNIT_ASSERT_EQUAL(numQuadPts, qCopy->_numQuadPts);
+  CPPUNIT_ASSERT_EQUAL(spaceDim, qCopy->_spaceDim);
+
+  CPPUNIT_ASSERT(0 != qCopy->_basis);
+  size = numCorners * numQuadPts;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(basis[i], qCopy->_basis[i]);
+
+  CPPUNIT_ASSERT(0 != qCopy->_basisDeriv);
+  size = numCorners * numQuadPts * spaceDim;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(basisDeriv[i], qCopy->_basisDeriv[i]);
+
+  CPPUNIT_ASSERT(0 != qCopy->_quadPtsRef);
+  size = numQuadPts * cellDim;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(quadPtsRef[i], qCopy->_quadPtsRef[i]);
+
+  CPPUNIT_ASSERT(0 != qCopy->_quadWts);
+  size = numQuadPts;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(quadWts[i], qCopy->_quadWts[i]);
+
+  size = 1;
+
+  CPPUNIT_ASSERT(0 != qCopy->_quadPts);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(quadPts[i], qCopy->_quadPts[i]);
+  CPPUNIT_ASSERT(0 != qCopy->_jacobian);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(jacobian[i], qCopy->_jacobian[i]);
+  CPPUNIT_ASSERT(0 != qCopy->_jacobianInv);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(jacobianInv[i], qCopy->_jacobianInv[i]);
+  CPPUNIT_ASSERT(0 != qCopy->_jacobianDet);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(jacobianDet[i], qCopy->_jacobianDet[i]);
+} // testCopy
+
+// ----------------------------------------------------------------------
+// Test minJacobian()
+void
+pylith::feassemble::TestQuadrature::testMinJacobian(void)
+{ // testMinJacobian
+  Quadrature1D q;
+  const double min = 1.0;
+  q.minJacobian(min);
+  CPPUNIT_ASSERT_EQUAL(min, q._minJacobian);
+} // testMinJacobian
+
+// ----------------------------------------------------------------------
+// Test initialize()
+void
+pylith::feassemble::TestQuadrature::testInitialize(void)
+{ // initialize
+  
+  const int cellDim = 1;
+  const int numCorners = 2;
+  const int numQuadPts = 1;
+  const int spaceDim = 1;
+  const double basis[] = { 0.5, 0.5 };
+  const double basisDeriv[] = { -0.5, 0.5 };
+  const double quadPtsRef[] = { 0.0 };
+  const double quadWts[] = { 2.0 };
+  const double minJacobian = 1.0;
+
+  Quadrature1D q;
+  q.initialize(basis, basisDeriv, quadPtsRef, quadWts,
+	       cellDim, numCorners, numQuadPts, spaceDim);
+  
+  CPPUNIT_ASSERT_EQUAL(cellDim, q._cellDim);
+  CPPUNIT_ASSERT_EQUAL(numCorners, q._numCorners);
+  CPPUNIT_ASSERT_EQUAL(numQuadPts, q._numQuadPts);
+  CPPUNIT_ASSERT_EQUAL(spaceDim, q._spaceDim);
+
+  int size = numCorners * numQuadPts;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(basis[i], q._basis[i]);
+
+  size = numCorners * numQuadPts * spaceDim;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(basisDeriv[i], q._basisDeriv[i]);
+
+  size = numQuadPts * cellDim;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(quadPtsRef[i], q._quadPtsRef[i]);
+
+  size = numQuadPts;
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_EQUAL(quadWts[i], q._quadWts[i]);
+
+  // Make sure Jacobian stuff has been allocated
+  CPPUNIT_ASSERT(0 != q._jacobian);
+  CPPUNIT_ASSERT(0 != q._jacobianInv);
+  CPPUNIT_ASSERT(0 != q._jacobianDet);
+  CPPUNIT_ASSERT(0 != q._quadPts);
+} // initialize
+
+// ----------------------------------------------------------------------
+// Test initialize() & computeGeometry()
+void
+pylith::feassemble::TestQuadrature::_testComputeGeometry(
+					    Quadrature* pQuad,
+					    const QuadratureData& data) const
+{ // testComputeGeometry
+  const int cellDim = data.cellDim;
+  const int numCorners = data.numCorners;
+  const int numQuadPts = data.numQuadPts;
+  const int spaceDim = data.spaceDim;
+  const double* basis = data.basis;
+  const double* basisDeriv = data.basisDeriv;
+  const double* quadPtsRef = data.quadPtsRef;
+  const double* quadWts = data.quadWts;
+
+  const int numVertices = data.numVertices;
+  const int numCells = data.numCells;
+  const double* vertCoords = data.vertices;
+  const int* cells = data.cells;
+  const double* quadPts = data.quadPts;
+  const double* jacobian = data.jacobian;
+  const double* jacobianInv = data.jacobianInv;
+  const double* jacobianDet = data.jacobianDet;
+
+  const double minJacobian = 1.0e-06;
+
+  CPPUNIT_ASSERT(0 != basis);
+  CPPUNIT_ASSERT(0 != basisDeriv);
+  CPPUNIT_ASSERT(0 != quadPtsRef);
+  CPPUNIT_ASSERT(0 != quadWts);
+  CPPUNIT_ASSERT(0 != vertCoords);
+  CPPUNIT_ASSERT(0 != cells);
+  CPPUNIT_ASSERT(0 != quadPts);
+  CPPUNIT_ASSERT(0 != jacobian);
+  CPPUNIT_ASSERT(0 != jacobianInv);
+  CPPUNIT_ASSERT(0 != jacobianDet);
+
+  pQuad->minJacobian(minJacobian);
+  pQuad->initialize(basis, basisDeriv, quadPtsRef, quadWts,
+		    cellDim, numCorners, numQuadPts, spaceDim);
+
+  // Create mesh with test cell
+  typedef ALE::Mesh::topology_type topology_type;
+  typedef topology_type::sieve_type sieve_type;
+  ALE::Obj<ALE::Mesh> mesh = new ALE::Mesh(PETSC_COMM_WORLD, cellDim);
+  ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
+  ALE::Obj<topology_type> topology = new topology_type(mesh->comm());
+
+  const bool interpolate = false;
+  ALE::New::SieveBuilder<sieve_type>::buildTopology(sieve, cellDim, numCells,
+		     (int*) cells, numVertices, interpolate, numCorners);
+  sieve->stratify();
+  topology->setPatch(0, sieve);
+  topology->stratify();
+  mesh->setTopology(topology);
+  ALE::New::SieveBuilder<sieve_type>::buildCoordinates(
+		    mesh->getRealSection("coordinates"), spaceDim, vertCoords);
+  
+  // Check values from _computeGeometry()
+  const ALE::Mesh::topology_type::patch_type patch = 0;
+  const ALE::Obj<topology_type::label_sequence>& elements = 
+    topology->heightStratum(patch, 0);
+  const topology_type::label_sequence::iterator e_iter = elements->begin(); 
+  const ALE::Obj<ALE::Mesh::real_section_type>& coordinates = 
+    mesh->getRealSection("coordinates");
+  pQuad->_computeGeometry(coordinates, *e_iter);
+
+  CPPUNIT_ASSERT(1 == numCells);
+
+  const double tolerance = 1.0e-06;
+  int size = numQuadPts * spaceDim;
+  CPPUNIT_ASSERT(0 != pQuad->_quadPts);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPts[i], pQuad->_quadPts[i], tolerance);
+
+  size = numQuadPts * cellDim * spaceDim;
+  CPPUNIT_ASSERT(0 != pQuad->_jacobian);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobian[i], pQuad->_jacobian[i], tolerance);
+
+  size = numQuadPts * spaceDim * cellDim;
+  CPPUNIT_ASSERT(0 != pQuad->_jacobianInv);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianInv[i], pQuad->_jacobianInv[i], 
+				 tolerance);
+
+  size = numQuadPts;
+  CPPUNIT_ASSERT(0 != pQuad->_jacobianDet);
+  for (int i=0; i < size; ++i)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDet[i], pQuad->_jacobianDet[i], 
+				 tolerance);
+} // testQuadratic
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/pytests/feassemble/TestQuadrature.hh
+ *
+ * @brief C++ TestQuadrature object
+ *
+ * Helper class for unit testing of Python Quadrature.
+ */
+
+#if !defined(pylith_feassemble_pytestquadrature_hh)
+#define pylith_feassemble_pytestquadrature_hh
+
+#include "pylith/feassemble/Quadrature.hh"
+
+/// Namespace for spatialdata package
+namespace pylith {
+  namespace feassemble {
+    class TestQuadrature;
+  } // feassemble
+} // pylith
+
+/// Helper class for unit testing of Python Quadrature
+class pylith::feassemble::TestQuadrature
+{ // class TestQuadrature
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /** Get number of dimensions in reference cell.
+   *
+   * @returns Number of dimensions
+   */
+  static int cellDim(const Quadrature& q);
+
+  /** Get number of vertices in cell.
+   *
+   * @returns Number of vertices
+   */
+  static int numCorners(const Quadrature& q);
+
+  /** Get number of quadrature points.
+   *
+   * @returns Number of points
+   */
+  static int numQuadPts(const Quadrature& q);
+
+  /** Get number of dimensions in coordinates of cell vertices.
+   *
+   * @returns Number of dimensions
+   */
+  static int spaceDim(const Quadrature& q);
+
+  /** Get basis functions evaluated at quadrature points.
+   *
+   * @returns Array of basis functions evaluated at quadrature points
+   */
+  static const double* basis(const Quadrature& q);
+
+  /** Get derivatives of basis functions evaluated at quadrature points.
+   *
+   * @returns Array of derivatives of basis fns evaluated at quad pts
+   */
+  static const double* basisDeriv(const Quadrature& q);
+
+  /** Get coordinates of quadrature points in reference cell.
+   *
+   * @returns Array of coordinates of quadrature points
+   */
+  static const double* quadPtsRef(const Quadrature& q);
+
+  /** Get weights of quadrature points.
+   *
+   * @returns Array of weights of quadrature points
+   */
+  static const double* quadWts(const Quadrature& q);
+
+}; // class TestQuadrature
+
+#include "TestQuadrature.icc" // inline methods
+
+#endif // pylith_feassemble_pytestquadrature_hh
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_feassemble_pytestquadrature_hh)
+#error "TestQuadrature.icc must be included only from TestQuadrature.hh"
+#else
+
+// Get number of dimensions in reference cell.
+int
+pylith::feassemble::TestQuadrature::cellDim(const Quadrature& q) {
+  return q._cellDim;
+}
+
+// Get number of vertices in cell.
+int
+pylith::feassemble::TestQuadrature::numCorners(const Quadrature& q) {
+  return q._numCorners;
+}
+
+// Get number of quadrature points.
+int
+pylith::feassemble::TestQuadrature::numQuadPts(const Quadrature& q) {
+  return q._numQuadPts;
+}
+
+// Get number of dimensions in coordinates of cell vertices.
+int
+pylith::feassemble::TestQuadrature::spaceDim(const Quadrature& q) {
+  return q._spaceDim;
+}
+
+// Get basis functions evaluated at quadrature points.
+const double*
+pylith::feassemble::TestQuadrature::basis(const Quadrature& q) {
+  return q._basis;
+}
+
+// Get derivatives of basis functions evaluated at quadrature points.
+const double*
+pylith::feassemble::TestQuadrature::basisDeriv(const Quadrature& q) {
+  return q._basisDeriv;
+}
+
+// Get coordinates of quadrature points
+const double*
+pylith::feassemble::TestQuadrature::quadPtsRef(const Quadrature& q) {
+  return q._quadPtsRef;
+}
+
+// Get weights of quadrature points
+const double*
+pylith::feassemble::TestQuadrature::quadWts(const Quadrature& q) {
+  return q._quadWts;
+}
+
+#endif
+
+// End of file

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/feassemble/TestQuadrature.py
+
+## @brief Unit testing of Python Quadrature object.
+
+import unittest
+import numpy
+from pylith.feassemble.Quadrature import *
+
+# ----------------------------------------------------------------------
+def N0(p):
+  return -0.5*p*(1.0-p)
+
+def N0p(p):
+  return -0.5*(1.0-p) + 0.5*p
+
+def N1(p):
+  return 0.5*p*(1.0+p)
+
+def N1p(p):
+  return +0.5*(1.0+p) + 0.5*p
+
+def N2(p):
+  return (1.0-p**2)
+
+def N2p(p):
+  return -2.0*p
+
+
+# ----------------------------------------------------------------------
+class TestQuadrature(unittest.TestCase):
+  """
+  Unit testing of Python Quadrature object.
+  """
+
+  def test_minJacobian(self):
+    """
+    Test minJacobian attribute.
+    """
+    minJacobian = 4.0e-02;
+    q = Quadrature1D()
+    q.minJacobian = minJacobian
+    self.assertEqual(minJacobian, q.minJacobian)
+    return
+    
+
+  def test_initialize(self):
+    """
+    Test initialize().
+    """
+    from pylith.feassemble.FIATSimplex import FIATSimplex
+    cell = FIATSimplex()
+    cell.shape = "line"
+    cell.degree = 2
+    cell.order = 2
+    quadPtsE = numpy.array( [(-1.0/3**0.5,),
+                             (+1.0/3**0.5,)],
+                            dtype=numpy.float64 )
+    quadWtsE = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
+    basisE = numpy.zeros( (2, 3), dtype=numpy.Float64)
+    basisDerivE = numpy.zeros( (2, 3, 1), dtype=numpy.Float64)
+    iQuad = 0
+    for q in quadPtsE:
+      basisE[iQuad] = numpy.array([N0(q), N1(q), N2(q)],
+                                 dtype=numpy.float64).reshape( (3,) )
+      deriv = numpy.array([[N0p(q)], [N1p(q)], [N2p(q)]],
+                          dtype=numpy.Float64)      
+      basisDerivE[iQuad] = deriv.reshape((3, 1))
+      iQuad += 1
+
+    quadrature = Quadrature1D()
+    quadrature.cell = cell
+
+    quadrature.initialize()
+
+    from pylith.utils.testarray import test_double
+    import pylith.feassemble.testfeassemble as testmodule
+
+    basis = testmodule.basis(quadrature.cppHandle)
+    test_double(self, basisE, basis)
+
+    basisDeriv = testmodule.basisDeriv(quadrature.cppHandle)
+    test_double(self, basisDerivE, basisDeriv)
+
+    quadWts = testmodule.quadWts(quadrature.cppHandle)
+    test_double(self, quadWtsE, quadWts)
+    
+    quadPts = testmodule.quadPtsRef(quadrature.cppHandle)
+    test_double(self, quadPtsE, quadPts)
+    
+    return
+
+
+  def test_constructors(self):
+    """
+    Test constructors for quadrature objects.
+    """
+    q = Quadrature1D()
+    self.assertEqual(1, q.spaceDim)
+    self.assertEqual(1, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    q = Quadrature1Din2D()
+    self.assertEqual(2, q.spaceDim)
+    self.assertEqual(1, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    q = Quadrature1Din3D()
+    self.assertEqual(3, q.spaceDim)
+    self.assertEqual(1, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    q = Quadrature2D()
+    self.assertEqual(2, q.spaceDim)
+    self.assertEqual(2, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    q = Quadrature2Din3D()
+    self.assertEqual(3, q.spaceDim)
+    self.assertEqual(2, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    q = Quadrature3D()
+    self.assertEqual(3, q.spaceDim)
+    self.assertEqual(3, q.cellDim)
+    self.failIf(None == q.cppHandle)
+    
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/feassemble/testfeassemble.py
+
+## @brief Python application for testing feassemble code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+  """
+  Test application.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="testapp"):
+    """
+    Constructor.
+    """
+    Script.__init__(self, name)
+    return
+
+
+  def main(self):
+    """
+    Run the application.
+    """
+    unittest.TextTestRunner(verbosity=2).run(self._suite())
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _suite(self):
+    """
+    Setup the test suite.
+    """
+
+    suite = unittest.TestSuite()
+
+    from TestFIATSimplex import TestFIATSimplex
+    suite.addTest(unittest.makeSuite(TestFIATSimplex))
+
+    from TestQuadrature import TestQuadrature
+    suite.addTest(unittest.makeSuite(TestQuadrature))
+
+    return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+  app = TestApp()
+  app.run()
+
+
+# End of file 


Property changes on: short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py
___________________________________________________________________
Name: svn:executable
   + *

Added: short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.pyxe
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.pyxe	2006-10-04 22:34:24 UTC (rev 4699)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.pyxe	2006-10-04 22:45:45 UTC (rev 4700)
@@ -0,0 +1,189 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+#header{
+#include "TestQuadrature.hh"
+#}header
+
+import spatialdata.utils.simplearray
+
+# ----------------------------------------------------------------------
+cdef extern from "Python.h":
+  object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
+  void* PyCObject_AsVoidPtr(object)
+
+cdef void* ptrFromHandle(obj):
+  return PyCObject_AsVoidPtr(obj.handle)
+
+cdef extern from "stdlib.h":
+    ctypedef unsigned long size_t
+    void* malloc(size_t size)
+    void free(void* mem)
+
+
+# ----------------------------------------------------------------------
+# create shim for TestQuadrature::cellDim
+#embed{ int TestQuadrature_cellDim(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return pylith::feassemble::TestQuadrature::cellDim(*q);
+#}embed
+
+# create shim for TestQuadrature::numCorners
+#embed{ int TestQuadrature_numCorners(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return pylith::feassemble::TestQuadrature::numCorners(*q);
+#}embed
+
+# create shim for TestQuadrature::numQuadPts
+#embed{ int TestQuadrature_numQuadPts(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return pylith::feassemble::TestQuadrature::numQuadPts(*q);
+#}embed
+
+# create shim for TestQuadrature::spaceDim
+#embed{ int TestQuadrature_spaceDim(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return pylith::feassemble::TestQuadrature::spaceDim(*q);
+#}embed
+
+# create shim for TestQuadrature::basis
+#embed{ double* TestQuadrature_basis(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return (double*) pylith::feassemble::TestQuadrature::basis(*q);
+#}embed
+
+# create shim for TestQuadrature::basisDeriv
+#embed{ double* TestQuadrature_basisDeriv(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return (double*) pylith::feassemble::TestQuadrature::basisDeriv(*q);
+#}embed
+
+# create shim for TestQuadrature::quadPtsRef
+#embed{ double* TestQuadrature_quadPtsRef(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return (double*) pylith::feassemble::TestQuadrature::quadPtsRef(*q);
+#}embed
+
+# create shim for TestQuadrature::quadWts
+#embed{ double* TestQuadrature_quadWts(void* obj)
+const pylith::feassemble::Quadrature* q =
+  (pylith::feassemble::Quadrature*) obj;
+return (double*) pylith::feassemble::TestQuadrature::quadWts(*q);
+#}embed
+
+# ----------------------------------------------------------------------
+def basis(qhandle):
+  """
+  Call TestQuadrature::basis().
+  """
+  if not qhandle.name == "pylith_feassemble_Quadrature":
+    raise TypeError, \
+          "Argument 'quadrature' must be extension type 'Quadrature'."
+
+  cdef void* qptr
+  qptr = ptrFromHandle(qhandle)
+
+  cdef int numQuadPts
+  cdef int numCorners
+  numQuadPts = TestQuadrature_numQuadPts(qptr)
+  numCorners = TestQuadrature_numCorners(qptr)
+
+  cdef double* values
+  values = TestQuadrature_basis(qptr)
+  dims = [numQuadPts, numCorners]
+  valuesObj = PyCObject_FromVoidPtr(values, NULL)
+  return spatialdata.utils.simplearray.SimpleCppArray(valuesObj, dims, "double")
+  
+
+# ----------------------------------------------------------------------
+def basisDeriv(qhandle):
+  """
+  Call TestQuadrature::basisDeriv().
+  """
+  if not qhandle.name == "pylith_feassemble_Quadrature":
+    raise TypeError, \
+          "Argument 'quadrature' must be extension type 'Quadrature'."
+
+  cdef void* qptr
+  qptr = ptrFromHandle(qhandle)
+
+  cdef int numQuadPts
+  cdef int numCorners
+  cdef int cellDim
+  numQuadPts = TestQuadrature_numQuadPts(qptr)
+  numCorners = TestQuadrature_numCorners(qptr)
+  cellDim = TestQuadrature_cellDim(qptr)
+
+  cdef double* values
+  values = TestQuadrature_basisDeriv(qptr)
+  dims = [numQuadPts, numCorners, cellDim]
+  valuesObj = PyCObject_FromVoidPtr(values, NULL)
+  return spatialdata.utils.simplearray.SimpleCppArray(valuesObj, dims,
+                                                      "double")
+  
+
+# ----------------------------------------------------------------------
+def quadPtsRef(qhandle):
+  """
+  Call TestQuadrature::quadPtsRef().
+  """
+  if not qhandle.name == "pylith_feassemble_Quadrature":
+    raise TypeError, \
+          "Argument 'quadrature' must be extension type 'Quadrature'."
+
+  cdef void* qptr
+  qptr = ptrFromHandle(qhandle)
+
+  cdef int numQuadPts
+  cdef int spaceDim
+  numQuadPts = TestQuadrature_numQuadPts(qptr)
+  spaceDim = TestQuadrature_spaceDim(qptr)
+
+  cdef double* values
+  values = TestQuadrature_quadPtsRef(qptr)
+  dims = [numQuadPts, spaceDim]
+  valuesObj = PyCObject_FromVoidPtr(values, NULL)
+  return spatialdata.utils.simplearray.SimpleCppArray(valuesObj, dims,
+                                                      "double")
+  
+
+# ----------------------------------------------------------------------
+def quadWts(qhandle):
+  """
+  Call TestQuadrature::quadWts().
+  """
+  if not qhandle.name == "pylith_feassemble_Quadrature":
+    raise TypeError, \
+          "Argument 'quadrature' must be extension type 'Quadrature'."
+
+  cdef void* qptr
+  qptr = ptrFromHandle(qhandle)
+
+  cdef int numQuadPts
+  numQuadPts = TestQuadrature_numQuadPts(qptr)
+
+  cdef double* values
+  values = TestQuadrature_quadWts(qptr)
+  dims = [numQuadPts]
+  valuesObj = PyCObject_FromVoidPtr(values, NULL)
+  return spatialdata.utils.simplearray.SimpleCppArray(valuesObj, dims,
+                                                      "double")
+
+
+# End of file 



More information about the cig-commits mailing list