[cig-commits] r9008 - in short/3D/PyLith/trunk: libsrc/meshio modulesrc/meshio pylith/meshio

brad at geodynamics.org brad at geodynamics.org
Sun Jan 13 21:02:45 PST 2008


Author: brad
Date: 2008-01-13 21:02:44 -0800 (Sun, 13 Jan 2008)
New Revision: 9008

Modified:
   short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc
   short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
   short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
   short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
   short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc
   short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
   short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
   short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
   short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
   short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
Log:
Worked on bindings for OutputManager. Adjusted OutputManager and DataWriter C++ objects.

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc	2008-01-14 05:02:44 UTC (rev 9008)
@@ -14,12 +14,9 @@
 
 #include "DataWriter.hh" // implementation of class methods
 
-#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
-
 // ----------------------------------------------------------------------
 // Constructor
-pylith::meshio::DataWriter::DataWriter(void) :
-  _cs(0)
+pylith::meshio::DataWriter::DataWriter(void)
 { // constructor
 } // constructor
 
@@ -27,18 +24,9 @@
 // Destructor
 pylith::meshio::DataWriter::~DataWriter(void)
 { // destructor
-  delete _cs; _cs = 0;
 } // destructor  
 
 // ----------------------------------------------------------------------
-// Set coordinate system for output.
-void
-pylith::meshio::DataWriter::coordsys(const spatialdata::geocoords::CoordSys* cs)
-{ // coordsys
-  delete _cs; _cs = (0 != cs) ? cs->clone() : 0;
-} // coordsys
-
-// ----------------------------------------------------------------------
 // Prepare for writing files.
 void
 pylith::meshio::DataWriter::open(
@@ -71,5 +59,11 @@
 { // closeTimeStep
 } // closeTimeStep
 
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::meshio::DataWriter::DataWriter(const DataWriter& w)
+{ // copy constructor
+} // copy constructor
 
+
 // End of file 

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-01-14 05:02:44 UTC (rev 9008)
@@ -29,7 +29,7 @@
 
 namespace spatialdata {
   namespace geocoords {
-    class CoordSys; // HOLDSA CoordSys
+    class CoordSys; // USES CoordSys
   } // geocoords
 } // spatialdata
 
@@ -46,11 +46,12 @@
   virtual
   ~DataWriter(void);
 
-  /** Set coordinate system for output.
+  /** Make copy of this object.
    *
-   * @param cs Coordinate system
+   * @returns Copy of this.
    */
-  void coordsys(const spatialdata::geocoords::CoordSys* cs);
+  virtual
+  DataWriter* clone(void) const = 0;
 
   /** Prepare for writing files.
    *
@@ -106,11 +107,20 @@
 		      const ALE::Obj<real_section_type>& field,
 		      const ALE::Obj<ALE::Mesh>& mesh) = 0;
 
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-public :
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
 
-  spatialdata::geocoords::CoordSys* _cs; ///< Coordinate system for output
+  /** Copy constructor.
+   *
+   * @param w Object to copy.
+   */
+  DataWriter(const DataWriter& w);
 
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+  const DataWriter& operator=(const DataWriter&); ///< Not implemented
+
 }; // DataWriter
 
 #endif // pylith_meshio_datawriter_hh

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-01-14 05:02:44 UTC (rev 9008)
@@ -39,6 +39,16 @@
 } // destructor  
 
 // ----------------------------------------------------------------------
+// Copy constructor.
+pylith::meshio::DataWriterVTK::DataWriterVTK(const DataWriterVTK& w) :
+  DataWriter(w),
+  _filename(w._filename),
+  _timeFormat(w._timeFormat),
+  _viewer(0)
+{ // copy constructor
+} // copy constructor
+
+// ----------------------------------------------------------------------
 // Prepare file for data at a new time step.
 void
 pylith::meshio::DataWriterVTK::openTimeStep(

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-01-14 05:02:44 UTC (rev 9008)
@@ -39,6 +39,12 @@
   /// Destructor
   ~DataWriterVTK(void);
 
+  /** Make copy of this object.
+   *
+   * @returns Copy of this.
+   */
+  DataWriter* clone(void) const;
+
   /** Set filename for VTK file.
    *
    * @param filename Name of VTK file.
@@ -88,6 +94,20 @@
 		      const ALE::Obj<real_section_type>& field,
 		      const ALE::Obj<ALE::Mesh>& mesh);
 
+// PRIVATE METHODS //////////////////////////////////////////////////////
+private :
+
+  /** Copy constructor.
+   *
+   * @param w Object to copy.
+   */
+  DataWriterVTK(const DataWriterVTK& w);
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+  const DataWriterVTK& operator=(const DataWriterVTK&); ///< Not implemented
+
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 private :
 

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc	2008-01-14 05:02:44 UTC (rev 9008)
@@ -14,6 +14,13 @@
 #error "DataWriterVTK.icc must be included only from DataWriterVTK.hh"
 #else
 
+// Make copy of this object.
+inline
+pylith::meshio::DataWriter*
+pylith::meshio::DataWriterVTK::clone(void) const {
+  return new DataWriterVTK(*this);
+}
+
 // Set filename for VTK file.
 inline
 void

Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-14 05:02:44 UTC (rev 9008)
@@ -17,6 +17,7 @@
 	CellFilter.hh \
 	DataWriter.hh \
 	DataWriterVTK.hh \
+	DataWriterVTK.icc \
 	MeshIO.hh \
 	MeshIO.icc \
 	MeshIOAscii.hh \

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc	2008-01-14 05:02:44 UTC (rev 9008)
@@ -19,9 +19,12 @@
 #include "CellFilter.hh" // USES CellFilter
 #include "pylith/topology/FieldsManager.hh" // USES FieldsManager
 
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
 // ----------------------------------------------------------------------
 // Constructor
 pylith::meshio::OutputManager::OutputManager(void) :
+  _coordsys(0),
   _writer(0),
   _vertexFilter(0),
   _cellFilter(0)
@@ -38,6 +41,22 @@
 } // destructor  
 
 // ----------------------------------------------------------------------
+// Set coordinate system in output. The vertex fields in the output
+void
+pylith::meshio::OutputManager::coordsys(const spatialdata::geocoords::CoordSys* cs)
+{ // coordsys
+  delete _coordsys; _coordsys = (0 != cs) ? cs->clone() : 0;
+} // coordsys
+
+// ----------------------------------------------------------------------
+// Set writer to write data to file.
+void
+pylith::meshio::OutputManager::writer(const DataWriter* datawriter)
+{ // writer
+  delete _writer; _writer = (0 != datawriter) ? datawriter->clone() : 0;
+} // writer
+
+// ----------------------------------------------------------------------
 // Set which vertex fields to output.
 void
 pylith::meshio::OutputManager::vertexFields(const char** names,
@@ -190,8 +209,7 @@
 			       const double t,
 			       const char* name,
 			       const ALE::Obj<real_section_type>& field,
-			       const ALE::Obj<ALE::Mesh>& mesh,
-			       const spatialdata::geocoords::CoordSys* csMesh)
+			       const ALE::Obj<ALE::Mesh>& mesh)
 { // appendVertexField
   assert(0 != name);
 
@@ -208,8 +226,7 @@
 				const double t,
 				const char* name,
 				const ALE::Obj<real_section_type>& field,
-				const ALE::Obj<ALE::Mesh>& mesh,
-				const spatialdata::geocoords::CoordSys* csMesh)
+				const ALE::Obj<ALE::Mesh>& mesh)
 { // appendCellField
   assert(0 != name);
 

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-14 05:02:44 UTC (rev 9008)
@@ -60,6 +60,13 @@
   /// Destructor
   ~OutputManager(void);
 
+  /** Set coordinate system in output. The vertex fields in the output
+   * are not affected by any change in coordinates.
+   *
+   * @param cs Coordinate system in output.
+   */
+  void coordsys(const spatialdata::geocoords::CoordSys* cs);
+
   /** Set writer to write data to file.
    *
    * @param datawriter Writer for data.
@@ -152,13 +159,11 @@
    * @param name Name of field.
    * @param field Vertex field.
    * @param mesh PETSc mesh object.
-   * @param csMesh Coordinate system of mesh geometry
    */
   void appendVertexField(const double t,
 			 const char* name,
 			 const ALE::Obj<real_section_type>& field,
-			 const ALE::Obj<ALE::Mesh>& mesh,
-			 const spatialdata::geocoords::CoordSys* csMesh);
+			 const ALE::Obj<ALE::Mesh>& mesh);
 
   /** Append finite-element cell field to file.
    *
@@ -171,8 +176,7 @@
   void appendCellField(const double t,
 		       const char* name,
 		       const ALE::Obj<real_section_type>& field,
-		       const ALE::Obj<ALE::Mesh>& mesh,
-		       const spatialdata::geocoords::CoordSys* csMesh);
+		       const ALE::Obj<ALE::Mesh>& mesh);
 
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 
@@ -184,9 +188,10 @@
   /// Name and section label of cell fields to output
   map_names_type _cellFields;
 
-  DataWriter* _writer; ///< Writer for data
-  VertexFilter* _vertexFilter; ///< Filter applied to vertex data
-  CellFilter* _cellFilter; ///< Filter applied to cell data
+  spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system for output.
+  DataWriter* _writer; ///< Writer for data.
+  VertexFilter* _vertexFilter; ///< Filter applied to vertex data.
+  CellFilter* _cellFilter; ///< Filter applied to cell data.
 
 }; // OutputManager
 

Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src	2008-01-14 05:02:44 UTC (rev 9008)
@@ -16,6 +16,9 @@
 #include "pylith/meshio/MeshIOLagrit.hh"
 #include "pylith/meshio/SolutionIO.hh"
 #include "pylith/meshio/SolutionIOVTK.hh"
+#include "pylith/meshio/OutputManager.hh"
+#include "pylith/meshio/DataWriter.hh"
+#include "pylith/meshio/DataWriterVTK.hh"
 
 #if defined(ENABLE_CUBIT)
 #include "pylith/meshio/MeshIOCubit.hh"
@@ -888,4 +891,487 @@
       SolutionIOVTK_timeFormat_set(self.thisptr, format)
 
 
-# End of file 
+# ----------------------------------------------------------------------
+cdef void OutputManager_destructor(void* obj):
+  """
+  Destroy OutputManager object.
+  """
+  # create shim for destructor
+  #embed{ void OutputManager_destructor_cpp(void* pObj)
+  pylith::meshio::OutputManager* io = (pylith::meshio::OutputManager*) pObj;
+  delete io;
+  #}embed
+  OutputManager_destructor_cpp(obj)
+  return
+
+cdef class OutputManager:
+
+  cdef void* thisptr # Pointer to C++ object
+  cdef readonly object handle # PyCObject holding pointer to C++ object
+  cdef readonly object name # Identifier for object base type
+
+  def __init__(self):
+    """
+    Constructor.
+    """
+    self.handle = None
+    self.thisptr = NULL
+    self.name = "pylith_meshio_OutputManager"
+    return
+
+
+  def open(self, mesh, cs):
+    """
+    Open output file.
+    """
+    # create shim for method 'open'
+    #embed{ void OutputManager_open(void* objVptr, void* meshVptr, void* csVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != csVptr);
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      spatialdata::geocoords::CoordSys* cs =
+        (spatialdata::geocoords::CoordSys*) csVptr;
+      ((pylith::meshio::OutputManager*) objVptr)->open(*mesh, cs);
+    } 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
+    if mesh.name != "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    if not cs.name == "spatialdata_geocoords_CoordSys":
+      raise TypeError, \
+            "Argument must be extension module type 'CoordSys'."
+    OutputManager_open(self.thisptr, ptrFromHandle(mesh),
+                       ptrFromHandle(cs))
+    return
+
+
+  def close(self):
+    """
+    Close solution files.
+    """
+    # create shim for method 'close'
+    #embed{ void OutputManager_close(void* objVptr)
+    try {
+      assert(0 != objVptr);
+      ((pylith::meshio::OutputManager*) objVptr)->close();
+    } 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
+    OutputManager_close(self.thisptr)
+    return
+
+
+  def writeFields(self, t, fields, mesh, cs):
+    """
+    Write fields to file.
+    """
+    # create shim for method 'writeFields'
+    #embed{ void OutputManager_writeFields(void* objVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldsVptr);
+      assert(0 != meshVptr);
+      assert(0 != csVptr);
+      pylith::topology::FieldsManager* fields = 
+        (pylith::topology::FieldsManager*) fieldsVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      spatialdata::geocoords::CoordSys* cs =
+        (spatialdata::geocoords::CoordSys*) csVptr;
+      ((pylith::meshio::OutputManager*) objVptr)->writeFields(t, fields,
+                                                              *mesh, cs);
+    } 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
+    if not fields.name == "pylith_topology_FieldsManager":
+      raise TypeError, \
+            "Argument must be extension module type 'FieldsManager'."
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    cdef void* fieldVptr
+    fieldVptr = PyCObject_AsVoidPtr(field)
+    OutputManager_writeFields(self.thisptr, t, ptrFromHandle(fields), 
+                              ptrFromHandle(mesh), ptrFromHandle(cs))
+    return
+
+
+  def openTimeStep(self, t, mesh, cs):
+    """
+    Prepare for writing solution to file.
+    """
+    # create shim for method 'openTimeStep'
+    #embed{ void OutputManager_openTimeStep(void* objVptr, double t, void* meshVptr, void* csVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != meshVptr);
+      assert(0 != csVptr);
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      spatialdata::geocoords::CoordSys* cs =
+        (spatialdata::geocoords::CoordSys*) csVptr;
+      ((pylith::meshio::OutputManager*) objVptr)->openTimeStep(t, *mesh, cs);
+    } 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
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    if not cs.name == "spatialdata_geocoords_CoordSys":
+      raise TypeError, \
+            "Argument must be extension module type 'CoordSys'."
+    OutputManager_openTimeStep(self.thisptr, t, 
+                            ptrFromHandle(mesh), ptrFromHandle(cs))
+    return
+
+
+  def closeTimeStep(self):
+    """
+    Prepare for writing solution to file.
+    """
+    # create shim for method 'closeTimeStep'
+    #embed{ void OutputManager_closeTimeStep(void* objVptr)
+    try {
+      assert(0 != objVptr);
+      ((pylith::meshio::OutputManager*) objVptr)->closeTimeStep();
+    } 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
+    OutputManager_closeTimeStep(self.thisptr)
+    return
+
+
+  def appendVertexField(self, t, name, field, mesh):
+    """
+    Append field over vertices to file.
+    """
+    # create shim for method 'appendVertxField'
+    #embed{ void OutputManager_appendVertexField(void* objVptr, double t, char* name, void* fieldVptr, void* meshVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldVptr);
+      assert(0 != name);
+      assert(0 != meshVptr);
+      ALE::Obj<pylith::real_section_type>* field =
+        (ALE::Obj<pylith::real_section_type>*) fieldVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ((pylith::meshio::OutputManager*) objVptr)->appendVertexField(t, name,
+                                                                *field, *mesh);
+    } 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
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    cdef void* fieldVptr
+    fieldVptr = PyCObject_AsVoidPtr(field)
+    OutputManager_appendVertexField(self.thisptr, t, name, fieldVptr, 
+                                ptrFromHandle(mesh))
+    return
+
+
+  def appendCellField(self, t, name, field, mesh):
+    """
+    Append field over cells to file.
+    """
+    # create shim for method 'appendCellField'
+    #embed{ void OutputManager_appendCellField(void* objVptr, double t, char* name, void* fieldVptr, void* meshVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldVptr);
+      assert(0 != name);
+      assert(0 != meshVptr);
+      ALE::Obj<pylith::real_section_type>* field =
+        (ALE::Obj<pylith::real_section_type>*) fieldVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ((pylith::meshio::OutputManager*) objVptr)->appendCellField(t, name, *field,
+                                                              *mesh);
+    } 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
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    cdef void* fieldVptr
+    fieldVptr = PyCObject_AsVoidPtr(field)
+    OutputManager_appendCellField(self.thisptr, t, name, fieldVptr,
+                              ptrFromHandle(mesh))
+    return
+
+
+  def _createHandle(self):
+    """Wrap pointer to C++ object in PyCObject."""
+    return PyCObject_FromVoidPtr(self.thisptr, OutputManager_destructor)
+
+
+  property coordsys:
+    def __set__(self, cs):
+      """Set coordinate system."""
+      # create shim for method 'coordsys'
+      #embed{ void OutputManager_coordsys_set(void* objVptr, void* csVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != csVptr);
+        spatialdata::geocoords::CoordSys* cs =
+          (spatialdata::geocoords::CoordSys*) csVptr;
+        ((pylith::meshio::OutputManager*) objVptr)->coordsys(cs);
+      } 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
+      OutputManager_coordsys_set(self.thisptr, ptrFromHandle(cs))
+
+
+  property writer:
+    def __set__(self, writer):
+      """
+      Writer for finite-element data.
+      """
+      # create shim for method 'writer'
+      #embed{ void OutputManager_writer_set(void* objVptr, void* writerVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != writerVptr);
+        pylith::meshio::DataWriter* writer = 
+          (pylith::meshio::DataWriter*) writerVptr;
+        ((pylith::meshio::OutputManager*) objVptr)->writer(writer);
+      } 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
+      OutputManager_writer_set(self.thisptr, ptrFromHandle(writer))
+
+
+  property vertexFields:
+    def __set__(self, fields):
+      """
+      Set names and mesh labels of vertex fields
+      """
+      # create shim for method 'vertexFields'
+      #embed{ void OutputManager_vertexFields_set(void* objVptr, char** names, char** labels, int numFields)
+      try {
+        assert(0 != objVptr);
+        ((pylith::meshio::OutputManager*) objVptr)->vertexFields((const char**) names, 
+                                                                 (const char**) labels,
+                                                                 numFields);
+      } 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
+
+      cdef char** names
+      names = NULL
+      cdef char** labels
+      labels = NULL
+      numFields = len(fields)
+      if numFields > 0:
+        names = <char**> malloc(numFields*sizeof(char*))
+        labels = <char**> malloc(numFields*sizeof(char*))
+      keys = fields.keys()
+      values = fields.values()
+      for i from 0 <= i <= numFields:
+        strsize = len(keys[i])
+        names[i] = <char*> malloc(1+strsize*sizeof(char))
+        tmp = keys[i]
+        strcpy(names[i], tmp)
+        strsize = len(values[i])
+        labels[i] = <char*> malloc(1+strsize*sizeof(char))
+        tmp = values[i]
+        strcpy(labels[i], tmp)
+      
+      OutputManager_vertexFields_set(self.thisptr, names, labels, numFields)
+
+      # memory cleanup
+      for i from 0 <= i < numFields:
+        free(<void*> names[i])
+        free(<void*> labels[i])
+      free(<void*> names)
+      free(<void*> labels)
+
+
+  property cellFields:
+    def __set__(self, fields):
+      """
+      Set names and mesh labels of cell fields
+      """
+      # create shim for method 'cellFields'
+      #embed{ void OutputManager_cellFields_set(void* objVptr, char** names, char** labels, int numFields)
+      try {
+        assert(0 != objVptr);
+        ((pylith::meshio::OutputManager*) objVptr)->cellFields((const char**) names, 
+                                                               (const char**) labels,
+                                                                 numFields);
+      } 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
+
+      cdef char** names
+      names = NULL
+      cdef char** labels
+      labels = NULL
+      numFields = len(fields)
+      if numFields > 0:
+        names = <char**> malloc(numFields*sizeof(char*))
+        labels = <char**> malloc(numFields*sizeof(char*))
+      keys = fields.keys()
+      values = fields.values()
+      for i from 0 <= i <= numFields:
+        strsize = len(keys[i])
+        names[i] = <char*> malloc(1+strsize*sizeof(char))
+        tmp = keys[i]
+        strcpy(names[i], tmp)
+        strsize = len(values[i])
+        labels[i] = <char*> malloc(1+strsize*sizeof(char))
+        tmp = values[i]
+        strcpy(labels[i], tmp)
+      
+      OutputManager_cellFields_set(self.thisptr, names, labels, numFields)
+
+      # memory cleanup
+      for i from 0 <= i < numFields:
+        free(<void*> names[i])
+        free(<void*> labels[i])
+      free(<void*> names)
+      free(<void*> labels)
+
+
+  property vertexFilter:
+    def __set__(self, filter):
+      """
+      Set vertex filter.
+      """
+      # create shim for method 'vertexFilter'
+      #embed{ void OutputManager_vertexFilter_set(void* objVptr, void* filterVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != filterVptr);
+        pylith::meshio::VertexFilter* filter = 
+          (pylith::meshio::VertexFilter*) filterVptr;
+        ((pylith::meshio::OutputManager*) objVptr)->vertexFilter(filter);
+      } 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
+      OutputManager_vertexFilter_set(self.thisptr, ptrFromHandle(filter))
+
+
+  property cellFilter:
+    def __set__(self, filter):
+      """
+      Set cell filter.
+      """
+      # create shim for method 'cellFilter'
+      #embed{ void OutputManager_cellFilter_set(void* objVptr, void* filterVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != filterVptr);
+        pylith::meshio::CellFilter* filter = 
+          (pylith::meshio::CellFilter*) filterVptr;
+        ((pylith::meshio::OutputManager*) objVptr)->cellFilter(filter);
+      } 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
+      OutputManager_cellFilter_set(self.thisptr, ptrFromHandle(filter))
+
+
+# End of file

Modified: short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-01-13 23:12:55 UTC (rev 9007)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-01-14 05:02:44 UTC (rev 9008)
@@ -330,6 +330,7 @@
       import pylith.meshio.meshio as bindings
       self.cppHandle = bindings.OutputManager()
     self.cppHandle.coordsys = self.coordsys
+    self.cppHandle.writer = self.writer
     self.cppHandle.vertexFields = self.vertexFields
     self.cppHandle.cellFields = self.cellFields
     self.cppHandle.vertexFilter = self.vertexFilter.cppHandle



More information about the cig-commits mailing list