From 67bf3feebc5884eb1884a098b0db2ce6e652b523 Mon Sep 17 00:00:00 2001 From: Kenneth Leiter Date: Tue, 7 Sep 2010 10:01:54 -0400 Subject: [PATCH] ENH: Revert back to XdmfGridCollection inheriting from XdmfGrid - we want the flexibility to be able to add global sets (might be necessary for dft work). --- XdmfDomain.hpp | 2 +- XdmfGrid.hpp | 9 +++++---- XdmfGridCollection.cpp | 29 +++++++++-------------------- XdmfGridCollection.hpp | 24 ++++++++---------------- 4 files changed, 23 insertions(+), 41 deletions(-) diff --git a/XdmfDomain.hpp b/XdmfDomain.hpp index 2ccc421f..2e1f5c86 100644 --- a/XdmfDomain.hpp +++ b/XdmfDomain.hpp @@ -14,7 +14,7 @@ class XdmfGridCollection; * XdmfDomain is the top XdmfItem in an Xdmf structure. It can store a number of grids and * provides methods to insert, retrieve, and remove these grids. */ -class XdmfDomain : public XdmfItem { +class XdmfDomain : public virtual XdmfItem { public: diff --git a/XdmfGrid.hpp b/XdmfGrid.hpp index 1bbdffd0..b9cdf16e 100644 --- a/XdmfGrid.hpp +++ b/XdmfGrid.hpp @@ -13,14 +13,14 @@ class XdmfTopology; #include "XdmfItem.hpp" /** - * @brief A mesh that consists of elements, points, and values attached to the mesh. + * @brief A mesh containing elements, points, and fields attached to the mesh. * * XdmfGrid represents a mesh. It is required to contain two other Xdmf data structures, an XdmfGeometry * that stores point locations and an XdmfTopology that store connectivity information. XdmfAttributes can be inserted - * into the XdmfGrid to specify values attached at various parts of the mesh. XdmfSets can be inserted in the XdmfGrid + * into the XdmfGrid to specify fields centered on various parts of the mesh. XdmfSets can be inserted into XdmfGrids * to specify collections of mesh elements. */ -class XdmfGrid : public XdmfItem { +class XdmfGrid : public virtual XdmfItem { public: @@ -265,6 +265,8 @@ protected: XdmfGrid(); virtual void populateItem(const std::map & itemProperties, std::vector > & childItems, const XdmfCoreReader * const reader); + std::string mName; + private: XdmfGrid(const XdmfGrid & grid); // Not implemented. @@ -273,7 +275,6 @@ private: std::vector > mAttributes; boost::shared_ptr mGeometry; boost::shared_ptr mMap; - std::string mName; std::vector > mSets; boost::shared_ptr mTime; boost::shared_ptr mTopology; diff --git a/XdmfGridCollection.cpp b/XdmfGridCollection.cpp index cf7b83d5..5e89ea30 100644 --- a/XdmfGridCollection.cpp +++ b/XdmfGridCollection.cpp @@ -15,9 +15,10 @@ boost::shared_ptr XdmfGridCollection::New() }; XdmfGridCollection::XdmfGridCollection() : - mCollectionType(XdmfGridCollectionType::NoCollectionType()), - mName("Collection") + XdmfGrid(), + mCollectionType(XdmfGridCollectionType::NoCollectionType()) { + mName = "Collection"; } XdmfGridCollection::~XdmfGridCollection() @@ -40,11 +41,6 @@ std::string XdmfGridCollection::getItemTag() const return ItemTag; } -std::string XdmfGridCollection::getName() const -{ - return mName; -} - boost::shared_ptr XdmfGridCollection::getType() const { return mCollectionType; @@ -53,24 +49,17 @@ boost::shared_ptr XdmfGridCollection::getType() co void XdmfGridCollection::populateItem(const std::map & itemProperties, std::vector > & childItems, const XdmfCoreReader * const reader) { mCollectionType = XdmfGridCollectionType::New(itemProperties); - std::map::const_iterator name = itemProperties.find("Name"); - if(name != itemProperties.end()) - { - mName = name->second; - } - else - { - mName = ""; - } XdmfDomain::populateItem(itemProperties, childItems, reader); + XdmfGrid::populateItem(itemProperties, childItems, reader); } -void XdmfGridCollection::setName(const std::string & name) +void XdmfGridCollection::setType(const boost::shared_ptr collectionType) { - mName = name; + mCollectionType = collectionType; } -void XdmfGridCollection::setType(const boost::shared_ptr collectionType) +void XdmfGridCollection::traverse(const boost::shared_ptr visitor) { - mCollectionType = collectionType; + XdmfGrid::traverse(visitor); + XdmfDomain::traverse(visitor); } diff --git a/XdmfGridCollection.hpp b/XdmfGridCollection.hpp index 75a6414f..5414a6f5 100644 --- a/XdmfGridCollection.hpp +++ b/XdmfGridCollection.hpp @@ -6,6 +6,7 @@ class XdmfGridCollectionType; // Includes #include "XdmfDomain.hpp" +#include "XdmfGrid.hpp" /** * @brief A spatial or temporal collection of XdmfGrids. @@ -15,7 +16,8 @@ class XdmfGridCollectionType; * * It is valid to nest collections. A spatial collection within a temporal collection is commonly used. */ -class XdmfGridCollection : public XdmfDomain { +class XdmfGridCollection : public XdmfGrid, + public XdmfDomain { public: @@ -28,20 +30,13 @@ public: virtual ~XdmfGridCollection(); - LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfDomain) + LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid) static const std::string ItemTag; std::map getItemProperties() const; std::string getItemTag() const; - /** - * Get the name of the grid collection. - * - * @return the name of the grid collection. - */ - std::string getName() const; - /** * Get the XdmfGridCollectionType associated with this grid collection. * @@ -49,12 +44,8 @@ public: */ boost::shared_ptr getType() const; - /** - * Set the name of the grid collection. - * - * @param name of the grid collection to set. - */ - void setName(const std::string & name); + using XdmfDomain::insert; + using XdmfGrid::insert; /** * Set the XdmfGridCollectionType associated with this grid collection. @@ -63,6 +54,8 @@ public: */ void setType(const boost::shared_ptr collectionType); + void traverse(const boost::shared_ptr visitor); + protected: XdmfGridCollection(); @@ -74,7 +67,6 @@ private: void operator=(const XdmfGridCollection & collection); // Not implemented. boost::shared_ptr mCollectionType; - std::string mName; }; #endif /* XDMFGRID_HPP_ */ -- GitLab