Commit 87bb27a4 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

merging from master

parents c7fdba20 26bed716
......@@ -227,6 +227,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfDomain
XdmfGeometry
XdmfGeometryType
XdmfGraph
XdmfGrid
XdmfGridCollection
XdmfGridCollectionType
......
......@@ -29,6 +29,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.hpp>
#include <XdmfSparseMatrix.hpp>
#include <XdmfSystemUtils.hpp>
#include <XdmfVisitor.hpp>
#include <XdmfWriter.hpp>
......@@ -41,6 +42,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfDomain.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGraph.hpp>
#include <XdmfGrid.hpp>
#include <XdmfGridCollection.hpp>
#include <XdmfGridCollectionType.hpp>
......@@ -192,6 +194,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%ignore XdmfCurvilinearGrid::ItemTag;
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
%ignore XdmfGraph::ItemTag;
%ignore XdmfGrid::ItemTag;
%ignore XdmfGridCollection::ItemTag;
%ignore XdmfMap::ItemTag;
......@@ -250,6 +253,9 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
else if(shared_ptr<XdmfGeometry> geometry = shared_dynamic_cast<XdmfGeometry>($1)) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfGeometry>(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN);
}
else if(shared_ptr<XdmfGraph> graph = shared_dynamic_cast<XdmfGraph>($1)) {
$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>($1)) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
}
......@@ -328,6 +334,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
%shared_ptr(XdmfGeometryType)
%shared_ptr(XdmfGraph)
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
%shared_ptr(XdmfGridCollectionType)
......@@ -353,6 +360,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include XdmfDomain.hpp
%include XdmfGeometry.hpp
%include XdmfGeometryType.hpp
%include XdmfGraph.hpp
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
......
......@@ -23,6 +23,7 @@
#include "XdmfDomain.hpp"
#include "XdmfCurvilinearGrid.hpp"
#include "XdmfGraph.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfRectilinearGrid.hpp"
#include "XdmfRegularGrid.hpp"
......@@ -36,6 +37,10 @@ XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
XdmfCurvilinearGrid,
CurvilinearGrid,
Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
XdmfGraph,
Graph,
Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfDomain,
XdmfRectilinearGrid,
RectilinearGrid,
......@@ -85,7 +90,7 @@ XdmfDomain::populateItem(const std::map<std::string, std::string> & itemProperti
const XdmfCoreReader * const reader)
{
XdmfItem::populateItem(itemProperties, childItems, reader);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
......@@ -97,6 +102,10 @@ XdmfDomain::populateItem(const std::map<std::string, std::string> & itemProperti
shared_dynamic_cast<XdmfCurvilinearGrid>(*iter)) {
this->insert(grid);
}
else if(shared_ptr<XdmfGraph> graph =
shared_dynamic_cast<XdmfGraph>(*iter)) {
this->insert(graph);
}
else if(shared_ptr<XdmfRectilinearGrid> grid =
shared_dynamic_cast<XdmfRectilinearGrid>(*iter)) {
this->insert(grid);
......@@ -116,31 +125,37 @@ void
XdmfDomain::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
{
XdmfItem::traverse(visitor);
for(std::vector<shared_ptr<XdmfGridCollection> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfGridCollection> >::const_iterator iter =
mGridCollections.begin();
iter != mGridCollections.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfCurvilinearGrid> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfCurvilinearGrid> >::const_iterator iter =
mCurvilinearGrids.begin();
iter != mCurvilinearGrids.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfRectilinearGrid> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfGraph> >::const_iterator iter =
mGraphs.begin();
iter != mGraphs.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfRectilinearGrid> >::const_iterator iter =
mRectilinearGrids.begin();
iter != mRectilinearGrids.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfRegularGrid> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfRegularGrid> >::const_iterator iter =
mRegularGrids.begin();
iter != mRegularGrids.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfUnstructuredGrid> >::const_iterator iter =
for(std::vector<shared_ptr<XdmfUnstructuredGrid> >::const_iterator iter =
mUnstructuredGrids.begin();
iter != mUnstructuredGrids.end();
++iter) {
......
......@@ -26,6 +26,7 @@
// Forward Declarations
class XdmfCurvilinearGrid;
class XdmfGraph;
class XdmfGridCollection;
class XdmfRectilinearGrid;
class XdmfRegularGrid;
......@@ -69,6 +70,7 @@ public:
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem);
XDMF_CHILDREN(XdmfDomain, XdmfGridCollection, GridCollection, Name);
XDMF_CHILDREN(XdmfDomain, XdmfGraph, Graph, Name);
XDMF_CHILDREN(XdmfDomain, XdmfCurvilinearGrid, CurvilinearGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfRectilinearGrid, RectilinearGrid, Name);
XDMF_CHILDREN(XdmfDomain, XdmfRegularGrid, RegularGrid, Name);
......
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfGraph.cpp */
/* */
/* Author: */
/* Kenneth Leiter */
/* kenneth.leiter@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2011 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#include "XdmfAttribute.hpp"
#include "XdmfGraph.hpp"
XDMF_CHILDREN_IMPLEMENTATION(XdmfGraph, XdmfAttribute, Attribute, Name)
shared_ptr<XdmfGraph>
XdmfGraph::New(const unsigned int numberNodes)
{
shared_ptr<XdmfGraph> p(new XdmfGraph(numberNodes));
return p;
}
XdmfGraph::XdmfGraph(const unsigned int numberNodes) :
XdmfSparseMatrix(numberNodes,
numberNodes)
{
}
XdmfGraph::~XdmfGraph()
{
}
const std::string XdmfGraph::ItemTag = "Graph";
std::string
XdmfGraph::getItemTag() const
{
return ItemTag;
}
unsigned int
XdmfGraph::getNumberNodes() const
{
return this->getNumberRows();
}
void
XdmfGraph::populateItem(const std::map<std::string, std::string> & itemProperties,
const std::vector<shared_ptr<XdmfItem> > & childItems,
const XdmfCoreReader * const reader)
{
XdmfSparseMatrix::populateItem(itemProperties,
childItems,
reader);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfAttribute> attribute =
shared_dynamic_cast<XdmfAttribute>(*iter)) {
this->insert(attribute);
}
}
}
void
XdmfGraph::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
{
XdmfSparseMatrix::traverse(visitor);
for(std::vector<shared_ptr<XdmfAttribute> >::const_iterator iter =
mAttributes.begin();
iter != mAttributes.end();
++iter) {
(*iter)->accept(visitor);
}
}
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfGraph.hpp */
/* */
/* Author: */
/* Kenneth Leiter */
/* kenneth.leiter@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2011 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#ifndef XDMFGRAPH_HPP_
#define XDMFGRAPH_HPP_
// Forward Declarations
class XdmfAttribute;
// Includes
#include "Xdmf.hpp"
#include "XdmfSparseMatrix.hpp"
/**
* @brief Graph stored in sparse matrix form.
*
* Stores graph information in sparse matrix form. Attributes defining
* node and edge information can be inserted.
*/
class XDMF_EXPORT XdmfGraph : public XdmfSparseMatrix {
public:
/**
* Create a new XdmfGraph.
*
* @param numberNodes number of nodes in graph.
*
* @return constructed XdmfGraph.
*/
static shared_ptr<XdmfGraph> New(const unsigned int numberNodes);
virtual ~XdmfGraph();
LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix);
XDMF_CHILDREN(XdmfAttribute, Attribute, Name);
static const std::string ItemTag;
std::string getItemTag() const;
unsigned int getNumberNodes() const;
using XdmfSparseMatrix::insert;
void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
protected:
XdmfGraph(const unsigned int numberNodes);
virtual void
populateItem(const std::map<std::string, std::string> & itemProperties,
const std::vector<shared_ptr<XdmfItem> > & childItems,
const XdmfCoreReader * const reader);
private:
XdmfGraph(const XdmfGraph &); // Not implemented.
void operator=(const XdmfGraph &); // Not implemented.
};
#ifdef _WIN32
#endif
#endif /* XDMFGRAPH_HPP_ */
......@@ -28,6 +28,7 @@
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
#include "XdmfGraph.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfInformation.hpp"
#include "XdmfItemFactory.hpp"
......@@ -35,6 +36,7 @@
#include "XdmfRectilinearGrid.hpp"
#include "XdmfRegularGrid.hpp"
#include "XdmfSet.hpp"
#include "XdmfSparseMatrix.hpp"
#include "XdmfTime.hpp"
#include "XdmfTopology.hpp"
#include "XdmfUnstructuredGrid.hpp"
......@@ -124,6 +126,9 @@ XdmfItemFactory::createItem(const std::string & itemTag,
}
return XdmfGeometry::New();
}
else if(itemTag.compare(XdmfGraph::ItemTag) == 0) {
return XdmfGraph::New(0);
}
else if(itemTag.compare(XdmfGrid::ItemTag) == 0) {
// For backwards compatibility with the old format, this tag can
// correspond to multiple XdmfItems.
......@@ -165,6 +170,9 @@ XdmfItemFactory::createItem(const std::string & itemTag,
else if(itemTag.compare(XdmfSet::ItemTag) == 0) {
return XdmfSet::New();
}
else if(itemTag.compare(XdmfSparseMatrix::ItemTag) == 0) {
return XdmfSparseMatrix::New(0, 0);
}
else if(itemTag.compare(XdmfTime::ItemTag) == 0) {
return XdmfTime::New();
}
......
......@@ -68,7 +68,7 @@ XdmfMap::New(const std::vector<shared_ptr<XdmfAttribute> > & globalNodeIds)
for(std::map<task_id, node_id>::const_iterator iter = currMap.begin();
iter != currMap.end();
++iter) {
if(iter->first != i) {
if(iter->first != (int)i) {
map->insert(iter->first, j, iter->second);
}
}
......
......@@ -4,7 +4,9 @@ if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif (POLICY CMP0015)
include(CheckCXXSourceCompiles)
include(SetUpVersion)
if(VERSION_CONTROL_AUTOUPDATE OR
NOT EXISTS ${CMAKE_BINARY_DIR}/XdmfVersion.hpp)
VersionCreate("Xdmf" "2" "XDMFCORE_EXPORT" "XdmfCore.hpp")
......@@ -69,6 +71,25 @@ if(LIBXML2_FOUND)
set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS})
endif(LIBXML2_FOUND)
# Perform compile-time checks and generate XdmfConfig.hpp
unset(HAVE_BOOST_SHARED_DYNAMIC_CAST CACHE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS})
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
struct Base { virtual ~Base(){} };
struct Derived : public Base {};
int main(int ac, char * av)
{
boost::shared_ptr<Base> ptr(new Base());
boost::shared_dynamic_cast<Derived>(ptr);
}
"
HAVE_BOOST_SHARED_DYNAMIC_CAST)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
${CMAKE_BINARY_DIR}/XdmfConfig.hpp)
set(XdmfCoreSources
XdmfArray
XdmfArrayType
......@@ -82,6 +103,7 @@ set(XdmfCoreSources
XdmfInformation
XdmfItem
XdmfItemProperty
XdmfSparseMatrix
XdmfSystemUtils
${CMAKE_BINARY_DIR}/XdmfVersion
XdmfVisitor
......
......@@ -46,7 +46,7 @@ public:
}
void
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return;
}
......@@ -67,7 +67,7 @@ public:
mArray->mArray);
}
private:
private:
XdmfArray * const mArray;
};
......@@ -82,7 +82,7 @@ public:
}
void
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return;
}
......@@ -96,7 +96,7 @@ public:
template<typename T>
void
operator()(const boost::shared_array<const T> & array) const
operator()(const boost::shared_array<const T> &) const
{
mArray->internalizeArrayPointer();
boost::apply_visitor(*this,
......@@ -179,10 +179,10 @@ public:
}
shared_ptr<const XdmfArrayType>
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
if(mHeavyDataController) {
return mHeavyDataController->getType();
if(mHeavyDataController.size > 0) {
return mHeavyDataControllers[0]->getType();
}
return XdmfArrayType::Uninitialized();
}
......@@ -214,7 +214,7 @@ public:
}
unsigned int
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return 0;
}
......@@ -228,7 +228,7 @@ public:
template<typename T>
unsigned int
operator()(const boost::shared_array<const T> & array) const
operator()(const boost::shared_array<const T> &) const
{
return 0;
}
......@@ -243,7 +243,7 @@ public:
}
const void *
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return NULL;
}
......@@ -314,7 +314,7 @@ public:
}
std::string
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return "";
}
......@@ -361,7 +361,7 @@ public:
}
void
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
mArray->initialize(mArrayToCopy->getArrayType());
boost::apply_visitor(*this,
......@@ -417,14 +417,14 @@ public:
}
void
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
return;
}
template<typename T>
void
operator()(const shared_ptr<std::vector<T> > & array) const
operator()(const shared_ptr<std::vector<T> > &) const
{
return;
}
......@@ -445,6 +445,33 @@ private:
XdmfArray * const mArray;
};
class XdmfArray::IsInitialized : public boost::static_visitor<bool> {
public:
IsInitialized()
{
}
bool
operator()(const boost::blank &) const
{
return false;
}
template<typename T>
bool
operator()(const shared_ptr<std::vector<T> > &) const
{
return true;
}
template<typename T>
bool
operator()(const T &) const
{
return true;
}
};
class XdmfArray::Reserve : public boost::static_visitor<void> {
public:
......@@ -456,7 +483,7 @@ public:
}
void
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
mArray->mTmpReserveSize = mSize;
}
......@@ -470,7 +497,7 @@ public:
template<typename T>
void
operator()(const boost::shared_array<const T> & array) const
operator()(const boost::shared_array<const T> &) const
{
mArray->internalizeArrayPointer();
boost::apply_visitor(*this,
......@@ -492,9 +519,9 @@ public:
}
unsigned int
operator()(const boost::blank & array) const
operator()(const boost::blank &) const
{
if(mArray->mHeavyDataControllers.size()>0) {
if(mArray->mHeavyDataControllers.size() > 0) {
return mArray->mHeavyDataControllers[0]->getSize();//modify this to compile all controllers
}
return 0;
......@@ -509,14 +536,14 @@ public:
template<typename T>
unsigned int
operator()(const boost::shared_array<const T> & array) const
operator()(const boost::shared_array<const T> &) const
{
return mArray->mArrayPointerNumValues;
}
private:
const XdmfArray * const mArray;
const XdmfArray * const mArray;
};
shared_ptr<XdmfArray>
......@@ -542,7 +569,7 @@ const std::string XdmfArray::ItemTag = "DataItem";
void
XdmfArray::clear()
{
boost::apply_visitor(Clear(this),
boost::apply_visitor(Clear(this),
mArray);
mDimensions.clear();
}
......@@ -574,7 +601,7 @@ XdmfArray::getArrayType() const
unsigned int
XdmfArray::getCapacity() const
{
return boost::apply_visitor(GetCapacity(),
return boost::apply_visitor(GetCapacity(),
mArray);
}
......@@ -619,7 +646,7 @@ XdmfArray::getItemProperties() const
else {
arrayProperties.insert(std::make_pair("Format", "XML"));
}
arrayProperties.insert(std::make_pair("Dimensions",
arrayProperties.insert(std::make_pair("Dimensions",
this->getDimensionsString()));
if(mName.compare("") != 0) {
arrayProperties.insert(std::make_pair("Name", mName));
......@@ -644,7 +671,7 @@ XdmfArray::getName() const
unsigned int
XdmfArray::getSize() const
{
return boost::apply_visitor(Size(this),
return boost::apply_visitor(Size(this),
mArray);
}
......@@ -658,14 +685,14 @@ XdmfArray::getValuesInternal()
const void *
XdmfArray::getValuesInternal() const
{
return boost::apply_visitor(GetValuesPointer(),
return boost::apply_visitor(GetValuesPointer(),
mArray);
}
std::string
XdmfArray::getValuesString() const
{
return boost::apply_visitor(GetValuesString(mArrayPointerNumValues),
return boost::apply_visitor(GetValuesString(mArrayPointerNumValues),
mArray);
}
......@@ -734,7 +761,7 @@ XdmfArray::initialize(const shared_ptr<const XdmfArrayType> arrayType,
this->release();
}
else {
XdmfError::message(XdmfError::FATAL,