Commit a3287659 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Cleanup to merge changes with Ken Renard.

parent bacda4b0
......@@ -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>
......
......@@ -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)
......
......@@ -9,6 +9,8 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfInformation.hpp>
......@@ -20,99 +22,57 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%}
#ifdef SWIGJAVA
<<<<<<< HEAD
=======
%extend XdmfArrayType {
bool equals(boost::shared_ptr<XdmfArrayType> arrayType) {
return(self == arrayType.get());
}
};
%ignore XdmfArrayType::operator==(const XdmfArrayType & arrayType) const;
%ignore XdmfArrayType::operator!=(const XdmfArrayType & arrayType) const;
#endif
#ifdef SWIGPYTHON
%extend XdmfArrayType {
bool __eq__(boost::shared_ptr<XdmfArrayType> arrayType) {
return(self == arrayType.get());
}
};
#endif
// Shared Pointer Templates
%shared_ptr(XdmfArray)
%shared_ptr(XdmfArrayType)
%shared_ptr(XdmfBaseVisitor)
%shared_ptr(XdmfCoreItemFactory)
%shared_ptr(XdmfCoreReader)
%shared_ptr(XdmfHDF5Controller)
%shared_ptr(XdmfHDF5Writer)
%shared_ptr(XdmfInformation)
%shared_ptr(XdmfItem)
%shared_ptr(XdmfItemProperty)
%shared_ptr(XdmfVisitor)
%shared_ptr(XdmfWriter)
// Abstract Base Classes
%template() Loki::BaseVisitable<void>;
%template() Loki::Visitor<XdmfArray>;
%template() Loki::Visitor<XdmfItem>;
>>>>>>> Cleanup: 1. XdmfArray -- took out getElementSize() 2. XdmfArrayType -- took out IsEqual() 3. Xdmf.i -- implement IsEqual() function here for Python and Java in XdmfArrayType and XdmfItem (see #2 and #5) 4. Xdmf.i -- getNumpyArray uses getElementSize on XdmfArrayType instead of on XdmfArray (see #1) 5. XdmfItem -- took out IsEqual() 6. XdmfWriter -- made setDocumentTitle() and setCersionString() protected functions 7. Java test TestXdmfEquals -- took out test of XdmfItem->IsEqual()
// Ignore const overloaded methods
%ignore XdmfArray::getHDF5Controller() const;
%ignore XdmfArray::getHeavyDataController() const;
%ignore XdmfArray::getValuesInternal() const;
%ignore XdmfItem::getInformation(const unsigned int) const;
%ignore XdmfItem::getInformation(const std::string &) const;
%ignore XdmfWriter::getHDF5Writer() const;
%ignore XdmfWriter::getHeavyDataWriter() const;
// Ignore ItemTags
%ignore XdmfArray::ItemTag;
%ignore XdmfInformation::ItemTag;
// Define equality operator
// Define equality operators
%extend XdmfItem {
<<<<<<< HEAD
bool equals(boost::shared_ptr<XdmfItem> item)
bool equals(boost::shared_ptr<XdmfItem> item)
{
if (item == NULL)
{
return false;
}
return self == item.get();
}
bool IsEqual(boost::shared_ptr<XdmfItem> item)
bool IsEqual(boost::shared_ptr<XdmfItem> item)
{
if (item == NULL)
{
return false;
}
return self == item.get();
}
=======
bool __eq__(boost::shared_ptr<XdmfItem> item) {
if (item == NULL) return (false);
if (self == item.get()) return(true);
return(false);
}
};
#endif
#ifdef SWIGJAVA
%extend XdmfItem {
bool equals(boost::shared_ptr<XdmfItem> item) {
if (item == NULL) return (false);
if (self == item.get()) return(true);
return(false);
}
>>>>>>> Cleanup: 1. XdmfArray -- took out getElementSize() 2. XdmfArrayType -- took out IsEqual() 3. Xdmf.i -- implement IsEqual() function here for Python and Java in XdmfArrayType and XdmfItem (see #2 and #5) 4. Xdmf.i -- getNumpyArray uses getElementSize on XdmfArrayType instead of on XdmfArray (see #1) 5. XdmfItem -- took out IsEqual() 6. XdmfWriter -- made setDocumentTitle() and setCersionString() protected functions 7. Java test TestXdmfEquals -- took out test of XdmfItem->IsEqual()
};
%extend XdmfItemProperty {
bool equals(boost::shared_ptr<XdmfItemProperty> itemProperty)
{
if (itemProperty == NULL)
{
return false;
}
return self == itemProperty.get();
}
bool IsEqual(boost::shared_ptr<XdmfItemProperty> itemProperty)
bool IsEqual(boost::shared_ptr<XdmfItemProperty> itemProperty)
{
if (itemProperty == NULL)
{
return false;
}
return self == itemProperty.get();
}
......@@ -139,58 +99,59 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
// Provide accessors from python lists to XdmfArrays
%extend XdmfArray {
PyObject * getBuffer ()
{
void *vp = $self->getValuesInternal();
Py_ssize_t sz = $self->getSize() * $self->getArrayType()->getElementSize();
PyObject * c = PyBuffer_FromMemory(vp, sz);
return(c);
}
%pythoncode {
def getNumpyArray(self):
h5ctl = self.getHDF5Controller()
if h5ctl == None :
try :
from numpy import frombuffer as ___frombuffer
except :
return None
buf = self.getBuffer()
aType = self.getArrayType()
if aType == XdmfArrayType.Int8() :
return(___frombuffer(buf, 'int8'))
if aType == XdmfArrayType.Int16() :
return(___frombuffer(buf, 'int16'))
if aType == XdmfArrayType.Int32() :
return(___frombuffer(buf, 'int32'))
if aType == XdmfArrayType.Int64() :
return(___frombuffer(buf, 'int64'))
if aType == XdmfArrayType.Float32() :
return(___frombuffer(buf, 'float32'))
if aType == XdmfArrayType.Float64() :
return(___frombuffer(buf, 'float64'))
if aType == XdmfArrayType.UInt8() :
return(___frombuffer(buf, 'uint8'))
if aType == XdmfArrayType.UInt16() :
return(___frombuffer(buf, 'uint16'))
if aType == XdmfArrayType.UInt32() :
return(___frombuffer(buf, 'uint32'))
return None
else :
h5FileName = h5ctl.getFilePath()
h5DataSetName = h5ctl.getDataSetPath()
if (h5FileName == None) | (h5DataSetName == None) :
return None
try :
from h5py import File as ___File
from numpy import array as ___array
f = ___File(h5FileName, 'r')
if h5DataSetName in f.keys() :
return(___array(f[h5DataSetName]))
except :
pass
return None
};
PyObject * getBuffer ()
{
void *vp = $self->getValuesInternal();
Py_ssize_t sz = $self->getSize() * $self->getArrayType()->getElementSize();
PyObject * c = PyBuffer_FromMemory(vp, sz);
return(c);
}
%pythoncode {
def getNumpyArray(self):
h5ctl = self.getHDF5Controller()
if h5ctl == None :
try :
from numpy import frombuffer as ___frombuffer
except :
return None
buf = self.getBuffer()
aType = self.getArrayType()
if aType == XdmfArrayType.Int8() :
return(___frombuffer(buf, 'int8'))
if aType == XdmfArrayType.Int16() :
return(___frombuffer(buf, 'int16'))
if aType == XdmfArrayType.Int32() :
return(___frombuffer(buf, 'int32'))
if aType == XdmfArrayType.Int64() :
return(___frombuffer(buf, 'int64'))
if aType == XdmfArrayType.Float32() :
return(___frombuffer(buf, 'float32'))
if aType == XdmfArrayType.Float64() :
return(___frombuffer(buf, 'float64'))
if aType == XdmfArrayType.UInt8() :
return(___frombuffer(buf, 'uint8'))
if aType == XdmfArrayType.UInt16() :
return(___frombuffer(buf, 'uint16'))
if aType == XdmfArrayType.UInt32() :
return(___frombuffer(buf, 'uint32'))
return None
else :
h5FileName = h5ctl.getFilePath()
h5DataSetName = h5ctl.getDataSetPath()
if (h5FileName == None) | (h5DataSetName == None) :
return None
try :
from h5py import File as ___File
from numpy import array as ___array
f = ___File(h5FileName, 'r')
if h5DataSetName in f.keys() :
return(___array(f[h5DataSetName]))
except :
pass
return None
};
void copyValueAsInt8(int index, char value) {
......@@ -303,6 +264,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)
......@@ -318,6 +281,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
......
......@@ -135,6 +135,16 @@ bool XdmfWriter::getWriteXPaths() const
return mImpl->mWriteXPaths;
}
void XdmfWriter::setDocumentTitle(std::string title)
{
mImpl->mDocumentTitle = title;
}
void
XdmfWriter::setVersionString(std::string version)
{
mImpl->mVersionString = version;
}
void XdmfWriter::setLightDataLimit(const unsigned int numValues)
{
mImpl->mLightDataLimit = numValues;
......@@ -219,7 +229,8 @@ void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisito
void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
if (mImpl->mDepth == 0) {
if (mImpl->mDepth == 0)
{
mImpl->openFile();
}
mImpl->mDepth++;
......@@ -291,14 +302,3 @@ void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor>
mImpl->closeFile();
}
}
void
XdmfWriter::setDocumentTitle(std::string title)
{
mImpl->mDocumentTitle = title;
}
void
XdmfWriter::setVersionString(std::string version)
{
mImpl->mVersionString = version;
}
......@@ -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