[cig-commits] r21824 - in short/3D/PyLith/trunk: libsrc/pylith/meshio unittests/libtests/meshio
brad at geodynamics.org
brad at geodynamics.org
Thu Apr 11 15:27:00 PDT 2013
Author: brad
Date: 2013-04-11 15:27:00 -0700 (Thu, 11 Apr 2013)
New Revision: 21824
Modified:
short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnSubset.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshCases.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
Log:
Code cleanup.
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnSubset.cc 2013-04-11 22:26:28 UTC (rev 21823)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnSubset.cc 2013-04-11 22:27:00 UTC (rev 21824)
@@ -42,9 +42,13 @@
void
pylith::meshio::OutputSolnSubset::deallocate(void)
{ // deallocate
+ PYLITH_METHOD_BEGIN;
+
OutputManager<topology::SubMesh, topology::Field<topology::Mesh> >::deallocate();
delete _submesh; _submesh = 0;
+
+ PYLITH_METHOD_END;
} // deallocate
// ----------------------------------------------------------------------
@@ -52,7 +56,11 @@
void
pylith::meshio::OutputSolnSubset::label(const char* value)
{ // label
+ PYLITH_METHOD_BEGIN;
+
_label = value;
+
+ PYLITH_METHOD_END;
} // label
// ----------------------------------------------------------------------
@@ -60,15 +68,19 @@
void
pylith::meshio::OutputSolnSubset::verifyConfiguration(const topology::Mesh& mesh) const
{ // verifyConfiguration
- const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
- assert(!sieveMesh.isNull());
+ PYLITH_METHOD_BEGIN;
- if (!sieveMesh->hasIntSection(_label)) {
+ PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
+ PetscBool hasLabel = PETSC_FALSE;
+ PetscErrorCode err = DMPlexHasLabel(dmMesh, _label.c_str(), &hasLabel);CHECK_PETSC_ERROR(err);
+ if (!hasLabel) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << _label
<< " for subdomain output.";
throw std::runtime_error(msg.str());
} // if
+
+ PYLITH_METHOD_END;
} // verifyConfiguration
// ----------------------------------------------------------------------
@@ -76,9 +88,12 @@
const pylith::topology::SubMesh&
pylith::meshio::OutputSolnSubset::subdomainMesh(const topology::Mesh& mesh)
{ // subdomainMesh
+ PYLITH_METHOD_BEGIN;
+
delete _submesh; _submesh = new topology::SubMesh(mesh, _label.c_str());
assert(_submesh);
- return *_submesh;
+
+ PYLITH_METHOD_RETURN(*_submesh);
} // subdomainMesh
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshCases.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshCases.cc 2013-04-11 22:26:28 UTC (rev 21823)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshCases.cc 2013-04-11 22:27:00 UTC (rev 21824)
@@ -20,6 +20,8 @@
#include "TestDataWriterVTKMatMeshCases.hh" // Implementation of class methods
+#include "pylith/utils/petscerror.h" // USES PYLITH_METHOD_BEGIN/END
+
#include "data/DataWriterVTKDataMatMeshLine2.hh"
#include "data/DataWriterVTKDataMatMeshTri3.hh"
#include "data/DataWriterVTKDataMatMeshQuad4.hh"
@@ -40,10 +42,14 @@
void
pylith::meshio::TestDataWriterVTKMatMeshLine2::setUp(void)
{ // setUp
+ PYLITH_METHOD_BEGIN;
+
TestDataWriterVTKMesh::setUp();
_data = new DataWriterVTKDataMatMeshLine2;
_flipFault = false;
_initialize();
+
+ PYLITH_METHOD_END;
} // setUp
@@ -52,10 +58,14 @@
void
pylith::meshio::TestDataWriterVTKMatMeshTri3::setUp(void)
{ // setUp
+ PYLITH_METHOD_BEGIN;
+
TestDataWriterVTKMesh::setUp();
_data = new DataWriterVTKDataMatMeshTri3;
_flipFault = true;
_initialize();
+
+ PYLITH_METHOD_END;
} // setUp
@@ -64,10 +74,14 @@
void
pylith::meshio::TestDataWriterVTKMatMeshQuad4::setUp(void)
{ // setUp
+ PYLITH_METHOD_BEGIN;
+
TestDataWriterVTKMesh::setUp();
_data = new DataWriterVTKDataMatMeshQuad4;
_flipFault = false;
_initialize();
+
+ PYLITH_METHOD_END;
} // setUp
@@ -76,10 +90,14 @@
void
pylith::meshio::TestDataWriterVTKMatMeshTet4::setUp(void)
{ // setUp
+ PYLITH_METHOD_BEGIN;
+
TestDataWriterVTKMesh::setUp();
_data = new DataWriterVTKDataMatMeshTet4;
_flipFault = false;
_initialize();
+
+ PYLITH_METHOD_END;
} // setUp
@@ -88,10 +106,14 @@
void
pylith::meshio::TestDataWriterVTKMatMeshHex8::setUp(void)
{ // setUp
+ PYLITH_METHOD_BEGIN;
+
TestDataWriterVTKMesh::setUp();
_data = new DataWriterVTKDataMatMeshHex8;
_flipFault = true;
_initialize();
+
+ PYLITH_METHOD_END;
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc 2013-04-11 22:26:28 UTC (rev 21823)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc 2013-04-11 22:27:00 UTC (rev 21824)
@@ -25,6 +25,7 @@
#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Stratum.hh" // USES Stratum
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include <string.h> // USES strcmp()
@@ -33,16 +34,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestOutputSolnSubset );
// ----------------------------------------------------------------------
-typedef pylith::topology::Mesh::SieveMesh SieveMesh;
-typedef pylith::topology::Mesh::RealSection RealSection;
-typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
-
-// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestOutputSolnSubset::testConstructor(void)
{ // testConstructor
+ PYLITH_METHOD_BEGIN;
+
OutputSolnSubset output;
+
+ PYLITH_METHOD_END;
} // testConstructor
// ----------------------------------------------------------------------
@@ -50,12 +50,16 @@
void
pylith::meshio::TestOutputSolnSubset::testLabel(void)
{ // testLabel
+ PYLITH_METHOD_BEGIN;
+
OutputSolnSubset output;
const char* label = "boundary";
output.label(label);
CPPUNIT_ASSERT(0 == strcmp(label, output._label.c_str()));
+
+ PYLITH_METHOD_END;
} // testLabel
// ----------------------------------------------------------------------
@@ -63,13 +67,18 @@
void
pylith::meshio::TestOutputSolnSubset::testSubdomainMesh(void)
{ // testSubdomainMesh
+ PYLITH_METHOD_BEGIN;
+
const char* filename = "data/quad4.mesh";
const char* label = "bc3";
const int nvertices = 3;
- const int verticesE[] = { 2, 4, 6 };
+ const int verticesE[nvertices] = { 2, 3, 4 };
const int ncells = 2;
const int ncorners = 2;
- const int cellsE[] = { 2, 4, 4, 6 };
+ const int cellsE[ncells*ncorners] = {
+ 2, 3,
+ 3, 4,
+ };
topology::Mesh mesh;
MeshIOAscii iohandler;
@@ -78,42 +87,42 @@
OutputSolnSubset output;
output.label(label);
- const topology::SubMesh& submesh = output.subdomainMesh(mesh);
- const ALE::Obj<SieveMesh>& sieveSubMesh = submesh.sieveMesh();
- CPPUNIT_ASSERT(!sieveSubMesh.isNull());
+ PetscDM dmMesh = output.subdomainMesh(mesh).dmMesh();CPPUNIT_ASSERT(dmMesh);
+
// Check vertices
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveSubMesh->depthStratum(0);
- const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- CPPUNIT_ASSERT_EQUAL(nvertices, int(vertices->size()));
- int ipt = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter, ++ipt)
- CPPUNIT_ASSERT_EQUAL(verticesE[ipt], *v_iter);
+ topology::Stratum verticesStratum(dmMesh, topology::Stratum::DEPTH, 0);
+ const PetscInt vStart = verticesStratum.begin();
+ const PetscInt vEnd = verticesStratum.end();
+ CPPUNIT_ASSERT_EQUAL(nvertices, verticesStratum.size());
+ for (PetscInt v=vStart, index = 0; v < vEnd; ++v, ++index) {
+ CPPUNIT_ASSERT_EQUAL(verticesE[index], v);
+ } // for
// Check cells
- const ALE::Obj<SieveMesh::label_sequence>& cells =
- sieveSubMesh->heightStratum(1);
- const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<SieveSubMesh::sieve_type>& sieve = sieveSubMesh->getSieve();
- assert(!sieve.isNull());
- typedef ALE::SieveAlg<SieveMesh> SieveAlg;
+ topology::Stratum cellsStratum(dmMesh, topology::Stratum::HEIGHT, 1);
+ const PetscInt cStart = cellsStratum.begin();
+ const PetscInt cEnd = cellsStratum.end();
+ PetscErrorCode err = 0;
+ CPPUNIT_ASSERT_EQUAL(ncells, cellsStratum.size());
+ for (PetscInt c = cStart, index = 0; c < cEnd; ++c) {
+ PetscInt *closure = NULL;
+ PetscInt closureSize = 0;
+ err = DMPlexGetTransitiveClosure(dmMesh, c, PETSC_TRUE, &closureSize, &closure);CHECK_PETSC_ERROR(err);
+ int count = 0;
+ for (int i=0; i < closureSize; ++i) {
+ const PetscInt p = closure[2*i];
+ if (p >= vStart && p < vEnd) {
+ CPPUNIT_ASSERT_EQUAL(cellsE[index], p);
+ ++count;
+ ++index;
+ } // if
+ } // for
+ CPPUNIT_ASSERT_EQUAL(ncorners, count);
+ err = DMPlexRestoreTransitiveClosure(dmMesh, c, PETSC_TRUE, &closureSize, &closure);CHECK_PETSC_ERROR(err);
+ } // for
- CPPUNIT_ASSERT_EQUAL(ncells, int(cells->size()));
-
- ALE::ISieveVisitor::PointRetriever<SieveSubMesh::sieve_type> pV(sieve->getMaxConeSize());
- int i = 0;
- for (SieveMesh::label_sequence::iterator c_iter=cells->begin(); c_iter != cellsEnd; ++c_iter) {
- sieve->cone(*c_iter, pV);
- const SieveSubMesh::point_type *cone = pV.getPoints();
- CPPUNIT_ASSERT_EQUAL(ncorners, (int) pV.getSize());
- for(int p = 0; p < pV.getSize(); ++p, ++i) {
- CPPUNIT_ASSERT_EQUAL(cellsE[i], cone[p]);
- }
- pV.clear();
- } // for
+ PYLITH_METHOD_END;
} // testSubdomainMesh
More information about the CIG-COMMITS
mailing list