[cig-commits] r6494 - in short/3D/PyLith/trunk: . examples/twotri3
modulesrc/topology modulesrc/utils pylith/problems pylith/topology
brad at geodynamics.org
brad at geodynamics.org
Sat Mar 31 16:21:29 PDT 2007
Author: brad
Date: 2007-03-31 16:21:29 -0700 (Sat, 31 Mar 2007)
New Revision: 6494
Modified:
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg
short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src
short/3D/PyLith/trunk/pylith/problems/Explicit.py
short/3D/PyLith/trunk/pylith/topology/Mesh.py
short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
Log:
Added debug flag for mesh generator and debug attribute to Mesh. Added matrix assembly.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/TODO 2007-03-31 23:21:29 UTC (rev 6494)
@@ -3,6 +3,10 @@
======================================================================
Error checking
+ Add debug Pyre property to MeshIO
+
+ Add debug attribute to Mesh and extension module
+
add isNull() assertions before using ALE::Obj.
add check to material::initialize material dimension must match cell dimension
Modified: short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg 2007-03-31 23:21:29 UTC (rev 6494)
@@ -22,6 +22,9 @@
# ----------------------------------------------------------------------
# mesh_generator
# ----------------------------------------------------------------------
+[pylithapp.mesh_generator]
+debug = 1
+
[pylithapp.mesh_generator.importer]
filename = twotri3.mesh
coordsys.space_dim = 2
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-03-31 23:21:29 UTC (rev 6494)
@@ -198,6 +198,52 @@
return PyCObject_FromVoidPtr(self.thisptr, MeshPtr_destructor)
+ property debug:
+ def __set__(self, value):
+ """
+ Set debugging flag.
+ """
+ # create shim for method 'debug'
+ #embed{ void Mesh_debug_set(void* objVptr, int value)
+ try {
+ ALE::Obj<ALE::Field::Mesh>* mesh = (ALE::Obj<ALE::Field::Mesh>*) objVptr;
+ assert(0 != mesh);
+ assert(!mesh->isNull());
+ (*mesh)->setDebug(value);
+ } 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
+ #}embed
+ Mesh_debug_set(self.thisptr, value)
+
+ def __get__(self):
+ """
+ Get debugging flag.
+ """
+ # create shim for method 'debug'
+ #embed{ int Mesh_debug_get(void* objVptr)
+ int result = 0;
+ try {
+ ALE::Obj<ALE::Field::Mesh>* mesh = (ALE::Obj<ALE::Field::Mesh>*) objVptr;
+ assert(0 != mesh);
+ assert(!mesh->isNull());
+ result = (*mesh)->debug();
+ } 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_debug_get(self.thisptr)
+
+
def zeroRealSection(section):
"""
Zero real section.
Modified: short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src 2007-03-31 23:21:29 UTC (rev 6494)
@@ -12,6 +12,7 @@
#header{
#include <petsc.h>
+#include <petscmat.h>
#}header
# ----------------------------------------------------------------------
@@ -68,7 +69,7 @@
"""
Finalize PETSc.
"""
- # create shim for 'PetscFnitialize'
+ # create shim for 'PetscFinalize'
#embed{ int Petsc_finalize()
PetscErrorCode err = PetscFinalize(); CHKERRQ(err);
return 0;
@@ -81,4 +82,25 @@
return
+def mat_assemble(mat):
+ """
+ Assemble matrix.
+ """
+ # create shim for 'MatAssemblyBegin/MatAssemblyEnd'
+ #embed{ int Mat_assemble(void* matVptr)
+ Mat* mat = (Mat*) matVptr;
+ PetscErrorCode err = 0;
+ err = MatAssemblyBegin(*mat, MAT_FINAL_ASSEMBLY); CHKERRQ(err);
+ err = MatAssemblyEnd(*mat, MAT_FINAL_ASSEMBLY); CHKERRQ(err);
+ return 0;
+ #}embed
+ cdef void* matVptr
+ matVptr = PyCObject_AsVoidPtr(mat)
+ err = Mat_assemble(matVptr)
+ if err:
+ raise RuntimError("Error assembling matrix.")
+
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py 2007-03-31 23:21:29 UTC (rev 6494)
@@ -96,6 +96,8 @@
self._info.log("Integrating Jacobian of operator.")
for integrator in self.integrators:
integrator.integrateJacobian(self.jacobian, self.dispT)
+ import pylith.utils.petsc as petsc
+ petsc.mat_assemble(self.jacobian)
return
Modified: short/3D/PyLith/trunk/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-03-31 23:21:29 UTC (rev 6494)
@@ -45,6 +45,15 @@
return
+ def setDebug(self, flag):
+ """
+ Set debugging flag.
+ """
+ self.debug = flag
+ self.cppHandle.debug = self.debug
+ return
+
+
def distribute(self):
"""
Distribute mesh across processors.
Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2007-03-31 23:21:29 UTC (rev 6494)
@@ -26,6 +26,28 @@
Factory: mesh_generator
"""
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """
+ Python object for managing MeshGenerator facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing MeshGenerator facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b debug Debugging flag for mesh.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ debug = pyre.inventory.bool("debug", default=False)
+ debug.meta['tip'] = "Debugging flag for mesh."
+
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="meshgenerator"):
@@ -44,4 +66,15 @@
return
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Component._configure(self)
+ self.debug = self.inventory.debug
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2007-03-31 22:19:13 UTC (rev 6493)
+++ short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2007-03-31 23:21:29 UTC (rev 6494)
@@ -63,7 +63,9 @@
"""
Hook for creating mesh.
"""
- return self.importer.read()
+ mesh = self.importer.read()
+ mesh.setDebug(self.debug)
+ return mesh
# PRIVATE METHODS ////////////////////////////////////////////////////
More information about the cig-commits
mailing list