[cig-commits] r8995 - short/3D/PyLith/trunk/libsrc/meshio
brad at geodynamics.org
brad at geodynamics.org
Tue Jan 8 17:43:59 PST 2008
Author: brad
Date: 2008-01-08 17:43:58 -0800 (Tue, 08 Jan 2008)
New Revision: 8995
Modified:
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/OutputManager.cc
short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
Log:
A little more work on reorganizing output.
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh 2008-01-08 19:14:02 UTC (rev 8994)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh 2008-01-09 01:43:58 UTC (rev 8995)
@@ -19,8 +19,7 @@
#if !defined(pylith_meshio_datawriter_hh)
#define pylith_meshio_datawriter_hh
-#include "pylith/utils/petscfwd.h" // USES PetscVec
-#include "pylith/utils/sievetypes.hh" // USES ALE::Mesh, real_section_type
+#include "pylith/utils/sievetypes.hh" // USES ALE::Obj, ALE::Mesh, real_section_type
namespace pylith {
namespace meshio {
@@ -84,24 +83,28 @@
/** Write field over vertices to file.
*
* @param t Time associated with field.
- * @param vec PETSc Vec field over vertices.
+ * @param field PETSc field over vertices.
+ * @param mesh Finite-element mesh
* @param name Name of field.
*/
virtual
void writeVertexField(const double t,
- const PetscVec* vec,
- const char* name) = 0;
+ 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 vec PETSc Vec field over cells.
+ * @param field PETSc field over cells.
* @param name Name of field.
+ * @param mesh PETSc mesh object.
*/
virtual
void writeCellField(const double t,
- const PetscVec* vec,
- const char* name) = 0;
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh) = 0;
// PROTECTED MEMBERS ////////////////////////////////////////////////////
public :
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2008-01-08 19:14:02 UTC (rev 8994)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2008-01-09 01:43:58 UTC (rev 8995)
@@ -14,8 +14,7 @@
#include "DataWriterVTK.hh" // implementation of class methods
-#include "petscmesh_viewers.hh" // USES VTKViewer
-#include "petscvec.h" // USES Petsc Vec
+#include <petscmesh_viewers.hh> // USES VTKViewer
#include <assert.h> // USES assert()
#include <sstream> // USES std::ostringstream
@@ -98,9 +97,11 @@
// ----------------------------------------------------------------------
// Write field over vertices to file.
void
-pylith::meshio::DataWriterVTK::writeVertexField(const double t,
- const PetscVec* vec,
- const char* name)
+pylith::meshio::DataWriterVTK::writeVertexField(
+ const double t,
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh)
{ // writeVertexField
try {
std::ostringstream buffer;
@@ -109,7 +110,9 @@
sprintf(timestamp, _timeFormat.c_str(), t);
buffer << name << "_t" << timestamp;
- PetscErrorCode err = VecView(*vec, _viewer);
+ PetscErrorCode err = SectionView_Sieve_Ascii(mesh, field,
+ buffer.str().c_str(),
+ _viewer);
if (err)
throw std::runtime_error("Could not write vertex data.");
} catch (const std::exception& err) {
@@ -130,8 +133,9 @@
void
pylith::meshio::DataWriterVTK::writeCellField(
const double t,
- const PetscVec* vec,
- const char* name)
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh)
{ // writeCellField
try {
PetscErrorCode err = 0;
@@ -143,7 +147,12 @@
buffer << name << "_t" << timestamp;
err = PetscViewerPushFormat(_viewer, PETSC_VIEWER_ASCII_VTK_CELL);
- err = VecView(*vec, _viewer);
+
+ // Get fiber dimension of first cell
+ const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const int fiberDim = field->getFiberDimension(*cells->begin());
+ err = SectionView_Sieve_Ascii(mesh, field, buffer.str().c_str(),
+ _viewer, fiberDim);
if (err)
throw std::runtime_error("Could not write cell data.");
} catch (const std::exception& err) {
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh 2008-01-08 19:14:02 UTC (rev 8994)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh 2008-01-09 01:43:58 UTC (rev 8995)
@@ -67,22 +67,26 @@
/** Write field over vertices to file.
*
* @param t Time associated with field.
- * @param vec PETSc Vec field over vertices.
+ * @param field PETSc field over vertices.
+ * @param mesh Finite-element mesh
* @param name Name of field.
*/
void writeVertexField(const double t,
- const PetscVec* vec,
- 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 vec PETSc Vec field over cells.
+ * @param field PETSc field over cells.
* @param name Name of field.
+ * @param mesh PETSc mesh object.
*/
void writeCellField(const double t,
- const PetscVec* vec,
- const char* name);
+ const ALE::Obj<real_section_type>& field,
+ const char* name,
+ const ALE::Obj<ALE::Mesh>& mesh);
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc 2008-01-08 19:14:02 UTC (rev 8994)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc 2008-01-09 01:43:58 UTC (rev 8995)
@@ -42,28 +42,6 @@
} // destructor
// ----------------------------------------------------------------------
-// Set which vertex fields to output.
-void
-pylith::meshio::OutputManager::vertexFields(const char** names,
- const int nfields)
-{ // vertexFields
- _vertexFields.resize(nfields);
- for (int i=0; i < nfields; ++i)
- _vertexFields[i] = names[i];
-} // vertexFields
-
-// ----------------------------------------------------------------------
-// Set which cell fields to output.
-void
-pylith::meshio::OutputManager::cellFields(const char** names,
- const int nfields)
-{ // cellFields
- _cellFields.resize(nfields);
- for (int i=0; i < nfields; ++i)
- _cellFields[i] = names[i];
-} // cellFields
-
-// ----------------------------------------------------------------------
// Set filter for vertex data.
void
pylith::meshio::OutputManager::vertexFilter(const VertexFilter* filter)
@@ -118,40 +96,35 @@
_writer->openTimeStep(t, mesh, csMesh);
- const int nvfields = _vertexFields.size();
- for (int i=0; i < nvfields; ++i) {
- const ALE::Obj<real_section_type>& field =
- fields->getReal(_vertexFields[i].c_str());
-
- // Create PETSc Vec for field values (if nec)
- // ADD STUFF HERE
+
+ for (map_names_type::iterator f_iter=_vertexFields.begin();
+ f_iter != _vertexFields.end();
+ ++f_iter) {
+ const char* fieldName = f_iter->first.c_str();
+ const char* fieldLabel = f_iter->second.c_str();
+ const ALE::Obj<real_section_type>& field = fields->getReal(fieldLabel);
- // Copy values from section to PETSc Vec
- // ADD STUFF HERE
-
- if (0 != _vertexFilter) {
- // Apply vertex filter
- // ADD STUFF HERE
- } // if
- //_writer->writeVertexField(t, fieldVec, _vertexFields[i], mesh);
+#if 0
+ const ALE::Obj<real_section_type>& fieldFiltered =
+ (0 != _vertexFilter) ? field : _vertexFilter->filter(field);
+
+ _writer->writeVertexField(t, fieldFiltered, fieldName, mesh);
+#endif
} // for
- const int ncfields = _cellFields.size();
- for (int i=0; i < ncfields; ++i) {
- const ALE::Obj<real_section_type>& field =
- fields->getReal(_cellFields[i].c_str());
+ for (map_names_type::iterator f_iter=_cellFields.begin();
+ f_iter != _cellFields.end();
+ ++f_iter) {
+ const char* fieldName = f_iter->first.c_str();
+ const char* fieldLabel = f_iter->second.c_str();
+ const ALE::Obj<real_section_type>& field = fields->getReal(fieldLabel);
- // Create PETSc Vec for field values (if nec)
- // ADD STUFF HERE
+#if 0
+ const ALE::Obj<real_section_type>& fieldFiltered =
+ (0 != _cellFilter) ? field : _cellFilter->filter(field);
- // Copy values from section to PETSc Vec
- // ADD STUFF HERE
-
- if (0 != _cellFilter) {
- // Apply vertex filter
- // ADD STUFF HERE
- } // if
- //_writer->writeCellField(t, fieldVec, _cellFields[i], mesh);
+ _writer->writeCellField(t, fieldFiltered, fieldName, mesh);
+#endif
} // for
_writer->closeTimeStep();
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh 2008-01-08 19:14:02 UTC (rev 8994)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh 2008-01-09 01:43:58 UTC (rev 8995)
@@ -19,7 +19,8 @@
#if !defined(pylith_meshio_outputmanager_hh)
#define pylith_meshio_outputmanager_hh
-#include "pylith/utils/sievetypes.hh" // USES ALE::Obj, ALE::Mesh, real_section_type
+#include "pylith/utils/sievetypes.hh" // USES ALE::Mesh, real_section_type
+#include <map> // USES std::map
namespace pylith {
namespace meshio {
@@ -47,6 +48,11 @@
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
+ typedef std::map<std::string, std::string> map_names_type;
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
/// Constructor
OutputManager(void);
@@ -61,19 +67,15 @@
/** Set which vertex fields to output.
*
- * @param names Names of fields.
- * @param nfields Number of fields
+ * @param fields Map of names and field labels.
*/
- void vertexFields(const char** names,
- const int nfields);
+ void vertexFields(const map_names_type& fields);
/** Set which cell fields to output.
*
- * @param names Names of fields.
- * @param nfields Number of fields
+ * @param fields Map of names and field labels.
*/
- void cellFields(const char** names,
- const int nfields);
+ void cellFields(const map_names_type& fields);
/** Set filter for vertex data.
*
@@ -114,9 +116,12 @@
private :
- std::vector<std::string> _vertexFields; ///< Names of vertex fields to output
- std::vector<std::string> _cellFields; ///< Names of cell fields to output
+ /// Name and section label of vertex fields to output
+ map_names_type _vertexFields;
+ /// Name and section label of cell fields to output
+ map_names_type _cellFields;
+
DataWriter* _writer; ///< Writer for data
VertexFilter* _vertexFilter; ///< Filter applied to vertex data
CellFilter* _cellFilter; ///< Filter applied to cell data
More information about the cig-commits
mailing list