[cig-commits] r13459 - in short/3D/PyLith/trunk: libsrc/topology unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Thu Dec 4 11:12:31 PST 2008
Author: brad
Date: 2008-12-04 11:12:30 -0800 (Thu, 04 Dec 2008)
New Revision: 13459
Modified:
short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc
short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
Log:
Removed obsolete methods associated with tags (long ago made obsolete by use of IMesh).
Modified: short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc 2008-12-04 17:22:00 UTC (rev 13458)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc 2008-12-04 19:12:30 UTC (rev 13459)
@@ -243,13 +243,6 @@
_real[_history[i]] = _real[_history[i-1]];
_real[_history[0]] = tmp;
- // Shift custom atlas tags as well
- if (_tags.size() > 0) {
- std::map<int,int> tmp = _tags[_history[size-1]];
- for (int i=size-1; i > 0; --i)
- _tags[_history[i]] = _tags[_history[i-1]];
- _tags[_history[0]] = tmp;
- } // if
} // shiftHistory
// ----------------------------------------------------------------------
@@ -261,105 +254,5 @@
return getReal(_history[index].c_str());
} // getFieldByHistory
-// ----------------------------------------------------------------------
-// Create custom atlases for fields.
-void
-pylith::topology::FieldsManager::createCustomAtlas(const char* label,
- const int id)
-{ // createCustomAtlas
- typedef std::map<int,int> map_tag_type;
- assert(!_mesh.isNull());
-
- const map_real_type::iterator f_begin = _real.begin();
- const map_real_type::iterator f_end = _real.end();
-
- if (f_begin == f_end) // If we don't have any fields, just return
- return;
-
- // Get cells with label 'label' set to 'id'
- const ALE::Obj<Mesh::label_sequence>& cells =
- _mesh->getLabelStratum(label, id);
-
- // Create custom atlas in first field
- const ALE::Obj<real_section_type>& field0 = f_begin->second;
- assert(!field0.isNull());
- int field0Tag = 0;
- bool alreadySet = true;
-
- const std::string& field0Name = f_begin->first;
- map_tags_type::iterator t_iter = _tags.find(field0Name);
- if (t_iter == _tags.end()) { // Need to create tags for field 'name'
- map_tag_type fieldTags;
- alreadySet = false;
- field0Tag = fieldTags[id];
- _tags[field0Name] = fieldTags;
- } else { // Use tags already created
- map_tag_type& fieldTags = t_iter->second;
- if (fieldTags.find(id) == fieldTags.end()) { // Need to set tags for id
- alreadySet = false;
- field0Tag = fieldTags[id];
- } // if
- } // if/else
- map_real_type::iterator f_iter=f_begin;
- if (!alreadySet)
- // Copy custom atlas in first field to other fields
- for (++f_iter; f_iter != f_end; ++f_iter) {
- assert(!f_iter->second.isNull());
- const std::string& fieldName = f_iter->first;
- t_iter = _tags.find(fieldName);
- if (t_iter == _tags.end()) { // Need to create tags for field 'name'
- map_tag_type fieldTags;
- _tags[fieldName] = fieldTags;
- } else { // Use tags already created
- map_tag_type& fieldTags = t_iter->second;
- } // if/else
- } // for
-} // createCustomAtlas
-
-// ----------------------------------------------------------------------
-// Get tag for field associated with label id.
-int
-pylith::topology::FieldsManager::getFieldAtlasTag(const char* name,
- const int id)
-{ // getFieldAtlasTag
- map_tags_type::const_iterator t_iter = _tags.find(name);
- if (t_iter == _tags.end()) {
- std::ostringstream msg;
- msg << "Could not find tags for field '" << name << "'.";
- throw std::runtime_error(msg.str());
- } // if
- std::map<int,int>::const_iterator tag = t_iter->second.find(id);
- if (tag == t_iter->second.end()) {
- std::ostringstream msg;
- msg << "Could not find tag for label '" << id
- << "' for field '" << name << "'.";
- throw std::runtime_error(msg.str());
- } // if
-
- return tag->second;
-} // getFieldAtlasTag
-
-// ----------------------------------------------------------------------
-// Get tag for field in history by position.
-int
-pylith::topology::FieldsManager::getFieldAtlasTagByHistory(const int index,
- const int id)
-{ // getFieldAtlasTagByHistory
- assert(index < _history.size());
- return getFieldAtlasTag(_history[index].c_str(), id);
-} // getFieldAtlasTagByHistory
-
-// ----------------------------------------------------------------------
-// Get solution field atlas tag.
-int
-pylith::topology::FieldsManager::getSolutionAtlasTag(const int id)
-{ // getSolutionAtlasTag
- if (_solutionName == "")
- throw std::runtime_error("Cannot retrieve solution atlas tag. "
- "Name of solution field has not been specified.");
- return getFieldAtlasTag(_solutionName.c_str(), id);
-} // getSolutionAtlasTag
-
-
// End of file
Modified: short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh 2008-12-04 17:22:00 UTC (rev 13458)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh 2008-12-04 19:12:30 UTC (rev 13459)
@@ -126,39 +126,6 @@
*/
const ALE::Obj<real_section_type>& getFieldByHistory(const int index);
- /** Create custom atlases for fields.
- *
- * @param label Name of label.
- * @param id Id associated with label.
- * @returns Tag for custom atlask.
- */
- void createCustomAtlas(const char* label,
- const int id);
-
- /** Get atlas tag for field associated with label id.
- *
- * @param name Name of field.
- * @param id Id associated with label.
- * @returns Tag for custom atlask.
- */
- int getFieldAtlasTag(const char* name,
- const int id);
-
- /** Get tag for field in history by position.
- *
- * @param index Index in history [0=most recent, 1=previous, etc]
- * @param id Id associated with label.
- */
- int getFieldAtlasTagByHistory(const int index,
- const int id);
-
- /** Get solution field atlas tag.
- *
- * @param id Id associated with label.
- * @returns Tag for custom atlask.
- */
- int getSolutionAtlasTag(const int id);
-
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
@@ -172,7 +139,6 @@
private :
typedef std::map< std::string, ALE::Obj<real_section_type> > map_real_type;
- typedef std::map< std::string, std::map<int,int> > map_tags_type;
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
@@ -189,9 +155,6 @@
/// History manager for a subset of the fields
std::vector<std::string> _history;
- /// Tags for each real field.
- map_tags_type _tags;
-
}; // FieldsManager
#endif // pylith_topology_fieldsmanager_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2008-12-04 17:22:00 UTC (rev 13458)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2008-12-04 19:12:30 UTC (rev 13459)
@@ -360,29 +360,6 @@
CPPUNIT_ASSERT_EQUAL(fiberDimA,
testB->getFiberDimension(*(vertices->begin())));
-#ifdef IMESH_TODO_TAG
- // Add custom atlas and retest shift history
- const int materialIds[] = { 4, 3 };
- const int numMaterials = 2;
-
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial)
- manager.createCustomAtlas("material-id", materialIds[iMaterial]);
-
- manager.shiftHistory(); // back to original
- manager.shiftHistory(); // shift once more
- for (int iField=0; iField < numFields; ++iField) {
- FieldsManager::map_tags_type::iterator t_iter =
- manager._tags.find(fieldNames[iField]);
- CPPUNIT_ASSERT(t_iter != manager._tags.end());
- const std::map<int,int>& tags = t_iter->second;
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial) {
- std::map<int,int>::const_iterator tag =
- tags.find(materialIds[iMaterial]);
- CPPUNIT_ASSERT(tag != tags.end());
- CPPUNIT_ASSERT_EQUAL(materialIds[iMaterial], tag->first);
- } // for
- } // for
-#endif
} // testShiftHistory
// ----------------------------------------------------------------------
@@ -421,199 +398,7 @@
} // testGetFieldByHistory
// ----------------------------------------------------------------------
-// Test createCustomAtlas().
void
-pylith::topology::TestFieldsManager::testCreateCustomAtlas(void)
-{ // testCreateCustomAtlas
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- const int materialIds[] = { 4, 3 };
- const int numMaterials = 2;
-
- for (int iField=0; iField < numFields; ++iField)
- manager.addReal(fieldNames[iField]);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldA->allocateStorage();
-
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldB->allocateStorage();
-
-#ifdef IMESH_TODO_TAG
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial)
- manager.createCustomAtlas("material-id", materialIds[iMaterial]);
-
- for (int iField=0; iField < numFields; ++iField) {
- FieldsManager::map_tags_type::iterator t_iter =
- manager._tags.find(fieldNames[iField]);
- CPPUNIT_ASSERT(t_iter != manager._tags.end());
- const std::map<int,int>& tags = t_iter->second;
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial) {
- std::map<int,int>::const_iterator tag =
- tags.find(materialIds[iMaterial]);
- CPPUNIT_ASSERT(tag != tags.end());
- CPPUNIT_ASSERT_EQUAL(materialIds[iMaterial], tag->first);
- CPPUNIT_ASSERT_EQUAL(iMaterial, tag->second);
- } // for
- } // for
-#endif
-} // testCreateCustomAtlas
-
-// ----------------------------------------------------------------------
-// Test getFieldAtlasTag().
-void
-pylith::topology::TestFieldsManager::testGetFieldAtlasTag(void)
-{ // testGetFieldAtlasTag
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- const int materialIds[] = { 4, 3 };
- const int numMaterials = 2;
-
- for (int iField=0; iField < numFields; ++iField)
- manager.addReal(fieldNames[iField]);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldA->allocateStorage();
-
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldB->allocateStorage();
-
-#ifdef IMESH_TODO_TAG
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial)
- manager.createCustomAtlas("material-id", materialIds[iMaterial]);
-
- for (int iField=0; iField < numFields; ++iField)
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial) {
- const int tagValueE = iMaterial;
- const int tagValue =
- manager.getFieldAtlasTag(fieldNames[iField], materialIds[iMaterial]);
- CPPUNIT_ASSERT_EQUAL(tagValueE, tagValue);
- } // for
-#endif
-} // testGetFieldAtlasTag
-
-// ----------------------------------------------------------------------
-// Test getFieldAtlasTagByHistory().
-void
-pylith::topology::TestFieldsManager::testGetFieldAtlasTagByHistory(void)
-{ // testGetFieldAtlasTagByHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- const int materialIds[] = { 4, 3 };
- const int numMaterials = 2;
-
- for (int iField=0; iField < numFields; ++iField)
- manager.addReal(fieldNames[iField]);
- manager.createHistory(fieldNames, numFields);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldA->allocateStorage();
-
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldB->allocateStorage();
-
-#ifdef IMESH_TODO_TAG
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial)
- manager.createCustomAtlas("material-id", materialIds[iMaterial]);
-
- for (int iField=0; iField < numFields; ++iField)
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial) {
- const int tagValueE = iMaterial;
- const int tagValue =
- manager.getFieldAtlasTagByHistory(iField, materialIds[iMaterial]);
- CPPUNIT_ASSERT_EQUAL(tagValueE, tagValue);
- } // for
-#endif
-} // testGetFieldAtlasTagByHistory
-
-// ----------------------------------------------------------------------
-// Test getSolutionAtlasTag().
-void
-pylith::topology::TestFieldsManager::testGetSolutionAtlasTag(void)
-{ // testGetFieldAtlasTag
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
- const char* solnName = "field B";
-
- const int materialIds[] = { 4, 3 };
- const int numMaterials = 2;
-
- for (int iField=0; iField < numFields; ++iField)
- manager.addReal(fieldNames[iField]);
- manager.solutionField(solnName);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldA->allocateStorage();
-
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldB->allocateStorage();
-
-#ifdef IMESH_TODO_TAG
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial)
- manager.createCustomAtlas("material-id", materialIds[iMaterial]);
-
- for (int iMaterial=0; iMaterial < numMaterials; ++iMaterial) {
- const int tagValueE = iMaterial;
- const int tagValue =
- manager.getSolutionAtlasTag(materialIds[iMaterial]);
- CPPUNIT_ASSERT_EQUAL(tagValueE, tagValue);
- } // for
-#endif
-} // testGetSolutionAtlasTag
-
-// ----------------------------------------------------------------------
-void
pylith::topology::TestFieldsManager::_initialize(ALE::Obj<Mesh>* mesh) const
{ // _initialize
CPPUNIT_ASSERT(0 != mesh);
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2008-12-04 17:22:00 UTC (rev 13458)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2008-12-04 19:12:30 UTC (rev 13459)
@@ -54,10 +54,6 @@
CPPUNIT_TEST( testCreateHistory );
CPPUNIT_TEST( testShiftHistory );
CPPUNIT_TEST( testGetFieldByHistory );
- CPPUNIT_TEST( testCreateCustomAtlas );
- CPPUNIT_TEST( testGetFieldAtlasTag );
- CPPUNIT_TEST( testGetFieldAtlasTagByHistory );
- CPPUNIT_TEST( testGetSolutionAtlasTag );
CPPUNIT_TEST_SUITE_END();
@@ -103,18 +99,6 @@
/// Test getFieldByHistory().
void testGetFieldByHistory(void);
- /// Test createCustomAtlas().
- void testCreateCustomAtlas(void);
-
- /// Test getFieldAtlasTag().
- void testGetFieldAtlasTag(void);
-
- /// Test getFieldAtlasTagByHistory().
- void testGetFieldAtlasTagByHistory(void);
-
- /// Test getSolutionAtlasTag().
- void testGetSolutionAtlasTag(void);
-
// PRIVATE METHODS ////////////////////////////////////////////////////
private :
More information about the CIG-COMMITS
mailing list