[cig-commits] r19031 - in short/3D/PyLith/branches/v1.6-stable: pylith unittests/pytests/feassemble
brad at geodynamics.org
brad at geodynamics.org
Thu Oct 6 09:40:57 PDT 2011
Author: brad
Date: 2011-10-06 09:40:56 -0700 (Thu, 06 Oct 2011)
New Revision: 19031
Modified:
short/3D/PyLith/branches/v1.6-stable/pylith/Makefile.am
short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATLagrange.py
short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATSimplex.py
Log:
Cleanup of collocated quadrature rule.
Modified: short/3D/PyLith/branches/v1.6-stable/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/Makefile.am 2011-10-06 14:49:10 UTC (rev 19030)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/Makefile.am 2011-10-06 16:40:56 UTC (rev 19031)
@@ -54,6 +54,7 @@
feassemble/ElasticityExplicitLgDeform.py \
feassemble/ElasticityImplicit.py \
feassemble/ElasticityImplicitLgDeform.py \
+ feassemble/FIATQuadrature.py \
feassemble/FIATLagrange.py \
feassemble/FIATSimplex.py \
feassemble/Integrator.py \
Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATLagrange.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATLagrange.py 2011-10-06 14:49:10 UTC (rev 19030)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATLagrange.py 2011-10-06 16:40:56 UTC (rev 19031)
@@ -582,6 +582,63 @@
# ----------------------------------------------------------------------
+class Hex8Collocated(Hex8):
+
+ def __init__(self):
+ """
+ Setup hex8 cell.
+ """
+ vertices = numpy.array([[-1.0, -1.0, -1.0],
+ [+1.0, -1.0, -1.0],
+ [+1.0, +1.0, -1.0],
+ [-1.0, +1.0, -1.0],
+ [-1.0, -1.0, +1.0],
+ [+1.0, -1.0, +1.0],
+ [+1.0, +1.0, +1.0],
+ [-1.0, +1.0, +1.0]])
+ quadPts = numpy.array([[-1.0, -1.0, -1.0],
+ [+1.0, -1.0, -1.0],
+ [-1.0, +1.0, -1.0],
+ [+1.0, +1.0, -1.0],
+ [-1.0, -1.0, +1.0],
+ [+1.0, -1.0, +1.0],
+ [-1.0, +1.0, +1.0],
+ [+1.0, +1.0, +1.0]])
+ quadWts = numpy.array( [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
+
+ # Compute basis fns and derivatives at quadrature points
+ basis = numpy.zeros( (8, 8), dtype=numpy.float64)
+ basisDeriv = numpy.zeros( (8, 8, 3), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPts:
+ basis[iQuad] = numpy.array([self.N0(q), self.N1(q),
+ self.N2(q), self.N3(q),
+ self.N4(q), self.N5(q),
+ self.N6(q), self.N7(q)],
+ dtype=numpy.float64).reshape( (8,) )
+ deriv = numpy.array([[self.N0p(q), self.N0q(q), self.N0r(q)],
+ [self.N1p(q), self.N1q(q), self.N1r(q)],
+ [self.N2p(q), self.N2q(q), self.N2r(q)],
+ [self.N3p(q), self.N3q(q), self.N3r(q)],
+ [self.N4p(q), self.N4q(q), self.N4r(q)],
+ [self.N5p(q), self.N5q(q), self.N5r(q)],
+ [self.N6p(q), self.N6q(q), self.N6r(q)],
+ [self.N7p(q), self.N7q(q), self.N7r(q)]])
+ basisDeriv[iQuad] = deriv.reshape((8, 3))
+ iQuad += 1
+
+ self.cellDim = 3
+ self.numCorners = len(vertices)
+ self.numQuadPts = len(quadPts)
+ self.vertices = vertices
+ self.quadPts = quadPts
+ self.quadWts = quadWts
+ self.basis = basis
+ self.basisDeriv = basisDeriv
+ return
+
+
+# ----------------------------------------------------------------------
class Hex27(object):
def __init__(self):
@@ -1101,7 +1158,6 @@
cell.inventory.order = 1
cell.inventory.collocateQuad = True
cell._configure()
- cell._info.activate()
cell.initialize(spaceDim=1)
@@ -1203,6 +1259,25 @@
return
+ def test_initialize_hex8_collocated(self):
+ """
+ Test initialize() with hex8 cell.
+ """
+ cell = FIATLagrange()
+ cell.inventory.dimension = 3
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell.inventory.collocateQuad = True
+ cell._configure()
+ cell.initialize(spaceDim=3)
+
+ cellE = Hex8Collocated()
+ self._checkVals(cellE, cell)
+ from pylith.feassemble.CellGeometry import GeometryHex3D
+ self.failUnless(isinstance(cell.geometry, GeometryHex3D))
+ return
+
+
def test_initialize_hex27(self):
"""
Test initialize() with hex27 cell.
Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATSimplex.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATSimplex.py 2011-10-06 14:49:10 UTC (rev 19030)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestFIATSimplex.py 2011-10-06 16:40:56 UTC (rev 19031)
@@ -73,6 +73,40 @@
return 0.5
# ----------------------------------------------------------------------
+class Line2Collocated(Line2):
+
+ def __init__(self):
+ """
+ Setup line2 cell.
+ """
+ vertices = numpy.array([[-1.0], [1.0]])
+ quadPts = vertices[:]
+ quadWts = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
+
+ # Compute basis fns and derivatives at quadrature points
+ basis = numpy.zeros( (2, 2), dtype=numpy.float64)
+ basisDeriv = numpy.zeros( (2, 2, 1), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPts:
+ basis[iQuad] = numpy.array([self.N0(q), self.N1(q)],
+ dtype=numpy.float64).reshape( (2,) )
+ deriv = numpy.array([[self.N0p(q)], [self.N1p(q)]],
+ dtype=numpy.float64)
+ basisDeriv[iQuad] = deriv.reshape((2, 1))
+ iQuad += 1
+
+ self.cellDim = 1
+ self.numCorners = len(vertices)
+ self.numQuadPts = len(quadPts)
+ self.vertices = vertices
+ self.quadPts = quadPts
+ self.quadWts = quadWts
+ self.basis = basis
+ self.basisDeriv = basisDeriv
+ return
+
+
+# ----------------------------------------------------------------------
class Line3(object):
def __init__(self):
@@ -197,6 +231,43 @@
# ----------------------------------------------------------------------
+class Tri3Collocated(Tri3):
+
+ def __init__(self):
+ """
+ Setup tri33 cell.
+ """
+ vertices = numpy.array([[-1.0, -1.0],
+ [+1.0, -1.0],
+ [-1.0, +1.0]])
+ quadPts = vertices[:]
+ quadWts = numpy.array( [2.0/3.0, 2.0/3.0, 2.0/3.0])
+
+ # Compute basis fns and derivatives at quadrature points
+ basis = numpy.zeros( (3, 3), dtype=numpy.float64)
+ basisDeriv = numpy.zeros( (3, 3, 2), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPts:
+ basis[iQuad] = numpy.array([self.N0(q), self.N1(q), self.N2(q)],
+ dtype=numpy.float64).reshape( (3,) )
+ deriv = numpy.array([[self.N0p(q), self.N0q(q)],
+ [self.N1p(q), self.N1q(q)],
+ [self.N2p(q), self.N2q(q)]])
+ basisDeriv[iQuad] = deriv.reshape((3, 2))
+ iQuad += 1
+
+ self.cellDim = 2
+ self.numCorners = len(vertices)
+ self.numQuadPts = len(quadPts)
+ self.vertices = vertices
+ self.quadPts = quadPts
+ self.quadWts = quadWts
+ self.basis = basis
+ self.basisDeriv = basisDeriv
+ return
+
+
+# ----------------------------------------------------------------------
class Tri6(object):
def __init__(self):
@@ -393,6 +464,46 @@
# ----------------------------------------------------------------------
+class Tet4Collocated(Tet4):
+
+ def __init__(self):
+ """
+ Setup tri33 cell.
+ """
+ vertices = numpy.array([[-1.0, -1.0, -1.0],
+ [+1.0, -1.0, -1.0],
+ [-1.0, +1.0, -1.0],
+ [-1.0, -1.0, +1.0]])
+ quadPts = vertices[:]
+ quadWts = numpy.array( [1.0/3.0, 1.0/3.0, 1.0/3.0, 1.0/3.0])
+
+ # Compute basis fns and derivatives at quadrature points
+ basis = numpy.zeros( (4, 4), dtype=numpy.float64)
+ basisDeriv = numpy.zeros( (4, 4, 3), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPts:
+ basis[iQuad] = numpy.array([self.N0(q), self.N1(q),
+ self.N2(q), self.N3(q)],
+ dtype=numpy.float64).reshape( (4,) )
+ deriv = numpy.array([[self.N0p(q), self.N0q(q), self.N0r(q)],
+ [self.N1p(q), self.N1q(q), self.N1r(q)],
+ [self.N2p(q), self.N2q(q), self.N2r(q)],
+ [self.N3p(q), self.N3q(q), self.N3r(q)]])
+ basisDeriv[iQuad] = deriv.reshape((4, 3))
+ iQuad += 1
+
+ self.cellDim = 3
+ self.numCorners = len(vertices)
+ self.numQuadPts = len(quadPts)
+ self.vertices = vertices
+ self.quadPts = quadPts
+ self.quadWts = quadWts
+ self.basis = basis
+ self.basisDeriv = basisDeriv
+ return
+
+
+# ----------------------------------------------------------------------
class TestFIATSimplex(unittest.TestCase):
"""
Unit testing of FIATSimplex object.
@@ -426,9 +537,10 @@
Test initialize() with line2 cell.
"""
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 1
- cell.order = 1
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
cell.initialize(spaceDim=1)
cellE = Line2()
@@ -438,14 +550,34 @@
return
+ def test_initialize_line2_collodated(self):
+ """
+ Test initialize() with line2 cell.
+ """
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell.inventory.collocateQuad = True
+ cell._configure()
+ cell.initialize(spaceDim=1)
+
+ cellE = Line2Collocated()
+ self._checkVals(cellE, cell)
+ from pylith.feassemble.CellGeometry import GeometryLine1D
+ self.failUnless(isinstance(cell.geometry, GeometryLine1D))
+ return
+
+
def test_initialize_line3(self):
"""
Test initialize() with line3 cell.
"""
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 2
- cell.order = 2
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
cell.initialize(spaceDim=2)
cellE = Line3()
@@ -472,6 +604,24 @@
return
+ def test_initialize_tri3_collocated(self):
+ """
+ Test initialize() with tri3 cell.
+ """
+ cell = FIATSimplex()
+ cell.inventory.shape = "triangle"
+ cell.inventory.degree = 1
+ cell.inventory.collocateQuad = True
+ cell._configure()
+ cell.initialize(spaceDim=2)
+
+ cellE = Tri3Collocated()
+ self._checkVals(cellE, cell)
+ from pylith.feassemble.CellGeometry import GeometryTri2D
+ self.failUnless(isinstance(cell.geometry, GeometryTri2D))
+ return
+
+
def test_initialize_tri6(self):
"""
Test initialize() with tri6 cell.
@@ -506,6 +656,24 @@
return
+ def test_initialize_tet4_collocated(self):
+ """
+ Test initialize() with tet4 cell.
+ """
+ cell = FIATSimplex()
+ cell.inventory.shape = "tetrahedron"
+ cell.inventory.degree = 1
+ cell.inventory.collocateQuad = True
+ cell._configure()
+ cell.initialize(spaceDim=3)
+
+ cellE = Tet4Collocated()
+ self._checkVals(cellE, cell)
+ from pylith.feassemble.CellGeometry import GeometryTet3D
+ self.failUnless(isinstance(cell.geometry, GeometryTet3D))
+ return
+
+
def test_factory(self):
"""
Test factory method.
More information about the CIG-COMMITS
mailing list