Commit d6c61374 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Added XdmfGridUnstructured and turned XdmfGrid into an abstract base...

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.
parent bc2792d3
...@@ -138,6 +138,7 @@ if(NOT XDMF_BUILD_CORE_ONLY) ...@@ -138,6 +138,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfGridCurvilinear XdmfGridCurvilinear
XdmfGridRectilinear XdmfGridRectilinear
XdmfGridRegular XdmfGridRegular
XdmfGridUnstructured
XdmfItemFactory XdmfItemFactory
XdmfMap XdmfMap
XdmfReader XdmfReader
......
...@@ -38,6 +38,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -38,6 +38,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfGridCurvilinear.hpp> #include <XdmfGridCurvilinear.hpp>
#include <XdmfGridRectilinear.hpp> #include <XdmfGridRectilinear.hpp>
#include <XdmfGridRegular.hpp> #include <XdmfGridRegular.hpp>
#include <XdmfGridUnstructured.hpp>
#include <XdmfItemFactory.hpp> #include <XdmfItemFactory.hpp>
#include <XdmfMap.hpp> #include <XdmfMap.hpp>
#include <XdmfReader.hpp> #include <XdmfReader.hpp>
...@@ -67,10 +68,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -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; *(boost::shared_ptr< XdmfGeometry > **)&($result) = value ? new boost::shared_ptr< XdmfGeometry >(value) : 0;
} }
else if(boost::shared_ptr<XdmfGrid> value = boost::shared_dynamic_cast<XdmfGrid>($1))
{
*(boost::shared_ptr< XdmfGrid > **)&($result) = value ? new boost::shared_ptr< XdmfGrid >(value) : 0;
}
else if(boost::shared_ptr<XdmfGridCollection> value = boost::shared_dynamic_cast<XdmfGridCollection>($1)) else if(boost::shared_ptr<XdmfGridCollection> value = boost::shared_dynamic_cast<XdmfGridCollection>($1))
{ {
*(boost::shared_ptr< XdmfGridCollection > **)&($result) = value ? new boost::shared_ptr< XdmfGridCollection >(value) : 0; *(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 ...@@ -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; *(boost::shared_ptr< XdmfGridRegular > **)&($result) = value ? new boost::shared_ptr< XdmfGridRegular >(value) : 0;
} }
else if(boost::shared_ptr<XdmfGridUnstructured> value = boost::shared_dynamic_cast<XdmfGridUnstructured>($1))
{
*(boost::shared_ptr< XdmfGridUnstructured > **)&($result) = value ? new boost::shared_ptr< XdmfGridUnstructured >(value) : 0;
}
else if(boost::shared_ptr<XdmfInformation> value = boost::shared_dynamic_cast<XdmfInformation>($1)) else if(boost::shared_ptr<XdmfInformation> value = boost::shared_dynamic_cast<XdmfInformation>($1))
{ {
*(boost::shared_ptr< XdmfInformation > **)&($result) = value ? new boost::shared_ptr< XdmfInformation >(value) : 0; *(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 ...@@ -110,18 +111,22 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
} }
// Ignore const overloaded methods // 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 unsigned int) const;
%ignore XdmfDomain::getGridCollection(const std::string &) 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 unsigned int) const;
%ignore XdmfGrid::getAttribute(const std::string &) const; %ignore XdmfGrid::getAttribute(const std::string &) const;
%ignore XdmfGrid::getGeometry() const;
%ignore XdmfGrid::getMap() const; %ignore XdmfGrid::getMap() const;
%ignore XdmfGrid::getSet(const unsigned int) const; %ignore XdmfGrid::getSet(const unsigned int) const;
%ignore XdmfGrid::getSet(const std::string &) const; %ignore XdmfGrid::getSet(const std::string &) const;
%ignore XdmfGrid::getTime() const; %ignore XdmfGrid::getTime() const;
%ignore XdmfGrid::getTopology() const;
%ignore XdmfGridCurvilinear::getDimensions() const; %ignore XdmfGridCurvilinear::getDimensions() const;
%ignore XdmfGridRectilinear::getCoordinates(const unsigned int) const; %ignore XdmfGridRectilinear::getCoordinates(const unsigned int) const;
%ignore XdmfGridRectilinear::getCoordinates() const; %ignore XdmfGridRectilinear::getCoordinates() const;
...@@ -191,10 +196,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -191,10 +196,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
{ {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGeometry>(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN); $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGeometry>(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN);
} }
else if(boost::shared_ptr<XdmfGrid> grid = boost::shared_dynamic_cast<XdmfGrid>($1))
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGrid>(grid)), SWIGTYPE_p_boost__shared_ptrT_XdmfGrid_t, SWIG_POINTER_OWN);
}
else if(boost::shared_ptr<XdmfGridCollection> gridCollection = boost::shared_dynamic_cast<XdmfGridCollection>($1)) else if(boost::shared_ptr<XdmfGridCollection> gridCollection = boost::shared_dynamic_cast<XdmfGridCollection>($1))
{ {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN); $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
...@@ -211,6 +212,10 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -211,6 +212,10 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
{ {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridRegular>(gridRegular)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridRegular_t, SWIG_POINTER_OWN); $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridRegular>(gridRegular)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridRegular_t, SWIG_POINTER_OWN);
} }
else if(boost::shared_ptr<XdmfGridUnstructured> gridUnstructured = boost::shared_dynamic_cast<XdmfGridUnstructured>($1))
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridUnstructured>(gridUnstructured)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridUnstructured_t, SWIG_POINTER_OWN);
}
else if(boost::shared_ptr<XdmfInformation> information = boost::shared_dynamic_cast<XdmfInformation>($1)) else if(boost::shared_ptr<XdmfInformation> information = boost::shared_dynamic_cast<XdmfInformation>($1))
{ {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN); $result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN);
...@@ -252,6 +257,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -252,6 +257,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%shared_ptr(XdmfGridCurvilinear) %shared_ptr(XdmfGridCurvilinear)
%shared_ptr(XdmfGridRectilinear) %shared_ptr(XdmfGridRectilinear)
%shared_ptr(XdmfGridRegular) %shared_ptr(XdmfGridRegular)
%shared_ptr(XdmfGridUnstructured)
%shared_ptr(XdmfItemFactory) %shared_ptr(XdmfItemFactory)
%shared_ptr(XdmfMap) %shared_ptr(XdmfMap)
%shared_ptr(XdmfReader) %shared_ptr(XdmfReader)
...@@ -273,6 +279,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -273,6 +279,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include XdmfGridCurvilinear.hpp %include XdmfGridCurvilinear.hpp
%include XdmfGridRectilinear.hpp %include XdmfGridRectilinear.hpp
%include XdmfGridRegular.hpp %include XdmfGridRegular.hpp
%include XdmfGridUnstructured.hpp
%include XdmfItemFactory.hpp %include XdmfItemFactory.hpp
%include XdmfMap.hpp %include XdmfMap.hpp
%include XdmfReader.hpp %include XdmfReader.hpp
......
...@@ -6,11 +6,17 @@ ...@@ -6,11 +6,17 @@
*/ */
#include "XdmfDomain.hpp" #include "XdmfDomain.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGridCollection.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, 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> XdmfDomain::New() boost::shared_ptr<XdmfDomain> XdmfDomain::New()
{ {
...@@ -48,7 +54,19 @@ void XdmfDomain::populateItem(const std::map<std::string, std::string> & itemPro ...@@ -48,7 +54,19 @@ void XdmfDomain::populateItem(const std::map<std::string, std::string> & itemPro
{ {
this->insert(gridCollection); this->insert(gridCollection);
} }
else if(boost::shared_ptr<XdmfGrid> grid = boost::shared_dynamic_cast<XdmfGrid>(*iter)) else if(boost::shared_ptr<XdmfGridCurvilinear> grid = boost::shared_dynamic_cast<XdmfGridCurvilinear>(*iter))
{
this->insert(grid);
}
else if(boost::shared_ptr<XdmfGridRectilinear> grid = boost::shared_dynamic_cast<XdmfGridRectilinear>(*iter))
{
this->insert(grid);
}
else if(boost::shared_ptr<XdmfGridRegular> grid = boost::shared_dynamic_cast<XdmfGridRegular>(*iter))
{
this->insert(grid);
}
else if(boost::shared_ptr<XdmfGridUnstructured> grid = boost::shared_dynamic_cast<XdmfGridUnstructured>(*iter))
{ {
this->insert(grid); this->insert(grid);
} }
...@@ -58,11 +76,23 @@ void XdmfDomain::populateItem(const std::map<std::string, std::string> & itemPro ...@@ -58,11 +76,23 @@ void XdmfDomain::populateItem(const std::map<std::string, std::string> & itemPro
void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{ {
XdmfItem::traverse(visitor); XdmfItem::traverse(visitor);
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter) for(std::vector<boost::shared_ptr<XdmfGridCollection> >::const_iterator iter = mGridCollections.begin(); iter != mGridCollections.end(); ++iter)
{ {
(*iter)->accept(visitor); (*iter)->accept(visitor);
} }
for(std::vector<boost::shared_ptr<XdmfGridCollection> >::const_iterator iter = mGridCollections.begin(); iter != mGridCollections.end(); ++iter) for(std::vector<boost::shared_ptr<XdmfGridCurvilinear> >::const_iterator iter = mGridCurvilinears.begin(); iter != mGridCurvilinears.end(); ++iter)
{
(*iter)->accept(visitor);
}
for(std::vector<boost::shared_ptr<XdmfGridRectilinear> >::const_iterator iter = mGridRectilinears.begin(); iter != mGridRectilinears.end(); ++iter)
{
(*iter)->accept(visitor);
}
for(std::vector<boost::shared_ptr<XdmfGridRegular> >::const_iterator iter = mGridRegulars.begin(); iter != mGridRegulars.end(); ++iter)
{
(*iter)->accept(visitor);
}
for(std::vector<boost::shared_ptr<XdmfGridUnstructured> >::const_iterator iter = mGridUnstructureds.begin(); iter != mGridUnstructureds.end(); ++iter)
{ {
(*iter)->accept(visitor); (*iter)->accept(visitor);
} }
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
#define XDMFDOMAIN_HPP_ #define XDMFDOMAIN_HPP_
// Forward Declarations // Forward Declarations
class XdmfGrid;
class XdmfGridCollection; class XdmfGridCollection;
class XdmfGridCurvilinear;
class XdmfGridRectilinear;
class XdmfGridRegular;
class XdmfGridUnstructured;
// Includes // Includes
#include "XdmfItem.hpp" #include "XdmfItem.hpp"
...@@ -27,8 +30,11 @@ public: ...@@ -27,8 +30,11 @@ public:
virtual ~XdmfDomain(); virtual ~XdmfDomain();
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem) LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem)
XDMF_CHILDREN(XdmfGrid, Grid, Name)
XDMF_CHILDREN(XdmfGridCollection, GridCollection, 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; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -16,18 +16,12 @@ ...@@ -16,18 +16,12 @@
XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name) XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name)
boost::shared_ptr<XdmfGrid> XdmfGrid::New()
{
boost::shared_ptr<XdmfGrid> p(new XdmfGrid());
return p;
}
XdmfGrid::XdmfGrid(const std::string & name) : XdmfGrid::XdmfGrid(const std::string & name) :
mGeometry(XdmfGeometry::New()), mGeometry(XdmfGeometry::New()),
mTopology(XdmfTopology::New()),
mMap(boost::shared_ptr<XdmfMap>()), mMap(boost::shared_ptr<XdmfMap>()),
mName(name), mName(name),
mTime(boost::shared_ptr<XdmfTime>()), mTime(boost::shared_ptr<XdmfTime>())
mTopology(XdmfTopology::New())
{ {
} }
...@@ -37,11 +31,6 @@ XdmfGrid::~XdmfGrid() ...@@ -37,11 +31,6 @@ XdmfGrid::~XdmfGrid()
const std::string XdmfGrid::ItemTag = "Grid"; const std::string XdmfGrid::ItemTag = "Grid";
boost::shared_ptr<XdmfGeometry> XdmfGrid::getGeometry()
{
return boost::const_pointer_cast<XdmfGeometry>(static_cast<const XdmfGrid &>(*this).getGeometry());
}
boost::shared_ptr<const XdmfGeometry> XdmfGrid::getGeometry() const boost::shared_ptr<const XdmfGeometry> XdmfGrid::getGeometry() const
{ {
return mGeometry; return mGeometry;
...@@ -84,11 +73,6 @@ boost::shared_ptr<const XdmfTime> XdmfGrid::getTime() const ...@@ -84,11 +73,6 @@ boost::shared_ptr<const XdmfTime> XdmfGrid::getTime() const
return mTime; return mTime;
} }
boost::shared_ptr<XdmfTopology> XdmfGrid::getTopology()
{
return boost::const_pointer_cast<XdmfTopology>(static_cast<const XdmfGrid &>(*this).getTopology());
}
boost::shared_ptr<const XdmfTopology> XdmfGrid::getTopology() const boost::shared_ptr<const XdmfTopology> XdmfGrid::getTopology() const
{ {
return mTopology; return mTopology;
...@@ -135,11 +119,6 @@ void XdmfGrid::populateItem(const std::map<std::string, std::string> & itemPrope ...@@ -135,11 +119,6 @@ void XdmfGrid::populateItem(const std::map<std::string, std::string> & itemPrope
} }
} }
void XdmfGrid::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
{
mGeometry = geometry;
}
void XdmfGrid::setMap(boost::shared_ptr<XdmfMap> map) void XdmfGrid::setMap(boost::shared_ptr<XdmfMap> map)
{ {
mMap = map; mMap = map;
...@@ -155,11 +134,6 @@ void XdmfGrid::setTime(const boost::shared_ptr<XdmfTime> time) ...@@ -155,11 +134,6 @@ void XdmfGrid::setTime(const boost::shared_ptr<XdmfTime> time)
mTime = time; mTime = time;
} }
void XdmfGrid::setTopology(const boost::shared_ptr<XdmfTopology> topology)
{
mTopology = topology;
}
void XdmfGrid::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) void XdmfGrid::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{ {
XdmfItem::traverse(visitor); XdmfItem::traverse(visitor);
......
...@@ -24,14 +24,7 @@ class XdmfGrid : public virtual XdmfItem { ...@@ -24,14 +24,7 @@ class XdmfGrid : public virtual XdmfItem {
public: public:
/** virtual ~XdmfGrid() = 0;
* Create a new XdmfGrid.
*
* @return constructed XdmfGrid.
*/
static boost::shared_ptr<XdmfGrid> New();
virtual ~XdmfGrid();
LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem) LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem)
XDMF_CHILDREN(XdmfAttribute, Attribute, Name) XDMF_CHILDREN(XdmfAttribute, Attribute, Name)
...@@ -43,13 +36,6 @@ public: ...@@ -43,13 +36,6 @@ public:
* *
* @return the geometry associated with this grid. * @return the geometry associated with this grid.
*/ */
boost::shared_ptr<XdmfGeometry> getGeometry();
/**
* Get the geometry associated with this grid (const version).
*
* @return the geometry associated with this grid.
*/
boost::shared_ptr<const XdmfGeometry> getGeometry() const; boost::shared_ptr<const XdmfGeometry> getGeometry() const;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
...@@ -96,24 +82,10 @@ public: ...@@ -96,24 +82,10 @@ public:
* *
* @return the topology associated with this grid. * @return the topology associated with this grid.
*/ */
boost::shared_ptr<XdmfTopology> getTopology();
/**
* Get the topology associated with this grid (const version).
*
* @return the topology associated with this grid.
*/
boost::shared_ptr<const XdmfTopology> getTopology() const; boost::shared_ptr<const XdmfTopology> getTopology() const;
using XdmfItem::insert; 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<XdmfGeometry> geometry);
/** /**
* Set the boundary communicator map associated with this grid. * Set the boundary communicator map associated with this grid.
* *
...@@ -135,13 +107,6 @@ public: ...@@ -135,13 +107,6 @@ public:
*/ */
void setTime(const boost::shared_ptr<XdmfTime> time); void setTime(const boost::shared_ptr<XdmfTime> time);
/**
* Set the topology associated with this grid.
*
* @param topology an XdmfTopology to associate with this grid.
*/
void setTopology(const boost::shared_ptr<XdmfTopology> topology);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor); virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected: protected:
...@@ -149,16 +114,17 @@ protected: ...@@ -149,16 +114,17 @@ protected:
XdmfGrid(const std::string & name = "Grid"); XdmfGrid(const std::string & name = "Grid");
virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader); virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader);
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfTopology> mTopology;
private: private:
XdmfGrid(const XdmfGrid & grid); // Not implemented. XdmfGrid(const XdmfGrid & grid); // Not implemented.
void operator=(const XdmfGrid & grid); // Not implemented. void operator=(const XdmfGrid & grid); // Not implemented.
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfMap> mMap; boost::shared_ptr<XdmfMap> mMap;
std::string mName; std::string mName;
boost::shared_ptr<XdmfTime> mTime; boost::shared_ptr<XdmfTime> mTime;
boost::shared_ptr<XdmfTopology> mTopology;
}; };
......
...@@ -143,7 +143,7 @@ boost::shared_ptr<XdmfGridCurvilinear> XdmfGridCurvilinear::New(const boost::sha ...@@ -143,7 +143,7 @@ boost::shared_ptr<XdmfGridCurvilinear> XdmfGridCurvilinear::New(const boost::sha
XdmfGridCurvilinear::XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints) : XdmfGridCurvilinear::XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints) :
mImpl(new XdmfGridCurvilinearImpl(numPoints)) mImpl(new XdmfGridCurvilinearImpl(numPoints))
{ {
this->setTopology(XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this)); mTopology = XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this);
} }
XdmfGridCurvilinear::~XdmfGridCurvilinear() XdmfGridCurvilinear::~XdmfGridCurvilinear()
...@@ -163,6 +163,11 @@ boost::shared_ptr<const XdmfArray> XdmfGridCurvilinear::getDimensions() const ...@@ -163,6 +163,11 @@ boost::shared_ptr<const XdmfArray> XdmfGridCurvilinear::getDimensions() const
return mImpl->mDimensions; return mImpl->mDimensions;
} }
boost::shared_ptr<XdmfGeometry> XdmfGridCurvilinear::getGeometry()
{
return boost::const_pointer_cast<XdmfGeometry>(static_cast<const XdmfGrid &>(*this).getGeometry());
}
void XdmfGridCurvilinear::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader) void XdmfGridCurvilinear::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader)
{ {
XdmfGrid::populateItem(itemProperties, childItems, reader); XdmfGrid::populateItem(itemProperties, childItems, reader);
...@@ -181,3 +186,8 @@ void XdmfGridCurvilinear::setDimensions(const boost::shared_ptr<XdmfArray> dimen ...@@ -181,3 +186,8 @@ void XdmfGridCurvilinear::setDimensions(const boost::shared_ptr<XdmfArray> dimen
mImpl->mDimensions = dimensions; mImpl->mDimensions = dimensions;
} }
void XdmfGridCurvilinear::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
{
mGeometry = geometry;
}
#ifndef XDMFGRIDCURVILINEAR_HPP_ #ifndef XDMFGRIDCURVILINEAR_HPP_
#define XDMFGRIDCURVILINEAR_HPP_ #define XDMFGRIDCURVILINEAR_HPP_
// Forward Declarations
class XdmfArray;
// Includes // Includes
#include "XdmfGrid.hpp" #include "XdmfGrid.hpp"
...@@ -68,6 +71,13 @@ public: ...@@ -68,6 +71,13 @@ public:
*/ */
boost::shared_ptr<const XdmfArray> getDimensions() const; boost::shared_ptr<const XdmfArray> getDimensions() const;
/**
* Get the geometry associated with this grid.
*
* @return the geometry associated with this grid.
*/
boost::shared_ptr<XdmfGeometry> getGeometry();
/** /**
* Set the dimensions of the grid, the number of points in each direction. * Set the dimensions of the grid, the number of points in each direction.
* *
...@@ -75,6 +85,13 @@ public: ...@@ -75,6 +85,13 @@ public:
*/ */
void setDimensions(const boost::shared_ptr<XdmfArray> dimensions); void setDimensions(const boost::shared_ptr<XdmfArray> dimensions);
/**
* Set the geometry associated with this grid.
*
* @param geometry an XdmfGeometry to associate with this grid.
*/
void setGeometry(const boost::shared_ptr<XdmfGeometry> geometry);
protected: protected:
XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints); XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints);
......
...@@ -237,8 +237,8 @@ boost::shared_ptr<XdmfGridRectilinear> XdmfGridRectilinear::New(const std::vecto ...@@ -237,8 +237,8 @@ boost::shared_ptr<XdmfGridRectilinear> XdmfGridRectilinear::New(const std::vecto
XdmfGridRectilinear::XdmfGridRectilinear(const std::vector<boost::shared_ptr<XdmfArray> > & axesCoordinates) : XdmfGridRectilinear::XdmfGridRectilinear(const std::vector<boost::shared_ptr<XdmfArray> > & axesCoordinates) :
mImpl(new XdmfGridRectilinearImpl(axesCoordinates)) mImpl(new XdmfGridRectilinearImpl(axesCoordinates))
{ {
this->setGeometry(XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this)); mGeometry = XdmfGridRectilinearImpl::XdmfGeometryRectilinear::New(this);
this->setTopology(XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this)); mTopology = XdmfGridRectilinearImpl::XdmfTopologyRectilinear::New(this);
} }
XdmfGridRectilinear::~XdmfGridRectilinear() XdmfGridRectilinear::~XdmfGridRectilinear()
......
#ifndef XDMFGRIDRECTILINEAR_HPP_ #ifndef XDMFGRIDRECTILINEAR_HPP_
#define XDMFGRIDRECTILINEAR_HPP_ #define XDMFGRIDRECTILINEAR_HPP_
// Forward Declarations
class XdmfArray;
// Includes // Includes
#include "XdmfGrid.hpp" #include "XdmfGrid.hpp"
......
...@@ -261,8 +261,8 @@ XdmfGridRegular::XdmfGridRegular(const boost::shared_ptr<XdmfArray> brickSize, c ...@@ -261,8 +261,8 @@ XdmfGridRegular::XdmfGridRegular(const boost::shared_ptr<XdmfArray> brickSize, c
const boost::shared_ptr<XdmfArray> origin) : const boost::shared_ptr<XdmfArray> origin) :
mImpl(new XdmfGridRegularImpl(brickSize, numPoints, origin)) mImpl(new XdmfGridRegularImpl(brickSize, numPoints, origin))
{ {
this->setGeometry(XdmfGridRegularImpl::XdmfGeometryRegular::New(this)); mGeometry = XdmfGridRegularImpl::XdmfGeometryRegular::New(this);
this->setTopology(XdmfGridRegularImpl::XdmfTopologyRegular::New(this)); mTopology = XdmfGridRegularImpl::XdmfTopologyRegular::New(this);
} }
XdmfGridRegular::~XdmfGridRegular() XdmfGridRegular::~XdmfGridRegular()
......
#ifndef XDMFGRIDREGULAR_HPP_ #ifndef XDMFGRIDREGULAR_HPP_
#define XDMFGRIDREGULAR_HPP_ #define XDMFGRIDREGULAR_HPP_
// Forward Declarations
class XdmfArray;
// Includes // Includes
#include "XdmfGrid.hpp" #include "XdmfGrid.hpp"
......
/*
* XdmfGridUnstructured.cpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#include "XdmfGridUnstructured.hpp"
boost::shared_ptr<XdmfGridUnstructured> XdmfGridUnstructured::New()
{
boost::shared_ptr<XdmfGridUnstructured> p(new XdmfGridUnstructured());
return p;
}
XdmfGridUnstructured::XdmfGridUnstructured() :
XdmfGrid()
{
}
XdmfGridUnstructured::~XdmfGridUnstructured()
{
}
const std::string XdmfGridUnstructured::ItemTag = "Grid";
boost::shared_ptr<XdmfGeometry> XdmfGridUnstructured::getGeometry()
{
return boost::const_pointer_cast<XdmfGeometry>(static_cast<const XdmfGrid &>(*this).getGeometry());
}
std::string XdmfGridUnstructured::getItemTag() const
{
return ItemTag;
}
boost::shared_ptr<XdmfTopology> XdmfGridUnstructured::getTopology()
{
return boost::const_pointer_cast<XdmfTopology>(static_cast<const XdmfGrid &>(*this).getTopology());
}
void XdmfGridUnstructured::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
{
mGeometry = geometry;
}
void XdmfGridUnstructured::setTopology(const boost::shared_ptr<XdmfTopology> topology)
{
mTopology = topology;
}
#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<XdmfGridUnstructured> New();
virtual ~XdmfGridUnstructured();
static const std::string ItemTag;