[cig-commits] r12768 - in short/3D/PyLith/trunk: libsrc/faults modulesrc/faults pylith/faults unittests/libtests/faults unittests/pytests/faults
brad at geodynamics.org
brad at geodynamics.org
Mon Sep 1 15:35:41 PDT 2008
Author: brad
Date: 2008-09-01 15:35:40 -0700 (Mon, 01 Sep 2008)
New Revision: 12768
Modified:
short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc
short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py
Log:
Added flag/filename for using fault mesh instead of group of vertices to define fault. Added relevant C++ and Python unit tests.
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc 2008-09-01 22:35:40 UTC (rev 12768)
@@ -25,7 +25,9 @@
// ----------------------------------------------------------------------
// Default constructor.
-pylith::faults::FaultCohesive::FaultCohesive(void)
+pylith::faults::FaultCohesive::FaultCohesive(void) :
+ _useFaultMesh(false),
+ _faultMeshFilename("fault.inp")
{ // constructor
} // constructor
@@ -36,6 +38,23 @@
} // destructor
// ----------------------------------------------------------------------
+// Set flag for using fault mesh or group of vertices to define
+// fault surface.
+void
+pylith::faults::FaultCohesive::useFaultMesh(const bool flag)
+{ // useFaultMesh
+ _useFaultMesh = flag;
+} // useFaultMesh
+
+// ----------------------------------------------------------------------
+// Set filename of UCD file for fault mesh.
+void
+pylith::faults::FaultCohesive::faultMeshFilename(const char* filename)
+{ // faultMeshFilename
+ _faultMeshFilename = filename;
+} // faultMeshFilename
+
+// ----------------------------------------------------------------------
// Adjust mesh topology for fault implementation.
void
pylith::faults::FaultCohesive::adjustTopology(const ALE::Obj<Mesh>& mesh)
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh 2008-09-01 22:35:40 UTC (rev 12768)
@@ -48,6 +48,20 @@
virtual
~FaultCohesive(void);
+ /** Set flag for using fault mesh or group of vertices to define
+ * fault surface.
+ *
+ * @param flag True if using fault mesh, false if using vertices.
+ */
+ void useFaultMesh(const bool flag);
+
+ // TEMPORARY
+ /** Set filename of UCD file for fault mesh.
+ *
+ * @param filename Filename for UCD file.
+ */
+ void faultMeshFilename(const char* filename);
+
/** Adjust mesh topology for fault implementation.
*
* @param mesh PETSc mesh
@@ -68,12 +82,18 @@
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
- /// Not implemented
- FaultCohesive(const FaultCohesive& m);
+ FaultCohesive(const FaultCohesive&); ///< Not implemented
+ const FaultCohesive& operator=(const FaultCohesive&); ///< Not implemented
- /// Not implemented
- const FaultCohesive& operator=(const FaultCohesive& m);
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+ /// If true, use fault mesh to define fault; otherwise, use group of
+ /// vertices to define fault.
+ bool _useFaultMesh;
+
+ std::string _faultMeshFilename; /// Filename for fault mesh UCD file.
+
}; // class FaultCohesive
#endif // pylith_faults_faultcohesive_hh
Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2008-09-01 22:35:40 UTC (rev 12768)
@@ -391,7 +391,54 @@
Fault.__init__(self)
return
+ property useFaultMesh:
+ def __set__(self, flag):
+ """
+ Set use fault mesh flag.
+ """
+ # create shim for method 'useFaultMesh'
+ #embed{ void FaultCohesiveKin_useFaultMesh_set(void* objVptr, int flag)
+ try {
+ assert(0 != objVptr);
+ ((pylith::faults::FaultCohesiveKin*) objVptr)->useFaultMesh(flag);
+ } 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
+ FaultCohesiveKin_useFaultMesh_set(self.thisptr, flag)
+
+ property faultMeshFilename: # TEMPORARY
+ def __set__(self, filename):
+ """
+ Set filename for fault mesh UCD file.
+ """
+ # create shim for method 'faultMeshFilename'
+ #embed{ void FaultCohesiveKin_faultMeshFilename_set(void* objVptr, char* filename)
+ try {
+ assert(0 != objVptr);
+ ((pylith::faults::FaultCohesiveKin*) objVptr)->faultMeshFilename(filename);
+ } 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
+ FaultCohesiveKin_faultMeshFilename_set(self.thisptr, filename)
+
+
# ----------------------------------------------------------------------
cdef class FaultCohesiveKin(FaultCohesive):
Modified: short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py 2008-09-01 22:35:40 UTC (rev 12768)
@@ -29,6 +29,42 @@
Factory: fault
"""
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Fault.Inventory):
+ """
+ Python object for managing FaultCohesive facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing FaultCohesive facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b use_fault_mesh If true, use fault mesh to define fault;
+ ## otherwise, use group of vertices to define fault.
+ ##
+ ## \b Facilities
+ ## @li \b fault_mesh_importer Importer for fault mesh.
+
+ import pyre.inventory
+
+ useFaultMesh = pyre.inventory.bool("use_fault_mesh", default=False)
+ useFaultMesh.meta['tip'] = "If true, use fault mesh to define fault; " \
+ "otherwise, use group of vertices to define fault."
+
+ # Future, improved implementation
+ #from pylith.meshio.MeshIOAscii imoport MeshIOAscii
+ #faultMeshImporter = pyre.inventory.facility("fault_mesh_importer",
+ # factory=MeshIOLagrit,
+ # family="mesh_io")
+ #faultMeshImporter.meta['tip'] = "Importer for fault mesh."
+
+ # Current kludge
+ faultMeshFilename = pyre.inventory.str("fault_mesh_filename",
+ default="fault.inp")
+ faultMeshFilename.meta['tip'] = "Filename for fault mesh UCD file."
+
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="faultcohesive"):
@@ -39,6 +75,20 @@
return
+ def adjustTopology(self, mesh):
+ """
+ Adjust mesh topology for fault implementation.
+ """
+ self._createCppHandle()
+ assert(None != self.cppHandle)
+ self.cppHandle.useFaultMesh = self.useFaultMesh
+ #self.cppHandle.faultMeshImporter = self.faultMeshImporter.cppHandle
+ self.cppHandle.faultMeshFilename = self.faultMeshFilename # TEMPORARY
+
+ Fault.adjustTopology(self, mesh)
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -46,6 +96,9 @@
Setup members using inventory.
"""
Fault._configure(self)
+ self.useFaultMesh = self.inventory.useFaultMesh
+ #self.faultMeshImporter = self.inventory.faultMeshImporter
+ self.faultMeshFilename = self.inventory.faultMeshFilename # TEMPORARY
return
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2008-09-01 22:35:40 UTC (rev 12768)
@@ -66,6 +66,30 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestFaultCohesive );
// ----------------------------------------------------------------------
+void
+pylith::faults::TestFaultCohesive::testUseFaultMesh(void)
+{ // testUseFaultMesh
+ FaultCohesiveDyn fault;
+ CPPUNIT_ASSERT(!fault._useFaultMesh);
+
+ fault.useFaultMesh(true);
+ CPPUNIT_ASSERT(fault._useFaultMesh);
+} // testUseFaultMesh
+
+// ----------------------------------------------------------------------
+// TEMPORARY
+void
+pylith::faults::TestFaultCohesive::testFaultMeshFilename(void)
+{ // testFaultMeshFilename
+ FaultCohesiveDyn fault;
+ CPPUNIT_ASSERT_EQUAL(std::string("fault.inp"), fault._faultMeshFilename);
+
+ const std::string filename = "SanAndreas.inp";
+ fault.faultMeshFilename(filename.c_str());
+ CPPUNIT_ASSERT_EQUAL(filename, fault._faultMeshFilename);
+} // testUseFaultMesh
+
+// ----------------------------------------------------------------------
// Test adjustTopology() with 1-D line element.
void
pylith::faults::TestFaultCohesive::testAdjustTopologyLine2(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2008-09-01 22:35:40 UTC (rev 12768)
@@ -41,6 +41,9 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestFaultCohesive );
+ CPPUNIT_TEST( testUseFaultMesh );
+ CPPUNIT_TEST( testFaultMeshFilename) ; // TEMPORARY
+
CPPUNIT_TEST( testAdjustTopologyLine2 );
CPPUNIT_TEST( testAdjustTopologyTri3 );
CPPUNIT_TEST( testAdjustTopologyTri3b );
@@ -86,6 +89,12 @@
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test useFaultMesh().
+ void testUseFaultMesh(void);
+
+ /// Test faultMeshFilename(). TEMPORARY
+ void testFaultMeshFilename(void);
+
/// Test adjustTopology() with 1-D line element.
void testAdjustTopologyLine2(void);
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py 2008-09-01 07:07:22 UTC (rev 12767)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py 2008-09-01 22:35:40 UTC (rev 12768)
@@ -33,4 +33,31 @@
return
+ def test_useFaultMesh(self):
+ """
+ Test useFaultMesh().
+ """
+ fault = FaultCohesive()
+ fault._configure()
+ self.assertEqual(False, fault.useFaultMesh)
+
+ fault.useFaultMesh = True;
+ self.assertEqual(True, fault.useFaultMesh)
+ return
+
+
+ def test_faultMeshFilename(self):
+ """
+ Test faultMeshFilename().
+ """
+ fault = FaultCohesive()
+ fault._configure()
+ self.assertEqual("fault.inp", fault.faultMeshFilename)
+
+ filename = "SanAndreas.inp"
+ fault.faultMeshFilename = filename
+ self.assertEqual(filename, fault.faultMeshFilename)
+ return
+
+
# End of file
More information about the cig-commits
mailing list