[cig-commits] r16507 - in short/3D/PyLith/trunk: playpen/friction/twoquad4 tests/2d/quad4
surendra at geodynamics.org
surendra at geodynamics.org
Thu Apr 8 11:13:57 PDT 2010
Author: surendra
Date: 2010-04-08 11:13:56 -0700 (Thu, 08 Apr 2010)
New Revision: 16507
Added:
short/3D/PyLith/trunk/tests/2d/quad4/TestFrictionCompression.py
short/3D/PyLith/trunk/tests/2d/quad4/friction_compression_soln.py
Modified:
short/3D/PyLith/trunk/playpen/friction/twoquad4/shear-stick.cfg
short/3D/PyLith/trunk/tests/2d/quad4/Makefile.am
short/3D/PyLith/trunk/tests/2d/quad4/testpylith.py
Log:
Added test for .vtk files of friction compression case
Modified: short/3D/PyLith/trunk/playpen/friction/twoquad4/shear-stick.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/friction/twoquad4/shear-stick.cfg 2010-04-08 03:31:22 UTC (rev 16506)
+++ short/3D/PyLith/trunk/playpen/friction/twoquad4/shear-stick.cfg 2010-04-08 18:13:56 UTC (rev 16507)
@@ -69,6 +69,8 @@
# Set interfaces to an array with 1 fault: 'fault'.
interfaces = [fault]
+[pylithapp.timedependent.formulation]
+matrix_type = aij
[pylithapp.timedependent.formulation.time_step]
total_time = 0.0*s
Modified: short/3D/PyLith/trunk/tests/2d/quad4/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/Makefile.am 2010-04-08 03:31:22 UTC (rev 16506)
+++ short/3D/PyLith/trunk/tests/2d/quad4/Makefile.am 2010-04-08 18:13:56 UTC (rev 16507)
@@ -30,6 +30,9 @@
rigidbody_gendb.py \
TestLgDeformTraction.py \
lgdeformtraction_soln.py \
+ TestFrictionQuad4.py \
+ TestFrictionCompression.py \
+ friction_compression_soln.py \
testpylith.py
dist_noinst_DATA = \
@@ -42,7 +45,8 @@
dislocation.cfg \
dislocation2.cfg \
lgdeformrigidbody.cfg \
- lgdeformtraction.cfg
+ lgdeformtraction.cfg \
+ friction_compression.cfg
noinst_TMP = \
axial_disp.spatialdb \
@@ -64,7 +68,10 @@
lgdeformrigidbody-elastic_t0000000.vtk \
lgdeformtraction_t0000000.vtk \
lgdeformtraction-elastic_info.vtk \
- lgdeformtraction-elastic_t0000000.vtk
+ lgdeformtraction-elastic_t0000000.vtk \
+ friction_compression_t0000000.vtk \
+ friction_compression-elastic_info.vtk \
+ friction_compression-elastic_t0000000.vtk
TESTS_ENVIRONMENT = $(PYTHON)
Added: short/3D/PyLith/trunk/tests/2d/quad4/TestFrictionCompression.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/TestFrictionCompression.py (rev 0)
+++ short/3D/PyLith/trunk/tests/2d/quad4/TestFrictionCompression.py 2010-04-08 18:13:56 UTC (rev 16507)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests/2d/quad4/TestFrictionCompression.py
+##
+## @brief Test suite for testing pylith with 2-D axial compression with friction.
+
+import numpy
+from TestFrictionQuad4 import TestFrictionQuad4
+from friction_compression_soln import AnalyticalSoln
+from pylith.utils.VTKDataReader import has_vtk
+from pylith.utils.VTKDataReader import VTKDataReader
+
+# Local version of PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
+class CompressionApp(PyLithApp):
+ def __init__(self):
+ PyLithApp.__init__(self, name="pylithapp")
+ return
+
+
+# Helper function to run PyLith
+def run_pylith():
+ """
+ Run pylith.
+ """
+ if not "done" in dir(run_pylith):
+ # Run PyLith
+ app = CompressionApp()
+ app.run()
+ run_pylith.done = True
+ return
+
+
+class TestFrictionCompression(TestFrictionQuad4):
+ """
+ Test suite for testing pylith with 2-D axial compression with friction.
+ """
+
+ def setUp(self):
+ """
+ Setup for test.
+ """
+ TestFrictionQuad4.setUp(self)
+ run_pylith()
+ self.outputRoot = "friction_compression"
+ if has_vtk():
+ self.reader = VTKDataReader()
+ self.soln = AnalyticalSoln()
+ else:
+ self.reader = None
+ return
+
+
+ def calcDisplacements(self, vertices):
+ """
+ Calculate displacement field given coordinates of vertices.
+ """
+ return self.soln.displacement(vertices)
+
+
+ def calcStateVar(self, name, vertices, cells):
+ """
+ Calculate state variable.
+ """
+ ncells = self.mesh['ncells']
+ pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
+ if name == "total_strain":
+ stateVar = self.soln.strain(pts)
+ elif name == "stress":
+ stateVar = self.soln.stress(pts)
+ else:
+ raise ValueError("Unknown state variable '%s'." % name)
+
+ return stateVar
+
+
+# End of file
Added: short/3D/PyLith/trunk/tests/2d/quad4/friction_compression_soln.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/friction_compression_soln.py (rev 0)
+++ short/3D/PyLith/trunk/tests/2d/quad4/friction_compression_soln.py 2010-04-08 18:13:56 UTC (rev 16507)
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests/2d/quad4/friction_compression_soln.py
+##
+## @brief Analytical solution to compression problem with friction.
+
+import numpy
+
+# Physical properties
+p_density = 2500.0
+p_vs = 3000.0
+p_vp = 5291.502622129181
+
+p_mu = p_density*p_vs**2
+p_lambda = p_density*p_vp**2 - 2*p_mu
+
+# Uniform stress field (plane strain)
+sxx = -1.2e+10
+sxy = 0.0
+syy = 0.0
+szz = p_lambda/(2*p_lambda+2*p_mu)*(sxx+syy)
+
+# Uniform strain field
+exx = 1.0/(2*p_mu) * (sxx - p_lambda/(3*p_lambda+2*p_mu) * (sxx+syy+szz))
+eyy = 1.0/(2*p_mu) * (syy - p_lambda/(3*p_lambda+2*p_mu) * (sxx+syy+szz))
+ezz = 1.0/(2*p_mu) * (szz - p_lambda/(3*p_lambda+2*p_mu) * (sxx+syy+szz))
+
+exy = 1.0/(2*p_mu) * (sxy)
+
+#print exx,eyy,exy,ezz
+#print -exx*p_lambda/(p_lambda+2*p_mu)
+
+# ----------------------------------------------------------------------
+class AnalyticalSoln(object):
+ """
+ Analytical solution to friction_compression problem.
+ """
+
+ def __init__(self):
+ return
+
+
+ def displacement(self, locs):
+ """
+ Compute displacement field at locations.
+ """
+ (nlocs, dim) = locs.shape
+
+ disp = numpy.zeros( (nlocs, 3), dtype=numpy.float64)
+ disp[:,0] = exx*locs[:,0] + exy*locs[:,1]
+ disp[:,1] = eyy*locs[:,1] + exy*locs[:,0]
+ return disp
+
+
+ def strain(self, locs):
+ """
+ Compute strain field at locations.
+ """
+ (npts, dim) = locs.shape
+ strain = numpy.zeros( (npts, 3), dtype=numpy.float64)
+ strain[:,0] = exx
+ strain[:,1] = eyy
+ strain[:,2] = exy
+ return strain
+
+
+ def stress(self, locs):
+ """
+ Compute stress field at locations.
+ """
+ (npts, dim) = locs.shape
+ stress = numpy.zeros( (npts, 3), dtype=numpy.float64)
+ stress[:,0] = sxx
+ stress[:,1] = syy
+ stress[:,2] = sxy
+ return stress
+
+
+# End of file
Modified: short/3D/PyLith/trunk/tests/2d/quad4/testpylith.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/testpylith.py 2010-04-08 03:31:22 UTC (rev 16506)
+++ short/3D/PyLith/trunk/tests/2d/quad4/testpylith.py 2010-04-08 18:13:56 UTC (rev 16507)
@@ -20,24 +20,27 @@
"""
suite = unittest.TestSuite()
- from TestAxialDisp import TestAxialDisp
- suite.addTest(unittest.makeSuite(TestAxialDisp))
+ #from TestAxialDisp import TestAxialDisp
+ #suite.addTest(unittest.makeSuite(TestAxialDisp))
- from TestShearDisp import TestShearDisp
- suite.addTest(unittest.makeSuite(TestShearDisp))
+ #from TestShearDisp import TestShearDisp
+ #suite.addTest(unittest.makeSuite(TestShearDisp))
- from TestDislocation import TestDislocation
- suite.addTest(unittest.makeSuite(TestDislocation))
+ #from TestDislocation import TestDislocation
+ #suite.addTest(unittest.makeSuite(TestDislocation))
#from TestDislocation2 import TestDislocation2
#suite.addTest(unittest.makeSuite(TestDislocation2))
- from TestLgDeformRigidBody import TestRigidBody
- suite.addTest(unittest.makeSuite(TestRigidBody))
+ #from TestLgDeformRigidBody import TestRigidBody
+ #3suite.addTest(unittest.makeSuite(TestRigidBody))
- from TestLgDeformTraction import TestTraction
- suite.addTest(unittest.makeSuite(TestTraction))
+ #from TestLgDeformTraction import TestTraction
+ #suite.addTest(unittest.makeSuite(TestTraction))
+ from TestFrictionCompression import TestFrictionCompression
+ suite.addTest(unittest.makeSuite(TestFrictionCompression))
+
return suite
More information about the CIG-COMMITS
mailing list