[cig-commits] r17279 - in short/3D/PyLith/trunk: libsrc/meshio libsrc/topology unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Fri Oct 15 10:54:40 PDT 2010
Author: brad
Date: 2010-10-15 10:54:40 -0700 (Fri, 15 Oct 2010)
New Revision: 17279
Modified:
short/3D/PyLith/trunk/libsrc/meshio/DataWriterHDF5.cc
short/3D/PyLith/trunk/libsrc/topology/Field.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
Log:
Set name in PETSc Vec from section name.
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterHDF5.cc 2010-10-15 03:32:07 UTC (rev 17278)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterHDF5.cc 2010-10-15 17:54:40 UTC (rev 17279)
@@ -95,7 +95,7 @@
// field_type can be Field<Mesh> (e.g., displacement field over a
// SubMesh).
topology::Field<mesh_type> coordinates(mesh, coordinatesSection, metadata);
-
+ coordinates.label("vertices");
coordinates.createVector();
coordinates.createScatter();
coordinates.scatterSectionToVector();
@@ -120,6 +120,7 @@
}
}
err = VecCreateMPIWithArray(sieveMesh->comm(), cones->size(), PETSC_DETERMINE, tmpVertices, &elemVec);CHECK_PETSC_ERROR(err);
+ err = PetscObjectSetName((PetscObject) elemVec, "cells");CHECK_PETSC_ERROR(err);
err = VecView(elemVec, _viewer);CHECK_PETSC_ERROR(err);
err = VecDestroy(elemVec);CHECK_PETSC_ERROR(err);
err = PetscFree(tmpVertices);CHECK_PETSC_ERROR(err);
Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc 2010-10-15 03:32:07 UTC (rev 17278)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc 2010-10-15 17:54:40 UTC (rev 17279)
@@ -674,6 +674,8 @@
err = VecCreate(_mesh.comm(), &_vector);
CHECK_PETSC_ERROR(err);
+ err = PetscObjectSetName((PetscObject)_vector, _metadata.label.c_str());
+ CHECK_PETSC_ERROR(err);
err = VecSetSizes(_vector, order->getLocalSize(), order->getGlobalSize());
CHECK_PETSC_ERROR(err);
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc 2010-10-15 03:32:07 UTC (rev 17278)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc 2010-10-15 17:54:40 UTC (rev 17279)
@@ -141,9 +141,14 @@
_buildMesh(&mesh);
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
+
field.newSection();
const ALE::Obj<Mesh::RealSection>& section = field.section();
CPPUNIT_ASSERT(!section.isNull());
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testNewSection
// ----------------------------------------------------------------------
@@ -159,6 +164,9 @@
CPPUNIT_ASSERT(!sieveMesh.isNull());
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
+
const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
@@ -171,6 +179,8 @@
v_iter != vertices->end();
++v_iter)
CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testNewSectionPoints
// ----------------------------------------------------------------------
@@ -186,6 +196,9 @@
CPPUNIT_ASSERT(!sieveMesh.isNull());
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
+
const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
@@ -219,6 +232,8 @@
// Points not int array should have a fiber dimension of zero.
for (int i=0; i < pointsOut.size(); ++i)
CPPUNIT_ASSERT_EQUAL(0, section->getFiberDimension(pointsOut[i]));
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testNewSectionPointsArray
// ----------------------------------------------------------------------
@@ -234,6 +249,8 @@
CPPUNIT_ASSERT(!sieveMesh.isNull());
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
const ALE::Obj<Mesh::RealSection>& section = field.section();
@@ -245,6 +262,8 @@
v_iter != vertices->end();
++v_iter)
CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testNewSectionDomain
// ----------------------------------------------------------------------
@@ -268,6 +287,8 @@
const int fiberDim2 = 5;
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
field.newSection(fieldSrc, fiberDim2);
const ALE::Obj<Mesh::RealSection>& section = field.section();
CPPUNIT_ASSERT(!section.isNull());
@@ -278,6 +299,8 @@
v_iter != vertices->end();
++v_iter)
CPPUNIT_ASSERT_EQUAL(fiberDim2, section->getFiberDimension(*v_iter));
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testNewSectionField
// ----------------------------------------------------------------------
@@ -327,6 +350,8 @@
} // Setup source field
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
field.cloneSection(fieldSrc);
const ALE::Obj<Mesh::RealSection>& section = field.section();
CPPUNIT_ASSERT(!section.isNull());
@@ -341,6 +366,8 @@
// Verify vector scatter was also copied.
CPPUNIT_ASSERT_EQUAL(fieldSrc._scatter, field._scatter);
+
+ CPPUNIT_ASSERT_EQUAL(label, std::string(section->getName()));
} // testCloneSection
// ----------------------------------------------------------------------
@@ -834,6 +861,8 @@
Mesh mesh;
_buildMesh(&mesh);
Field<Mesh> field(mesh);
+ const std::string& label = "field A";
+ field.label(label.c_str());
field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
field.allocate();
@@ -854,6 +883,10 @@
// Make sure we can do multiple calls to createVector().
field.createVector();
CPPUNIT_ASSERT(0 != field._vector);
+
+ const char* vecname = 0;
+ PetscObjectGetName((PetscObject)field._vector, &vecname);
+ CPPUNIT_ASSERT_EQUAL(label, std::string(vecname));
} // testCreateVector
// ----------------------------------------------------------------------
More information about the CIG-COMMITS
mailing list