[cig-commits] [commit] knepley/upgrade-petsc-interface: Fixed Mesh::view() with view option. Updated unit tests. (f47c6e3)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu Mar 6 16:11:14 PST 2014
Repository : ssh://geoshell/pylith
On branch : knepley/upgrade-petsc-interface
Link : https://github.com/geodynamics/pylith/compare/687c383d3af9cc4c33c72ebdfe5dc3c70ec327a8...f47c6e33e941ae327cc9240e4a142bdd9473d094
>---------------------------------------------------------------
commit f47c6e33e941ae327cc9240e4a142bdd9473d094
Author: Brad Aagaard <baagaard at usgs.gov>
Date: Thu Mar 6 09:33:27 2014 -0800
Fixed Mesh::view() with view option. Updated unit tests.
>---------------------------------------------------------------
f47c6e33e941ae327cc9240e4a142bdd9473d094
libsrc/pylith/topology/Mesh.cc | 11 +++++++----
libsrc/pylith/topology/Mesh.hh | 6 ++----
modulesrc/topology/Mesh.i | 6 ++----
unittests/libtests/topology/TestMesh.cc | 22 ++++++++++++++++++++++
unittests/libtests/topology/TestMesh.hh | 4 ++++
unittests/pytests/topology/TestMesh.py | 9 ++++++++-
6 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/libsrc/pylith/topology/Mesh.cc b/libsrc/pylith/topology/Mesh.cc
index e82a14a..db32865 100644
--- a/libsrc/pylith/topology/Mesh.cc
+++ b/libsrc/pylith/topology/Mesh.cc
@@ -214,8 +214,7 @@ pylith::topology::Mesh::commRank(void) const
// ----------------------------------------------------------------------
// Print mesh to stdout.
void
-pylith::topology::Mesh::view(const char* label,
- const char* viewOption) const
+pylith::topology::Mesh::view(const char* viewOption) const
{ // view
PYLITH_METHOD_BEGIN;
@@ -223,13 +222,17 @@ pylith::topology::Mesh::view(const char* label,
PetscErrorCode err;
if (strlen(viewOption) > 0) {
+ const char* label = 0;
+ err = PetscObjectGetName((PetscObject) _dmMesh, &label);PYLITH_CHECK_ERROR(err);
+
std::ostringstream optionname, optionprefix;
- optionname << "-" << label << "_dm_view";
optionprefix << label << "_";
+ optionname << "-" << label << "_dm_view";
err = DMSetOptionsPrefix(_dmMesh, optionprefix.str().c_str());PYLITH_CHECK_ERROR(err);
err = PetscOptionsSetValue(optionname.str().c_str(), viewOption);PYLITH_CHECK_ERROR(err);
- err = DMSetFromOptions(_dmMesh);PYLITH_CHECK_ERROR(err);
+ err = DMViewFromOptions(_dmMesh, NULL, "-dm_view");PYLITH_CHECK_ERROR(err);
+
} else {
err = DMView(_dmMesh, PETSC_VIEWER_STDOUT_WORLD);PYLITH_CHECK_ERROR(err);
} // if/else
diff --git a/libsrc/pylith/topology/Mesh.hh b/libsrc/pylith/topology/Mesh.hh
index 8a27022..84d1ea6 100644
--- a/libsrc/pylith/topology/Mesh.hh
+++ b/libsrc/pylith/topology/Mesh.hh
@@ -176,8 +176,7 @@ public :
/** View mesh.
*
- * @param label Label for mesh.
- * @param viewOption View option
+ * @param viewOption PETSc DM view option.
*
* PETSc mesh view options include:
* short summary [empty]
@@ -186,8 +185,7 @@ public :
* latex in a file :refined.tex:ascii_latex
* VTK vtk:refined.vtk:ascii_vtk
*/
- void view(const char* label,
- const char* viewOption ="") const;
+ void view(const char* viewOption ="") const;
/** Return the names of all vertex groups.
*
diff --git a/modulesrc/topology/Mesh.i b/modulesrc/topology/Mesh.i
index 5a0ba8a..0d239d1 100644
--- a/modulesrc/topology/Mesh.i
+++ b/modulesrc/topology/Mesh.i
@@ -114,8 +114,7 @@ namespace pylith {
/** View mesh.
*
- * @param label Label for mesh.
- * @param viewOption View option
+ * @param viewOption PETSc DM view option.
*
* PETSc mesh view options include:
* short summary [empty]
@@ -124,8 +123,7 @@ namespace pylith {
* latex in a file :refined.tex:ascii_latex
* VTK vtk:refined.vtk:ascii_vtk
*/
- void view(const char* label,
- const char* viewOption ="") const;
+ void view(const char* viewOption ="") const;
/** Return the names of all vertex groups.
*
diff --git a/unittests/libtests/topology/TestMesh.cc b/unittests/libtests/topology/TestMesh.cc
index 8703d66..3d98191 100644
--- a/unittests/libtests/topology/TestMesh.cc
+++ b/unittests/libtests/topology/TestMesh.cc
@@ -155,4 +155,26 @@ pylith::topology::TestMesh::testComm(void)
PYLITH_METHOD_END;
} // testComm
+
+// ----------------------------------------------------------------------
+// Test view().
+void
+pylith::topology::TestMesh::testView(void)
+{ // testView
+ PYLITH_METHOD_BEGIN;
+
+ const char* filename = "data/tri3.mesh";
+
+ Mesh mesh;
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(filename);
+ iohandler.read(&mesh);
+
+ mesh.view();
+ mesh.view(":mesh.view:ascii_info_detail");
+
+ PYLITH_METHOD_END;
+} // testView
+
+
// End of file
diff --git a/unittests/libtests/topology/TestMesh.hh b/unittests/libtests/topology/TestMesh.hh
index a3b2ccb..1b40baa 100644
--- a/unittests/libtests/topology/TestMesh.hh
+++ b/unittests/libtests/topology/TestMesh.hh
@@ -52,6 +52,7 @@ class pylith::topology::TestMesh : public CppUnit::TestFixture
CPPUNIT_TEST( testDebug );
CPPUNIT_TEST( testDimension );
CPPUNIT_TEST( testComm );
+ CPPUNIT_TEST( testView );
CPPUNIT_TEST_SUITE_END();
@@ -76,6 +77,9 @@ public :
/// Test comm().
void testComm(void);
+ /// Test view().
+ void testView(void);
+
}; // class TestMesh
#endif // pylith_topology_testmesh_hh
diff --git a/unittests/pytests/topology/TestMesh.py b/unittests/pytests/topology/TestMesh.py
index 246bf66..c0d7e85 100644
--- a/unittests/pytests/topology/TestMesh.py
+++ b/unittests/pytests/topology/TestMesh.py
@@ -118,7 +118,14 @@ class TestMesh(unittest.TestCase):
"""
mesh = self._getMesh()
- mesh.view("Testing view")
+ mesh.view()
+
+ import os
+ filename = "mesh.view"
+ if os.path.isfile(filename):
+ os.remove(filename)
+ mesh.view(":%s:ascii_info_detail" % filename)
+ self.assertTrue(os.path.isfile(filename))
return
More information about the CIG-COMMITS
mailing list