[cig-commits] r16076 - short/3D/PyLith/branches/pylith-friction/tests/2d/quad4

brad at geodynamics.org brad at geodynamics.org
Sat Dec 5 16:30:30 PST 2009


Author: brad
Date: 2009-12-05 16:30:29 -0800 (Sat, 05 Dec 2009)
New Revision: 16076

Added:
   short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestLgDeformRigidBody.py
Modified:
   short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/Makefile.am
   short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestDislocation.py
   short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/lgdeformrigidbody.cfg
   short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/testpylith.py
Log:
Added large deformation rigid body motion to automated full-scale tests.

Modified: short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/Makefile.am	2009-12-05 01:19:46 UTC (rev 16075)
+++ short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/Makefile.am	2009-12-06 00:30:29 UTC (rev 16076)
@@ -25,6 +25,9 @@
 	TestDislocation.py \
 	dislocation_soln.py \
 	dislocation2_soln.py \
+	TestLgDeformRigidBody.py \
+	rigidbody_soln.py \
+	rigidbody_gendb.py \
 	testpylith.py
 
 dist_noinst_DATA = \
@@ -35,7 +38,9 @@
 	axialdisp.cfg \
 	sheardisp.cfg \
 	dislocation.cfg \
-	dislocation2.cfg
+	dislocation2.cfg \
+	lgdeformrigidbody.cfg \
+	lgdeformtraction.cfg
 
 noinst_TMP = \
 	axial_disp.spatialdb \
@@ -50,7 +55,11 @@
 	dislocation-elastic_info.vtk \
 	dislocation-elastic_t0000000.vtk \
 	dislocation-fault_info.vtk \
-	dislocation-fault_t0000000.vtk
+	dislocation-fault_t0000000.vtk \
+	rigidbody_disp.spatialdb \
+	lgdeformrigidbody_t0000000.vtk \
+	lgdeformrigidbody-elastic_info.vtk \
+	lgdeformrigidbody-elastic_t0000000.vtk
 
 
 TESTS_ENVIRONMENT = $(PYTHON)

Modified: short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestDislocation.py
===================================================================
--- short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestDislocation.py	2009-12-05 01:19:46 UTC (rev 16075)
+++ short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestDislocation.py	2009-12-06 00:30:29 UTC (rev 16076)
@@ -92,7 +92,7 @@
       return
 
     filename = "%s-fault_t0000000.vtk" % self.outputRoot
-    fields = ["cumulative_slip", "traction_change"]
+    fields = ["slip", "traction_change"]
     check_vertex_fields(self, filename, self.faultMesh, fields)
 
     return
@@ -144,7 +144,7 @@
     elif name == "slip_time":
       field = slipTime*numpy.zeros( (nvertices, 1), dtype=numpy.float64)
       
-    elif name == "cumulative_slip":
+    elif name == "slip":
       field = numpy.zeros( (nvertices, 3), dtype=numpy.float64)
       field[:,0] = finalSlip
 

Added: short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestLgDeformRigidBody.py
===================================================================
--- short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestLgDeformRigidBody.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/TestLgDeformRigidBody.py	2009-12-06 00:30:29 UTC (rev 16076)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests/2d/quad4/TestRigidBody.py
+##
+## @brief Test suite for testing pylith with rigid body motion for
+## large deformations in 2-D.
+
+import numpy
+from TestQuad4 import TestQuad4
+from rigidbody_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 RigidBodyApp(PyLithApp):
+  def __init__(self):
+    PyLithApp.__init__(self, name="lgdeformrigidbody")
+    return
+
+
+# Helper function to run PyLith
+def run_pylith():
+  """
+  Run pylith.
+  """
+  if not "done" in dir(run_pylith):
+    # Generate spatial databases
+    from rigidbody_gendb import GenerateDB
+    db = GenerateDB()
+    db.run()
+
+    # Run PyLith
+    app = RigidBodyApp()
+    app.run()
+    run_pylith.done = True
+  return
+
+
+class TestRigidBody(TestQuad4):
+  """
+  Test suite for testing pylith with 2-D axial extension.
+  """
+
+  def setUp(self):
+    """
+    Setup for test.
+    """
+    TestQuad4.setUp(self)
+    run_pylith()
+    self.outputRoot = "lgdeformrigidbody"
+    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 

Modified: short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/lgdeformrigidbody.cfg
===================================================================
--- short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/lgdeformrigidbody.cfg	2009-12-05 01:19:46 UTC (rev 16075)
+++ short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/lgdeformrigidbody.cfg	2009-12-06 00:30:29 UTC (rev 16076)
@@ -1,13 +1,13 @@
 # -*- Python -*-
-[pylithapp]
+[lgdeformrigidbody]
 
-[pylithapp.launcher] # WARNING: THIS IS NOT PORTABLE
+[lgdeformrigidbody.launcher] # WARNING: THIS IS NOT PORTABLE
 command = mpirun -np ${nodes}
 
 # ----------------------------------------------------------------------
 # journal
 # ----------------------------------------------------------------------
-[pylithapp.journal.info]
+[lgdeformrigidbody.journal.info]
 #timedependent = 1
 #implicit = 1
 #petsc = 1
@@ -20,35 +20,35 @@
 # ----------------------------------------------------------------------
 # mesh_generator
 # ----------------------------------------------------------------------
-[pylithapp.mesh_generator]
+[lgdeformrigidbody.mesh_generator]
 #debug = 1
 reader = pylith.meshio.MeshIOCubit
 
-[pylithapp.mesh_generator.reader]
+[lgdeformrigidbody.mesh_generator.reader]
 filename = mesh.exo
 coordsys.space_dim = 2
 
 # ----------------------------------------------------------------------
 # problem
 # ----------------------------------------------------------------------
-[pylithapp.timedependent]
+[lgdeformrigidbody.timedependent]
 dimension = 2
 bc = [x_neg,x_pos]
 
 formulation = pylith.problems.ImplicitLgDeform
 formulation.solver = pylith.problems.SolverNonlinear
 
-[pylithapp.timedependent.formulation.time_step]
+[lgdeformrigidbody.timedependent.formulation.time_step]
 total_time = 0.0*s
 
 # ----------------------------------------------------------------------
 # materials
 # ----------------------------------------------------------------------
-[pylithapp.timedependent]
+[lgdeformrigidbody.timedependent]
 materials = [elastic]
 materials.elastic = pylith.materials.ElasticPlaneStrain
 
-[pylithapp.timedependent.materials.elastic]
+[lgdeformrigidbody.timedependent.materials.elastic]
 label = Elastic material
 id = 1
 db_properties.iohandler.filename = matprops.spatialdb
@@ -58,14 +58,14 @@
 # ----------------------------------------------------------------------
 # boundary conditions
 # ----------------------------------------------------------------------
-[pylithapp.timedependent.bc.x_neg]
+[lgdeformrigidbody.timedependent.bc.x_neg]
 bc_dof = [0,1]
 label = 21
 db_initial = spatialdata.spatialdb.SimpleDB
 db_initial.label = Dirichlet BC -x edge
 db_initial.iohandler.filename = rigidbody_disp.spatialdb
 
-[pylithapp.timedependent.bc.x_pos]
+[lgdeformrigidbody.timedependent.bc.x_pos]
 bc_dof = [0,1]
 label = 20
 db_initial = spatialdata.spatialdb.SimpleDB
@@ -75,7 +75,7 @@
 # ----------------------------------------------------------------------
 # PETSc
 # ----------------------------------------------------------------------
-[pylithapp.petsc]
+[lgdeformrigidbody.petsc]
 ksp_rtol = 1.0e-8
 pc_type = asm
 # Change the preconditioner settings (must turn off
@@ -83,8 +83,8 @@
 sub_pc_factor_shift_positive_definite = 0
 sub_pc_factor_shift_nonzero = 
 
-ksp_max_it = 100
-ksp_gmres_restart = 50
+ksp_max_it = 200
+ksp_gmres_restart = 100
 #ksp_monitor = true
 #ksp_view = true
 #snes_monitor = true
@@ -98,9 +98,9 @@
 # ----------------------------------------------------------------------
 # output
 # ----------------------------------------------------------------------
-[pylithapp.problem.formulation.output.output.writer]
+[lgdeformrigidbody.problem.formulation.output.output.writer]
 filename = lgdeformrigidbody.vtk
 
-[pylithapp.timedependent.materials.elastic.output]
+[lgdeformrigidbody.timedependent.materials.elastic.output]
 cell_filter = pylith.meshio.CellFilterAvgMesh
 writer.filename = lgdeformrigidbody-elastic.vtk

Modified: short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/testpylith.py
===================================================================
--- short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/testpylith.py	2009-12-05 01:19:46 UTC (rev 16075)
+++ short/3D/PyLith/branches/pylith-friction/tests/2d/quad4/testpylith.py	2009-12-06 00:30:29 UTC (rev 16076)
@@ -32,6 +32,9 @@
   #from TestDislocation2 import TestDislocation2
   #suite.addTest(unittest.makeSuite(TestDislocation2))
 
+  from TestLgDeformRigidBody import TestRigidBody
+  suite.addTest(unittest.makeSuite(TestRigidBody))
+
   return suite
 
 



More information about the CIG-COMMITS mailing list