[cig-commits] r6557 - in short/3D/PyLith/trunk: .
modulesrc/materials modulesrc/topology pylith/materials
pylith/topology unittests/pytests/materials unittests/pytests/meshio
brad at geodynamics.org
brad at geodynamics.org
Thu Apr 12 12:59:01 PDT 2007
Author: brad
Date: 2007-04-12 12:59:01 -0700 (Thu, 12 Apr 2007)
New Revision: 6557
Modified:
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src
short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py
short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py
short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py
short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py
short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py
short/3D/PyLith/trunk/pylith/materials/Material.py
short/3D/PyLith/trunk/pylith/topology/Mesh.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
Log:
Added ability to check compatibility of Material, Mesh, and Quadrature at Python level. Updated unit tests accordingly.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/TODO 2007-04-12 19:59:01 UTC (rev 6557)
@@ -6,9 +6,6 @@
add isNull() assertions before using ALE::Obj.
- add check to material::initialize: material dimension must match
- cell dimension
-
0. Update unit testing.
b. Update MeshIOAscii tests (groups of vertices and cells)
Modified: short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src 2007-04-12 19:59:01 UTC (rev 6557)
@@ -211,6 +211,29 @@
Material_label_set(self.thisptr, value)
+ property dimension:
+ def __get__(self):
+ """
+ Get dimension associated with material.
+ """
+ # create shim for method 'dimension'
+ #embed{ int Material_dimension_get(void* pObj)
+ int result = 0;
+ try {
+ assert(0 != pObj);
+ result = ((pylith::materials::Material*) pObj)->dimension();
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+ return Material_dimension_get(self.thisptr)
+
+
# ----------------------------------------------------------------------
cdef class ElasticMaterial(Material):
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-04-12 19:59:01 UTC (rev 6557)
@@ -248,6 +248,31 @@
return Mesh_debug_get(self.thisptr)
+ property dimension:
+ def __get__(self):
+ """
+ Get dimension of mesh (dimension of cells).
+ """
+ # create shim for method 'dimension'
+ #embed{ int Mesh_dimension_get(void* objVptr)
+ int result = 0;
+ try {
+ ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) objVptr;
+ assert(0 != mesh);
+ assert(!mesh->isNull());
+ result = (*mesh)->getDimension();
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+ return Mesh_dimension_get(self.thisptr)
+
+
def zeroRealSection(section):
"""
Zero real section.
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -38,6 +38,7 @@
Material.__init__(self, name)
import pylith.materials.materials as bindings
self.cppHandle = bindings.ElasticIsotropic3D()
+ self.dimension = self.cppHandle.dimension
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -39,6 +39,7 @@
"""
Material.__init__(self, name)
self.cppHandle = bindings.ElasticPlaneStrain()
+ self.dimension = self.cppHandle.dimension
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -39,6 +39,7 @@
"""
Material.__init__(self, name)
self.cppHandle = bindings.ElasticPlaneStress()
+ self.dimension = self.cppHandle.dimension
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -38,6 +38,7 @@
"""
Material.__init__(self, name)
self.cppHandle = bindings.ElasticStrain1D()
+ self.dimension = self.cppHandle.dimension
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -38,6 +38,7 @@
"""
Material.__init__(self, name)
self.cppHandle = bindings.ElasticStress1D()
+ self.dimension = self.cppHandle.dimension
return
Modified: short/3D/PyLith/trunk/pylith/materials/Material.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/Material.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/materials/Material.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -82,6 +82,7 @@
"""
Component.__init__(self, name, facility="material")
self.cppHandle = None
+ self.dimension = None
return
@@ -90,6 +91,18 @@
Initialize material property manager.
"""
self._info.log("Initializing material '%s'." % self.label)
+
+ if self.dimension != self.quadrature.cell.cellDim:
+ raise ValueError, \
+ "Quadrature is incompatible with material.\n" \
+ "Dimensions for quadrature: %d, dimensions for material: %d" % \
+ (self.quadrature.cell.cellDim, self.dimension)
+ if self.dimension != mesh.dimension():
+ raise ValueError, \
+ "Material is incompatible with mesh.\n" \
+ "Dimensions for mesh: %d, dimensions for material: %d" % \
+ (mesh.dimension(), self.dimension)
+
self.db.initialize()
self.cppHandle.id = self.id
self.cppHandle.label = self.label
Modified: short/3D/PyLith/trunk/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -55,6 +55,15 @@
return
+ def dimension(self):
+ """
+ Get dimension of mesh.
+ """
+ dim = None
+ if not self.cppHandle is None:
+ dim = self.cppHandle.dimension
+ return dim
+
def distribute(self):
"""
Distribute mesh across processors.
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -16,6 +16,8 @@
import unittest
+from pylith.materials.ElasticIsotropic3D import ElasticIsotropic3D
+
# ----------------------------------------------------------------------
class TestElasticIsotropic3D(unittest.TestCase):
"""
@@ -33,4 +35,13 @@
return
+ def test_dimension(self):
+ """
+ Test dimension().
+ """
+ material = ElasticIsotropic3D()
+ self.assertEqual(3, material.dimension)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -16,6 +16,8 @@
import unittest
+from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
+
# ----------------------------------------------------------------------
class TestElasticPlaneStrain(unittest.TestCase):
"""
@@ -26,11 +28,19 @@
"""
Test constructor.
"""
- from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
material = ElasticPlaneStrain()
self.assertNotEqual(None, material.cppHandle)
return
+ def test_dimension(self):
+ """
+ Test dimension().
+ """
+ material = ElasticPlaneStrain()
+ self.assertEqual(2, material.dimension)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -16,6 +16,8 @@
import unittest
+from pylith.materials.ElasticPlaneStress import ElasticPlaneStress
+
# ----------------------------------------------------------------------
class TestElasticPlaneStress(unittest.TestCase):
"""
@@ -26,11 +28,19 @@
"""
Test constructor.
"""
- from pylith.materials.ElasticPlaneStress import ElasticPlaneStress
material = ElasticPlaneStress()
self.assertNotEqual(None, material.cppHandle)
return
+ def test_dimension(self):
+ """
+ Test dimension().
+ """
+ material = ElasticPlaneStress()
+ self.assertEqual(2, material.dimension)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -16,6 +16,8 @@
import unittest
+from pylith.materials.ElasticStrain1D import ElasticStrain1D
+
# ----------------------------------------------------------------------
class TestElasticStrain1D(unittest.TestCase):
"""
@@ -26,11 +28,19 @@
"""
Test constructor.
"""
- from pylith.materials.ElasticStrain1D import ElasticStrain1D
material = ElasticStrain1D()
self.assertNotEqual(None, material.cppHandle)
return
+ def test_dimension(self):
+ """
+ Test dimension().
+ """
+ material = ElasticStrain1D()
+ self.assertEqual(1, material.dimension)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -16,6 +16,8 @@
import unittest
+from pylith.materials.ElasticStress1D import ElasticStress1D
+
# ----------------------------------------------------------------------
class TestElasticStress1D(unittest.TestCase):
"""
@@ -26,11 +28,19 @@
"""
Test constructor.
"""
- from pylith.materials.ElasticStress1D import ElasticStress1D
material = ElasticStress1D()
self.assertNotEqual(None, material.cppHandle)
return
+ def test_dimension(self):
+ """
+ Test dimension().
+ """
+ material = ElasticStress1D()
+ self.assertEqual(1, material.dimension)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -29,8 +29,8 @@
WARNING: This is not a rigorous test of initialize() because we
don't verify the results.
"""
- from pylith.materials.ElasticIsotropic3D import ElasticIsotropic3D
- material = ElasticIsotropic3D()
+ from pylith.materials.ElasticStrain1D import ElasticStrain1D
+ material = ElasticStrain1D()
from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
quadrature = Quadrature1D()
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2007-04-12 19:13:55 UTC (rev 6556)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2007-04-12 19:59:01 UTC (rev 6557)
@@ -56,9 +56,13 @@
iohandler.filename = filenameIn
iohandler.coordsys = CSCart()
mesh = iohandler.read(debug=False, interpolate=False)
+
+ self.assertEqual(2, mesh.dimension())
+
iohandler.filename = filenameOut
iohandler.write(mesh)
+
fileE = open(filenameIn, "r")
linesE = fileE.readlines()
fileE.close()
More information about the cig-commits
mailing list