[cig-commits] r7152 - in short/3D/PyLith/trunk: modulesrc/solver
modulesrc/topology pylith/problems tests/2d/quad4
brad at geodynamics.org
brad at geodynamics.org
Mon Jun 11 23:14:25 PDT 2007
Author: brad
Date: 2007-06-11 23:14:25 -0700 (Mon, 11 Jun 2007)
New Revision: 7152
Added:
short/3D/PyLith/trunk/tests/2d/quad4/test.py
short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh
short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh~
short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg
short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg~
short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb
short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb~
short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.vtk
Modified:
short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src
short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
short/3D/PyLith/trunk/pylith/problems/Implicit.py
Log:
Added binding to sectionView. Moved some debugging stuff from solver module to Implicit.py. Added some temporary test problem stuff to tests/2d/quad4.
Modified: short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src 2007-06-12 06:14:25 UTC (rev 7152)
@@ -241,8 +241,6 @@
PetscErrorCode err = 0;
Vec localVec;
- (*fieldIn)->view("Rhs");
- (*fieldOut)->view("Solution Before");
err = VecCreateSeqWithArray(PETSC_COMM_SELF, (*fieldIn)->sizeWithBC(),
(*fieldIn)->restrict(), &localVec);CHKERRQ(err);
err = VecScatterBegin(scatter, localVec, vecIn, INSERT_VALUES, SCATTER_FORWARD
@@ -260,7 +258,6 @@
err = VecScatterEnd(scatter, vecOut, localVec, INSERT_VALUES, SCATTER_REVERSE
); CHKERRQ(err);
err = VecDestroy(localVec); CHKERRQ(err);
- (*fieldOut)->view("Solution After");
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-06-12 06:14:25 UTC (rev 7152)
@@ -827,7 +827,7 @@
Add two sections, storing result in third section.
"""
# create shim for Field::add()
- #embed{ void* Section_addRealSections(void* objVptr, void* aVptr, void* bVptr)
+ #embed{ void Section_addRealSections(void* objVptr, void* aVptr, void* bVptr)
try {
ALE::Obj<pylith::real_section_type>* dst =
(ALE::Obj<pylith::real_section_type>*) objVptr;
@@ -856,4 +856,32 @@
return
+# ----------------------------------------------------------------------
+def sectionView(field, label):
+ """
+ View section.
+ """
+ # create shim for section::view()
+ #embed{ void Section_view(void* objVptr, char* label)
+ try {
+ ALE::Obj<pylith::real_section_type>* field =
+ (ALE::Obj<pylith::real_section_type>*) objVptr;
+ assert(0 != field);
+ assert(!field->isNull());
+ (*field)->view(label);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ Section_view(PyCObject_AsVoidPtr(field), label)
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py 2007-06-12 06:14:25 UTC (rev 7152)
@@ -100,6 +100,11 @@
self.fields.addReal("dispIncr")
self.fields.addReal("residual")
self.fields.copyLayout("dispTBctpdt")
+
+ dispTBctpdt = self.fields.getReal("dispTBctpdt")
+ import pylith.topology.topology as bindings
+ bindings.sectionView(dispTBctpdt, "dispTBctpdt")
+
self.jacobian = mesh.createMatrix(self.fields.getReal("dispTBctpdt"))
self.solver.initialize(mesh, self.fields.getReal("dispIncr"))
@@ -222,10 +227,16 @@
petsc.mat_assemble(self.jacobian)
self._info.log("Solving equations.")
+ print "BEFORE SOLVE"
+ bindings.sectionView(residual, "residual")
+ bindings.sectionView(dispIncr, "dispIncr")
self.solver.solve(dispIncr, self.jacobian, residual)
+ print "AFTER SOLVE"
+ bindings.sectionView(dispIncr, "dispIncr")
import pylith.topology.topology as bindings
bindings.addRealSections(solnField, solnField, dispIncr)
+ bindings.sectionView(solnField, "solution")
self._info.log("Updating integrators states.")
for integrator in self.integrators:
Added: short/3D/PyLith/trunk/tests/2d/quad4/test.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/test.py 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/test.py 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,42 @@
+import numpy
+j = numpy.zeros( (4,4), dtype=numpy.float64)
+
+j[0,0] = +2.41071e+10 +2.41071e+10
+j[0,1] = +6.42857e+09
+j[0,2] = -1.84821e+10 -1.84821e+10
+j[0,3] = -1.20536e+10
+
+j[1,0] = +6.42857e+09
+j[1,1] = +2.41071e+10 +2.41071e+10
+j[1,2] = -1.20536e+10
+j[1,3] = -1.84821e+10 -1.84821e+10
+
+j[2,0] = -1.84821e+10 -1.84821e+10
+j[2,1] = -1.20536e+10
+j[2,2] = +2.41071e+10 +2.41071e+10
+j[2,3] = +6.42857e+09
+
+j[3,0] = -1.20536e+10
+j[3,1] = -1.84821e+10 -1.84821e+10
+j[3,2] = +6.42857e+09
+j[3,3] = +2.41071e+10 +2.41071e+10
+
+print "jacobian:\n",j
+
+
+r = numpy.zeros( (4,1), dtype=numpy.float64)
+
+r[0,0] = -3*6.42857e+9 - 3*-1.20536e+10
+r[1,0] = +3*6.42857e+9 + 3*-1.20536e+10
+r[2,0] = -3*6.42857e+9 - 3*-1.20536e+10
+r[3,0] = +3*6.42857e+9 + 3*-1.20536e+10
+print "residual:\n",r
+
+#r[0,0] = 1.6875e+10
+#r[1,0] = 1.6875e+10
+#r[2,0] = -1.6875e+10
+#r[3,0] = -1.6875e+10
+
+
+u = numpy.dot(numpy.linalg.inv(j), r)
+print "dispIncr:\n",u
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,68 @@
+mesh = {
+ dimension = 2
+ use-index-zero = true
+ vertices = {
+ dimension = 2
+ count = 8
+ coordinates = {
+ 0 -3.0 -1.0
+ 1 -1.0 -1.0
+ 2 1.0 -1.0
+ 3 3.0 -1.0
+ 4 -3.0 1.0
+ 5 -1.0 1.0
+ 6 1.0 1.0
+ 7 3.0 1.0
+ }
+ }
+ cells = {
+ count = 3
+ num-corners = 4
+ simplices = {
+ 0 0 1 5 4
+ 1 1 2 6 5
+ 2 2 3 7 6
+ }
+ material-ids = {
+ 0 0
+ 1 0
+ 2 0
+ }
+ }
+ group = {
+ name = x_neg
+ type = vertices
+ count = 2
+ indices = {
+ 0
+ 4
+ }
+ }
+ group = {
+ name = x_pos
+ type = vertices
+ count = 2
+ indices = {
+ 3
+ 7
+ }
+ }
+ group = {
+ name = y_neg
+ type = vertices
+ count = 2
+ indices = {
+ 1
+ 2
+ }
+ }
+ group = {
+ name = y_pos
+ type = vertices
+ count = 2
+ indices = {
+ 5
+ 6
+ }
+ }
+}
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh~
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh~ 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4.mesh~ 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,72 @@
+mesh = {
+ dimension = 2
+ use-index-zero = true
+ vertices = {
+ dimension = 2
+ count = 8
+ coordinates = {
+ 0 -3.0 -1.0
+ 1 -1.0 -1.0
+ 2 1.0 -1.0
+ 3 3.0 -1.0
+ 4 -3.0 1.0
+ 5 -1.0 1.0
+ 6 1.0 1.0
+ 7 3.0 1.0
+ }
+ }
+ cells = {
+ count = 3
+ num-corners = 4
+ simplices = {
+ 0 0 1 5 4
+ 1 1 2 6 5
+ 2 2 3 7 6
+ }
+ material-ids = {
+ 0 0
+ 1 0
+ 2 0
+ }
+ }
+ group = {
+ name = x_neg
+ type = vertices
+ count = 2
+ indices = {
+ 0
+ 4
+ }
+ }
+ group = {
+ name = x_pos
+ type = vertices
+ count = 2
+ indices = {
+ 3
+ 7
+ }
+ }
+ group = {
+ name = y_neg
+ type = vertices
+ count = 4
+ indices = {
+ 0
+ 1
+ 2
+ 3
+ }
+ }
+ group = {
+ name = y_pos
+ type = vertices
+ count = 4
+ indices = {
+ 4
+ 5
+ 6
+ 7
+ }
+ }
+}
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,98 @@
+# -*- Python -*-
+[pylithapp]
+
+# ----------------------------------------------------------------------
+# journal
+# ----------------------------------------------------------------------
+[pylithapp.journal.info]
+timedependent = 1
+explicit = 1
+implicit = 1
+petsc = 1
+solverlinear = 1
+meshioascii = 1
+homogeneous = 1
+explicitelasticity = 1
+quadrature2d = 1
+fiatlagrange = 1
+
+# ----------------------------------------------------------------------
+# mesh_generator
+# ----------------------------------------------------------------------
+[pylithapp.mesh_generator]
+debug = 1
+
+[pylithapp.mesh_generator.importer]
+filename = threequad4.mesh
+coordsys.space_dim = 2
+
+# ----------------------------------------------------------------------
+# problem
+# ----------------------------------------------------------------------
+[pylithapp.timedependent]
+total_time = 0.0*s
+default_dt = 1.0*s
+dimension = 2
+formulation = pylith.problems.Implicit
+bc = pylith.problems.BCQuadrilateral
+
+# ----------------------------------------------------------------------
+# materials
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.materials]
+material = pylith.materials.ElasticPlaneStress
+
+[pylithapp.timedependent.materials.material]
+label = elastic material
+id = 0
+db.iohandler.filename = matprops.spatialdb
+quadrature = pylith.feassemble.quadrature.Quadrature2D
+quadrature.cell = pylith.feassemble.FIATLagrange
+quadrature.cell.dimension = 2
+
+# ----------------------------------------------------------------------
+# boundary conditions
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.bc.x_neg]
+fixed_dof = [0, 1]
+id = 10
+label = x_neg
+db.label = Dirichlet BC -x edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.x_pos]
+fixed_dof = [0, 1]
+id = 11
+label = x_pos
+db.label = Dirichlet BC +x edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.y_pos]
+fixed_dof = [0]
+id = 12
+label = y_pos
+db.label = Dirichlet BC +y edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.y_neg]
+fixed_dof = [0]
+id = 13
+label = y_neg
+db.label = Dirichlet BC -y edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+# ----------------------------------------------------------------------
+# PETSc
+# ----------------------------------------------------------------------
+[pylithapp.petsc]
+pc_type = jacobi
+
+# ----------------------------------------------------------------------
+# output
+# ----------------------------------------------------------------------
+[pylithapp.problem.formulation.output.output]
+filename = threequad4_shear.vtk
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg~
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg~ 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.cfg~ 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,98 @@
+# -*- Python -*-
+[pylithapp]
+
+# ----------------------------------------------------------------------
+# journal
+# ----------------------------------------------------------------------
+[pylithapp.journal.info]
+timedependent = 1
+explicit = 1
+implicit = 1
+petsc = 1
+solverlinear = 1
+meshioascii = 1
+homogeneous = 1
+explicitelasticity = 1
+quadrature2d = 1
+fiatlagrange = 1
+
+# ----------------------------------------------------------------------
+# mesh_generator
+# ----------------------------------------------------------------------
+[pylithapp.mesh_generator]
+debug = 1
+
+[pylithapp.mesh_generator.importer]
+filename = threequad4.mesh
+coordsys.space_dim = 2
+
+# ----------------------------------------------------------------------
+# problem
+# ----------------------------------------------------------------------
+[pylithapp.timedependent]
+total_time = 0.0*s
+default_dt = 1.0*s
+dimension = 2
+formulation = pylith.problems.Implicit
+bc = pylith.problems.BCQuadrilateral
+
+# ----------------------------------------------------------------------
+# materials
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.materials]
+material = pylith.materials.ElasticPlaneStrain
+
+[pylithapp.timedependent.materials.material]
+label = elastic material
+id = 0
+db.iohandler.filename = matprops.spatialdb
+quadrature = pylith.feassemble.quadrature.Quadrature2D
+quadrature.cell = pylith.feassemble.FIATLagrange
+quadrature.cell.dimension = 2
+
+# ----------------------------------------------------------------------
+# boundary conditions
+# ----------------------------------------------------------------------
+[pylithapp.timedependent.bc.x_neg]
+fixed_dof = [0, 1]
+id = 10
+label = x_neg
+db.label = Dirichlet BC -x edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.x_pos]
+fixed_dof = [0, 1]
+id = 11
+label = x_pos
+db.label = Dirichlet BC +x edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.y_pos]
+fixed_dof = [0, 1]
+id = 12
+label = y_pos
+db.label = Dirichlet BC +y edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+[pylithapp.timedependent.bc.y_neg]
+fixed_dof = [0, 1]
+id = 13
+label = y_neg
+db.label = Dirichlet BC -y edge
+db.iohandler.filename = threequad4_shear.spatialdb
+db.query_type = linear
+
+# ----------------------------------------------------------------------
+# PETSc
+# ----------------------------------------------------------------------
+[pylithapp.petsc]
+pc_type = jacobi
+
+# ----------------------------------------------------------------------
+# output
+# ----------------------------------------------------------------------
+[pylithapp.problem.formulation.output.output]
+filename = threequad4_shear.vtk
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 2
+ value-names = dof-0 dof-1
+ value-units = m m
+ num-locs = 2
+ data-dim = 1
+ space-dim = 2
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+-3.0 0.0 0.0 -3.0
++3.0 0.0 0.0 +3.0
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb~
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb~ 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.spatialdb~ 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 2
+ value-names = dof-0 dof-1
+ value-units = m m
+ num-locs = 2
+ data-dim = 1
+ space-dim = 2
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+-250.0 0.0 0.0 -1.0
++250.0 0.0 0.0 +1.0
Added: short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.vtk
===================================================================
--- short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.vtk 2007-06-12 03:17:37 UTC (rev 7151)
+++ short/3D/PyLith/trunk/tests/2d/quad4/threequad4_shear.vtk 2007-06-12 06:14:25 UTC (rev 7152)
@@ -0,0 +1,32 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 8 double
+-3 -1 0.0
+-1 -1 0.0
+1 -1 0.0
+3 -1 0.0
+-3 1 0.0
+-1 1 0.0
+1 1 0.0
+3 1 0.0
+CELLS 3 15
+4 0 1 5 4
+4 1 2 6 5
+4 2 3 7 6
+CELL_TYPES 3
+9
+9
+9
+POINT_DATA 8
+SCALARS displacements double 2
+LOOKUP_TABLE default
+0 -3
+0 0.248062
+0 0.403101
+0 3
+0 -3
+0 -0.403101
+0 -0.248062
+0 3
More information about the cig-commits
mailing list