Commit ab5584f2 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add ID for topology type to support mixed cells. Cleanup some formatting and constness.

parent bddb0698
......@@ -12,6 +12,8 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfCoreReader.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp>
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
......
......@@ -94,7 +94,7 @@ public:
private:
XdmfTopologyTypeCurvilinear(const XdmfGridCurvilinear * const curvilinearGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured),
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1110),
mCurvilinearGrid(curvilinearGrid)
{
}
......
......@@ -187,7 +187,7 @@ public:
private:
XdmfTopologyTypeRectilinear(const XdmfGridRectilinear * const rectilinearGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured),
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1101),
mRectilinearGrid(rectilinearGrid)
{
}
......
......@@ -186,7 +186,7 @@ public:
private:
XdmfTopologyTypeRegular(const XdmfGridRegular * const regularGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured),
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1102),
mRegularGrid(regularGrid)
{
}
......
......@@ -11,19 +11,19 @@
// Supported XdmfTopologyTypes
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::NoTopologyType()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(0, "NoTopology", NoCellType));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(0, "NoTopology", NoCellType, 0x0));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Polyvertex()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(1, "Polyvertex", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(1, "Polyvertex", Linear, 0x1));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Polyline()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(1, "Polyline", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(1, "Polyline", Linear, 0x2));
return p;
}
......@@ -35,145 +35,146 @@ boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Polygon(const unsign
{
return type->second;
}
boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(nodesPerElement, "Polygon", Linear));
boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(nodesPerElement, "Polygon", Linear, 0x3));
previousTypes[nodesPerElement] = p;
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Triangle()
{
boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(3, "Triangle", Linear));
boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(3, "Triangle", Linear, 0x4));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Quadrilateral()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(4, "Quadrilateral", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(4, "Quadrilateral", Linear, 0x5));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Tetrahedron()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(4, "Tetrahedron", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(4, "Tetrahedron", Linear, 0x6));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Pyramid()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(5, "Pyramid", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(5, "Pyramid", Linear, 0x7));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Wedge()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(6, "Wedge", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(6, "Wedge", Linear, 0x8));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(8, "Hexahedron", Linear));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(8, "Hexahedron", Linear, 0x9));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Edge_3()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(3, "Edge_3", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(3, "Edge_3", Quadratic, 0x22));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Triangle_6()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(6, "Triangle_6", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(6, "Triangle_6", Quadratic, 0x24));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Quadrilateral_8()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(8, "Quadrilateral_8", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(8, "Quadrilateral_8", Quadratic, 0x25));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Quadrilateral_9()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(9, "Quadrilateral_9", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(9, "Quadrilateral_9", Quadratic, 0x23));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Tetrahedron_10()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(10, "Tetrahedron_10", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(10, "Tetrahedron_10", Quadratic, 0x26));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Pyramid_13()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(13, "Pyramid_13", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(13, "Pyramid_13", Quadratic, 0x27));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Wedge_15()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(15, "Wedge_15", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(15, "Wedge_15", Quadratic, 0x28));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Wedge_18()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(18, "Wedge_18", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(18, "Wedge_18", Quadratic, 0x29));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_20()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(20, "Hexahedron_20", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(20, "Hexahedron_20", Quadratic, 0x30));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_24()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(24, "Hexahedron_24", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(24, "Hexahedron_24", Quadratic, 0x31));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_27()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(27, "Hexahedron_27", Quadratic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(27, "Hexahedron_27", Quadratic, 0x32));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_64()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(64, "Hexahedron_64", Cubic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(64, "Hexahedron_64", Cubic, 0x33));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_64_GLL()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(64, "Hexahedron_64_GLL", Cubic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(64, "Hexahedron_64_GLL", Cubic, 0x35));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_125()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(125, "Hexahedron_125", Quartic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(125, "Hexahedron_125", Quartic, 0x34));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Hexahedron_125_GLL()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(125, "Hexahedron_125_GLL", Quartic));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(125, "Hexahedron_125_GLL", Quartic, 0x36));
return p;
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopologyType::Mixed()
{
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(0, "Mixed", Arbitrary));
static boost::shared_ptr<const XdmfTopologyType> p(new XdmfTopologyType(0, "Mixed", Arbitrary, 0x70));
return p;
}
XdmfTopologyType::XdmfTopologyType(const unsigned int nodesPerElement, const std::string & name, const CellType cellType) :
XdmfTopologyType::XdmfTopologyType(const unsigned int nodesPerElement, const std::string & name, const CellType cellType, const unsigned int id) :
mCellType(cellType),
mID(id),
mName(name),
mNodesPerElement(nodesPerElement)
{
......@@ -297,6 +298,11 @@ XdmfTopologyType::CellType XdmfTopologyType::getCellType() const
return mCellType;
}
unsigned int XdmfTopologyType::getID() const
{
return mID;
}
std::string XdmfTopologyType::getName() const
{
return mName;
......
......@@ -90,6 +90,13 @@ public:
*/
CellType getCellType() const;
/**
* Get the id of this cell type, necessary in order to create grids containing mixed cells.
*
* @return the ID of the topology type.
*/
virtual unsigned int getID() const;
/**
* Get the name of this topology type.
*
......@@ -113,7 +120,7 @@ protected:
* by Xdmf should be accessed through more specific static methods that construct XdmfTopologyType -
* i.e. XdmfTopologyType::Tetrahedron()
*/
XdmfTopologyType(const unsigned int nodesPerElement, const std::string & name, const CellType cellType);
XdmfTopologyType(const unsigned int nodesPerElement, const std::string & name, const CellType cellType, const unsigned int id);
private:
......@@ -122,9 +129,11 @@ private:
static boost::shared_ptr<const XdmfTopologyType> New(const std::map<std::string, std::string> & itemProperties);
CellType mCellType;
std::string mName;
unsigned int mNodesPerElement;
const CellType mCellType;
const unsigned int mID;
const std::string mName;
const unsigned int mNodesPerElement;
};
#endif /* XDMFTOPOLOGYTYPE_HPP_ */
......@@ -8,6 +8,8 @@ SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(XDMF_BUILD_DSM OFF)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
......@@ -18,6 +20,21 @@ if(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIR})
endif(HDF5_FOUND)
if(XDMF_BUILD_DSM)
find_path(HDF5DSM_DIR include/H5FDdsm.h)
if(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
include_directories(${HDF5DSM_DIR}/include)
find_library(HDF5DSM_LIBRARIES H5FDdsm ${HDF5DSM_DIR}/lib)
else(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
message(SEND_ERROR "Cannot find HDF5DSM! Please set HDF5DSM_DIR and configure again.")
endif(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
endif(MPI_FOUND)
endif(XDMF_BUILD_DSM)
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
......@@ -40,8 +57,12 @@ set(XdmfCoreSources
XdmfWriter
)
if(XDMF_BUILD_DSM)
set(XdmfCoreSources ${XdmfCoreSources} XdmfHDF5WriterDSM)
endif(XDMF_BUILD_DSM)
add_library(XdmfCore ${XdmfCoreSources})
target_link_libraries(XdmfCore ${HDF5_LIBRARIES} ${LIBXML2_LIBRARIES})
target_link_libraries(XdmfCore ${HDF5_LIBRARIES} ${HDF5DSM_LIBRARIES} ${LIBXML2_LIBRARIES})
if(XDMF_WRAP_JAVA)
XDMF_SWIG_JAVA(XdmfCore)
......
......@@ -11,6 +11,8 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#include <XdmfCoreReader.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp>
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
......@@ -248,6 +250,8 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%shared_ptr(XdmfCoreReader)
%shared_ptr(XdmfHDF5Controller)
%shared_ptr(XdmfHDF5Writer)
%shared_ptr(XdmfHeavyDataController)
%shared_ptr(XdmfHeavyDataWriter)
%shared_ptr(XdmfInformation)
%shared_ptr(XdmfItem)
%shared_ptr(XdmfItemProperty)
......@@ -263,6 +267,9 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%include XdmfItemProperty.hpp
%include XdmfVisitor.hpp
%include XdmfHeavyDataController.hpp
%include XdmfHeavyDataWriter.hpp
%include XdmfCoreItemFactory.hpp
%include XdmfCoreReader.hpp
%include XdmfInformation.hpp
......
......@@ -38,8 +38,6 @@ private:
XdmfHDF5Writer(const XdmfHDF5Writer & hdf5Writer); // Not implemented.
void operator=(const XdmfHDF5Writer & hdf5Writer); // Not implemented.
int mDataSetId;
};
#endif /* XDMFHDF5WRITER_HPP_ */
......@@ -4,9 +4,9 @@
#include "XdmfHeavyDataController.hpp"
#include "XdmfSystemUtils.hpp"
XdmfHeavyDataController::XdmfHeavyDataController(const std::string & heavyDataFilePath, const std::string & dataSetPath, const unsigned int size, const boost::shared_ptr<const XdmfArrayType> type) :
XdmfHeavyDataController::XdmfHeavyDataController(const std::string & filePath, const std::string & dataSetPath, const unsigned int size, const boost::shared_ptr<const XdmfArrayType> type) :
mDataSetPath(dataSetPath),
mFilePath(XdmfSystemUtils::getRealPath(heavyDataFilePath)),
mFilePath(XdmfSystemUtils::getRealPath(filePath)),
mSize(size),
mType(type)
{
......
......@@ -69,7 +69,7 @@ public:
protected:
XdmfHeavyDataController(const std::string & hdf5FilePath, const std::string & dataSetPath, const unsigned int size, const boost::shared_ptr<const XdmfArrayType> type);
XdmfHeavyDataController(const std::string & filePath, const std::string & dataSetPath, const unsigned int size, const boost::shared_ptr<const XdmfArrayType> type);
std::string mDataSetPath;
std::string mFilePath;
......
......@@ -4,7 +4,15 @@
#include "XdmfHeavyDataWriter.hpp"
#include "XdmfSystemUtils.hpp"
XdmfHeavyDataWriter::XdmfHeavyDataWriter() :
mDataSetId(0),
mFilePath(""),
mMode(Default)
{
}
XdmfHeavyDataWriter::XdmfHeavyDataWriter(const std::string & filePath) :
mDataSetId(0),
mFilePath(XdmfSystemUtils::getRealPath(filePath)),
mMode(Default)
{
......
......@@ -67,8 +67,10 @@ public:
protected:
XdmfHeavyDataWriter();
XdmfHeavyDataWriter(const std::string & filePath);
int mDataSetId;
std::string mFilePath;
Mode mMode;
......
......@@ -19,6 +19,8 @@ class XdmfWriter::XdmfWriterImpl {
public:
XdmfWriterImpl(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHeavyDataWriter> heavyDataWriter) :
mDepth(0),
mDocumentTitle("Xdmf"),
mHeavyDataWriter(heavyDataWriter),
mLastXPathed(false),
mLightDataLimit(100),
......@@ -29,9 +31,7 @@ public:
mXMLFilePath(XdmfSystemUtils::getRealPath(xmlFilePath)),
mXPathCount(0),
mXPathString(""),
mDocumentTitle("Xdmf"),
mVersionString("2.0"),
mDepth(0)
mVersionString("2.0")
{
};
......@@ -56,6 +56,8 @@ public:
xmlDocSetRootElement(mXMLDocument, mXMLCurrentNode);
}
int mDepth;
std::string mDocumentTitle;
boost::shared_ptr<XdmfHeavyDataWriter> mHeavyDataWriter;
bool mLastXPathed;
unsigned int mLightDataLimit;
......@@ -67,9 +69,8 @@ public:
std::map<const XdmfItem * const, std::string> mXPath;
unsigned int mXPathCount;
std::string mXPathString;
std::string mDocumentTitle;
std::string mVersionString;
int mDepth;
};
boost::shared_ptr<XdmfWriter> XdmfWriter::New(const std::string & xmlFilePath)
......
......@@ -160,6 +160,7 @@ private:
void operator=(const XdmfWriter & coreWriter); // Not implemented.
XdmfWriterImpl * mImpl;
};
#endif /* XDMFWRITER_HPP_ */
......@@ -14,6 +14,10 @@ ADD_TEST_CXX(TestXdmfArray)
ADD_TEST_CXX(TestXdmfArrayWriteRead)
ADD_TEST_CXX(TestXdmfHDF5Controller)
ADD_TEST_CXX(TestXdmfHDF5Writer)
if(XDMF_BUILD_DSM)
ADD_TEST_CXX(TestXdmfHDF5WriterDSM)
ADD_TEST_CXX(TestXdmfHDF5WriterDSMServer)
endif(XDMF_BUILD_DSM)
ADD_TEST_CXX(TestXdmfInformation)
# Add any cxx cleanup here:
......@@ -27,4 +31,7 @@ CLEAN_TEST_CXX(TestXdmfArrayWriteRead
CLEAN_TEST_CXX(TestXdmfHDF5Controller)
CLEAN_TEST_CXX(TestXdmfHDF5Writer
hdf5WriterTest.h5)
if(XDMF_BUILD_DSM)
CLEAN_TEST_CXX(TestXdmfHDF5WriterDSM)
endif(XDMF_BUILD_DSM)
CLEAN_TEST_CXX(TestXdmfInformation)
......@@ -12,6 +12,8 @@ swig -v -c++ -python -o XdmfUtilsPython.cpp XdmfUtils.i
#include <XdmfCoreReader.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp>
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment