[cig-commits] r14883 - short/3D/PyLith/trunk/tests/1d/line2
brad at geodynamics.org
brad at geodynamics.org
Tue May 5 23:10:57 PDT 2009
Author: brad
Date: 2009-05-05 23:10:56 -0700 (Tue, 05 May 2009)
New Revision: 14883
Added:
short/3D/PyLith/trunk/tests/1d/line2/TestDislocation.py
short/3D/PyLith/trunk/tests/1d/line2/dislocation.cfg
short/3D/PyLith/trunk/tests/1d/line2/finalslip.spatialdb
short/3D/PyLith/trunk/tests/1d/line2/sliptime.spatialdb
Modified:
short/3D/PyLith/trunk/tests/1d/line2/README
short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py
Log:
Started working on more full-scale tests.
Modified: short/3D/PyLith/trunk/tests/1d/line2/README
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/README 2009-05-06 03:39:40 UTC (rev 14882)
+++ short/3D/PyLith/trunk/tests/1d/line2/README 2009-05-06 06:10:56 UTC (rev 14883)
@@ -1,6 +1,5 @@
-1-D axial extension test with linear cells.
+Full-scale tests for 1-D bar.
-
0 1 2 3 4
* ---- * ---- * ---- * ---- *
@@ -11,9 +10,31 @@
3 3.0
4 4.0
+
+AXIAL EXTENSION
+
+1-D axial extension test with linear cells.
+
Dirichlet boundary conditions
u(0) = -0.2
u(4) = +0.2
Analytical solution
u(x) = -0.2 + 0.1 * x
+
+
+DISLOCATION
+
+1-D axial extension with dislocation test with linear cells.
+
+Dirichlet boundary conditions (same as extension)
+ u(0) = -0.2
+ u(4) = +0.2
+
+Dislocation (1-D fault).
+ u(2+)-u(2-) = D(2) = 0.5
+
+Analytical solution
+ u(x<2) = -0.20 - 0.025 * x
+ u(x>2) = +0.30 - 0.025 * x
+
Modified: short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py 2009-05-06 03:39:40 UTC (rev 14882)
+++ short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py 2009-05-06 06:10:56 UTC (rev 14883)
@@ -22,7 +22,7 @@
# Local version of PyLithApp
from pylith.apps.PyLithApp import PyLithApp
-class AxialPlaneStrainApp(PyLithApp):
+class AxialApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="axialextension")
return
@@ -34,7 +34,7 @@
Run pylith.
"""
if not "done" in dir(run_pylith):
- app = AxialPlaneStrainApp()
+ app = AxialApp()
app.run()
run_pylith.done = True
return
Added: short/3D/PyLith/trunk/tests/1d/line2/TestDislocation.py
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/TestDislocation.py (rev 0)
+++ short/3D/PyLith/trunk/tests/1d/line2/TestDislocation.py 2009-05-06 06:10:56 UTC (rev 14883)
@@ -0,0 +1,182 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests/1d/line2/TestDislocation.py
+##
+## @brief Test suite for testing pylith with 1-D axial extension.
+
+import unittest
+import numpy
+from pylith.utils.VTKDataReader import has_vtk
+from pylith.utils.VTKDataReader import VTKDataReader
+
+
+# Local version of PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
+class DislocationApp(PyLithApp):
+ def __init__(self):
+ PyLithApp.__init__(self, name="dislocation")
+ return
+
+
+# Helper function to run PyLith
+def run_pylith():
+ """
+ Run pylith.
+ """
+ if not "done" in dir(run_pylith):
+ app = DislocationApp()
+ app.run()
+ run_pylith.done = True
+ return
+
+
+class TestDislocation(unittest.TestCase):
+ """
+ Test suite for testing pylith with 1-D axial extension.
+ """
+
+ def setUp(self):
+ """
+ Setup for test.
+ """
+ run_pylith()
+ if has_vtk():
+ self.reader = VTKDataReader()
+ else:
+ self.reader = None
+ return
+
+
+ def test_elastic_info(self):
+ """
+ Check elastic info.
+ """
+ if self.reader is None:
+ return
+
+ data = self.reader.read("dislocation-statevars-elastic_info.vtk")
+
+ # Check cells
+ ncellsE = 4
+ ncornersE = 2
+ (ncells, ncorners) = data['cells'].shape
+ self.assertEqual(ncellsE, ncells)
+ self.assertEqual(ncornersE, ncorners)
+
+ # Check vertices
+ nverticesE = 5
+ spaceDimE = 3
+ (nvertices, spaceDim) = data['vertices'].shape
+ self.assertEqual(nverticesE, nvertices)
+ self.assertEqual(spaceDimE, spaceDim)
+
+ # Check physical properties
+ tolerance = 1.0e-5
+ vsE = 3000.0
+ vpE = 5291.502622129181
+ densityE = 2500.0
+
+ # Lame's constant mu (shear modulus)
+ muE = densityE*vsE**2
+ diff = numpy.abs(1.0 - data['cell_fields']['mu']/muE)
+ okay = diff < tolerance
+ if numpy.sum(okay) != ncells:
+ print "Expected Lame's constant mu: ",muE
+ print "Lame's constant mu: ",data['cell_fields']['mu']
+ self.assertEqual(ncells, numpy.sum(okay))
+
+ # Lame's constant lambda
+ lambdaE = densityE*vpE**2 - 2*muE
+ diff = numpy.abs(1.0 - data['cell_fields']['lambda']/lambdaE)
+ okay = diff < tolerance
+ if numpy.sum(okay) != ncells:
+ print "Expected Lame's constant lambda: ",lambdaE
+ print "Lame's constant lambda: ",data['cell_fields']['lambda']
+ self.assertEqual(ncells, numpy.sum(okay))
+
+ # Density
+ diff = numpy.abs(1.0 - data['cell_fields']['density']/densityE)
+ okay = diff < tolerance
+ if numpy.sum(okay) != ncells:
+ print "Expected density: ",densityE
+ print "Density: ",data['cell_fields']['density']
+ self.assertEqual(ncells, numpy.sum(okay))
+ return
+
+
+ def test_soln(self):
+ """
+ Check solution (displacement) field.
+ """
+ if self.reader is None:
+ return
+
+ data = self.reader.read("dislocation_t0000000.vtk")
+
+ # Check cells
+ ncellsE = 4
+ ncornersE = 2
+ (ncells, ncorners) = data['cells'].shape
+ self.assertEqual(ncellsE, ncells)
+ self.assertEqual(ncornersE, ncorners)
+
+ # Check vertices
+ nverticesE = 5
+ spaceDimE = 3
+ vertices = data['vertices']
+ (nvertices, spaceDim) = vertices.shape
+ self.assertEqual(nverticesE, nvertices)
+ self.assertEqual(spaceDimE, spaceDim)
+
+ # Check displacement solution
+ tolerance = 1.0e-5
+ dispE = numpy.zeros( (nvertices, spaceDim), dtype=numpy.float64)
+ dispE[:,0] = -0.2 + 0.1 * vertices[:,0]
+
+ disp = data['vertex_fields']['displacement']
+
+ # Check x displacements
+ diff = numpy.abs(disp[:,0] - dispE[:,0])
+ okay = diff < tolerance
+ if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
+ print "Displacement field: ",disp
+ self.assertEqual(nvertices, numpy.sum(okay))
+
+ # Check y displacements
+ diff = numpy.abs(disp[:,1] - dispE[:,1])
+ okay = diff < tolerance
+ if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
+ print "Displacement field: ",disp
+ self.assertEqual(nvertices, numpy.sum(okay))
+
+ # Check z displacements
+ diff = numpy.abs(disp[:,2] - dispE[:,2])
+ okay = diff < tolerance
+ if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
+ print "Displacement field: ",disp
+ self.assertEqual(nvertices, numpy.sum(okay))
+
+ return
+
+
+ #def test_elastic_statevars(self):
+ # """
+ # Check elastic state variables.
+ # """
+ # return
+
+
+# End of file
Added: short/3D/PyLith/trunk/tests/1d/line2/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/dislocation.cfg (rev 0)
+++ short/3D/PyLith/trunk/tests/1d/line2/dislocation.cfg 2009-05-06 06:10:56 UTC (rev 14883)
@@ -0,0 +1,108 @@
+# -*- Python -*-
+[pylithapp]
+
+[pylithapp.launcher]
+command = mpiexec -n ${nodes}
+
+# ----------------------------------------------------------------------
+# journal
+# ----------------------------------------------------------------------
+[pylithapp.journal.info]
+timedependent = 1
+implicit = 1
+petsc = 1
+solverlinear = 1
+meshiocubit = 1
+implicitelasticity = 1
+quadrature = 1
+fiatsimplex = 1
+
+# ----------------------------------------------------------------------
+# mesh_generator
+# ----------------------------------------------------------------------
+[pylithapp.mesh_generator]
+#debug = 1
+
+[pylithapp.mesh_generator.reader]
+filename = bar.mesh
+coordsys.space_dim = 1
+
+# ----------------------------------------------------------------------
+# problem
+# ----------------------------------------------------------------------
+[pylithapp.timedependent]
+dimension = 1
+bc = [bc]
+interfaces = [fault]
+
+#formulation.solver = pylith.problems.SolverNonlinear
+
+[pylithapp.timedependent.formulation.time_step]
+total_time = 0.0*s
+
+# ----------------------------------------------------------------------
+# materials
+# ----------------------------------------------------------------------
+[pylithapp.timedependent]
+materials = [elastic]
+materials.elastic = pylith.materials.ElasticStrain1D
+
+[pylithapp.timedependent.materials.elastic]
+label = Elastic material
+id = 1
+properties_db.iohandler.filename = matprops.spatialdb
+quadrature.cell.shape = line
+
+# ----------------------------------------------------------------------
+# boundary conditions
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.bc.bc]
+fixed_dof = [0]
+label = end points
+db = spatialdata.spatialdb.SimpleDB
+db.label = Dirichlet BC
+db.iohandler.filename = axialextension_disp.spatialdb
+
+# ----------------------------------------------------------------------
+# faults
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.interfaces]
+# Set the type of fault interface condition.
+fault = pylith.faults.FaultCohesiveKin
+
+# Set the parameters for the fault interface condition.
+
+[pylithapp.timedependent.interfaces.fault]
+label = fault
+quadrature.cell.shape = point
+mat_db.iohandler.filename = matprops.spatialdb
+
+[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
+slip.iohandler.filename = finalslip.spatialdb
+slip_time.iohandler.filename = sliptime.spatialdb
+
+
+# ----------------------------------------------------------------------
+# PETSc
+# ----------------------------------------------------------------------
+[pylithapp.petsc]
+ksp_rtol = 1.0e-8
+pc_type = asm
+ksp_max_it = 100
+ksp_gmres_restart = 50
+#ksp_monitor = true
+#ksp_view = true
+#log_summary = true
+#start_in_debugger = true
+snes_monitor = true
+snes_view = true
+
+# ----------------------------------------------------------------------
+# output
+# ----------------------------------------------------------------------
+[pylithapp.problem.formulation.output.output.writer]
+filename = dislocation.vtk
+
+[pylithapp.timedependent.materials.elastic.output]
+cell_filter = pylith.meshio.CellFilterAvgMesh
+writer.filename = dislocation-statevars-elastic.vtk
Added: short/3D/PyLith/trunk/tests/1d/line2/finalslip.spatialdb
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/finalslip.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/tests/1d/line2/finalslip.spatialdb 2009-05-06 06:10:56 UTC (rev 14883)
@@ -0,0 +1,15 @@
+// -*- C++ -*-
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = fault-opening
+ value-units = m
+ num-locs = 1
+ data-dim = 0
+ space-dim = 1
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 1
+ }
+}
+0.0 +0.50
Added: short/3D/PyLith/trunk/tests/1d/line2/sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/sliptime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/tests/1d/line2/sliptime.spatialdb 2009-05-06 06:10:56 UTC (rev 14883)
@@ -0,0 +1,15 @@
+// -*- C++ -*-
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = slip-time
+ value-units = s
+ num-locs = 1
+ data-dim = 0
+ space-dim = 1
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 1
+ }
+}
+0.0 0.0
More information about the CIG-COMMITS
mailing list