Commit 8e14630a authored by Kenneth Leiter's avatar Kenneth Leiter
parents 6db38e95 053a30bd
project(Xdmf)
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)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
......@@ -41,6 +46,13 @@ endif(BUILD_TESTING)
option(XDMF_WRAP_PYTHON 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(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
find_package(SWIG REQUIRED)
......@@ -54,7 +66,11 @@ endif(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
if(XDMF_WRAP_PYTHON)
find_package(PythonInterp 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
# Since we essentually do the same thing inside and outside core, it
......@@ -69,6 +85,10 @@ if(XDMF_WRAP_PYTHON)
# optimize swig generation --- these are all flags corresponding to -O
# except -fvirtual which breaks visitor operation
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(swig_extra_generated_files "")
swig_add_module(${python_name} python ${python_name}.i)
......@@ -198,7 +218,7 @@ if(XDMF_WRAP_JAVA)
endif(XDMF_WRAP_JAVA)
add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS})
include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS})
link_directories(${XDMF_LIBRARY_DIRS})
option(XDMF_BUILD_CORE_ONLY OFF)
......@@ -228,7 +248,11 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfUnstructuredGrid)
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)
set_target_properties(Xdmf PROPERTIES
......@@ -248,7 +272,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
endif(XDMF_WRAP_JAVA)
if(XDMF_WRAP_PYTHON)
XDMF_SWIG_PYTHON(Xdmf XdmfCore)
XDMF_SWIG_PYTHON(Xdmf XdmfCore XdmfDSM)
endif(XDMF_WRAP_PYTHON)
if(BUILD_TESTING)
......
......@@ -65,8 +65,68 @@
* constructors in the XDMF API are protected, ensuring that only
* shared pointers can be created. These pointers are freed
* 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 */
#ifdef _WIN32
/* Used to export/import from the dlls */
......@@ -75,6 +135,11 @@
#undef XDMFCORE_TEMPLATE
#define XDMFCORE_TEMPLATE extern
#undef XDMFDSM_EXPORT
#define XDMFDSM_EXPORT __declspec(dllimport)
#undef XDMFDSM_TEMPLATE
#define XDMFDSM_TEMPLATE extern
#ifdef Xdmf_EXPORTS
#define XDMF_EXPORT __declspec(dllexport)
#define XDMF_TEMPLATE
......@@ -98,8 +163,10 @@
#else /* _WIN32 */
/* We don't need to export/import since there are no dlls */
#define XDMFCORE_EXPORT
#define XDMFDSM_EXPORT
#define XDMF_EXPORT
#define XDMFCORE_TEMPLATE
#define XDMFDSM_TEMPLATE
#define XDMF_TEMPLATE
#endif /* _WIN32 */
#endif /* _XDMF_HPP */
......
......@@ -3,22 +3,31 @@ XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/
#ifdef XDMF_BUILD_DSM
%module Xdmf
%{
// MPI Includes
#include <mpi.h>
// XdmfCore Includes
#include <Xdmf.hpp>
#include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
#include <XdmfDSMManager.hpp>
#include <XdmfDSMBuffer.hpp>
#include <XdmfDSMCommMPI.hpp>
#include <XdmfError.hpp>
#include <XdmfFunction.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#ifdef XDMF_BUILD_DSM
#include <XdmfHDF5ControllerDSM.hpp>
#include <XdmfHDF5WriterDSM.hpp>
#endif
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfInformation.hpp>
......@@ -26,6 +35,62 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.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 <XdmfVisitor.hpp>
#include <XdmfWriter.hpp>
......@@ -55,6 +120,8 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfUnstructuredGrid.hpp>
%}
#endif
%import XdmfCore.i
#ifdef SWIGJAVA
......@@ -171,15 +238,39 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include std_set.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(XdmfMapNodeIdMap) 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 {
from XdmfCore import *
from XdmfDSM import *
}
#else
%pythoncode {
from XdmfCore import *
}
#endif /* XDMF_BUILD_DSM */
%fragment("XdmfItemCast", "header") {
#include <XdmfSharedPtr.hpp>
PyObject * XdmfItemCast(shared_ptr<XdmfItem> obj) {
......
......@@ -94,9 +94,14 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second;
}
else {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
try {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
mCenter = XdmfAttributeCenter::New(itemProperties);
......
......@@ -48,7 +48,21 @@ public:
/**
* 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();
......@@ -60,7 +74,29 @@ public:
/**
* 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;
......@@ -71,35 +107,133 @@ public:
/**
* 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;
/**
* 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;
/**
* 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);
/**
* 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);
/**
* Set the XdmfAttributeType associated with this attribute.
*
* @param type XdmfAttributeType to set.
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setType
* @until //#setType
*
* Python
*
* @dontinclude XdmfExampleAttribute.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setType
* @until #//setType
*
* @param type XdmfAttributeType to set.
*/
void setType(const shared_ptr<const XdmfAttributeType> type);
......
......@@ -81,9 +81,14 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
std::map<std::string, std::string>::const_iterator center =
itemProperties.find("Center");
if(center == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
try {
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & centerVal = center->second;
......@@ -103,9 +108,14 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
return Edge();
}
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
try {
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfAttributeCenter>();
}
......
......@@ -35,8 +35,30 @@
* where its values are centered on an XdmfGrid. A specific
* XdmfAttributeCenter can be created by calling on of the static
* methods in the class, i.e. XdmfAttributeCenter::Cell().
*
* Xdmf supports the following attribute centers:
*
* 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
*
* Grid
* Cell
* Face
......@@ -71,7 +93,7 @@ protected:
* construct XdmfAttributeCenters -
* i.e. XdmfAttributeCenter::Node().
*
* @param name the name of the XdmfAttributeCenter to construct.
* @param name The name of the XdmfAttributeCenter to construct.
*/
XdmfAttributeCenter(const std::string & name);
......
......@@ -100,9 +100,14 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
type = itemProperties.find("AttributeType");
}
if(type == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'AttributeType' found in "
"itemProperties in XdmfAttributeType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'AttributeType' found in "
"itemProperties in XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
......@@ -128,10 +133,15 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
return NoAttributeType();
}
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfAttributeType>();
}
......
......@@ -37,6 +37,28 @@
* XdmfAttributeType can be created by calling one of the static
* methods in the class, i.e. XdmfAttributeType::Scalar().
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfAttribute.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setType
* @until //#setType
* @skipline //#getType
* @until //#getType