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

brad at geodynamics.org brad at geodynamics.org
Sat Jan 12 16:31:30 PST 2008


Author: brad
Date: 2008-01-12 16:31:29 -0800 (Sat, 12 Jan 2008)
New Revision: 9000

Added:
   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/libsrc/Makefile.am
   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/Makefile.am
   short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
   short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
Log:
Worked on OutputManager and DataWriter implementations.

Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am	2008-01-13 00:31:29 UTC (rev 9000)
@@ -78,6 +78,7 @@
 	meshio/MeshIO.cc \
 	meshio/MeshIOAscii.cc \
 	meshio/MeshIOLagrit.cc \
+	meshio/OutputFilter.cc \
 	meshio/OutputManager.cc \
 	meshio/PsetFile.cc \
 	meshio/PsetFileAscii.cc \

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-01-13 00:31:29 UTC (rev 9000)
@@ -83,27 +83,27 @@
   /** Write field over vertices to file.
    *
    * @param t Time associated with field.
+   * @param name Name of field.
    * @param field PETSc field over vertices.
    * @param mesh Finite-element mesh
-   * @param name Name of field.
    */
   virtual
   void writeVertexField(const double t,
+			const char* name,
 			const ALE::Obj<real_section_type>& field,
-			const char* name,
 			const ALE::Obj<ALE::Mesh>& mesh) = 0;
 
   /** Write field over cells to file.
    *
    * @param t Time associated with field.
+   * @param name Name of field.
    * @param field PETSc field over cells.
-   * @param name Name of field.
    * @param mesh PETSc mesh object.
    */
   virtual
   void writeCellField(const double t,
+		      const char* name,
 		      const ALE::Obj<real_section_type>& field,
-		      const char* name,
 		      const ALE::Obj<ALE::Mesh>& mesh) = 0;
 
 // PROTECTED MEMBERS ////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-01-13 00:31:29 UTC (rev 9000)
@@ -99,10 +99,12 @@
 void
 pylith::meshio::DataWriterVTK::writeVertexField(
 				       const double t,
+				       const char* name,
 				       const ALE::Obj<real_section_type>& field,
-				       const char* name,
 				       const ALE::Obj<ALE::Mesh>& mesh)
 { // writeVertexField
+  assert(0 != name);
+
   try {
     std::ostringstream buffer;
     buffer.str("");
@@ -133,10 +135,12 @@
 void
 pylith::meshio::DataWriterVTK::writeCellField(
 				       const double t,
+				       const char* name,
 				       const ALE::Obj<real_section_type>& field,
-				       const char* name,
 				       const ALE::Obj<ALE::Mesh>& mesh)
 { // writeCellField
+  assert(0 != name);
+
   try {
     PetscErrorCode err = 0;
 

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-01-13 00:31:29 UTC (rev 9000)
@@ -67,25 +67,25 @@
   /** Write field over vertices to file.
    *
    * @param t Time associated with field.
+   * @param name Name of field.
    * @param field PETSc field over vertices.
    * @param mesh Finite-element mesh
-   * @param name Name of field.
    */
   void writeVertexField(const double t,
+			const char* name,
 			const ALE::Obj<real_section_type>& field,
-			const char* name,
 			const ALE::Obj<ALE::Mesh>& mesh);
 
   /** Write field over cells to file.
    *
    * @param t Time associated with field.
+   * @param name Name of field.
    * @param field PETSc field over cells.
-   * @param name Name of field.
    * @param mesh PETSc mesh object.
    */
   void writeCellField(const double t,
+		      const char* name,
 		      const ALE::Obj<real_section_type>& field,
-		      const char* name,
 		      const ALE::Obj<ALE::Mesh>& mesh);
 
 // PRIVATE MEMBERS //////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am	2008-01-13 00:31:29 UTC (rev 9000)
@@ -21,6 +21,9 @@
 	MeshIOAscii.icc \
 	MeshIOLagrit.hh \
 	MeshIOLagrit.icc \
+	OutputFilter.hh \
+	OutputFilter.icc \
+	OutputManager.hh \
 	SolutionIO.hh \
 	SolutionIOVTK.hh \
 	SolutionIOVTK.icc

Added: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.cc	2008-01-13 00:31:29 UTC (rev 9000)
@@ -0,0 +1,48 @@
+// -*- 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

Added: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.hh	2008-01-13 00:31:29 UTC (rev 9000)
@@ -0,0 +1,102 @@
+// -*- 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 

Added: short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputFilter.icc	2008-01-13 00:31:29 UTC (rev 9000)
@@ -0,0 +1,25 @@
+// -*- 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-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc	2008-01-13 00:31:29 UTC (rev 9000)
@@ -15,11 +15,8 @@
 #include "OutputManager.hh" // implementation of class methods
 
 #include "DataWriter.hh" // HOLDSA DataWriter
+#include "OutputFilter.hh" // HOLDS OutputFilter
 #include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#if 0 // TEMPORARY
-#include "VertexFilter.hh" // HOLDS VertexFilter
-#include "CellFilter.hh" // HOLDS CellFilter
-#endif // TEMPORARY
 
 // ----------------------------------------------------------------------
 // Constructor
@@ -35,30 +32,70 @@
 pylith::meshio::OutputManager::~OutputManager(void)
 { // destructor
   delete _writer; _writer = 0;
-#if 0 // TEMPORARY
   delete _vertexFilter; _vertexFilter = 0;
   delete _cellFilter; _cellFilter = 0;
-#endif // TEMPORARY
 } // destructor  
 
 // ----------------------------------------------------------------------
+// Set which vertex fields to output.
+void
+pylith::meshio::OutputManager::vertexFields(const char** names,
+					    const char** labels,
+					    const int numFields)
+{ // vertexFields
+  assert( (0 == numFields && 0 == names && 0 == labels) ||
+	  (0 < numFields && 0 != names && 0 != labels) );
+
+  _vertexFields.clear();
+  for (int iField=0; iField < numFields; ++iField)
+    _vertexFields[names[iField]] = _vertexFields[labels[iField]];
+} // vertexFields
+
+// ----------------------------------------------------------------------
+// Set which cell fields to output.
+void
+pylith::meshio::OutputManager::cellFields(const char** names,
+					  const char** labels,
+					  const int numFields)
+{ // cellFields
+  assert( (0 == numFields && 0 == names && 0 == labels) ||
+	  (0 < numFields && 0 != names && 0 != labels) );
+
+  _cellFields.clear();
+  for (int iField=0; iField < numFields; ++iField)
+    _cellFields[names[iField]] = _cellFields[labels[iField]];
+} // cellFields
+
+// ----------------------------------------------------------------------
+// Get vertex fields to output.
+const pylith::meshio::OutputManager::map_names_type&
+pylith::meshio::OutputManager::vertexFields(void) const
+{ // vertexFields
+  return _vertexFields;
+} // vertexFields
+
+// ----------------------------------------------------------------------
+// Get cell fields to output.
+const pylith::meshio::OutputManager::map_names_type&
+pylith::meshio::OutputManager::cellFields(void) const
+{ // cellFields
+  return _cellFields;
+} // cellFields
+
+// ----------------------------------------------------------------------
 // Set filter for vertex data.
 void
-pylith::meshio::OutputManager::vertexFilter(const VertexFilter* filter)
+pylith::meshio::OutputManager::vertexFilter(const OutputFilter* filter)
 { // vertexFilter
-#if 0 // TEMPORARY
   delete _vertexFilter; _vertexFilter = (0 != filter) ? filter->clone() : 0;
-#endif // TEMPORARY
 } // vertexFilter
 
 // ----------------------------------------------------------------------
 // Set filter for cell data.
 void
-pylith::meshio::OutputManager::cellFilter(const CellFilter* filter)
+pylith::meshio::OutputManager::cellFilter(const OutputFilter* filter)
 { // cellFilter
-#if 0 // TEMPORARY
   delete _cellFilter; _cellFilter = (0 != filter) ? filter->clone() : 0;
-#endif // TEMPORARY
 } // cellFilter
 
 // ----------------------------------------------------------------------
@@ -95,7 +132,6 @@
   assert(0 != fields);
 
   _writer->openTimeStep(t, mesh, csMesh);
-
   
   for (map_names_type::iterator f_iter=_vertexFields.begin();
        f_iter != _vertexFields.end();
@@ -104,12 +140,10 @@
     const char* fieldLabel = f_iter->second.c_str();
     const ALE::Obj<real_section_type>& field = fields->getReal(fieldLabel);
 
-#if 0
     const ALE::Obj<real_section_type>& fieldFiltered = 
-      (0 != _vertexFilter) ? field : _vertexFilter->filter(field);
+      (0 != _vertexFilter) ? field : _vertexFilter->filter(field, mesh);
 
     _writer->writeVertexField(t, fieldFiltered, fieldName, mesh);
-#endif
   } // for
 
   for (map_names_type::iterator f_iter=_cellFields.begin();
@@ -119,16 +153,68 @@
     const char* fieldLabel = f_iter->second.c_str();
     const ALE::Obj<real_section_type>& field = fields->getReal(fieldLabel);
     
-#if 0
     const ALE::Obj<real_section_type>& fieldFiltered = 
-      (0 != _cellFilter) ? field : _cellFilter->filter(field);
+      (0 != _cellFilter) ? field : _cellFilter->filter(field, mesh);
 
     _writer->writeCellField(t, fieldFiltered, fieldName, mesh);
-#endif
   } // for
 
   _writer->closeTimeStep();
 } // writeFields
 
+// ----------------------------------------------------------------------
+// Setup file for writing fields at time step.
+void
+pylith::meshio::OutputManager::openTimeStep(const double t,
+	     const ALE::Obj<ALE::Mesh>& mesh,
+	     const spatialdata::geocoords::CoordSys* csMesh)
+{ // openTimeStep
+  assert(0 != _writer);
+  _writer->openTimeStep(t, mesh, csMesh);
+} // openTimeStep
 
+// ----------------------------------------------------------------------
+// End writing fields at time step.
+void
+pylith::meshio::OutputManager::closeTimeStep(void)
+{ // closeTimeStep
+  assert(0 != _writer);
+  _writer->closeTimeStep();
+} // closeTimeStep
+
+// ----------------------------------------------------------------------
+// Append finite-element vertex field to file.
+void
+pylith::meshio::OutputManager::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)
+{ // appendVertexField
+  assert(0 != name);
+
+  const ALE::Obj<real_section_type>& fieldFiltered = 
+    (0 != _vertexFilter) ? field : _vertexFilter->filter(field, mesh);
+
+  _writer->writeVertexField(t, fieldFiltered, name, mesh);
+} // appendVertexField
+
+// ----------------------------------------------------------------------
+// Append finite-element cell field to file.
+void
+appendCellField(const double t,
+		const ALE::Obj<real_section_type>& field,
+		const ALE::Obj<ALE::Mesh>& mesh,
+		const spatialdata::geocoords::CoordSys* csMesh)
+{ // appendCellField
+  assert(0 != name);
+
+  const ALE::Obj<real_section_type>& fieldFiltered = 
+    (0 != _cellFilter) ? field : _cellFilter->filter(field, mesh);
+
+  _writer->writeCellField(t, fieldFiltered, name, mesh);
+} // appendCellField
+
+
 // End of file 

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-11 21:20:42 UTC (rev 8999)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-01-13 00:31:29 UTC (rev 9000)
@@ -27,8 +27,7 @@
     class OutputManager;
 
     class DataWriter; // HOLDS DataWriter
-    class VertexFilter; // HOLDSA VertexFilter
-    class CellFilter; // HOLDSA CellFilter
+    class OutputFilter; // HOLDSA OutputFilter
   } // meshio
 
   namespace topology {
@@ -48,6 +47,7 @@
 // PUBLIC METHODS ///////////////////////////////////////////////////////
 public :
 
+  /// Map to hold field names and mesh labels (name -> label).
   typedef std::map<std::string, std::string> map_names_type;
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -67,27 +67,47 @@
 
   /** Set which vertex fields to output.
    *
-   * @param fields Map of names and field labels.
+   * @param names Names of fields.
+   * @param labels Mesh labels of fields.
+   * @param numFields Number of fields.
    */
-  void vertexFields(const map_names_type& fields);
+  void vertexFields(const char** names,
+		    const char** labels,
+		    const int numFields);
 
   /** Set which cell fields to output.
    *
-   * @param fields Map of names and field labels.
+   * @param names Names of fields.
+   * @param labels Mesh labels of fields.
+   * @param numFields Number of fields.
    */
-  void cellFields(const map_names_type& fields);
+  void cellFields(const char** names,
+		  const char** labels,
+		  const int numFields);
 
+  /** Get vertex fields to output.
+   *
+   * @returns Map of field name to mesh label for fields.
+   */
+  const map_names_type& vertexFields(void) const;
+
+  /** Get cell fields to output.
+   *
+   * @returns Map of field name to mesh label for fields.
+   */
+  const map_names_type& cellFields(void) const;
+
   /** Set filter for vertex data.
    *
    * @param filter Filter to apply to vertex data before writing.
    */
-  void vertexFilter(const VertexFilter* filter);
+  void vertexFilter(const OutputFilter* filter);
 
   /** Set filter for cell data.
    *
    * @param filter Filter to apply to cell data before writing.
    */
-  void cellFilter(const CellFilter* filter);
+  void cellFilter(const OutputFilter* filter);
 
   /** Prepare for output.
    *
@@ -112,6 +132,43 @@
 		   const ALE::Obj<ALE::Mesh>& mesh,
 		   const spatialdata::geocoords::CoordSys* csMesh);
 
+  /** Setup file for writing fields at time step.
+   *
+   * @param t Time of time step.
+   * @param mesh PETSc mesh object.
+   * @param csMesh Coordinate system of mesh geometry
+   */
+  void openTimeStep(const double t,
+	       const ALE::Obj<ALE::Mesh>& mesh,
+	       const spatialdata::geocoords::CoordSys* csMesh);
+
+  /// End writing fields at time step.
+  void closeTimeStep(void);
+
+  /** Append finite-element vertex field to file.
+   *
+   * @param t Time associated with field.
+   * @param field Vertex field.
+   * @param mesh PETSc mesh object.
+   * @param csMesh Coordinate system of mesh geometry
+   */
+  void appendVertexField(const double t,
+			 const ALE::Obj<real_section_type>& field,
+			 const ALE::Obj<ALE::Mesh>& mesh,
+			 const spatialdata::geocoords::CoordSys* csMesh);
+
+  /** Append finite-element cell field to file.
+   *
+   * @param t Time associated with field.
+   * @param field Cell field.
+   * @param mesh PETSc mesh object.
+   * @param csMesh Coordinate system of mesh geometry
+   */
+  void appendCellField(const double t,
+		       const ALE::Obj<real_section_type>& field,
+		       const ALE::Obj<ALE::Mesh>& mesh,
+		       const spatialdata::geocoords::CoordSys* csMesh);
+
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 
 private :
@@ -123,8 +180,8 @@
   map_names_type _cellFields;
 
   DataWriter* _writer; ///< Writer for data
-  VertexFilter* _vertexFilter; ///< Filter applied to vertex data
-  CellFilter* _cellFilter; ///< Filter applied to cell data
+  OutputFilter* _vertexFilter; ///< Filter applied to vertex data
+  OutputFilter* _cellFilter; ///< Filter applied to cell data
 
 }; // OutputManager
 



More information about the cig-commits mailing list