Commit 8e14630a authored by Kenneth Leiter's avatar Kenneth Leiter
parents 6db38e95 053a30bd
project(Xdmf) project(Xdmf)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
#Needed to build DSM because relative paths are used to add its libraries
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif (POLICY CMP0015)
if(MSVC10) if(MSVC10)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
...@@ -41,6 +46,13 @@ endif(BUILD_TESTING) ...@@ -41,6 +46,13 @@ endif(BUILD_TESTING)
option(XDMF_WRAP_PYTHON OFF) option(XDMF_WRAP_PYTHON OFF)
option(XDMF_WRAP_JAVA OFF) option(XDMF_WRAP_JAVA OFF)
# Test for DSM
option(XDMF_BUILD_DSM OFF)
if(XDMF_BUILD_DSM)
option(XDMF_BUILD_DSM_THREADS ON)
endif(XDMF_BUILD_DSM)
# If we are wrapping either, we need swig # If we are wrapping either, we need swig
if(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA) if(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
find_package(SWIG REQUIRED) find_package(SWIG REQUIRED)
...@@ -54,7 +66,11 @@ endif(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA) ...@@ -54,7 +66,11 @@ endif(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
if(XDMF_WRAP_PYTHON) if(XDMF_WRAP_PYTHON)
find_package(PythonInterp REQUIRED) find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED) find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS}) if (XDMF_BUILD_DSM)
include_directories(${PYTHON_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_PATH})
else (XDMF_BUILD_DSM)
include_directories(${PYTHON_INCLUDE_DIRS})
endif (XDMF_BUILD_DSM)
# A macro to swig and create the python files # A macro to swig and create the python files
# Since we essentually do the same thing inside and outside core, it # Since we essentually do the same thing inside and outside core, it
...@@ -69,6 +85,10 @@ if(XDMF_WRAP_PYTHON) ...@@ -69,6 +85,10 @@ if(XDMF_WRAP_PYTHON)
# optimize swig generation --- these are all flags corresponding to -O # optimize swig generation --- these are all flags corresponding to -O
# except -fvirtual which breaks visitor operation # except -fvirtual which breaks visitor operation
set(CMAKE_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -modern -fastdispatch -nosafecstrings -noproxydel -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone) set(CMAKE_SWIG_FLAGS ${XDMF_SWIG_FLAGS} -modern -fastdispatch -nosafecstrings -noproxydel -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone)
#Enables DSM
if (XDMF_BUILD_DSM)
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM)
endif (XDMF_BUILD_DSM)
set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON) set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON)
set(swig_extra_generated_files "") set(swig_extra_generated_files "")
swig_add_module(${python_name} python ${python_name}.i) swig_add_module(${python_name} python ${python_name}.i)
...@@ -198,7 +218,7 @@ if(XDMF_WRAP_JAVA) ...@@ -198,7 +218,7 @@ if(XDMF_WRAP_JAVA)
endif(XDMF_WRAP_JAVA) endif(XDMF_WRAP_JAVA)
add_subdirectory(core) add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS}) include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS})
link_directories(${XDMF_LIBRARY_DIRS}) link_directories(${XDMF_LIBRARY_DIRS})
option(XDMF_BUILD_CORE_ONLY OFF) option(XDMF_BUILD_CORE_ONLY OFF)
...@@ -228,7 +248,11 @@ if(NOT XDMF_BUILD_CORE_ONLY) ...@@ -228,7 +248,11 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfUnstructuredGrid) XdmfUnstructuredGrid)
add_library(Xdmf ${XdmfSources}) add_library(Xdmf ${XdmfSources})
target_link_libraries(Xdmf XdmfCore) if(XDMF_BUILD_DSM)
target_link_libraries(Xdmf XdmfCore XdmfDSM)
else(XDMF_BUILD_DSM)
target_link_libraries(Xdmf XdmfCore)
endif(XDMF_BUILD_DSM)
if(WIN32) if(WIN32)
set_target_properties(Xdmf PROPERTIES set_target_properties(Xdmf PROPERTIES
...@@ -248,7 +272,7 @@ if(NOT XDMF_BUILD_CORE_ONLY) ...@@ -248,7 +272,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
endif(XDMF_WRAP_JAVA) endif(XDMF_WRAP_JAVA)
if(XDMF_WRAP_PYTHON) if(XDMF_WRAP_PYTHON)
XDMF_SWIG_PYTHON(Xdmf XdmfCore) XDMF_SWIG_PYTHON(Xdmf XdmfCore XdmfDSM)
endif(XDMF_WRAP_PYTHON) endif(XDMF_WRAP_PYTHON)
if(BUILD_TESTING) if(BUILD_TESTING)
......
...@@ -65,8 +65,68 @@ ...@@ -65,8 +65,68 @@
* constructors in the XDMF API are protected, ensuring that only * constructors in the XDMF API are protected, ensuring that only
* shared pointers can be created. These pointers are freed * shared pointers can be created. These pointers are freed
* automatically by the shared pointer reference counting mechanism. * automatically by the shared pointer reference counting mechanism.
*
*
* Structure:
*
* Xdmf2 is structured in a tree format with an XdmfDomain serving
* as the base. The Domain contains multiple grid collections or
* grids; each with their own geometries, topologies, attributes,
* and/or sets. With the inclusion of shared pointers in Xdmf2
* a topology could be shared across multiple grids or a grid
* could be included in multiple grid collections and/or the domain.
*
*
* C++ Examples:
*
* \subpage cppwrite "C++ Example of Xdmf Creation"
*
* \subpage cppread "C++ Example of Reading Xdmf"
*
* \subpage cppedit "C++ Example of Reading and Modifying Xdmf"
*
* Python Examples:
*
* \subpage pywrite "Python Example of Xdmf Creation"
*
* \subpage pyread "Python Example of Reading Xdmf"
*
* \subpage pyedit "Python Example of Reading and Modifying Xdmf"
*
*/
/*!
* \page cppwrite Example of Xdmf Creation
* \include ExampleXdmfWrite.cpp
*/
/*!
* \page cppread Example of Reading Xdmf
* \include ExampleXdmfRead.cpp
*/
/*!
* \page cppedit Example of Reading and Modifying
* \include ExampleXdmfEdit.cpp
*/
/*!
* \page pywrite Example of Xdmf Creation
* \include XdmfExampleWrite.py
*/ */
/*!
* \page pyread Example of Reading Xdmf
* \include XdmfExampleRead.py
*/
/*!
* \page pyedit Example of Reading and Modifying
* \include XdmfExampleEdit.py
*/
/* Keep all our Win32 Conversions here */ /* Keep all our Win32 Conversions here */
#ifdef _WIN32 #ifdef _WIN32
/* Used to export/import from the dlls */ /* Used to export/import from the dlls */
...@@ -75,6 +135,11 @@ ...@@ -75,6 +135,11 @@
#undef XDMFCORE_TEMPLATE #undef XDMFCORE_TEMPLATE
#define XDMFCORE_TEMPLATE extern #define XDMFCORE_TEMPLATE extern
#undef XDMFDSM_EXPORT
#define XDMFDSM_EXPORT __declspec(dllimport)
#undef XDMFDSM_TEMPLATE
#define XDMFDSM_TEMPLATE extern
#ifdef Xdmf_EXPORTS #ifdef Xdmf_EXPORTS
#define XDMF_EXPORT __declspec(dllexport) #define XDMF_EXPORT __declspec(dllexport)
#define XDMF_TEMPLATE #define XDMF_TEMPLATE
...@@ -98,8 +163,10 @@ ...@@ -98,8 +163,10 @@
#else /* _WIN32 */ #else /* _WIN32 */
/* We don't need to export/import since there are no dlls */ /* We don't need to export/import since there are no dlls */
#define XDMFCORE_EXPORT #define XDMFCORE_EXPORT
#define XDMFDSM_EXPORT
#define XDMF_EXPORT #define XDMF_EXPORT
#define XDMFCORE_TEMPLATE #define XDMFCORE_TEMPLATE
#define XDMFDSM_TEMPLATE
#define XDMF_TEMPLATE #define XDMF_TEMPLATE
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif /* _XDMF_HPP */ #endif /* _XDMF_HPP */
......
...@@ -3,22 +3,31 @@ XdmfPython.cpp: ...@@ -3,22 +3,31 @@ XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/ */
#ifdef XDMF_BUILD_DSM
%module Xdmf %module Xdmf
%{ %{
// MPI Includes
#include <mpi.h>
// XdmfCore Includes // XdmfCore Includes
#include <Xdmf.hpp> #include <Xdmf.hpp>
#include <XdmfArray.hpp> #include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp> #include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp> #include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp> #include <XdmfCoreReader.hpp>
#include <XdmfDSMManager.hpp>
#include <XdmfDSMBuffer.hpp>
#include <XdmfDSMCommMPI.hpp>
#include <XdmfError.hpp> #include <XdmfError.hpp>
#include <XdmfFunction.hpp>
#include <XdmfHDF5Controller.hpp> #include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp> #include <XdmfHDF5Writer.hpp>
#ifdef XDMF_BUILD_DSM
#include <XdmfHDF5ControllerDSM.hpp> #include <XdmfHDF5ControllerDSM.hpp>
#include <XdmfHDF5WriterDSM.hpp> #include <XdmfHDF5WriterDSM.hpp>
#endif
#include <XdmfHeavyDataController.hpp> #include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp> #include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp> #include <XdmfInformation.hpp>
...@@ -26,6 +35,62 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -26,6 +35,62 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfItemProperty.hpp> #include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.hpp> #include <XdmfSharedPtr.hpp>
#include <XdmfSparseMatrix.hpp> #include <XdmfSparseMatrix.hpp>
#include <XdmfSubset.hpp>
#include <XdmfSystemUtils.hpp>
#include <XdmfVisitor.hpp>
#include <XdmfWriter.hpp>
// Xdmf Includes
#include <XdmfAttribute.hpp>
#include <XdmfAttributeCenter.hpp>
#include <XdmfAttributeType.hpp>
#include <XdmfCurvilinearGrid.hpp>
#include <XdmfDomain.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGraph.hpp>
#include <XdmfGrid.hpp>
#include <XdmfGridCollection.hpp>
#include <XdmfGridCollectionType.hpp>
#include <XdmfItemFactory.hpp>
#include <XdmfMap.hpp>
#include <XdmfReader.hpp>
#include <XdmfRectilinearGrid.hpp>
#include <XdmfRegularGrid.hpp>
#include <XdmfSet.hpp>
#include <XdmfSetType.hpp>
#include <XdmfTime.hpp>
#include <XdmfTopology.hpp>
#include <XdmfTopologyType.hpp>
#include <XdmfUnstructuredGrid.hpp>
%}
%import XdmfDSM.i
#else
%module Xdmf
%{
// XdmfCore Includes
#include <Xdmf.hpp>
#include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
#include <XdmfError.hpp>
#include <XdmfFunction.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp>
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.hpp>
#include <XdmfSparseMatrix.hpp>
#include <XdmfSubset.hpp>
#include <XdmfSystemUtils.hpp> #include <XdmfSystemUtils.hpp>
#include <XdmfVisitor.hpp> #include <XdmfVisitor.hpp>
#include <XdmfWriter.hpp> #include <XdmfWriter.hpp>
...@@ -55,6 +120,8 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -55,6 +120,8 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfUnstructuredGrid.hpp> #include <XdmfUnstructuredGrid.hpp>
%} %}
#endif
%import XdmfCore.i %import XdmfCore.i
#ifdef SWIGJAVA #ifdef SWIGJAVA
...@@ -171,15 +238,39 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -171,15 +238,39 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include std_set.i %include std_set.i
%include std_map.i %include std_map.i
%include std_vector.i
#ifdef XDMF_BUILD_DSM
%include mpi4py/mpi4py.i
%mpi4py_typemap(Comm, MPI_Comm);
#endif /* XDMF_BUILD_DSM */
%template(XdmfMapNodeIdSet) std::set<int>; %template(XdmfMapNodeIdSet) std::set<int>;
%template(XdmfMapNodeIdMap) std::map<int, std::set<int> >; %template(XdmfMapNodeIdMap) std::map<int, std::set<int> >;
%template(XdmfMapMap) std::map<int, std::map<int, std::set<int> > >; %template(XdmfMapMap) std::map<int, std::map<int, std::set<int> > >;
%template(AttributeVector) std::vector<shared_ptr<XdmfAttribute> >;
%template(MapVector) std::vector<shared_ptr<XdmfMap> >;
%template(ArrayVector) std::vector<shared_ptr<XdmfArray> >;
#ifdef XDMF_BUILD_DSM
%pythoncode { %pythoncode {
from XdmfCore import * from XdmfCore import *
from XdmfDSM import *
} }
#else
%pythoncode {
from XdmfCore import *
}
#endif /* XDMF_BUILD_DSM */
%fragment("XdmfItemCast", "header") { %fragment("XdmfItemCast", "header") {
#include <XdmfSharedPtr.hpp> #include <XdmfSharedPtr.hpp>
PyObject * XdmfItemCast(shared_ptr<XdmfItem> obj) { PyObject * XdmfItemCast(shared_ptr<XdmfItem> obj) {
......
...@@ -94,9 +94,14 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope ...@@ -94,9 +94,14 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second; mName = name->second;
} }
else { else {
XdmfError::message(XdmfError::FATAL, try {
"'Name' not found in itemProperties in " XdmfError::message(XdmfError::FATAL,
"XdmfAttribute::populateItem"); "'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
mCenter = XdmfAttributeCenter::New(itemProperties); mCenter = XdmfAttributeCenter::New(itemProperties);
......
...@@ -48,7 +48,21 @@ public: ...@@ -48,7 +48,21 @@ public:
/** /**
* Create a new XdmfAttribute. * Create a new XdmfAttribute.
* *
* @return constructed XdmfAttribute. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
*
* @return Constructed XdmfAttribute.
*/ */
static shared_ptr<XdmfAttribute> New(); static shared_ptr<XdmfAttribute> New();
...@@ -60,7 +74,29 @@ public: ...@@ -60,7 +74,29 @@ public:
/** /**
* Get the XdmfAttributeCenter associated with this attribute. * Get the XdmfAttributeCenter associated with this attribute.
* *
* @return XdmfAttributeCenter of the attribute. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setCenter
* @until //#setCenter
* @skipline //#getCenter
* @until //#getCenter
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setCenter
* @until #//setCenter
* @skipline #//getCenter
* @until #//getCenter
*
* @return XdmfAttributeCenter of the attribute.
*/ */
shared_ptr<const XdmfAttributeCenter> getCenter() const; shared_ptr<const XdmfAttributeCenter> getCenter() const;
...@@ -71,35 +107,133 @@ public: ...@@ -71,35 +107,133 @@ public:
/** /**
* Get the name of the attribute. * Get the name of the attribute.
* *
* @return a string containing the name of the attribute. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setName
* @until //#setName
* @skipline //#getName
* @until //#getName
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setName
* @until #//setName
* @skipline #//getName
* @until #//getName
*
* @return A string containing the name of the attribute.
*/ */
std::string getName() const; std::string getName() const;
/** /**
* Get the XdmfAttributeType associated with this attribute. * Get the XdmfAttributeType associated with this attribute.
* *
* @return XdmfAttributeType of the attribute. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setType
* @until //#setType
* @skipline //#getType
* @until //#getType
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setType
* @until #//setType
* @skipline #//getType
* @until #//getType
*
* @return XdmfAttributeType of the attribute.
*/ */
shared_ptr<const XdmfAttributeType> getType() const; shared_ptr<const XdmfAttributeType> getType() const;
/** /**
* Set the XdmfAttributeCenter associated with this attribute. * Set the XdmfAttributeCenter associated with this attribute.
* *
* @param center the XdmfAttributeCenter to set. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setCenter
* @until //#setCenter
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setCenter
* @until #//setCenter
*
* @param center The XdmfAttributeCenter to set.
*/ */
void setCenter(const shared_ptr<const XdmfAttributeCenter> center); void setCenter(const shared_ptr<const XdmfAttributeCenter> center);
/** /**
* Set the name of the attribute. * Set the name of the attribute.
* *
* @param name a string containing the name to set. * Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setName
* @until //#setName
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setName
* @until #//setName
*
* @param name A string containing the name to set.
*/ */
void setName(const std::string & name); void setName(const std::string & name);
/** /**