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

brad at geodynamics.org brad at geodynamics.org
Sun Jan 13 15:12:55 PST 2008


Author: brad
Date: 2008-01-13 15:12:55 -0800 (Sun, 13 Jan 2008)
New Revision: 9007

Added:
   short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc
   short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh
   short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc
   short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh
   short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
   short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py
Removed:
   short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc
   short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh
   short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc
Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/libsrc/Makefile.am
   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/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
   short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
   short/3D/PyLith/trunk/pylith/meshio/__init__.py
Log:
Worked on output (Python and C++). Still need to work on bindings.

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/TODO	2008-01-13 23:12:55 UTC (rev 9007)
@@ -24,8 +24,8 @@
      g. Implement output of solution subset (ground surface).
         i. OutputSubdomain
         ii. OutputPoints
-     h. OutputManager/DataWriter
-        i. Implement support for writing vertex coordinates in another 
+     h. VertexFilterChangeCS
+        i. OutputFilter for writing vertex coordinates in another 
            coordinate system.
      i. DataWriterHDF5
 

Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am	2008-01-13 23:12:55 UTC (rev 9007)
@@ -70,6 +70,7 @@
 	materials/MaxwellIsotropic3D.cc \
 	materials/ViscoelasticMaxwell.cc \
 	meshio/BinaryIO.cc \
+	meshio/CellFilter.cc \
 	meshio/DataWriter.cc \
 	meshio/DataWriterVTK.cc \
 	meshio/GMVFile.cc \
@@ -78,13 +79,13 @@
 	meshio/MeshIO.cc \
 	meshio/MeshIOAscii.cc \
 	meshio/MeshIOLagrit.cc \
-	meshio/OutputFilter.cc \
 	meshio/OutputManager.cc \
 	meshio/PsetFile.cc \
 	meshio/PsetFileAscii.cc \
 	meshio/PsetFileBinary.cc \
 	meshio/SolutionIO.cc \
 	meshio/SolutionIOVTK.cc \
+	meshio/VertexFilter.cc \
 	topology/FieldsManager.cc \
 	topology/Distributor.cc \
 	utils/EventLogger.cc

Added: short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "CellFilter.hh" // implementation of class methods
+
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::CellFilter::CellFilter(void) :
+  _quadrature(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::CellFilter::~CellFilter(void)
+{ // destructor
+  delete _quadrature; _quadrature = 0;
+} // destructor  
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::meshio::CellFilter::CellFilter(const CellFilter& f) :
+  _quadrature(0)
+{ // copy constructor
+  if (0 != f._quadrature)
+    _quadrature = f._quadrature->clone();
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// operator=.
+const pylith::meshio::CellFilter&
+pylith::meshio::CellFilter::operator=(const CellFilter& f)
+{ // operator=
+  if (&f != this) {
+    delete _quadrature; 
+    _quadrature = (0 != f._quadrature) ? f._quadrature->clone() : 0;
+  } // if
+} // operator=
+
+// ----------------------------------------------------------------------
+// Set quadrature associated with cells.
+void
+pylith::meshio::CellFilter::quadrature(const feassemble::Quadrature* q)
+{ // quadrature
+    delete _quadrature; _quadrature = (0 != q) ? q->clone() : 0;
+} // quadrature
+
+
+// End of file

Added: short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/meshio/CellFilter.hh
+ *
+ * @brief C++ object for filtering cell fields when outputing
+ * finite-element data.
+ */
+
+#if !defined(pylith_meshio_cellfilter_hh)
+#define pylith_meshio_cellfilter_hh
+
+#include "pylith/utils/sievetypes.hh" // USES ALE::Mesh, real_section_type
+
+namespace pylith {
+  namespace meshio {
+    class CellFilter;
+  } // meshio
+
+  namespace feassemble {
+    class Quadrature;
+  } // meshio  
+} // pylith
+
+class pylith::meshio::CellFilter
+{ // CellFilter
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+  /// Constructor
+  CellFilter(void);
+
+  /// Destructor
+  ~CellFilter(void);
+
+  /** Create copy of filter.
+   *
+   * @returns Copy of filter.
+   */
+  virtual
+  CellFilter* clone(void) const = 0;
+
+  /** Set quadrature associated with cells.
+   *
+   * @param q Quadrature for cells.
+   */
+  void quadrature(const feassemble::Quadrature* q);
+
+  /** Filter field.
+   *
+   * @param fieldIn Field to filter.
+   * @param mesh PETSc mesh.
+   */
+  virtual
+  const ALE::Obj<real_section_type>&
+  filter(const ALE::Obj<real_section_type>& fieldIn,
+	 const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+  /** Copy constructor.
+   *
+   * @param f Filter to copy.
+   * @returns Pointer to this.
+   */
+  CellFilter(const CellFilter& f);
+
+  /** operator=.
+  *
+  * @param f Filter to copy.
+  * @returns Copy of filter.
+  */
+  const CellFilter& operator=(const CellFilter& f);
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+  feassemble::Quadrature* _quadrature; ///< Quadrature associated with cells.
+
+}; // CellFilter
+
+#endif // pylith_meshio_cellfilter_hh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-13 23:12:55 UTC (rev 9007)
@@ -14,19 +14,20 @@
 include $(top_srcdir)/subpackage.am
 
 subpkginclude_HEADERS = \
+	CellFilter.hh \
 	DataWriter.hh \
+	DataWriterVTK.hh \
 	MeshIO.hh \
 	MeshIO.icc \
 	MeshIOAscii.hh \
 	MeshIOAscii.icc \
 	MeshIOLagrit.hh \
 	MeshIOLagrit.icc \
-	OutputFilter.hh \
-	OutputFilter.icc \
 	OutputManager.hh \
 	SolutionIO.hh \
 	SolutionIOVTK.hh \
-	SolutionIOVTK.icc
+	SolutionIOVTK.icc \
+	VertexFilter.hh
 
 if ENABLE_CUBIT
   subpkginclude_HEADERS += \

Deleted: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc	2008-01-13 23:12:55 UTC (rev 9007)
@@ -1,48 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-//                           Brad T. Aagaard
-//                        U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "OutputFilter.hh" // implementation of class methods
-
-// ----------------------------------------------------------------------
-// Constructor
-pylith::meshio::OutputFilter::OutputFilter(void) :
-  _filterType(VERTEX_FILTER)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor
-pylith::meshio::OutputFilter::~OutputFilter(void)
-{ // destructor
-} // destructor  
-
-// ----------------------------------------------------------------------
-// Copy constructor.
-pylith::meshio::OutputFilter::OutputFilter(const OutputFilter& f) :
-  _filterType(f._filterType)
-{ // copy constructor
-} // copy constructor
-
-// ----------------------------------------------------------------------
-// operator=.
-const pylith::meshio::OutputFilter&
-pylith::meshio::OutputFilter::operator=(const OutputFilter& f)
-{ // operator=
-  if (this != &f) {
-    _filterType = f._filterType;
-  } // if
-} // operator=
-
-
-// End of file

Deleted: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh	2008-01-13 23:12:55 UTC (rev 9007)
@@ -1,102 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-//                           Brad T. Aagaard
-//                        U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/meshio/OutputFilter.hh
- *
- * @brief C++ object for filtering finite-element output fields.
- */
-
-#if !defined(pylith_meshio_outputfilter_hh)
-#define pylith_meshio_outputfilter_hh
-
-#include "pylith/utils/sievetypes.hh" // USES ALE::Mesh, real_section_type
-
-namespace pylith {
-  namespace meshio {
-    class OutputFilter;
-  } // meshio
-
-} // pylith
-
-class pylith::meshio::OutputFilter
-{ // OutputFilter
-
-// PUBLIC ENUMS /////////////////////////////////////////////////////////
-public :
-
-  /// Type of filter.
-  enum FilterEnum { 
-    VERTEX_FILTER, ///< Filter vertex field.
-    CELL_FILTER ///< Filter cell field.
-  };
-
-// PUBLIC METHODS ///////////////////////////////////////////////////////
-public :
-
-  /// Constructor
-  OutputFilter(void);
-
-  /// Destructor
-  ~OutputFilter(void);
-
-  /** Create copy of filter.
-   *
-   * @returns Copy of filter.
-   */
-  virtual
-  OutputFilter* clone(void) const = 0;
-
-  /** Get filter type.
-   *
-   * @returns Type of filter.
-   */
-  FilterEnum filterType(void) const;
-
-  /** Filter field.
-   *
-   * @param fieldIn Field to filter.
-   * @param mesh PETSc mesh.
-   */
-  virtual
-  const ALE::Obj<real_section_type>&
-  filter(const ALE::Obj<real_section_type>& fieldIn,
-	 const ALE::Obj<ALE::Mesh>& mesh) = 0;
-
-// PROTECTED METHODS ////////////////////////////////////////////////////
-protected :
-
-  /** Copy constructor.
-   *
-   * @param f Filter to copy.
-   * @returns Pointer to this.
-   */
-  OutputFilter(const OutputFilter& f);
-
-  /** operator=.
-  *
-  * @param f Filter to copy.
-  * @returns Copy of filter.
-  */
-  const OutputFilter& operator=(const OutputFilter& f);
-
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
-
-  FilterEnum _filterType; ///< Type of filter.
-
-}; // OutputFilter
-
-#endif // pylith_meshio_outputfilter_hh
-
-
-// End of file 

Deleted: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc	2008-01-13 23:12:55 UTC (rev 9007)
@@ -1,25 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-//                           Brad T. Aagaard
-//                        U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_outputfilter_hh)
-#error OutputFilter.icc must only be included from OutputFilter.hh
-#endif
-
-// Get filter type.
-inline
-pylith::meshio::OutputFilter::FilterEnum
-pylith::meshio::OutputFilter::filterType(void) const {
-  return _filterType;
-}
-
-
-// End of file

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc	2008-01-13 23:12:55 UTC (rev 9007)
@@ -14,8 +14,9 @@
 
 #include "OutputManager.hh" // implementation of class methods
 
-#include "DataWriter.hh" // HOLDSA DataWriter
-#include "OutputFilter.hh" // HOLDS OutputFilter
+#include "DataWriter.hh" // USES DataWriter
+#include "VertexFilter.hh" // USES VertexFilter
+#include "CellFilter.hh" // USES CellFilter
 #include "pylith/topology/FieldsManager.hh" // USES FieldsManager
 
 // ----------------------------------------------------------------------
@@ -85,7 +86,7 @@
 // ----------------------------------------------------------------------
 // Set filter for vertex data.
 void
-pylith::meshio::OutputManager::vertexFilter(const OutputFilter* filter)
+pylith::meshio::OutputManager::vertexFilter(const VertexFilter* filter)
 { // vertexFilter
   delete _vertexFilter; _vertexFilter = (0 != filter) ? filter->clone() : 0;
 } // vertexFilter
@@ -93,7 +94,7 @@
 // ----------------------------------------------------------------------
 // Set filter for cell data.
 void
-pylith::meshio::OutputManager::cellFilter(const OutputFilter* filter)
+pylith::meshio::OutputManager::cellFilter(const CellFilter* filter)
 { // cellFilter
   delete _cellFilter; _cellFilter = (0 != filter) ? filter->clone() : 0;
 } // cellFilter

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-13 23:12:55 UTC (rev 9007)
@@ -27,7 +27,8 @@
     class OutputManager;
 
     class DataWriter; // HOLDS DataWriter
-    class OutputFilter; // HOLDSA OutputFilter
+    class CellFilter; // HOLDSA CellFilter
+    class VertexFilter; // HOLDSA VertexFilter
   } // meshio
 
   namespace topology {
@@ -101,13 +102,13 @@
    *
    * @param filter Filter to apply to vertex data before writing.
    */
-  void vertexFilter(const OutputFilter* filter);
+  void vertexFilter(const VertexFilter* filter);
 
   /** Set filter for cell data.
    *
    * @param filter Filter to apply to cell data before writing.
    */
-  void cellFilter(const OutputFilter* filter);
+  void cellFilter(const CellFilter* filter);
 
   /** Prepare for output.
    *
@@ -184,8 +185,8 @@
   map_names_type _cellFields;
 
   DataWriter* _writer; ///< Writer for data
-  OutputFilter* _vertexFilter; ///< Filter applied to vertex data
-  OutputFilter* _cellFilter; ///< Filter applied to cell data
+  VertexFilter* _vertexFilter; ///< Filter applied to vertex data
+  CellFilter* _cellFilter; ///< Filter applied to cell data
 
 }; // OutputManager
 

Copied: short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc (from rev 9000, short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc	2008-01-13 00:31:29 UTC (rev 9000)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "VertexFilter.hh" // implementation of class methods
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::VertexFilter::VertexFilter(void)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::VertexFilter::~VertexFilter(void)
+{ // destructor
+} // destructor  
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::meshio::VertexFilter::VertexFilter(const VertexFilter& f)
+{ // copy constructor
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// operator=.
+const pylith::meshio::VertexFilter&
+pylith::meshio::VertexFilter::operator=(const VertexFilter& f)
+{ // operator=
+} // operator=
+
+
+// End of file

Copied: short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh (from rev 9000, short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh	2008-01-13 00:31:29 UTC (rev 9000)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/meshio/VertexFilter.hh
+ *
+ * @brief C++ object for filtering vertex fields when outputing
+ * finite-element data.
+ */
+
+#if !defined(pylith_meshio_vertexfilter_hh)
+#define pylith_meshio_vertexfilter_hh
+
+#include "pylith/utils/sievetypes.hh" // USES ALE::Mesh, real_section_type
+
+namespace pylith {
+  namespace meshio {
+    class VertexFilter;
+  } // meshio
+
+} // pylith
+
+class pylith::meshio::VertexFilter
+{ // VertexFilter
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+  /// Constructor
+  VertexFilter(void);
+
+  /// Destructor
+  ~VertexFilter(void);
+
+  /** Create copy of filter.
+   *
+   * @returns Copy of filter.
+   */
+  virtual
+  VertexFilter* clone(void) const = 0;
+
+  /** Filter field.
+   *
+   * @param fieldIn Field to filter.
+   * @param mesh PETSc mesh.
+   */
+  virtual
+  const ALE::Obj<real_section_type>&
+  filter(const ALE::Obj<real_section_type>& fieldIn,
+	 const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+  /** Copy constructor.
+   *
+   * @param f Filter to copy.
+   * @returns Pointer to this.
+   */
+  VertexFilter(const VertexFilter& f);
+
+  /** operator=.
+  *
+  * @param f Filter to copy.
+  * @returns Copy of filter.
+  */
+  const VertexFilter& operator=(const VertexFilter& f);
+
+}; // VertexFilter
+
+#endif // pylith_meshio_vertexfilter_hh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2008-01-13 23:12:55 UTC (rev 9007)
@@ -75,13 +75,18 @@
 	materials/Material.py \
 	materials/MaxwellIsotropic3D.py \
 	meshio/__init__.py \
+	meshio/CellFilter.py \
+	meshio/DataWriter.py \
+	meshio/DataWriterVTK.py \
 	meshio/MeshIO.py \
 	meshio/MeshIOAscii.py \
 	meshio/MeshIOCubit.py \
 	meshio/MeshIOLagrit.py \
+	meshio/OutputManager.py \
 	meshio/SingleOutput.py \
 	meshio/SolutionIO.py \
 	meshio/SolutionIOVTK.py \
+	meshio/VertexFilter.py \
 	problems/__init__.py \
 	problems/Explicit.py \
 	problems/Formulation.py \

Added: short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilter.py	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilter.py	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/CellFilter.py
+##
+## @brief Python abstract base class for filtering cell fields when
+## writing finite-element data.
+##
+## Factory: output_cell_filter
+
+from pyre.components.Component import Component
+
+# CellFilter class
+class CellFilter(Component):
+  """
+  Python abstract base class for filtering cell fields when writing
+  finite-element data.
+
+  Factory: output_cell_filter
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(Component.Inventory):
+    """
+    Python object for managing CellFilter facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing CellFilter facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li None
+
+    import pyre.inventory
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="cellfilter"):
+    """
+    Constructor.
+    """
+    Component.__init__(self, name, facility="cellfilter")
+    self.cppHandle = None
+    return
+
+
+  def verifyConfiguration(self):
+    """
+    Verify compatibility of configuration.
+    """
+    return
+
+
+  def initialize(self):
+    """
+    Initialize output manager.
+    """
+    if None == self.cppHandle:
+      import pylith.meshio.meshio as bindings
+      self.cppHandle = bindings.CellFilter()
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    Component._configure(self)
+    return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_cell_filter():
+  """
+  Factory associated with CellFilter.
+  """
+  return CellFilter()
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriter.py	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriter.py	2008-01-13 23:12:55 UTC (rev 9007)
@@ -38,15 +38,10 @@
     ## @li None
     ##
     ## \b Facilities
-    ## @li \b coordsys Coordinate system for output.
+    ## @li None
 
     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 /////////////////////////////////////////////////////
 
@@ -56,8 +51,6 @@
     """
     Component.__init__(self, name, facility="datawriter")
     self.cppHandle = None
-    self.coordsys = None
-    self.mesh = None
     return
 
 
@@ -74,11 +67,6 @@
     """
     self._createCppHandle()
 
-    # Initialize coordinate system
-    if self.coordsys is None:
-      raise ValueError, "Coordinate system for output is unknown."
-    self.coordsys.initialize()
-    self.cppHandle.coordsys = self.coordsys
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-01-13 23:12:55 UTC (rev 9007)
@@ -12,8 +12,8 @@
 
 ## @file pyre/meshio/OutputManager.py
 ##
-## @brief Python abstract base class for managing output of
-## finite-element information.
+## @brief Python object for managing output of finite-element
+## information.
 ##
 ## Factory: output_manager
 
@@ -22,8 +22,7 @@
 # OutputManager class
 class OutputManager(Component):
   """
-  Python abstract base class for managing output of finite-element
-  information.
+  Python object for managing output of finite-element information.
 
   Factory: output_manager
   """
@@ -39,8 +38,8 @@
     ## Python object for managing OutputManager facilities and properties.
     ##
     ## \b Properties
-    ## @li \b vertex_fields Fields of vertex data to output.
-    ## @li \b cell_fields Fields of cell data to output.
+    ## @li \b vertex_fields Names of vertex fields to output.
+    ## @li \b cell_fields Names of cell fields to output.
     ## @li \b output_freq Flag indicating whether to use 'time_step' or 'skip'
     ##   to set frequency of solution output.
     ## @li \b time_step Time step between solution output.
@@ -48,11 +47,25 @@
     ##
     ## \b Facilities
     ## @li \b writer Writer for data.
+    ## @li \b coordsys Coordinate system for output.
     ## @li \b vertex_filter Filter for vertex data.
     ## @li \b cell_filter Filter for cell data.
 
     import pyre.inventory
 
+    outputFreq = pyre.inventory.str("output_freq", default="skip",
+             validator=pyre.inventory.choice(["skip", "time_step"]))
+    outputFreq.meta['tip'] = "Flag indicating whether to use 'time_step' " \
+                             "or 'skip' to set frequency of output."
+
+    from pyre.units.time import s
+    dt = pyre.inventory.dimensional("time_step", default=1.0*s)
+    dt.meta['tip'] = "Time step between output."
+
+    skip = pyre.inventory.int("skip", default=0,
+                              validator=pyre.inventory.greaterEqual(0))
+    skip.meta['tip'] = "Number of time steps to skip between output."
+
     vertexFields = pyre.inventory.list("vertex_fields", default=[])
     vertexFields.meta['tip'] = "Fields of vertex data to output."
 
@@ -63,11 +76,18 @@
                                      family="data_writer")
     writer.meta['tip'] = "Writer for data."
 
+    from spatialdata.geocoords.CSCart import CSCart
+    coordsys = pyre.inventory.facility("coordsys", family="coordsys",
+                                       factory=CSCart)
+    coordsys.meta['tip'] = "Coordinate system for output."
+  
+    from VertexFilter import VertexFilter
     vertexFilter = pyre.inventory.facility("vertex_filter",
                                            factory=VertexFilter,
                                            family="output_vertex_filter")
     vertexFilter.meta['tip'] = "Filter for vertex data."
                                      
+    from CellFilter import CellFilter
     cellFilter = pyre.inventory.facility("cell_filter",
                                            factory=CellFilter,
                                            family="output_cell_filter")
@@ -82,9 +102,12 @@
     """
     Component.__init__(self, name, facility="outputmanager")
     self._loggingPrefix = "OutM "
+    self.cppHandle = None
+    self.coordsys = None
+    self.mesh = None
     self._t = None
     self._istep = None
-    self.cppHandle = None
+    self._fieldTranslator = None
     return
 
 
@@ -92,13 +115,35 @@
     """
     Verify compatibility of configuration.
     """
+    # Verify fields requested for output are available by creating map
+    # of names of requested fields to mesh labels.
+    self.vertexFields = {}
+    self.cellFields = {}
+    if None != self.fieldTraslator: # TEMPORARY
+      for name in self.vertexFieldNames:
+        self.vertexFields[name] = self._fieldTranslator(name)
+      for name in self.cellFieldNames:
+        self.cellFields[name] = self._fieldTranslator(name)
     return
 
 
+  def fieldTranslator(self, translator):
+    """
+    Set function to call to translate names of fields to mesh labels.
+    """
+    self._fieldTranslator = translator
+    return
+
+
   def initialize(self, quadrature):
     """
     Initialize output manager.
     """
+    # Initialize coordinate system
+    if self.coordsys is None:
+      raise ValueError, "Coordinate system for output is unknown."
+    self.coordsys.initialize()
+
     self.cellFilter.initialize(quadrature)
     return
 
@@ -137,13 +182,13 @@
     return
 
 
-  def writeFields(self, t, istep, fields=None):
+  def writeFields(self, t, istep, fields):
     """
     Write vertex and cell fields.
 
     @param fields FieldsManager containing fields (if not in mesh).
     """
-    logEvent = "%swriteVertex" % self._loggingPrefix
+    logEvent = "%swriteFields" % self._loggingPrefix
     self._logger.eventBegin(logEvent)    
 
     write = False
@@ -169,6 +214,95 @@
     return
   
 
+  def openTimeStep(self, t, istep):
+    """
+    Prepare for writing solution to file.
+    """
+    logEvent = "%sopenStep" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)    
+    self._info.log("Preparing for writing solution to file.")
+
+    write = False
+    if self.istep == None or not "value" in dir(self.t):
+      write = True
+    elif self.outputFreq == "skip":
+      if istep > self.istep + self.skip:
+        write = True
+    elif t >= self.t + self.dt:
+      write = True
+    self.writeFlag = write
+
+    assert(self.cppHandle != None)
+    assert(self.mesh.cppHandle != None)
+    assert(self.mesh.coordsys.cppHandle != None)
+    self.cppHandle.openTimeStep(t.value,
+                                self.mesh.cppHandle,
+                                self.mesh.coordsys.cppHandle)
+
+    self._logger.eventEnd(logEvent)    
+    return
+
+
+  def closeTimeStep(self):
+    """
+    Cleanup after writing solution to file.
+    """
+    logEvent = "%scloseStep" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)    
+    self._info.log("Cleaning up afterwriting solution to file.")
+
+    if self.write:
+      self._istep = istep
+      self._t = t
+    self.writeFlag = False
+
+    assert(self.cppHandle != None)
+    self.cppHandle.closeTimeStep()
+
+    self._logger.eventEnd(logEvent)    
+    return
+
+
+  def writeVertexField(self, t, istep, name, field):
+    """
+    Write field over vertices at time t to file.
+    """
+    logEvent = "%swriteVertex" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)    
+
+    if self.writeFlag:
+      self._info.log("Writing solution field '%s'." % name)
+      assert(self.cppHandle != None)
+      assert(self.mesh.cppHandle != None)
+      self.cppHandle.writeVertexField(t.value, name, field,
+                                      self.mesh.cppHandle)
+      self.istep = istep
+      self.t = t
+
+    self._logger.eventEnd(logEvent)
+    return
+
+
+  def writeCellField(self, t, istep, name, field):
+    """
+    Write field over cells at time t to file.
+    """
+    logEvent = "%swriteCell" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)    
+
+    if self.writeFlag:
+      self._info.log("Writing solution field '%s'." % name)
+      assert(self.cppHandle != None)
+      assert(self.mesh.cppHandle != None)
+      self.cppHandle.writeCellField(t.value, name, field, 
+                                    self.mesh.cppHandle)
+      self.istep = istep
+      self.t = t
+
+    self._logger.eventEnd(logEvent)
+    return
+
+
   # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):
@@ -176,9 +310,13 @@
     Set members based using inventory.
     """
     Component._configure(self)
-    self.vertexFields = self.inventory.vertexFields
-    self.cellFields = self.inventory.cellFields
+    self.outputFreq = self.inventory.outputFreq
+    self.dt = self.inventory.dt
+    self.skip = self.inventory.skip
+    self.coordsys = self.inventory.coordsys
     self.writer = self.inventory.writer
+    self.vertexFieldsNames = self.inventory.vertexFields
+    self.cellFieldsNames = self.inventory.cellFields
     self.vertexFilter = self.inventory.vertexFilter
     self.cellFilter = self.inventory.cellFilter
     return
@@ -191,6 +329,7 @@
     if None == self.cppHandle:
       import pylith.meshio.meshio as bindings
       self.cppHandle = bindings.OutputManager()
+    self.cppHandle.coordsys = self.coordsys
     self.cppHandle.vertexFields = self.vertexFields
     self.cppHandle.cellFields = self.cellFields
     self.cppHandle.vertexFilter = self.vertexFilter.cppHandle
@@ -212,7 +351,11 @@
 
     events = ["open",
               "close",
-              "writeFields"]
+              "writeFields",
+              "openStep",
+              "closeStep",
+              "writeVertex",
+              "writeCell"]
     for event in events:
       logger.registerEvent("%s%s" % (self._loggingPrefix, event))
 

Added: short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py	2008-01-13 23:12:55 UTC (rev 9007)
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/VertexFilter.py
+##
+## @brief Python abstract base class for filtering vertex fields when
+## writing finite-element data.
+##
+## Factory: output_vertex_filter
+
+from pyre.components.Component import Component
+
+# VertexFilter class
+class VertexFilter(Component):
+  """
+  Python abstract base class for filtering cell fields when writing
+  finite-element data.
+
+  Factory: output_vertex_filter
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(Component.Inventory):
+    """
+    Python object for managing VertexFilter facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing VertexFilter facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li None
+
+    import pyre.inventory
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="vertexfilter"):
+    """
+    Constructor.
+    """
+    Component.__init__(self, name, facility="vertexfilter")
+    self.cppHandle = None
+    return
+
+
+  def verifyConfiguration(self):
+    """
+    Verify compatibility of configuration.
+    """
+    return
+
+
+  def initialize(self):
+    """
+    Initialize output manager.
+    """
+    if None == self.cppHandle:
+      import pylith.meshio.meshio as bindings
+      self.cppHandle = bindings.VertexFilter()
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    Component._configure(self)
+    return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_vertex_filter():
+  """
+  Factory associated with VertexFilter.
+  """
+  return VertexFilter()
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/pylith/meshio/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/__init__.py	2008-01-13 21:10:19 UTC (rev 9006)
+++ short/3D/PyLith/trunk/pylith/meshio/__init__.py	2008-01-13 23:12:55 UTC (rev 9007)
@@ -14,13 +14,18 @@
 ##
 ## @brief Python PyLith meshio module initialization
 
-__all__ = ['MeshIO',
+__all__ = ['CellFilter',
+           'DataWriter',
+           'DataWriterVTK',
+           'MeshIO',
            'MeshIOAscii',
            'MeshIOCubit',
            'MeshIOLagrit',
+           'OutputManager',
            'SingleOutput',
            'SolutionIO',
-           'SolutionIOVTK']
+           'SolutionIOVTK',
+           'VertexFilter']
 
 
 # End of file



More information about the cig-commits mailing list