[cig-commits] r6847 - in short/3D/PyLith/trunk/pylith: . meshio

brad at geodynamics.org brad at geodynamics.org
Thu May 10 17:48:16 PDT 2007


Author: brad
Date: 2007-05-10 17:48:16 -0700 (Thu, 10 May 2007)
New Revision: 6847

Added:
   short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py
   short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py
Modified:
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/meshio/__init__.py
Log:
Started setting up top-level code for VTK output.

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2007-05-10 23:30:11 UTC (rev 6846)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2007-05-11 00:48:16 UTC (rev 6847)
@@ -50,11 +50,13 @@
 	materials/Homogeneous.py \
 	materials/Material.py \
 	materials/MaterialsBin.py \
+	meshio/__init__.py \
 	meshio/MeshIO.py \
 	meshio/MeshIOAscii.py \
 	meshio/MeshIOCubit.py \
 	meshio/MeshIOLagrit.py \
-	meshio/__init__.py \
+	meshio/SolutionIO.py \
+	meshio/SolutionIOVTK.py \
 	problems/__init__.py \
 	problems/BCPrism.py \
 	problems/BCQuadrilateral.py \

Added: short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py	2007-05-10 23:30:11 UTC (rev 6846)
+++ short/3D/PyLith/trunk/pylith/meshio/SolutionIO.py	2007-05-11 00:48:16 UTC (rev 6847)
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/SolutionIO.py
+##
+## @brief Python abstract base class for I/O of the finite-element
+## solution.
+##
+## Factory: solution_io
+
+from pyre.components.Component import Component
+
+# SolutionIO class
+class SolutionIO(Component):
+  """
+  Python abstract base class for finite-element mesh I/O.
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(SolutionIO.Inventory):
+    """
+    Python object for managing SolutionIOVTK facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing SolutionIOVTK facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li \b coordsys Coordinate system for output.
+
+    import pyre.inventory
+
+    from spatialdata.geocoords.CSCart import CSCart
+    coordsys = pyre.inventory.facility("coordsys", family="coordsys",
+                                       factory=CSCart)
+    coordsys.meta['tip'] = "Coordinate system for output."
+  
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="solutionio"):
+    """
+    Constructor.
+    """
+    Component.__init__(self, name, facility="solution_io")
+    self.cppHandle = None
+    self.coordsys = None
+    return
+
+
+  def write(self, t, fields, mesh):
+    """
+    Write solution at time t to file.
+    """
+    self._info.log("Writing solution information.")
+
+    # Set flags
+    self._sync()
+
+    # Initialize coordinate system
+    if self.coordsys is None:
+      raise ValueError, "Coordinate system for mesh is unknown."
+    self.coordsys.initialize()
+
+    #self.cppHandle.write(t, fields, mesh.cppHandle)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    Component._configure(self)
+    self.coordsys = self.inventory.coordsys
+    return
+
+
+  def _sync(self):
+    """
+    Force synchronization between Python and C++.
+    """
+    #self.cppHandle.coordsys = self.coordsys
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py	2007-05-10 23:30:11 UTC (rev 6846)
+++ short/3D/PyLith/trunk/pylith/meshio/SolutionIOVTK.py	2007-05-11 00:48:16 UTC (rev 6847)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/SolutionIOVTK.py
+##
+## @brief Python object for writing solution of finite-element problem
+## to VTK file.
+##
+## Factory: solution_io
+
+from SolutionIO import SolutionIO
+
+# SolutionIOVTK class
+class SolutionIOVTK(SolutionIO):
+  """
+  Python object for writing solution of finite-element problem to VTK file.
+
+  Factory: solution_io
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(SolutionIO.Inventory):
+    """
+    Python object for managing SolutionIOVTK facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing SolutionIOVTK facilities and properties.
+    ##
+    ## \b Properties
+    ## @li \b filename Name of mesh file
+    ##
+    ## \b Facilities
+    ## @li None
+
+    import pyre.inventory
+
+    filename = pyre.inventory.str("filename", default="output.vtk")
+    filename.meta['tip'] = "Name of VTK file."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="solutioniovtk"):
+    """
+    Constructor.
+    """
+    SolutionIO.__init__(self, name)
+    #import pylith.meshio.meshio as bindings
+    #self.cppHandle = bindings.SolutionIOVTK()
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    SolutionIO._configure(self)
+    self.filename = self.inventory.filename
+    return
+
+
+  def _sync(self):
+    """
+    Force synchronization between Python and C++.
+    """
+    SolutionIO._sync(self)
+    self.cppHandle.filename = self.filename
+    return
+  
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def solution_io():
+  """
+  Factory associated with SolutionIOVTK.
+  """
+  return SolutionIOVTK()
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/pylith/meshio/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/__init__.py	2007-05-10 23:30:11 UTC (rev 6846)
+++ short/3D/PyLith/trunk/pylith/meshio/__init__.py	2007-05-11 00:48:16 UTC (rev 6847)
@@ -17,7 +17,9 @@
 __all__ = ['MeshIO',
            'MeshIOAscii',
            'MeshIOCubit',
-           'MeshIOLagrit']
+           'MeshIOLagrit'
+           'SolutionIO',
+           'SolutionIOVTK']
 
 
 # End of file



More information about the cig-commits mailing list