Commit 3249266f authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

Merge branch 'master' of /data/Repository/Xdmf2 into ajb-dev

parents 058ce901 7ea61be2
......@@ -126,15 +126,15 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
else if(shared_ptr<XdmfCurvilinearGrid> value = shared_dynamic_cast<XdmfCurvilinearGrid>($1)) {
*(shared_ptr< XdmfCurvilinearGrid > **)&($result) = value ? new shared_ptr< XdmfCurvilinearGrid >(value) : 0;
}
else if(shared_ptr<XdmfGridCollection> value = shared_dynamic_cast<XdmfGridCollection>($1)) {
*(shared_ptr< XdmfGridCollection > **)&($result) = value ? new shared_ptr< XdmfGridCollection >(value) : 0;
}
else if(shared_ptr<XdmfDomain> value = shared_dynamic_cast<XdmfDomain>($1)) {
*(shared_ptr< XdmfDomain > **)&($result) = value ? new shared_ptr< XdmfDomain >(value) : 0;
}
else if(shared_ptr<XdmfGeometry> value = shared_dynamic_cast<XdmfGeometry>($1)) {
*(shared_ptr< XdmfGeometry > **)&($result) = value ? new shared_ptr< XdmfGeometry >(value) : 0;
}
else if(shared_ptr<XdmfGridCollection> value = shared_dynamic_cast<XdmfGridCollection>($1)) {
*(shared_ptr< XdmfGridCollection > **)&($result) = value ? new shared_ptr< XdmfGridCollection >(value) : 0;
}
else if(shared_ptr<XdmfInformation> value = shared_dynamic_cast<XdmfInformation>($1)) {
*(shared_ptr< XdmfInformation > **)&($result) = value ? new shared_ptr< XdmfInformation >(value) : 0;
}
......@@ -260,6 +260,9 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
else if(shared_ptr<XdmfCurvilinearGrid> gridCurvilinear = shared_dynamic_cast<XdmfCurvilinearGrid>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfCurvilinearGrid>(gridCurvilinear)), SWIGTYPE_p_boost__shared_ptrT_XdmfCurvilinearGrid_t, SWIG_POINTER_OWN);
}
else if(shared_ptr<XdmfGridCollection> gridCollection = shared_dynamic_cast<XdmfGridCollection>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
}
else if(shared_ptr<XdmfDomain> domain = shared_dynamic_cast<XdmfDomain>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfDomain>(domain)), SWIGTYPE_p_boost__shared_ptrT_XdmfDomain_t, SWIG_POINTER_OWN);
}
......@@ -269,9 +272,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
else if(shared_ptr<XdmfGraph> graph = shared_dynamic_cast<XdmfGraph>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfGraph>(graph)), SWIGTYPE_p_boost__shared_ptrT_XdmfGraph_t, SWIG_POINTER_OWN);
}
else if(shared_ptr<XdmfGridCollection> gridCollection = shared_dynamic_cast<XdmfGridCollection>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
}
else if(shared_ptr<XdmfInformation> information = shared_dynamic_cast<XdmfInformation>(obj)) {
result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN);
}
......
......@@ -16,6 +16,7 @@ ADD_TEST_PYTHON_PYTHONPATH("")
# -----------------------
ADD_TEST_PYTHON(TestXdmfEquals)
ADD_TEST_PYTHON(TestXdmfHDF5Writer)
ADD_TEST_PYTHON(TestXdmfRead)
ADD_TEST_PYTHON(TestXdmfSet)
ADD_TEST_PYTHON(TestXdmfWriter)
......@@ -28,6 +29,8 @@ ADD_TEST_PYTHON(TestXdmfWriter)
CLEAN_TEST_PYTHON(TestXdmfEquals)
CLEAN_TEST_PYTHON(TestXdmfHDF5Writer
hdf5WriterPythonTest.h5)
CLEAN_TEST_PYTHON(TestXdmfRead
TestXdmfRead.xmf)
CLEAN_TEST_PYTHON(TestXdmfSet)
CLEAN_TEST_PYTHON(TestXdmfWriter
output.h5
......
from Xdmf import *
if __name__ == "__main__":
fileName ="TestXdmfRead.xmf"
# create a simple empty file
domain = XdmfDomain.New()
collection = XdmfGridCollection.New()
grid = XdmfUnstructuredGrid.New()
attribute1 = XdmfAttribute.New()
attribute2 = XdmfAttribute.New()
information = XdmfInformation.New()
domain.insert(collection)
collection.insert(grid)
grid.insert(attribute1)
grid.insert(attribute2)
grid.insert(information)
writer = XdmfWriter.New(fileName)
domain.accept(writer)
# read file using XPaths and verify downcasts to appropriate XdmfItems
reader = XdmfReader.New()
domain = reader.read(fileName, "/Xdmf/Domain")
assert(len(domain) == 1)
assert(isinstance(domain[0], XdmfDomain))
collection = reader.read(fileName, "/Xdmf/Domain/Grid")
assert(len(collection) == 1)
assert(isinstance(collection[0], XdmfGridCollection))
grid = reader.read(fileName, "/Xdmf/Domain/Grid/Grid")
assert(len(grid) == 1)
assert(isinstance(grid[0], XdmfUnstructuredGrid))
attributes = reader.read(fileName, "/Xdmf/Domain/Grid/Grid/Attribute")
assert(len(attributes) == 2)
assert(isinstance(attributes[0], XdmfAttribute))
assert(isinstance(attributes[1], XdmfAttribute))
information = reader.read(fileName, "/Xdmf/Domain/Grid/Grid/Information")
assert(len(information) == 1)
assert(isinstance(information[0], XdmfInformation))
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