From d6c6137482297f371f55d220899008e210ea3742 Mon Sep 17 00:00:00 2001 From: Kenneth Leiter Date: Tue, 26 Oct 2010 11:43:33 -0400 Subject: [PATCH] ENH: Added XdmfGridUnstructured and turned XdmfGrid into an abstract base class for all grids (both structured and unstructured). Modified a bunch of utils and other classes to fit this new hierarchy. --- CMakeLists.txt | 1 + Xdmf.i | 31 ++++---- XdmfDomain.cpp | 40 +++++++++-- XdmfDomain.hpp | 10 ++- XdmfGrid.cpp | 30 +------- XdmfGrid.hpp | 42 ++--------- XdmfGridCurvilinear.cpp | 12 +++- XdmfGridCurvilinear.hpp | 17 +++++ XdmfGridRectilinear.cpp | 4 +- XdmfGridRectilinear.hpp | 3 + XdmfGridRegular.cpp | 4 +- XdmfGridRegular.hpp | 3 + XdmfGridUnstructured.cpp | 50 +++++++++++++ XdmfGridUnstructured.hpp | 71 +++++++++++++++++++ XdmfItemFactory.cpp | 4 +- tests/Cxx/CMakeLists.txt | 4 +- tests/Cxx/TestXdmfGridCollection.cpp | 14 ++-- ...fGrid.cpp => TestXdmfGridUnstructured.cpp} | 4 +- tests/Cxx/TestXdmfReader.cpp | 6 +- tests/Cxx/TestXdmfWriter.cpp | 2 +- tests/Cxx/TestXdmfWriterHDF5ThenXML.cpp | 2 +- tests/Cxx/TestXdmfXPath.cpp | 4 +- tests/Cxx/XdmfTestDataGenerator.hpp | 6 +- tests/Java/TestXdmfJava.java | 2 +- tests/Python/TestXdmfHDF5Writer.py | 2 +- tests/Python/TestXdmfWriter.py | 2 +- utils/XdmfExodusReader.cpp | 8 +-- utils/XdmfExodusReader.hpp | 6 +- utils/XdmfExodusWriter.cpp | 14 ++-- utils/XdmfExodusWriter.hpp | 6 +- utils/XdmfPartitioner.cpp | 24 +++---- utils/XdmfPartitioner.hpp | 8 +-- utils/XdmfTopologyConverter.cpp | 20 +++--- utils/XdmfTopologyConverter.hpp | 12 ++-- utils/XdmfUtils.i | 1 + utils/tests/Cxx/TestXdmfExodusIO.cpp | 4 +- utils/tests/Cxx/TestXdmfTopologyConverter.cpp | 10 +-- 37 files changed, 311 insertions(+), 172 deletions(-) create mode 100644 XdmfGridUnstructured.cpp create mode 100644 XdmfGridUnstructured.hpp rename tests/Cxx/{TestXdmfGrid.cpp => TestXdmfGridUnstructured.cpp} (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2af609ce..4cf37b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ if(NOT XDMF_BUILD_CORE_ONLY) XdmfGridCurvilinear XdmfGridRectilinear XdmfGridRegular + XdmfGridUnstructured XdmfItemFactory XdmfMap XdmfReader diff --git a/Xdmf.i b/Xdmf.i index d66400ea..ce1ebc23 100644 --- a/Xdmf.i +++ b/Xdmf.i @@ -38,6 +38,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i #include #include #include + #include #include #include #include @@ -67,10 +68,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i { *(boost::shared_ptr< XdmfGeometry > **)&($result) = value ? new boost::shared_ptr< XdmfGeometry >(value) : 0; } - else if(boost::shared_ptr value = boost::shared_dynamic_cast($1)) - { - *(boost::shared_ptr< XdmfGrid > **)&($result) = value ? new boost::shared_ptr< XdmfGrid >(value) : 0; - } else if(boost::shared_ptr value = boost::shared_dynamic_cast($1)) { *(boost::shared_ptr< XdmfGridCollection > **)&($result) = value ? new boost::shared_ptr< XdmfGridCollection >(value) : 0; @@ -87,6 +84,10 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i { *(boost::shared_ptr< XdmfGridRegular > **)&($result) = value ? new boost::shared_ptr< XdmfGridRegular >(value) : 0; } + else if(boost::shared_ptr value = boost::shared_dynamic_cast($1)) + { + *(boost::shared_ptr< XdmfGridUnstructured > **)&($result) = value ? new boost::shared_ptr< XdmfGridUnstructured >(value) : 0; + } else if(boost::shared_ptr value = boost::shared_dynamic_cast($1)) { *(boost::shared_ptr< XdmfInformation > **)&($result) = value ? new boost::shared_ptr< XdmfInformation >(value) : 0; @@ -110,18 +111,22 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i } // Ignore const overloaded methods -%ignore XdmfDomain::getGrid(const unsigned int) const; -%ignore XdmfDomain::getGrid(const std::string &) const; %ignore XdmfDomain::getGridCollection(const unsigned int) const; %ignore XdmfDomain::getGridCollection(const std::string &) const; +%ignore XdmfDomain::getGridCurvilinear(const unsigned int) const; +%ignore XdmfDomain::getGridCurvilinear(const std::string &) const; +%ignore XdmfDomain::getGridRectilinear(const unsigned int) const; +%ignore XdmfDomain::getGridRectilinear(const std::string &) const; +%ignore XdmfDomain::getGridRegular(const unsigned int) const; +%ignore XdmfDomain::getGridRegular(const std::string &) const; +%ignore XdmfDomain::getGridUnstructured(const unsigned int) const; +%ignore XdmfDomain::getGridUnstructured(const std::string &) const; %ignore XdmfGrid::getAttribute(const unsigned int) const; %ignore XdmfGrid::getAttribute(const std::string &) const; -%ignore XdmfGrid::getGeometry() const; %ignore XdmfGrid::getMap() const; %ignore XdmfGrid::getSet(const unsigned int) const; %ignore XdmfGrid::getSet(const std::string &) const; %ignore XdmfGrid::getTime() const; -%ignore XdmfGrid::getTopology() const; %ignore XdmfGridCurvilinear::getDimensions() const; %ignore XdmfGridRectilinear::getCoordinates(const unsigned int) const; %ignore XdmfGridRectilinear::getCoordinates() const; @@ -191,10 +196,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN); } - else if(boost::shared_ptr grid = boost::shared_dynamic_cast($1)) - { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(grid)), SWIGTYPE_p_boost__shared_ptrT_XdmfGrid_t, SWIG_POINTER_OWN); - } else if(boost::shared_ptr gridCollection = boost::shared_dynamic_cast($1)) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN); @@ -211,6 +212,10 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(gridRegular)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridRegular_t, SWIG_POINTER_OWN); } + else if(boost::shared_ptr gridUnstructured = boost::shared_dynamic_cast($1)) + { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(gridUnstructured)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridUnstructured_t, SWIG_POINTER_OWN); + } else if(boost::shared_ptr information = boost::shared_dynamic_cast($1)) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN); @@ -252,6 +257,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i %shared_ptr(XdmfGridCurvilinear) %shared_ptr(XdmfGridRectilinear) %shared_ptr(XdmfGridRegular) +%shared_ptr(XdmfGridUnstructured) %shared_ptr(XdmfItemFactory) %shared_ptr(XdmfMap) %shared_ptr(XdmfReader) @@ -273,6 +279,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i %include XdmfGridCurvilinear.hpp %include XdmfGridRectilinear.hpp %include XdmfGridRegular.hpp +%include XdmfGridUnstructured.hpp %include XdmfItemFactory.hpp %include XdmfMap.hpp %include XdmfReader.hpp diff --git a/XdmfDomain.cpp b/XdmfDomain.cpp index 51e0d8a0..d7b27e63 100644 --- a/XdmfDomain.cpp +++ b/XdmfDomain.cpp @@ -6,11 +6,17 @@ */ #include "XdmfDomain.hpp" -#include "XdmfGrid.hpp" #include "XdmfGridCollection.hpp" +#include "XdmfGridCurvilinear.hpp" +#include "XdmfGridRectilinear.hpp" +#include "XdmfGridRegular.hpp" +#include "XdmfGridUnstructured.hpp" -XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGrid, Grid, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGridCollection, GridCollection, Name) +XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGridCurvilinear, GridCurvilinear, Name) +XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGridRectilinear, GridRectilinear, Name) +XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGridRegular, GridRegular, Name) +XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain, XdmfGridUnstructured, GridUnstructured, Name) boost::shared_ptr XdmfDomain::New() { @@ -48,7 +54,19 @@ void XdmfDomain::populateItem(const std::map & itemPro { this->insert(gridCollection); } - else if(boost::shared_ptr grid = boost::shared_dynamic_cast(*iter)) + else if(boost::shared_ptr grid = boost::shared_dynamic_cast(*iter)) + { + this->insert(grid); + } + else if(boost::shared_ptr grid = boost::shared_dynamic_cast(*iter)) + { + this->insert(grid); + } + else if(boost::shared_ptr grid = boost::shared_dynamic_cast(*iter)) + { + this->insert(grid); + } + else if(boost::shared_ptr grid = boost::shared_dynamic_cast(*iter)) { this->insert(grid); } @@ -58,11 +76,23 @@ void XdmfDomain::populateItem(const std::map & itemPro void XdmfDomain::traverse(const boost::shared_ptr visitor) { XdmfItem::traverse(visitor); - for(std::vector >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter) + for(std::vector >::const_iterator iter = mGridCollections.begin(); iter != mGridCollections.end(); ++iter) { (*iter)->accept(visitor); } - for(std::vector >::const_iterator iter = mGridCollections.begin(); iter != mGridCollections.end(); ++iter) + for(std::vector >::const_iterator iter = mGridCurvilinears.begin(); iter != mGridCurvilinears.end(); ++iter) + { + (*iter)->accept(visitor); + } + for(std::vector >::const_iterator iter = mGridRectilinears.begin(); iter != mGridRectilinears.end(); ++iter) + { + (*iter)->accept(visitor); + } + for(std::vector >::const_iterator iter = mGridRegulars.begin(); iter != mGridRegulars.end(); ++iter) + { + (*iter)->accept(visitor); + } + for(std::vector >::const_iterator iter = mGridUnstructureds.begin(); iter != mGridUnstructureds.end(); ++iter) { (*iter)->accept(visitor); } diff --git a/XdmfDomain.hpp b/XdmfDomain.hpp index 63dad0bb..3b466b5c 100644 --- a/XdmfDomain.hpp +++ b/XdmfDomain.hpp @@ -2,8 +2,11 @@ #define XDMFDOMAIN_HPP_ // Forward Declarations -class XdmfGrid; class XdmfGridCollection; +class XdmfGridCurvilinear; +class XdmfGridRectilinear; +class XdmfGridRegular; +class XdmfGridUnstructured; // Includes #include "XdmfItem.hpp" @@ -27,8 +30,11 @@ public: virtual ~XdmfDomain(); LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem) - XDMF_CHILDREN(XdmfGrid, Grid, Name) XDMF_CHILDREN(XdmfGridCollection, GridCollection, Name) + XDMF_CHILDREN(XdmfGridCurvilinear, GridCurvilinear, Name) + XDMF_CHILDREN(XdmfGridRectilinear, GridRectilinear, Name) + XDMF_CHILDREN(XdmfGridRegular, GridRegular, Name) + XDMF_CHILDREN(XdmfGridUnstructured, GridUnstructured, Name) static const std::string ItemTag; std::map getItemProperties() const; diff --git a/XdmfGrid.cpp b/XdmfGrid.cpp index 7c5b6cb7..6104d4ca 100644 --- a/XdmfGrid.cpp +++ b/XdmfGrid.cpp @@ -16,18 +16,12 @@ XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name) -boost::shared_ptr XdmfGrid::New() -{ - boost::shared_ptr p(new XdmfGrid()); - return p; -} - XdmfGrid::XdmfGrid(const std::string & name) : mGeometry(XdmfGeometry::New()), + mTopology(XdmfTopology::New()), mMap(boost::shared_ptr()), mName(name), - mTime(boost::shared_ptr()), - mTopology(XdmfTopology::New()) + mTime(boost::shared_ptr()) { } @@ -37,11 +31,6 @@ XdmfGrid::~XdmfGrid() const std::string XdmfGrid::ItemTag = "Grid"; -boost::shared_ptr XdmfGrid::getGeometry() -{ - return boost::const_pointer_cast(static_cast(*this).getGeometry()); -} - boost::shared_ptr XdmfGrid::getGeometry() const { return mGeometry; @@ -84,11 +73,6 @@ boost::shared_ptr XdmfGrid::getTime() const return mTime; } -boost::shared_ptr XdmfGrid::getTopology() -{ - return boost::const_pointer_cast(static_cast(*this).getTopology()); -} - boost::shared_ptr XdmfGrid::getTopology() const { return mTopology; @@ -135,11 +119,6 @@ void XdmfGrid::populateItem(const std::map & itemPrope } } -void XdmfGrid::setGeometry(const boost::shared_ptr geometry) -{ - mGeometry = geometry; -} - void XdmfGrid::setMap(boost::shared_ptr map) { mMap = map; @@ -155,11 +134,6 @@ void XdmfGrid::setTime(const boost::shared_ptr time) mTime = time; } -void XdmfGrid::setTopology(const boost::shared_ptr topology) -{ - mTopology = topology; -} - void XdmfGrid::traverse(const boost::shared_ptr visitor) { XdmfItem::traverse(visitor); diff --git a/XdmfGrid.hpp b/XdmfGrid.hpp index 7ca9a917..0c1b9a92 100644 --- a/XdmfGrid.hpp +++ b/XdmfGrid.hpp @@ -24,14 +24,7 @@ class XdmfGrid : public virtual XdmfItem { public: - /** - * Create a new XdmfGrid. - * - * @return constructed XdmfGrid. - */ - static boost::shared_ptr New(); - - virtual ~XdmfGrid(); + virtual ~XdmfGrid() = 0; LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem) XDMF_CHILDREN(XdmfAttribute, Attribute, Name) @@ -43,13 +36,6 @@ public: * * @return the geometry associated with this grid. */ - boost::shared_ptr getGeometry(); - - /** - * Get the geometry associated with this grid (const version). - * - * @return the geometry associated with this grid. - */ boost::shared_ptr getGeometry() const; std::map getItemProperties() const; @@ -96,24 +82,10 @@ public: * * @return the topology associated with this grid. */ - boost::shared_ptr getTopology(); - - /** - * Get the topology associated with this grid (const version). - * - * @return the topology associated with this grid. - */ boost::shared_ptr getTopology() const; using XdmfItem::insert; - /** - * Set the geometry associated with this grid. - * - * @param geometry an XdmfGeometry to associate with this grid. - */ - void setGeometry(const boost::shared_ptr geometry); - /** * Set the boundary communicator map associated with this grid. * @@ -135,13 +107,6 @@ public: */ void setTime(const boost::shared_ptr time); - /** - * Set the topology associated with this grid. - * - * @param topology an XdmfTopology to associate with this grid. - */ - void setTopology(const boost::shared_ptr topology); - virtual void traverse(const boost::shared_ptr visitor); protected: @@ -149,16 +114,17 @@ protected: XdmfGrid(const std::string & name = "Grid"); virtual void populateItem(const std::map & itemProperties, std::vector > & childItems, const XdmfCoreReader * const reader); + boost::shared_ptr mGeometry; + boost::shared_ptr mTopology; + private: XdmfGrid(const XdmfGrid & grid); // Not implemented. void operator=(const XdmfGrid & grid); // Not implemented. - boost::shared_ptr mGeometry; boost::shared_ptr mMap; std::string mName; boost::shared_ptr mTime; - boost::shared_ptr mTopology; }; diff --git a/XdmfGridCurvilinear.cpp b/XdmfGridCurvilinear.cpp index a9a23189..418260db 100644 --- a/XdmfGridCurvilinear.cpp +++ b/XdmfGridCurvilinear.cpp @@ -143,7 +143,7 @@ boost::shared_ptr XdmfGridCurvilinear::New(const boost::sha XdmfGridCurvilinear::XdmfGridCurvilinear(const boost::shared_ptr numPoints) : mImpl(new XdmfGridCurvilinearImpl(numPoints)) { - this->setTopology(XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this)); + mTopology = XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this); } XdmfGridCurvilinear::~XdmfGridCurvilinear() @@ -163,6 +163,11 @@ boost::shared_ptr XdmfGridCurvilinear::getDimensions() const return mImpl->mDimensions; } +boost::shared_ptr XdmfGridCurvilinear::getGeometry() +{ + return boost::const_pointer_cast(static_cast(*this).getGeometry()); +} + void XdmfGridCurvilinear::populateItem(const std::map & itemProperties, std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfGrid::populateItem(itemProperties, childItems, reader); @@ -181,3 +186,8 @@ void XdmfGridCurvilinear::setDimensions(const boost::shared_ptr dimen mImpl->mDimensions = dimensions; } +void XdmfGridCurvilinear::setGeometry(const boost::shared_ptr geometry) +{ + mGeometry = geometry; +} + diff --git a/XdmfGridCurvilinear.hpp b/XdmfGridCurvilinear.hpp index ea15de9b..5b26498a 100644 --- a/XdmfGridCurvilinear.hpp +++ b/XdmfGridCurvilinear.hpp @@ -1,6 +1,9 @@ #ifndef XDMFGRIDCURVILINEAR_HPP_ #define XDMFGRIDCURVILINEAR_HPP_ +// Forward Declarations +class XdmfArray; + // Includes #include "XdmfGrid.hpp" @@ -68,6 +71,13 @@ public: */ boost::shared_ptr getDimensions() const; + /** + * Get the geometry associated with this grid. + * + * @return the geometry associated with this grid. + */ + boost::shared_ptr getGeometry(); + /** * Set the dimensions of the grid, the number of points in each direction. * @@ -75,6 +85,13 @@ public: */ void setDimensions(const boost::shared_ptr dimensions); + /** + * Set the geometry associated with this grid. + * + * @param geometry an XdmfGeometry to associate with this grid. + */ + void setGeometry(const boost::shared_ptr geometry); + protected: XdmfGridCurvilinear(const boost::shared_ptr numPoints); diff --git a/XdmfGridRectilinear.cpp b/XdmfGridRectilinear.cpp index ff7f78ba..33e26a29 100644 --- a/XdmfGridRectilinear.cpp +++ b/XdmfGridRectilinear.cpp @@ -237,8 +237,8 @@ boost::shared_ptr XdmfGridRectilinear::New(const std::vecto XdmfGridRectilinear::XdmfGridRectilinear(const std::vector > & axesCoordinates) : mImpl(new XdmfGridRectilinearImpl(axesCoordinates)) { - this->setGeometry(XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this)); - this->setTopology(XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this)); + mGeometry = XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this); + mTopology = XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this); } XdmfGridRectilinear::~XdmfGridRectilinear() diff --git a/XdmfGridRectilinear.hpp b/XdmfGridRectilinear.hpp index 7fb1de35..77fd9e85 100644 --- a/XdmfGridRectilinear.hpp +++ b/XdmfGridRectilinear.hpp @@ -1,6 +1,9 @@ #ifndef XDMFGRIDRECTILINEAR_HPP_ #define XDMFGRIDRECTILINEAR_HPP_ +// Forward Declarations +class XdmfArray; + // Includes #include "XdmfGrid.hpp" diff --git a/XdmfGridRegular.cpp b/XdmfGridRegular.cpp index 15af9c16..42bf4231 100644 --- a/XdmfGridRegular.cpp +++ b/XdmfGridRegular.cpp @@ -261,8 +261,8 @@ XdmfGridRegular::XdmfGridRegular(const boost::shared_ptr brickSize, c const boost::shared_ptr origin) : mImpl(new XdmfGridRegularImpl(brickSize, numPoints, origin)) { - this->setGeometry(XdmfGridRegularImpl::XdmfGeometryRegular::New(this)); - this->setTopology(XdmfGridRegularImpl::XdmfTopologyRegular::New(this)); + mGeometry = XdmfGridRegularImpl::XdmfGeometryRegular::New(this); + mTopology = XdmfGridRegularImpl::XdmfTopologyRegular::New(this); } XdmfGridRegular::~XdmfGridRegular() diff --git a/XdmfGridRegular.hpp b/XdmfGridRegular.hpp index d542c9cb..0c5b1be7 100644 --- a/XdmfGridRegular.hpp +++ b/XdmfGridRegular.hpp @@ -1,6 +1,9 @@ #ifndef XDMFGRIDREGULAR_HPP_ #define XDMFGRIDREGULAR_HPP_ +// Forward Declarations +class XdmfArray; + // Includes #include "XdmfGrid.hpp" diff --git a/XdmfGridUnstructured.cpp b/XdmfGridUnstructured.cpp new file mode 100644 index 00000000..3a26ee82 --- /dev/null +++ b/XdmfGridUnstructured.cpp @@ -0,0 +1,50 @@ +/* + * XdmfGridUnstructured.cpp + * + * Created on: Jan 25, 2010 + * Author: kleiter + */ + +#include "XdmfGridUnstructured.hpp" + +boost::shared_ptr XdmfGridUnstructured::New() +{ + boost::shared_ptr p(new XdmfGridUnstructured()); + return p; +} + +XdmfGridUnstructured::XdmfGridUnstructured() : + XdmfGrid() +{ +} + +XdmfGridUnstructured::~XdmfGridUnstructured() +{ +} + +const std::string XdmfGridUnstructured::ItemTag = "Grid"; + +boost::shared_ptr XdmfGridUnstructured::getGeometry() +{ + return boost::const_pointer_cast(static_cast(*this).getGeometry()); +} + +std::string XdmfGridUnstructured::getItemTag() const +{ + return ItemTag; +} + +boost::shared_ptr XdmfGridUnstructured::getTopology() +{ + return boost::const_pointer_cast(static_cast(*this).getTopology()); +} + +void XdmfGridUnstructured::setGeometry(const boost::shared_ptr geometry) +{ + mGeometry = geometry; +} + +void XdmfGridUnstructured::setTopology(const boost::shared_ptr topology) +{ + mTopology = topology; +} diff --git a/XdmfGridUnstructured.hpp b/XdmfGridUnstructured.hpp new file mode 100644 index 00000000..ca773f95 --- /dev/null +++ b/XdmfGridUnstructured.hpp @@ -0,0 +1,71 @@ +#ifndef XDMFGRIDUNSTRUCTURED_HPP_ +#define XDMFGRIDUNSTRUCTURED_HPP_ + +// Includes +#include "XdmfGrid.hpp" + +/** + * @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 fields centered on various parts of the mesh. XdmfSets can be inserted into XdmfGrids + * to specify collections of mesh elements. + */ +class XdmfGridUnstructured : public XdmfGrid { + +public: + + /** + * Create a new XdmfGridUnstructured. + * + * @return constructed XdmfGridUnstructured. + */ + static boost::shared_ptr New(); + + virtual ~XdmfGridUnstructured(); + + static const std::string ItemTag; + + /** + * Get the geometry associated with this grid. + * + * @return the geometry associated with this grid. + */ + boost::shared_ptr getGeometry(); + + virtual std::string getItemTag() const; + + /** + * Get the topology associated with this grid. + * + * @return the topology associated with this grid. + */ + boost::shared_ptr getTopology(); + + /** + * Set the geometry associated with this grid. + * + * @param geometry an XdmfGeometry to associate with this grid. + */ + void setGeometry(const boost::shared_ptr geometry); + + /** + * Set the topology associated with this grid. + * + * @param topology an XdmfTopology to associate with this grid. + */ + void setTopology(const boost::shared_ptr topology); + +protected: + + XdmfGridUnstructured(); + +private: + + XdmfGridUnstructured(const XdmfGridUnstructured & grid); // Not implemented. + void operator=(const XdmfGridUnstructured & grid); // Not implemented. + +}; + +#endif /* XDMFGRID_HPP_ */ diff --git a/XdmfItemFactory.cpp b/XdmfItemFactory.cpp index 13a09b7e..4855806e 100644 --- a/XdmfItemFactory.cpp +++ b/XdmfItemFactory.cpp @@ -3,11 +3,11 @@ #include "XdmfDomain.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCurvilinear.hpp" #include "XdmfGridRectilinear.hpp" #include "XdmfGridRegular.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfInformation.hpp" #include "XdmfItemFactory.hpp" #include "XdmfMap.hpp" @@ -124,7 +124,7 @@ boost::shared_ptr XdmfItemFactory::createItem(const std::string & item return XdmfGridRectilinear::New(coordinateValues); } } - return XdmfGrid::New(); + return XdmfGridUnstructured::New(); } } else if(itemTag.compare(XdmfInformation::ItemTag) == 0) diff --git a/tests/Cxx/CMakeLists.txt b/tests/Cxx/CMakeLists.txt index bd029367..40109e26 100644 --- a/tests/Cxx/CMakeLists.txt +++ b/tests/Cxx/CMakeLists.txt @@ -12,11 +12,11 @@ ADD_TEST_CXX_DEPENDENCIES("Xdmf") # --------------------------------------- ADD_TEST_CXX(TestXdmfAttribute) ADD_TEST_CXX(TestXdmfGeometry) -ADD_TEST_CXX(TestXdmfGrid) ADD_TEST_CXX(TestXdmfGridCollection) ADD_TEST_CXX(TestXdmfGridCurvilinear) ADD_TEST_CXX(TestXdmfGridRegular) ADD_TEST_CXX(TestXdmfGridRectilinear) +ADD_TEST_CXX(TestXdmfGridUnstructured) ADD_TEST_CXX(TestXdmfReader) ADD_TEST_CXX(TestXdmfSet) ADD_TEST_CXX(TestXdmfTime) @@ -33,7 +33,6 @@ ADD_TEST_CXX(TestXdmfXPath) # --------------------------------------- CLEAN_TEST_CXX(TestXdmfAttribute) CLEAN_TEST_CXX(TestXdmfGeometry) -CLEAN_TEST_CXX(TestXdmfGrid) CLEAN_TEST_CXX(TestXdmfGridCurvilinear TestXdmfGridCurvilinear1.xmf TestXdmfGridCurvilinear2.xmf @@ -53,6 +52,7 @@ CLEAN_TEST_CXX(TestXdmfGridRectilinear TestXdmfGridRectilinear1.xmf TestXdmfGridRectilinear2.xmf ) +CLEAN_TEST_CXX(TestXdmfGridUnstructured) CLEAN_TEST_CXX(TestXdmfReader TestXdmfReader1.h5 TestXdmfReader1.xmf diff --git a/tests/Cxx/TestXdmfGridCollection.cpp b/tests/Cxx/TestXdmfGridCollection.cpp index dabb00ea..10c6cb63 100644 --- a/tests/Cxx/TestXdmfGridCollection.cpp +++ b/tests/Cxx/TestXdmfGridCollection.cpp @@ -20,15 +20,15 @@ int main(int, char *) gridCollection->setName("Collection2"); assert(gridCollection->getName().compare("Collection2") == 0); - boost::shared_ptr childGrid1 = XdmfTestDataGenerator::createHexahedron(); - boost::shared_ptr childGrid2 = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr childGrid1 = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr childGrid2 = XdmfTestDataGenerator::createHexahedron(); - assert(gridCollection->getNumberGrids() == 0); + assert(gridCollection->getNumberGridUnstructureds() == 0); gridCollection->insert(childGrid1); - assert(gridCollection->getNumberGrids() == 1); - assert(gridCollection->getGrid(0) == childGrid1); - gridCollection->removeGrid(0); - assert(gridCollection->getNumberGrids() == 0); + assert(gridCollection->getNumberGridUnstructureds() == 1); + assert(gridCollection->getGridUnstructured(0) == childGrid1); + gridCollection->removeGridUnstructured(0); + assert(gridCollection->getNumberGridUnstructureds() == 0); gridCollection->insert(childGrid1); gridCollection->insert(childGrid2); diff --git a/tests/Cxx/TestXdmfGrid.cpp b/tests/Cxx/TestXdmfGridUnstructured.cpp similarity index 94% rename from tests/Cxx/TestXdmfGrid.cpp rename to tests/Cxx/TestXdmfGridUnstructured.cpp index a0291f74..d79e7956 100644 --- a/tests/Cxx/TestXdmfGrid.cpp +++ b/tests/Cxx/TestXdmfGridUnstructured.cpp @@ -1,12 +1,12 @@ #include "XdmfAttribute.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfInformation.hpp" #include "XdmfSet.hpp" #include "XdmfTime.hpp" int main(int, char *) { - boost::shared_ptr grid = XdmfGrid::New(); + boost::shared_ptr grid = XdmfGridUnstructured::New(); std::string gridName = "Grid1"; grid->setName(gridName); diff --git a/tests/Cxx/TestXdmfReader.cpp b/tests/Cxx/TestXdmfReader.cpp index c5b2ffa7..0a6cd9e7 100644 --- a/tests/Cxx/TestXdmfReader.cpp +++ b/tests/Cxx/TestXdmfReader.cpp @@ -10,8 +10,8 @@ int main(int, char *) boost::shared_ptr writer = XdmfWriter::New("TestXdmfReader1.xmf"); writer->setLightDataLimit(10); - boost::shared_ptr grid1 = XdmfTestDataGenerator::createHexahedron(); - boost::shared_ptr grid2 = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr grid1 = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr grid2 = XdmfTestDataGenerator::createHexahedron(); boost::shared_ptr domain = XdmfDomain::New(); domain->insert(grid1); @@ -29,7 +29,7 @@ int main(int, char *) std::vector > readItems = reader->read("TestXdmfReader1.xmf", "/Xdmf/Domain/Grid[1]"); assert(readItems.size() == 1); - boost::shared_ptr readGrid = boost::shared_dynamic_cast(readItems[0]); + boost::shared_ptr readGrid = boost::shared_dynamic_cast(readItems[0]); assert(readGrid->getName().compare("Hexahedron") == 0); std::vector > readItems2 = reader->read("TestXdmfReader1.xmf", "//Attribute"); diff --git a/tests/Cxx/TestXdmfWriter.cpp b/tests/Cxx/TestXdmfWriter.cpp index 78a96607..89e9e4c4 100644 --- a/tests/Cxx/TestXdmfWriter.cpp +++ b/tests/Cxx/TestXdmfWriter.cpp @@ -14,7 +14,7 @@ int main(int, char *) writer->setLightDataLimit(10); assert(writer->getLightDataLimit() == 10); - boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); boost::shared_ptr domain = XdmfDomain::New(); domain->insert(grid); diff --git a/tests/Cxx/TestXdmfWriterHDF5ThenXML.cpp b/tests/Cxx/TestXdmfWriterHDF5ThenXML.cpp index 809be0f1..0b016c8a 100644 --- a/tests/Cxx/TestXdmfWriterHDF5ThenXML.cpp +++ b/tests/Cxx/TestXdmfWriterHDF5ThenXML.cpp @@ -6,7 +6,7 @@ int main(int, char *) { - boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); // First write and release heavy data boost::shared_ptr hdf5Writer = XdmfHDF5Writer::New("output.h5"); diff --git a/tests/Cxx/TestXdmfXPath.cpp b/tests/Cxx/TestXdmfXPath.cpp index be58cf0c..2673d5ec 100644 --- a/tests/Cxx/TestXdmfXPath.cpp +++ b/tests/Cxx/TestXdmfXPath.cpp @@ -8,9 +8,9 @@ int main(int, char *) { boost::shared_ptr writer = XdmfWriter::New("XdmfXPath1.xmf"); - boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr grid = XdmfTestDataGenerator::createHexahedron(); - boost::shared_ptr newGrid = XdmfGrid::New(); + boost::shared_ptr newGrid = XdmfGridUnstructured::New(); newGrid->setName("NoAttributes"); newGrid->setGeometry(grid->getGeometry()); newGrid->setTopology(grid->getTopology()); diff --git a/tests/Cxx/XdmfTestDataGenerator.hpp b/tests/Cxx/XdmfTestDataGenerator.hpp index 70fef223..aa95667b 100644 --- a/tests/Cxx/XdmfTestDataGenerator.hpp +++ b/tests/Cxx/XdmfTestDataGenerator.hpp @@ -4,7 +4,7 @@ #include "XdmfArray.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTime.hpp" @@ -25,9 +25,9 @@ public: * Time = 100 * Total Number of Values = 69 */ - static boost::shared_ptr createHexahedron() + static boost::shared_ptr createHexahedron() { - boost::shared_ptr grid = XdmfGrid::New(); + boost::shared_ptr grid = XdmfGridUnstructured::New(); grid->setName("Hexahedron"); // Set Geometry diff --git a/tests/Java/TestXdmfJava.java b/tests/Java/TestXdmfJava.java index 530d058b..eaffa315 100644 --- a/tests/Java/TestXdmfJava.java +++ b/tests/Java/TestXdmfJava.java @@ -11,7 +11,7 @@ public class TestXdmfJava { XdmfWriter writer = XdmfWriter.New("outputJavaTest.xmf"); writer.setLightDataLimit((long)10); - XdmfGrid grid = XdmfGrid.New(); + XdmfGridUnstructured grid = XdmfGridUnstructured.New(); grid.setName("test"); grid.getGeometry().setType(XdmfGeometryType.XYZ()); diff --git a/tests/Python/TestXdmfHDF5Writer.py b/tests/Python/TestXdmfHDF5Writer.py index 6c3849a4..bfe872f6 100644 --- a/tests/Python/TestXdmfHDF5Writer.py +++ b/tests/Python/TestXdmfHDF5Writer.py @@ -4,7 +4,7 @@ if __name__ == "__main__": writer = XdmfHDF5Writer.New("hdf5WriterPythonTest.h5") - grid = XdmfGrid.New() + grid = XdmfGridUnstructured.New() grid.setName("test") points = [0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1] diff --git a/tests/Python/TestXdmfWriter.py b/tests/Python/TestXdmfWriter.py index 6ec116f2..0afaf8f7 100644 --- a/tests/Python/TestXdmfWriter.py +++ b/tests/Python/TestXdmfWriter.py @@ -5,7 +5,7 @@ if __name__ == "__main__": writer = XdmfWriter.New("output.xmf") writer.setLightDataLimit(10) - grid = XdmfGrid.New() + grid = XdmfGridUnstructured.New() grid.setName("test") points = [0.1, 0.1, 1.1, 1.1, 0.1, 1.1, 3.1, 0.1, 2.1, 0.1, 1.1, 1.1, 1.1, 1.1, 1.1, 3.1, 2.1, 2.1, 0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1] diff --git a/utils/XdmfExodusReader.cpp b/utils/XdmfExodusReader.cpp index d93df71e..9e721431 100644 --- a/utils/XdmfExodusReader.cpp +++ b/utils/XdmfExodusReader.cpp @@ -6,7 +6,7 @@ #include "XdmfExodusReader.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" @@ -27,11 +27,11 @@ XdmfExodusReader::~XdmfExodusReader() { } -boost::shared_ptr XdmfExodusReader::read(const std::string & fileName, const boost::shared_ptr heavyDataWriter) const +boost::shared_ptr XdmfExodusReader::read(const std::string & fileName, const boost::shared_ptr heavyDataWriter) const { - boost::shared_ptr toReturn = XdmfGrid::New(); + boost::shared_ptr toReturn = XdmfGridUnstructured::New(); - // Read Exodus II file to XdmfGrid via Exodus II API + // Read Exodus II file to XdmfGridUnstructured via Exodus II API float version; int CPU_word_size = sizeof(double); int IO_word_size = 0; // Get from file diff --git a/utils/XdmfExodusReader.hpp b/utils/XdmfExodusReader.hpp index 75257576..87a38fc0 100644 --- a/utils/XdmfExodusReader.hpp +++ b/utils/XdmfExodusReader.hpp @@ -2,7 +2,7 @@ #define XDMFEXODUSREADER_HPP_ // Forward Declarations -class XdmfGrid; +class XdmfGridUnstructured; class XdmfHDF5Writer; class XdmfTopologyType; @@ -32,9 +32,9 @@ public: * @param fileName containing the path of the exodus file to read. * @param heavyDataWriter an XdmfHDF5Writer to write the mesh to. If no heavyDataWriter is specified, all mesh data will remain in memory. * - * @return XdmfGrid containing the mesh stored in the ExodusII file. + * @return XdmfGridUnstructured containing the mesh stored in the ExodusII file. */ - boost::shared_ptr read(const std::string & fileName, const boost::shared_ptr heavyDataWriter = boost::shared_ptr()) const; + boost::shared_ptr read(const std::string & fileName, const boost::shared_ptr heavyDataWriter = boost::shared_ptr()) const; protected: diff --git a/utils/XdmfExodusWriter.cpp b/utils/XdmfExodusWriter.cpp index 37966bb7..11bb672e 100644 --- a/utils/XdmfExodusWriter.cpp +++ b/utils/XdmfExodusWriter.cpp @@ -6,9 +6,9 @@ #include "XdmfExodusWriter.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfSet.hpp" #include "XdmfSetType.hpp" #include "XdmfTopology.hpp" @@ -80,7 +80,7 @@ XdmfExodusWriter::~XdmfExodusWriter() delete mImpl; } -void XdmfExodusWriter::write(const std::string & filePath, const boost::shared_ptr gridToWrite) const +void XdmfExodusWriter::write(const std::string & filePath, const boost::shared_ptr gridToWrite) const { // Open Exodus File @@ -96,14 +96,14 @@ void XdmfExodusWriter::write(const std::string & filePath, const boost::shared_p } boost::shared_ptr gridCollection = boost::shared_ptr(); - boost::shared_ptr currGrid = gridToWrite; + boost::shared_ptr currGrid = gridToWrite; // Check if they are temporal collections and use the first grid to determine geometry and topology. if(boost::shared_ptr tmpGrid = boost::shared_dynamic_cast(gridToWrite)) { - if(tmpGrid->getType() == XdmfGridCollectionType::Temporal() && tmpGrid->getNumberGrids() > 0) + if(tmpGrid->getType() == XdmfGridCollectionType::Temporal() && tmpGrid->getNumberGridUnstructureds() > 0) { - currGrid = tmpGrid->getGrid(0); + currGrid = tmpGrid->getGridUnstructured(0); gridCollection = tmpGrid; } else @@ -332,7 +332,7 @@ void XdmfExodusWriter::write(const std::string & filePath, const boost::shared_p int numGrids = 1; if(gridCollection) { - numGrids = gridCollection->getNumberGrids(); + numGrids = gridCollection->getNumberGridUnstructureds(); } for(int i=0; igetGrid(i); + currGrid = gridCollection->getGridUnstructured(i); } for(unsigned int j=0; jgetNumberAttributes(); ++j) diff --git a/utils/XdmfExodusWriter.hpp b/utils/XdmfExodusWriter.hpp index f4477bb5..0d7ce88e 100644 --- a/utils/XdmfExodusWriter.hpp +++ b/utils/XdmfExodusWriter.hpp @@ -2,7 +2,7 @@ #define XDMFEXODUSWRITER_HPP_ // Forward Declarations -class XdmfGrid; +class XdmfGridUnstructured; class XdmfTopologyType; // Includes @@ -26,12 +26,12 @@ public: virtual ~XdmfExodusWriter(); /*! - * Write an XdmfGrid to an ExodusII file. + * Write an XdmfGridUnstructured to an ExodusII file. * * @param filePath of the ExodusII file to write. * @param gridToWrite an XdmfGrid to write to ExodusII file format. */ - void write(const std::string & filePath, const boost::shared_ptr gridToWrite) const; + void write(const std::string & filePath, const boost::shared_ptr gridToWrite) const; protected: diff --git a/utils/XdmfPartitioner.cpp b/utils/XdmfPartitioner.cpp index e74bd7c5..e22e4715 100644 --- a/utils/XdmfPartitioner.cpp +++ b/utils/XdmfPartitioner.cpp @@ -12,7 +12,7 @@ extern "C" #include "XdmfAttributeType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfGridCollection.hpp" #include "XdmfGridCollectionType.hpp" #include "XdmfHDF5Writer.hpp" @@ -37,7 +37,7 @@ XdmfPartitioner::~XdmfPartitioner() { } -boost::shared_ptr XdmfPartitioner::partition(const boost::shared_ptr gridToPartition, const unsigned int numberOfPartitions, +boost::shared_ptr XdmfPartitioner::partition(const boost::shared_ptr gridToPartition, const unsigned int numberOfPartitions, const boost::shared_ptr heavyDataWriter) const { // Make sure geometry and topology are non null @@ -182,7 +182,7 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh std::stringstream name; name << gridToPartition->getName() << "_" << i; - boost::shared_ptr partitioned = XdmfGrid::New(); + boost::shared_ptr partitioned = XdmfGridUnstructured::New(); partitioned->setName(name.str()); partitionedGrids->insert(partitioned); @@ -271,7 +271,7 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh std::vector & currElemIds = globalElementIds[j]; if(currElemIds.size() > 0) { - boost::shared_ptr partitioned = partitionedGrids->getGrid(partitionId); + boost::shared_ptr partitioned = partitionedGrids->getGridUnstructured(partitionId); partitionId++; boost::shared_ptr createdAttribute = boost::shared_ptr(); if(currAttribute->getCenter() == XdmfAttributeCenter::Grid()) @@ -346,7 +346,7 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh std::vector & currElemIds = globalElementIds[j]; if(currElemIds.size() > 0) { - boost::shared_ptr partitioned = partitionedGrids->getGrid(partitionId); + boost::shared_ptr partitioned = partitionedGrids->getGridUnstructured(partitionId); partitionId++; boost::shared_ptr partitionedSet = XdmfSet::New(); @@ -395,9 +395,9 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh // Add XdmfMap to map boundary nodes between partitions std::vector > globalNodeIds; - for(unsigned int i=0; igetNumberGrids(); ++i) + for(unsigned int i=0; igetNumberGridUnstructureds(); ++i) { - boost::shared_ptr globalNodeId = partitionedGrids->getGrid(i)->getAttribute("GlobalNodeId"); + boost::shared_ptr globalNodeId = partitionedGrids->getGridUnstructured(i)->getAttribute("GlobalNodeId"); if(!globalNodeId->isInitialized()) { globalNodeId->read(); @@ -406,10 +406,10 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh } std::vector > maps = XdmfMap::New(globalNodeIds); - for(unsigned int i=0; igetNumberGrids(); ++i) + for(unsigned int i=0; igetNumberGridUnstructureds(); ++i) { boost::shared_ptr map = maps[i]; - partitionedGrids->getGrid(i)->setMap(map); + partitionedGrids->getGridUnstructured(i)->setMap(map); if(heavyDataWriter) { globalNodeIds[i]->release(); @@ -435,7 +435,7 @@ boost::shared_ptr XdmfPartitioner::partition(const boost::sh /** * XdmfPartitioner is a command line utility for partitioning Xdmf grids. * The XdmfPartitioner uses the metis library to partition Triangular, Quadrilateral, Tetrahedral, - * and Hexahedral XdmfGrids. + * and Hexahedral XdmfGridUnstructureds. * * Usage: * XdmfPartitioner (Optional: ) @@ -490,7 +490,7 @@ int main(int argc, char* argv[]) boost::shared_ptr reader = XdmfReader::New(); boost::shared_ptr domain = boost::shared_dynamic_cast(reader->read(argv[1])); - if(domain->getNumberGrids() <= 0) + if(domain->getNumberGridUnstructureds() <= 0) { std::cout << "No grids to partition" << std::endl; return 1; @@ -501,7 +501,7 @@ int main(int argc, char* argv[]) boost::shared_ptr heavyDataWriter = XdmfHDF5Writer::New(heavyFileName.str()); boost::shared_ptr partitioner = XdmfPartitioner::New(); - boost::shared_ptr toWrite = partitioner->partition(domain->getGrid(0), numPartitions, heavyDataWriter); + boost::shared_ptr toWrite = partitioner->partition(domain->getGridUnstructured(0), numPartitions, heavyDataWriter); boost::shared_ptr newDomain = XdmfDomain::New(); newDomain->insert(toWrite); diff --git a/utils/XdmfPartitioner.hpp b/utils/XdmfPartitioner.hpp index fe81b703..322357f1 100644 --- a/utils/XdmfPartitioner.hpp +++ b/utils/XdmfPartitioner.hpp @@ -2,7 +2,7 @@ #define XDMFPARTITIONER_HPP_ // Forward Declarations -class XdmfGrid; +class XdmfGridUnstructured; class XdmfGridCollection; class XdmfHDF5Writer; @@ -42,17 +42,17 @@ public: * XdmfTopologyType::Hexahedron_27 * XdmfTopologyType::Hexahedron_64 * - * The partitioner splits the XdmfGrid and all attached XdmfAttributes and XdmfSets into their proper partition. + * The partitioner splits the XdmfGridUnstructured and all attached XdmfAttributes and XdmfSets into their proper partition. * An XdmfAttribute named "GlobalNodeId" is added to each partitioned grid to map partitioned node ids to their * original unpartitioned id. All arrays attached to the passed gridToPartition are read from disk if not initialized. * - * @param gridToPartition an XdmfGrid to partition. + * @param gridToPartition an XdmfGridUnstructured to partition. * @param numberOfPartitions the number of pieces to partition the grid into. * @param heavyDataWriter an XdmfHDF5Writer to write the partitioned mesh to. If no heavyDataWriter is specified, all partitioned data will remain in memory. * * @return a spatial collection containing partitioned grids. */ - boost::shared_ptr partition(const boost::shared_ptr gridToPartition, const unsigned int numberOfPartitions, + boost::shared_ptr partition(const boost::shared_ptr gridToPartition, const unsigned int numberOfPartitions, const boost::shared_ptr heavyDataWriter = boost::shared_ptr()) const; protected: diff --git a/utils/XdmfTopologyConverter.cpp b/utils/XdmfTopologyConverter.cpp index 502d80db..1f501230 100644 --- a/utils/XdmfTopologyConverter.cpp +++ b/utils/XdmfTopologyConverter.cpp @@ -4,7 +4,7 @@ #include "XdmfAttributeType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfHDF5Writer.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" @@ -67,7 +67,7 @@ public: } }; - virtual boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const = 0; + virtual boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const = 0; void insertPointWithoutCheck(const std::vector & newPoint, const boost::shared_ptr & newConnectivity, const boost::shared_ptr & newPoints) const { @@ -102,9 +102,9 @@ public: { } - boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const + boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const { - boost::shared_ptr toReturn = XdmfGrid::New(); + boost::shared_ptr toReturn = XdmfGridUnstructured::New(); toReturn->setName(gridToConvert->getName()); toReturn->setGeometry(gridToConvert->getGeometry()); @@ -232,9 +232,9 @@ public: rightPoint[2] = (1.0/3.0)*(2*point2[2] + point1[2]); } - boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const + boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const { - boost::shared_ptr toReturn = XdmfGrid::New(); + boost::shared_ptr toReturn = XdmfGridUnstructured::New(); toReturn->setName(gridToConvert->getName()); boost::shared_ptr toReturnGeometry = toReturn->getGeometry(); @@ -558,9 +558,9 @@ public: threeQuarterPoint[2] = (1.0/4.0)*(3.0*point2[2] + point1[2]); } - boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const + boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr heavyDataWriter) const { - boost::shared_ptr toReturn = XdmfGrid::New(); + boost::shared_ptr toReturn = XdmfGridUnstructured::New(); toReturn->setName(gridToConvert->getName()); boost::shared_ptr toReturnGeometry = toReturn->getGeometry(); @@ -1804,7 +1804,7 @@ XdmfTopologyConverter::~XdmfTopologyConverter() { } -boost::shared_ptr XdmfTopologyConverter::convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr topologyType, +boost::shared_ptr XdmfTopologyConverter::convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr topologyType, const boost::shared_ptr heavyDataWriter) const { // Make sure geometry and topology are non null @@ -1858,7 +1858,7 @@ boost::shared_ptr XdmfTopologyConverter::convert(const boost::shared_p } if(converter) { - boost::shared_ptr toReturn = converter->convert(gridToConvert, heavyDataWriter); + boost::shared_ptr toReturn = converter->convert(gridToConvert, heavyDataWriter); delete converter; return toReturn; } diff --git a/utils/XdmfTopologyConverter.hpp b/utils/XdmfTopologyConverter.hpp index aaabc970..dc8a6a3d 100644 --- a/utils/XdmfTopologyConverter.hpp +++ b/utils/XdmfTopologyConverter.hpp @@ -2,7 +2,7 @@ #define XDMFTOPOLOGYCONVERTER_HPP_ // Forward Declarations -class XdmfGrid; +class XdmfGridUnstructured; class XdmfHDF5Writer; class XdmfTopologyType; @@ -10,7 +10,7 @@ class XdmfTopologyType; #include /*! - * @brief XdmfTopologyConverter converts an XdmfGrid to different topology types. XdmfAttributes and XdmfSets attached to the XdmfGrid + * @brief XdmfTopologyConverter converts an XdmfGridUnstructured to different topology types. XdmfAttributes and XdmfSets attached to the XdmfGrid * are adjusted to remain valid for the new topology type. * * When converting from a lower order topology to a higher order topology type (e.g. Hexahedron to Hexahedron_64) additional points are added to the mesh, no additional elements are added. @@ -38,15 +38,15 @@ public: virtual ~XdmfTopologyConverter(); /** - * Converts an XdmfGrid to a different topology type + * Converts an XdmfGridUnstructured to a different topology type * - * @param gridToConvert the XdmfGrid to convert to a different topology + * @param gridToConvert the XdmfGridUnstructured to convert to a different topology * @param topologyType the XdmfTopologyType to convert to. * @param heavyDataWriter an XdmfHDF5Writer to write the converted mesh to. If no heavyDataWriter is specified, all mesh data will remain in memory. * - * @return the converted XdmfGrid. + * @return the converted XdmfGridUnstructured. */ - boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr topologyType, + boost::shared_ptr convert(const boost::shared_ptr gridToConvert, const boost::shared_ptr topologyType, const boost::shared_ptr heavyDataWriter = boost::shared_ptr()) const; protected: diff --git a/utils/XdmfUtils.i b/utils/XdmfUtils.i index d628667b..0734100e 100644 --- a/utils/XdmfUtils.i +++ b/utils/XdmfUtils.i @@ -38,6 +38,7 @@ swig -v -c++ -python -o XdmfUtilsPython.cpp XdmfUtils.i #include #include #include + #include #include #include #include diff --git a/utils/tests/Cxx/TestXdmfExodusIO.cpp b/utils/tests/Cxx/TestXdmfExodusIO.cpp index 76a31027..72bd80fa 100644 --- a/utils/tests/Cxx/TestXdmfExodusIO.cpp +++ b/utils/tests/Cxx/TestXdmfExodusIO.cpp @@ -9,11 +9,11 @@ int main(int, char *) { boost::shared_ptr exodusWriter = XdmfExodusWriter::New(); - boost::shared_ptr hexahedron = XdmfTestDataGenerator::createHexahedron(); + boost::shared_ptr hexahedron = XdmfTestDataGenerator::createHexahedron(); exodusWriter->write("TestXdmfExodusIO.exo", hexahedron); boost::shared_ptr reader = XdmfExodusReader::New(); - boost::shared_ptr grid = reader->read("TestXdmfExodusIO.exo"); + boost::shared_ptr grid = reader->read("TestXdmfExodusIO.exo"); assert(grid->getName() == hexahedron->getName()); assert(grid->getGeometry()->getType() == hexahedron->getGeometry()->getType()); assert(grid->getGeometry()->getNumberPoints() == hexahedron->getGeometry()->getNumberPoints()); diff --git a/utils/tests/Cxx/TestXdmfTopologyConverter.cpp b/utils/tests/Cxx/TestXdmfTopologyConverter.cpp index 8506abb3..b58ab34a 100644 --- a/utils/tests/Cxx/TestXdmfTopologyConverter.cpp +++ b/utils/tests/Cxx/TestXdmfTopologyConverter.cpp @@ -3,7 +3,7 @@ #include "XdmfArrayType.hpp" #include "XdmfGeometry.hpp" #include "XdmfGeometryType.hpp" -#include "XdmfGrid.hpp" +#include "XdmfGridUnstructured.hpp" #include "XdmfTopology.hpp" #include "XdmfTopologyConverter.hpp" #include "XdmfTopologyType.hpp" @@ -16,7 +16,7 @@ int main(int, char *) boost::shared_ptr converter = XdmfTopologyConverter::New(); // Create Hexahedron Grid - boost::shared_ptr hexGrid = XdmfGrid::New(); + boost::shared_ptr hexGrid = XdmfGridUnstructured::New(); double hexPoints[24] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1}; hexGrid->getGeometry()->setType(XdmfGeometryType::XYZ()); hexGrid->getGeometry()->resize(24, 0); @@ -29,7 +29,7 @@ int main(int, char *) /* * Hexahedron to Hexahedron_64 */ - boost::shared_ptr hex64Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_64()); + boost::shared_ptr hex64Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_64()); assert(hex64Grid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(hex64Grid->getGeometry()->getNumberPoints() == 64); @@ -64,7 +64,7 @@ int main(int, char *) /* * Hexahedron to Hexahedron_125 */ - boost::shared_ptr hex125Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_125()); + boost::shared_ptr hex125Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_125()); assert(hex125Grid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(hex125Grid->getGeometry()->getNumberPoints() == 125); @@ -78,7 +78,7 @@ int main(int, char *) /* * Hexahedron_64 to Hexahedron */ - boost::shared_ptr newHexGrid = converter->convert(hex64Grid, XdmfTopologyType::Hexahedron()); + boost::shared_ptr newHexGrid = converter->convert(hex64Grid, XdmfTopologyType::Hexahedron()); assert(newHexGrid->getGeometry()->getType() == XdmfGeometryType::XYZ()); assert(newHexGrid->getGeometry()->getNumberPoints() == 64); for(unsigned int i=0; i<192; ++i) -- GitLab