[cig-commits] r6855 - in short/3D/PyLith/trunk: libsrc
libsrc/meshio modulesrc/meshio pylith/meshio
brad at geodynamics.org
brad at geodynamics.org
Fri May 11 14:10:23 PDT 2007
Author: brad
Date: 2007-05-11 14:10:22 -0700 (Fri, 11 May 2007)
New Revision: 6855
Added:
short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.icc
Modified:
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.cc
short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.hh
short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.cc
short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.hh
short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py
short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py
Log:
Finished layout of source code for preliminary implementation of solution output via VTK files.
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2007-05-11 21:10:22 UTC (rev 6855)
@@ -60,7 +60,8 @@
meshio/PsetFile.cc \
meshio/PsetFileAscii.cc \
meshio/PsetFileBinary.cc \
- meshio/SolutionIO.cc
+ meshio/SolutionIO.cc \
+ meshio/SolutionIOVTK.cc
if ENABLE_CUBIT
libpylith_la_SOURCES += \
Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2007-05-11 21:10:22 UTC (rev 6855)
@@ -20,7 +20,9 @@
MeshIOAscii.icc \
MeshIOLagrit.hh \
MeshIOLagrit.icc \
- SolutionIO.hh
+ SolutionIO.hh \
+ SolutionIOVTK.hh \
+ SolutionIOVTK.icc
if ENABLE_CUBIT
subpkginclude_HEADERS += \
Modified: short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.cc 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.cc 2007-05-11 21:10:22 UTC (rev 6855)
@@ -14,9 +14,12 @@
#include "SolutionIO.hh" // implementation of class methods
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::SolutionIO::SolutionIO(void)
+pylith::meshio::SolutionIO::SolutionIO(void) :
+ _cs(0)
{ // constructor
} // constructor
@@ -24,7 +27,16 @@
// Destructor
pylith::meshio::SolutionIO::~SolutionIO(void)
{ // destructor
+ delete _cs; _cs = 0;
} // destructor
+// ----------------------------------------------------------------------
+// Set coordinate system for output.
+void
+pylith::meshio::SolutionIO::coordsys(const spatialdata::geocoords::CoordSys* cs)
+{ // coordsys
+ delete _cs; _cs = (0 != cs) ? cs->clone() : 0;
+} // coordsys
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.hh 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/SolutionIO.hh 2007-05-11 21:10:22 UTC (rev 6855)
@@ -10,22 +10,41 @@
// ======================================================================
//
-#if !defined(pylith_solutionio_solutionio_hh)
-#define pylith_solutionio_solutionio_hh
+/**
+ * @file pylith/meshio/SolutionIO.hh
+ *
+ * @brief Abstract base class for writing finite-element solution to file.
+ *
+ * :TODO: Replace this implementation with one that extracts data from
+ * Sieve and calls virtual functions to write data to file (similar to
+ * interface for MeshIO), so that children of SolutionIO don't
+ * replicate code. This will also make it easier to implement
+ * exporters for various formats (HDF5, OpenDX, etc).
+ */
-#include "pylith/utils/sievefwd.hh" // USES ALE::Obj, ALE::Mesh
+#if !defined(pylith_meshio_solutionio_hh)
+#define pylith_meshio_solutionio_hh
+#include "pylith/utils/sievetypes.hh" // USES ALE::Obj, ALE::Mesh, real_section_type
+
namespace pylith {
namespace meshio {
class SolutionIO;
} // meshio
} // pylith
+namespace spatialdata {
+ namespace geocoords {
+ class CoordSys; // HOLDSA CoordSys
+ } // geocoords
+} // spatialdata
+
class pylith::meshio::SolutionIO
{ // SolutionIO
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
+
/// Constructor
SolutionIO(void);
@@ -33,15 +52,52 @@
virtual
~SolutionIO(void);
- /** Write solution to file.
+ /** Set coordinate system for output.
*
+ * @param cs Coordinate system
+ */
+ void coordsys(const spatialdata::geocoords::CoordSys* cs);
+
+ /** Open output files.
+ *
* @param mesh PETSc mesh object
*/
virtual
- void write(const ALE::Obj<ALE::Mesh>& mesh) = 0;
+ void open(const ALE::Obj<ALE::Mesh>& mesh) = 0;
+ /// Close output files.
+ virtual
+ void close(void) = 0;
+
+ /** Write solution topology to file.
+ *
+ * @param mesh PETSc mesh object.
+ * @param
+ */
+ virtual
+ void writeTopology(const ALE::Obj<ALE::Mesh>& mesh,
+ const spatialdata::geocoords::CoordSys* csMesh) = 0;
+
+ /** Write solution field to file.
+ *
+ * @param t Time associated with field.
+ * @param field PETSc field.
+ * @param name Name of field.
+ * @param mesh PETSc mesh object.
+ */
+ virtual
+ void writeField(const double t,
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+public :
+
+ spatialdata::geocoords::CoordSys* _cs; ///< Coordinate system for output
+
}; // SolutionIO
-#endif // pylith_solutionio_solutionio_hh
+#endif // pylith_meshio_solutionio_hh
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.cc 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.cc 2007-05-11 21:10:22 UTC (rev 6855)
@@ -14,9 +14,15 @@
#include "SolutionIOVTK.hh" // implementation of class methods
+#include <fstream> // USES std::ofstream
+#include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::SolutionIOVTK::SolutionIOVTK(void)
+pylith::meshio::SolutionIOVTK::SolutionIOVTK(void) :
+ _fout(new std::ofstream)
{ // constructor
} // constructor
@@ -24,7 +30,85 @@
// Destructor
pylith::meshio::SolutionIOVTK::~SolutionIOVTK(void)
{ // destructor
+ delete _fout; _fout = 0;
} // destructor
+// ----------------------------------------------------------------------
+// Open output files.
+void
+pylith::meshio::SolutionIOVTK::open(const ALE::Obj<ALE::Mesh>& mesh)
+{ // open
+ assert(0 != _fout);
+ _fout->open(_filename.c_str());
+ if (!_fout->is_open() || !_fout->good()) {
+ std::ostringstream msg;
+ msg << "Could not open VTK file '" << _filename
+ << "' for solution output.\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ // Write header
+ // ADD STUFF HERE
+} // open
+
+// ----------------------------------------------------------------------
+// Close output files.
+void
+pylith::meshio::SolutionIOVTK::close(void)
+{ // close
+ _fout->close();
+} // close
+
+// ----------------------------------------------------------------------
+// Write solution topology to file.
+void
+pylith::meshio::SolutionIOVTK::writeTopology(const ALE::Obj<ALE::Mesh>& mesh,
+ const spatialdata::geocoords::CoordSys* csMesh)
+{ // writeTopology
+ try {
+ // ADD STUFF HERE
+
+ // Use spatialdata::geocoords::Converter::convert() to convert
+ // coordinates of vertices from csMesh to _cs (postpone and wait
+ // for more general implementation of SolutionIO?).
+
+ } catch (const std::exception& err) {
+ std::ostringstream msg;
+ msg << "Error while writing topology information to VTK file '"
+ << _filename << "'.\n" << err.what();
+ throw std::runtime_error(msg.str());
+ } catch (...) {
+ std::ostringstream msg;
+ msg << "Error while writing topology information to VTK file '"
+ << _filename << "'.\n";
+ throw std::runtime_error(msg.str());
+ } // try/catch
+} // writeTopology
+
+// ----------------------------------------------------------------------
+// Write field to file.
+void
+pylith::meshio::SolutionIOVTK::writeField(
+ const double t,
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh)
+{ // writeField
+ try {
+ // ADD STUFF HERE
+ } catch (const std::exception& err) {
+ std::ostringstream msg;
+ msg << "Error while writing field '" << name << "' at time "
+ << t << " to VTK file '" << _filename << "'.\n" << err.what();
+ throw std::runtime_error(msg.str());
+ } catch (...) {
+ std::ostringstream msg;
+ msg << "Error while writing field '" << name << "' at time "
+ << t << " to VTK file '" << _filename << "'.\n";
+ throw std::runtime_error(msg.str());
+ } // try/catch
+} // writeField
+
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.hh 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.hh 2007-05-11 21:10:22 UTC (rev 6855)
@@ -15,6 +15,8 @@
#include "SolutionIO.hh" // ISA SolutionIO
+#include <iosfwd> // HOLDSA std::ofstream
+
namespace pylith {
namespace meshio {
class SolutionIOVTK;
@@ -31,7 +33,6 @@
SolutionIOVTK(void);
/// Destructor
- virtual
~SolutionIOVTK(void);
/** Set filename for VTK file.
@@ -40,19 +41,52 @@
*/
void filename(const char* filename);
- /** Write solution to file.
+ /** Get filename of VTK file.
*
+ * @returns filename Name of VTK file.
+ */
+ const char* filename(void) const;
+
+ /** Open output files.
+ *
* @param mesh PETSc mesh object
*/
- void write(const ALE::Obj<ALE::Mesh>& mesh);
+ void open(const ALE::Obj<ALE::Mesh>& mesh);
+ /// Close output files.
+ void close(void);
+
+ /** Write solution topology to file.
+ *
+ * @param mesh PETSc mesh object.
+ * @param
+ */
+ void writeTopology(const ALE::Obj<ALE::Mesh>& mesh,
+ const spatialdata::geocoords::CoordSys* csMesh);
+
+ /** Write solution field to file.
+ *
+ * @param t Time associated with field.
+ * @param field PETSc field.
+ * @param name Name of field.
+ * @param mesh PETSc mesh object.
+ */
+ void writeField(const double t,
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh);
+
// PRIVATE MEMBERS //////////////////////////////////////////////////////
public :
std::string _filename; ///< Name of VTK file.
+ std::ofstream* _fout; ///< Output stream
+
}; // SolutionIOVTK
+#include "SolutionIOVTK.icc" // inline methods
+
#endif // pylith_solutionio_solutioniovtk_hh
// End of file
Added: short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.icc 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/libsrc/meshio/SolutionIOVTK.icc 2007-05-11 21:10:22 UTC (rev 6855)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_solutionio_hh)
+#error "SolutionIOVTK.icc must be included only from SolutionIOVTK.hh"
+#else
+
+// Set filename for VTK file.
+inline
+void
+pylith::meshio::SolutionIOVTK::filename(const char* filename) {
+ _filename = filename;
+}
+
+// Get filename of VTK file.
+inline
+const char*
+pylith::meshio::SolutionIOVTK::filename(void) const {
+ return _filename.c_str();
+}
+
+#endif
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2007-05-11 21:10:22 UTC (rev 6855)
@@ -14,6 +14,8 @@
#include "pylith/meshio/MeshIO.hh"
#include "pylith/meshio/MeshIOAscii.hh"
#include "pylith/meshio/MeshIOLagrit.hh"
+#include "pylith/meshio/SolutionIO.hh"
+#include "pylith/meshio/SolutionIOVTK.hh"
#if defined(ENABLE_CUBIT)
#include "pylith/meshio/MeshIOCubit.hh"
@@ -44,12 +46,24 @@
"""
# create shim for destructor
#embed{ void MeshIO_destructor_cpp(void* pObj)
- pylith::meshio::MeshIO* pMesh = (pylith::meshio::MeshIO*) pObj;
- delete pMesh;
+ pylith::meshio::MeshIO* io = (pylith::meshio::MeshIO*) pObj;
+ delete io;
#}embed
MeshIO_destructor_cpp(obj)
return
+cdef void SolutionIO_destructor(void* obj):
+ """
+ Destroy SolutionIO object.
+ """
+ # create shim for destructor
+ #embed{ void SolutionIO_destructor_cpp(void* pObj)
+ pylith::meshio::SolutionIO* io = (pylith::meshio::SolutionIO*) pObj;
+ delete io;
+ #}embed
+ SolutionIO_destructor_cpp(obj)
+ return
+
# ----------------------------------------------------------------------
cdef class MeshIO:
@@ -76,8 +90,8 @@
try {
assert(0 != objVptr);
assert(0 != meshVptr);
- ALE::Obj<ALE::Mesh>* pMesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
- ((pylith::meshio::MeshIO*) objVptr)->read(pMesh);
+ ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+ ((pylith::meshio::MeshIO*) objVptr)->read(mesh);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -101,8 +115,8 @@
#embed{ void MeshIO_write(void* objVptr, void* meshVptr)
try {
assert(0 != objVptr);
- ALE::Obj<ALE::Mesh>* pMesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
- ((pylith::meshio::MeshIO*) objVptr)->write(pMesh);
+ ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+ ((pylith::meshio::MeshIO*) objVptr)->write(mesh);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -487,4 +501,226 @@
return MeshIOLagrit_flipEndian_get(self.thisptr)
+# ----------------------------------------------------------------------
+cdef class SolutionIO:
+
+ 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_SolutionIO"
+ return
+
+
+ def open(self, mesh):
+ """
+ Open solution files.
+ """
+ # create shim for method 'open'
+ #embed{ void SolutionIO_open(void* objVptr, void* meshVptr)
+ try {
+ assert(0 != objVptr);
+ assert(0 != meshVptr);
+ ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+ ((pylith::meshio::SolutionIO*) objVptr)->open(*mesh);
+ } 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
+ if mesh.name != "pylith_topology_Mesh":
+ raise TypeError, \
+ "Argument must be extension module type 'Mesh'."
+ SolutionIO_open(self.thisptr, ptrFromHandle(mesh))
+ return
+
+
+ def close(self):
+ """
+ Close solution files.
+ """
+ # create shim for method 'close'
+ #embed{ void SolutionIO_close(void* objVptr)
+ try {
+ assert(0 != objVptr);
+ ((pylith::meshio::SolutionIO*) objVptr)->close();
+ } 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
+ SolutionIO_close(self.thisptr)
+ return
+
+
+ def writeTopology(self, mesh, cs):
+ """
+ Write solution topology to file.
+ """
+ # create shim for method 'writeTopology'
+ #embed{ void SolutionIO_writeTopology(void* objVptr, 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::SolutionIO*) objVptr)->writeTopology(*mesh, cs);
+ } 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
+ 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'."
+ SolutionIO_writeTopology(self.thisptr, ptrFromHandle(mesh), ptrFromHandle(cs))
+ return
+
+
+ def writeField(self, t, field, name, mesh):
+ """
+ Write solution field to file.
+ """
+ # create shim for method 'writeField'
+ #embed{ void SolutionIO_writeField(void* objVptr, double t, void* fieldVptr, char* name, 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::SolutionIO*) objVptr)->writeField(t, *field, name,
+ *mesh);
+ } 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
+ if not mesh.name == "pylith_topology_Mesh":
+ raise TypeError, \
+ "Argument must be extension module type 'Mesh'."
+ cdef void* fieldVptr
+ fieldVptr = PyCObject_AsVoidPtr(field)
+ SolutionIO_writeField(self.thisptr, t, fieldVptr, name, ptrFromHandle(mesh))
+ return
+
+
+ def _createHandle(self):
+ """Wrap pointer to C++ object in PyCObject."""
+ return PyCObject_FromVoidPtr(self.thisptr, SolutionIO_destructor)
+
+
+ property coordsys:
+ def __set__(self, cs):
+ """Set coordinate system."""
+ # create shim for method 'coordsys'
+ #embed{ void SolutionIO_coordsys_set(void* objVptr, void* csVptr)
+ try {
+ assert(0 != objVptr);
+ assert(0 != csVptr);
+ spatialdata::geocoords::CoordSys* cs =
+ (spatialdata::geocoords::CoordSys*) csVptr;
+ ((pylith::meshio::SolutionIO*) objVptr)->coordsys(cs);
+ } 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
+ SolutionIO_coordsys_set(self.thisptr, ptrFromHandle(cs))
+
+
+# ----------------------------------------------------------------------
+cdef class SolutionIOVTK(SolutionIO):
+
+ def __init__(self):
+ """Constructor."""
+ # create shim for constructor
+ #embed{ void* SolutionIOVTK_constructor()
+ void* result = 0;
+ try {
+ result = (void*)(new pylith::meshio::SolutionIOVTK);
+ assert(0 != result);
+ } 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
+
+ SolutionIO.__init__(self)
+ self.thisptr = SolutionIOVTK_constructor()
+ self.handle = self._createHandle()
+ return
+
+
+ property filename:
+ def __set__(self, name):
+ """Set filename."""
+ # create shim for method 'filename'
+ #embed{ void SolutionIOVTK_filename_set(void* objVptr, char* name)
+ try {
+ assert(0 != objVptr);
+ ((pylith::meshio::SolutionIOVTK*) objVptr)->filename(name);
+ } 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
+ SolutionIOVTK_filename_set(self.thisptr, name)
+
+ def __get__(self):
+ """Get filename."""
+ # create shim for method 'filename'
+ #embed{ char* SolutionIOVTK_filename_get(void* objVptr)
+ char* result = 0;
+ try {
+ assert(0 != objVptr);
+ result = (char*) ((pylith::meshio::SolutionIOVTK*) objVptr)->filename();
+ assert(0 != result);
+ } 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 SolutionIOVTK_filename_get(self.thisptr)
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py 2007-05-11 21:10:22 UTC (rev 6855)
@@ -27,7 +27,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SolutionIO.Inventory):
+ class Inventory(Component.Inventory):
"""
Python object for managing SolutionIOVTK facilities and properties.
"""
@@ -61,24 +61,46 @@
return
- def write(self, t, fields, mesh):
+ def open(self, mesh):
"""
- Write solution at time t to file.
+ Open files for solution.
"""
- self._info.log("Writing solution information.")
+ self._info.log("Opening files for output of solution.")
# Set flags
self._sync()
# Initialize coordinate system
if self.coordsys is None:
- raise ValueError, "Coordinate system for mesh is unknown."
+ raise ValueError, "Coordinate system for output is unknown."
self.coordsys.initialize()
- #self.cppHandle.write(t, fields, mesh.cppHandle)
+ assert(cppHandle != None)
+ self.cppHandle.open(mesh.cppHandle)
return
+ def writeTopology(self, mesh):
+ """
+ Write solution topology to file.
+ """
+ self._info.log("Writing solution topology.")
+
+ assert(cppHandle != None)
+ self.cppHandle.write(mesh.cppHandle, mesh.coordsys.cppHandle)
+ return
+
+
+ def writeField(self, t, field, name, mesh):
+ """
+ Write solution field at time t to file.
+ """
+ self._info.log("Writing solution field '%s'." % name)
+
+ self.cppHandle.write(t, field, name, mesh.cppHandle)
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -94,7 +116,7 @@
"""
Force synchronization between Python and C++.
"""
- #self.cppHandle.coordsys = self.coordsys
+ self.cppHandle.coordsys = self.coordsys
return
Modified: short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py 2007-05-11 20:19:28 UTC (rev 6854)
+++ short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py 2007-05-11 21:10:22 UTC (rev 6855)
@@ -56,8 +56,8 @@
Constructor.
"""
SolutionIO.__init__(self, name)
- #import pylith.meshio.meshio as bindings
- #self.cppHandle = bindings.SolutionIOVTK()
+ import pylith.meshio.meshio as bindings
+ self.cppHandle = bindings.SolutionIOVTK()
return
More information about the cig-commits
mailing list