[cig-commits] r18523 - in short/3D/PyLith/trunk: . applications/utilities modulesrc/meshio pylith pylith/meshio unittests/pytests/meshio

brad at geodynamics.org brad at geodynamics.org
Wed Jun 1 14:32:23 PDT 2011


Author: brad
Date: 2011-06-01 14:32:23 -0700 (Wed, 01 Jun 2011)
New Revision: 18523

Added:
   short/3D/PyLith/trunk/applications/utilities/pylith_genxdmf
   short/3D/PyLith/trunk/modulesrc/meshio/Xdmf.i
   short/3D/PyLith/trunk/pylith/meshio/Xdmf.py
   short/3D/PyLith/trunk/unittests/pytests/meshio/TestXdmf.py
Modified:
   short/3D/PyLith/trunk/
   short/3D/PyLith/trunk/COPYING
   short/3D/PyLith/trunk/applications/utilities/Makefile.am
   short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
   short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/meshio/testhdf5.py
Log:
Added pylith_genxdmf utility for creating Xdmf file from HDF5 (only necessary if HDF5 is modified or Xdmf file gets lost).


Property changes on: short/3D/PyLith/trunk
___________________________________________________________________
Name: buildbot:config
   - # -*- cfg -*-

[packaging]

bin_dirs =
    bin

lib_dirs =
    lib

misc_dirs =
    etc
    share

files =
    ./setup.sh


strip_list =
    lib/libpylith
    lib/libspatialdata

exclude =
    bin/cpp
    bin/c\+\+
    bin/gcc
    bin/gccbug
    bin/g\+\+
    bin/gcov
    bin/gfortran
    bin/.*-.*-c\+\+.*
    bin/.*-.*-g\+\+.*
    bin/.*-.*-gcc.*
    bin/.*-.*-gfortran.*
    bin/mpicc
    bin/mpicxx
    bin/mpic\+\+
    bin/mpif77
    bin/mpif90
    bin/TOPSGenerator\.py
    bin/TOPSInstaller\.py
    bin/adiforfix\.py
    bin/adprocess\.py
    bin/2to3
    bin/bfort
    bin/bib2html
    bin/bsp_virtual
    bin/configVars\.py
    bin/doc2lt
    bin/doctext
    bin/f2py
    bin/maint/.*
    bin/matio\.py
    bin/matlab/.*
    bin/parseargs\.py
    bin/petsc_libtool
    bin/petscmpiexec
    bin/petscrun
    bin/popup
    bin/portabilitycheck\.py
    bin/processSummary\.py
    bin/pstogif
    bin/pstoxbm
    bin/task_manager
    bin/taucc\.py
    bin/tohtml
    bin/update\.py
    bin/urlget
    bin/urlget\.py
    bin/win32fe/.*
    share/man/man1/cpp\.1
    share/man/man1/g\+\+\.1
    share/man/man1/gcc\.1
    share/man/man1/gfortran\.1
    share/man/man3/.*
    share/info/.*
    share/doc/.*
    lib/.*\.a
    lib/gcc/.*-.*/.*

scripts =
    pylith
    pylithinfo
    pyconvert.py
    gensimpledb.py
    powerlaw_gendb.py



   + # -*- cfg -*-

[packaging]

bin_dirs =
    bin

lib_dirs =
    lib

misc_dirs =
    etc
    share

files =
    ./setup.sh


strip_list =
    lib/libpylith
    lib/libspatialdata

exclude =
    bin/cpp
    bin/c\+\+
    bin/gcc
    bin/gccbug
    bin/g\+\+
    bin/gcov
    bin/gfortran
    bin/.*-.*-c\+\+.*
    bin/.*-.*-g\+\+.*
    bin/.*-.*-gcc.*
    bin/.*-.*-gfortran.*
    bin/mpicc
    bin/mpicxx
    bin/mpic\+\+
    bin/mpif77
    bin/mpif90
    bin/TOPSGenerator\.py
    bin/TOPSInstaller\.py
    bin/adiforfix\.py
    bin/adprocess\.py
    bin/2to3
    bin/bfort
    bin/bib2html
    bin/bsp_virtual
    bin/configVars\.py
    bin/doc2lt
    bin/doctext
    bin/f2py
    bin/maint/.*
    bin/matio\.py
    bin/matlab/.*
    bin/parseargs\.py
    bin/petsc_libtool
    bin/petscmpiexec
    bin/petscrun
    bin/popup
    bin/portabilitycheck\.py
    bin/processSummary\.py
    bin/pstogif
    bin/pstoxbm
    bin/task_manager
    bin/taucc\.py
    bin/tohtml
    bin/update\.py
    bin/urlget
    bin/urlget\.py
    bin/win32fe/.*
    share/man/man1/cpp\.1
    share/man/man1/g\+\+\.1
    share/man/man1/gcc\.1
    share/man/man1/gfortran\.1
    share/man/man3/.*
    share/info/.*
    share/doc/.*
    lib/.*\.a
    lib/gcc/.*-.*/.*

scripts =
    pylith
    pylithinfo
    pylith_genxdmf
    pyconvert.py
    gensimpledb.py
    powerlaw_gendb.py





Modified: short/3D/PyLith/trunk/COPYING
===================================================================
--- short/3D/PyLith/trunk/COPYING	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/COPYING	2011-06-01 21:32:23 UTC (rev 18523)
@@ -1,4 +1,4 @@
-Copyright (c) 2010 University of California, Davis
+Copyright (c) 2010-2011 University of California, Davis
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the

Modified: short/3D/PyLith/trunk/applications/utilities/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/applications/utilities/Makefile.am	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/applications/utilities/Makefile.am	2011-06-01 21:32:23 UTC (rev 18523)
@@ -16,8 +16,10 @@
 # ----------------------------------------------------------------------
 #
 
-dist_bin_SCRIPTS = pylithinfo \
-		   powerlaw_gendb.py
+dist_bin_SCRIPTS = \
+	pylithinfo \
+	pylith_genxdmf \
+	powerlaw_gendb.py
 
 
 # End of file 

Added: short/3D/PyLith/trunk/applications/utilities/pylith_genxdmf
===================================================================
--- short/3D/PyLith/trunk/applications/utilities/pylith_genxdmf	                        (rev 0)
+++ short/3D/PyLith/trunk/applications/utilities/pylith_genxdmf	2011-06-01 21:32:23 UTC (rev 18523)
@@ -0,0 +1,74 @@
+#!/usr/bin/env nemesis
+#
+# ======================================================================
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ======================================================================
+#
+
+# This script creates a metadata file (.xmf) from an HDF5 file written
+# by PyLith permitting the data to be viewed in VTK visualization
+# software, such as ParaView and Visit.
+#
+# Usage: pylith_genxdmf --file=FILE
+
+__requires__ = "PyLith"
+
+
+# ======================================================================
+class GenXdmfApp(object):
+  """
+  Application for generating an Xdmf file for an HDF5 file.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="pylith_genxdmf"):
+    """
+    Constructor.
+    """
+    self.filename = "output.h5"
+    return
+
+
+  def main(self, *args, **kwds):
+    """
+    Main entry point for application.
+    """
+    from pylith.meshio.Xdmf import Xdmf
+    writer = Xdmf()
+    filenameHDF5 = self.filename
+    filenameXdmf = filenameHDF5.replace(".h5", ".xmf")
+    writer.write(filenameXdmf, filenameHDF5)
+    return
+
+
+# ----------------------------------------------------------------------
+if __name__ == "__main__":
+
+  usage = "%prog --file=FILE"
+  from optparse import OptionParser
+  parser = OptionParser(usage=usage)
+  parser.add_option("-f", "--file", 
+                    dest="filename",
+                    type="string", metavar="FILE",
+                    help="Create Xdmf file for HDF5 file FILE. [output.h5]",
+                    default="output.h5")
+  (options, args) = parser.parse_args()
+
+  app = GenXdmfApp()
+  app.filename = options.filename
+  app.main()
+
+
+# End of file 


Property changes on: short/3D/PyLith/trunk/applications/utilities/pylith_genxdmf
___________________________________________________________________
Name: svn:executable
   + *

Modified: short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am	2011-06-01 21:32:23 UTC (rev 18523)
@@ -36,8 +36,6 @@
 	CellFilterAvg.i \
 	DataWriter.i \
 	DataWriterVTK.i \
-	DataWriterHDF5.i \
-	DataWriterHDF5Ext.i \
 	OutputManager.i \
 	OutputSolnSubset.i
 
@@ -69,7 +67,14 @@
 	$(SWIG) $(PYLITH_SWIG_CPPFLAGS) -Wall -c++ -python $<
 endif
 
+if ENABLE_HDF5
+  swig_sources += \
+	DataWriterHDF5.i \
+	DataWriterHDF5Ext.i \
+	Xdmf.i
+endif
 
+
 MAINTAINERCLEANFILES = \
 	$(srcdir)/meshio_wrap.cxx \
 	$(srcdir)/meshio.py

Added: short/3D/PyLith/trunk/modulesrc/meshio/Xdmf.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/Xdmf.i	                        (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/Xdmf.i	2011-06-01 21:32:23 UTC (rev 18523)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/Xdmf.i
+ *
+ * @brief Python interface to C++ Xdmf object.
+ */
+
+namespace pylith {
+  namespace meshio {
+
+    class pylith::meshio::Xdmf
+    { // HDF5
+
+      // PUBLIC METHODS -------------------------------------------------
+    public :
+  
+      /// Default constructor.
+      Xdmf(void);
+      
+      /// Destructor
+      ~Xdmf(void);
+      
+      /** Write Xdmf file associated with HDF5 file.
+       *
+       * @param filenameXdmf Name of Xdmf file.
+       * @param filenameHDF5 Name of HDF5 file.
+       */
+      void write(const char* filenameXdmf,
+		 const char* filenameHDF5);
+      
+      
+    }; // Xdmf
+    
+  } // meshio
+} // pylith
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.i	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.i	2011-06-01 21:32:23 UTC (rev 18523)
@@ -40,6 +40,7 @@
 #if defined(ENABLE_HDF5)
 #include "pylith/meshio/DataWriterHDF5.hh"
 #include "pylith/meshio/DataWriterHDF5Ext.hh"
+#include "pylith/meshio/Xdmf.hh"
 #endif
 
 #include "pylith/utils/arrayfwd.hh"
@@ -78,6 +79,7 @@
 #if defined(ENABLE_HDF5)
 %include "DataWriterHDF5.i"
 %include "DataWriterHDF5Ext.i"
+%include "Xdmf.i"
 #endif
 
 // Template instatiation

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2011-06-01 21:32:23 UTC (rev 18523)
@@ -189,7 +189,8 @@
 	meshio/DataWriterHDF5Ext.py \
 	meshio/DataWriterHDF5ExtMesh.py \
 	meshio/DataWriterHDF5ExtSubMesh.py \
-	meshio/DataWriterHDF5ExtSubSubMesh.py
+	meshio/DataWriterHDF5ExtSubSubMesh.py \
+	meshio/Xdmf.py
 endif
 
 if ENABLE_CUDA

Added: short/3D/PyLith/trunk/pylith/meshio/Xdmf.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/Xdmf.py	                        (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/Xdmf.py	2011-06-01 21:32:23 UTC (rev 18523)
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/Xdmf.py
+##
+## @brief Python class for Xdmf metadata file associated with an HDF5 file.
+##
+## Factory: xdmf
+
+from pylith.utils.PetscComponent import PetscComponent
+from meshio import Xdmf as ModuleXdmf
+
+# Xdmf class
+class Xdmf(PetscComponent, ModuleXdmf):
+  """
+  Python class for Xdmf metadata file associated with an HDF5 file.
+
+  \b Properties
+  @li \b filename Name of HDF5 file.
+  
+  \b Facilities
+  @li None
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  import pyre.inventory
+
+  filename = pyre.inventory.str("filename", default="output.h5")
+  filename.meta['tip'] = "Name of HDF5 file."
+  
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="xdmf"):
+    """
+    Constructor.
+    """
+    PetscComponent.__init__(self, name, facility="xdmf")
+    self._loggingPrefix = "Xdmf "
+
+    ModuleXdmf.__init__(self)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    PetscComponent._configure(self)
+    self.filename = self.inventory.filename
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/meshio/TestXdmf.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestXdmf.py	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestXdmf.py	2011-06-01 21:32:23 UTC (rev 18523)
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestXdmf.py
+
+## @brief Unit testing of Python Xdmf object.
+
+import unittest
+
+from pylith.meshio.Xdmf import Xdmf
+
+# ----------------------------------------------------------------------
+class TestXdmf(unittest.TestCase):
+  """
+  Unit testing of Python OutputManagerMesh object.
+  """
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    writer = Xdmf()
+    writer._configure()
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/testhdf5.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testhdf5.py	2011-06-01 16:54:34 UTC (rev 18522)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testhdf5.py	2011-06-01 21:32:23 UTC (rev 18523)
@@ -69,6 +69,9 @@
     from TestDataWriterHDF5 import TestDataWriterHDF5SubSubMesh
     suite.addTest(unittest.makeSuite(TestDataWriterHDF5SubSubMesh))
 
+    from TestXdmf import TestXdmf
+    suite.addTest(unittest.makeSuite(TestXdmf))
+
     return suite
 
 



More information about the CIG-COMMITS mailing list