Commit d51c5f3e authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add graphs to Xdmf.

Graphs are stored in compressed sparse row format (XdmfSparseMatrix).
Added ability to partition graphs in XdmfPartitioner.
Added tests for new sparse matrix and graph classes.
parent 0cb8d449
......@@ -211,6 +211,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfDomain
XdmfGeometry
XdmfGeometryType
XdmfGraph
XdmfGrid
XdmfGridCollection
XdmfGridCollectionType
......
......@@ -25,6 +25,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>
......@@ -37,6 +38,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>
......@@ -139,6 +141,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;
......@@ -190,6 +193,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);
}
......@@ -268,6 +274,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)
......@@ -293,6 +300,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;
......@@ -56,8 +57,9 @@ public:
virtual ~XdmfDomain();
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem);
XDMF_CHILDREN(XdmfGridCollection, GridCollection, Name);
XDMF_CHILDREN(XdmfCurvilinearGrid, CurvilinearGrid, Name);
XDMF_CHILDREN(XdmfGraph, Graph, Name);
XDMF_CHILDREN(XdmfGridCollection, GridCollection, Name);
XDMF_CHILDREN(XdmfRectilinearGrid, RectilinearGrid, Name);
XDMF_CHILDREN(XdmfRegularGrid, RegularGrid, Name);
XDMF_CHILDREN(XdmfUnstructuredGrid, UnstructuredGrid, 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;
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();
}
......
......@@ -79,6 +79,7 @@ set(XdmfCoreSources
XdmfInformation
XdmfItem
XdmfItemProperty
XdmfSparseMatrix
XdmfSystemUtils
${CMAKE_BINARY_DIR}/XdmfVersion
XdmfVisitor
......
......@@ -183,6 +183,8 @@ public:
/**
* Get a copy of a single value stored in this array.
*
* @param index the index in the array to copy.
*
* @return the requested value.
*/
template <typename T>
......@@ -323,7 +325,7 @@ public:
template<typename T>
void insert(const unsigned int startIndex,
const T * const valuesPointer,
const unsigned int numValues = 1,
const unsigned int numValues,
const unsigned int arrayStride = 1,
const unsigned int valuesStride = 1);
......@@ -538,7 +540,7 @@ private:
boost::shared_array<const double>,
boost::shared_array<const unsigned char>,
boost::shared_array<const unsigned short>,
boost::shared_array<const unsigned int> > ArrayVariant;
boost::shared_array<const unsigned int> > ArrayVariant;
ArrayVariant mArray;
unsigned int mArrayPointerNumValues;
......
......@@ -23,6 +23,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.hpp>
#include <XdmfSparseMatrix.hpp>
#include <XdmfSystemUtils.hpp>
#include <XdmfVersion.hpp>
#include <XdmfVisitor.hpp>
......@@ -45,6 +46,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
// Ignore ItemTags
%ignore XdmfArray::ItemTag;
%ignore XdmfInformation::ItemTag;
%ignore XdmfSparseMatrix::ItemTag;
// Define equality operators
%extend XdmfItem {
......@@ -296,6 +298,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%shared_ptr(XdmfInformation)
%shared_ptr(XdmfItem)
%shared_ptr(XdmfItemProperty)
%shared_ptr(XdmfSparseMatrix)
%shared_ptr(XdmfVisitor)
%shared_ptr(XdmfWriter)
......@@ -317,6 +320,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%include XdmfInformation.hpp
%include XdmfHDF5Controller.hpp
%include XdmfHDF5Writer.hpp
%include XdmfSparseMatrix.hpp
%include XdmfWriter.hpp
%include CMake/VersionSuite/ProjectVersion.hpp
......@@ -395,4 +399,3 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%template(UIntVector) std::vector<unsigned int>;
%template(ItemVector) std::vector<boost::shared_ptr<XdmfItem> >;
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfSparseMatrix.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 <iostream>
#include <sstream>
#include "XdmfSparseMatrix.hpp"
#include "XdmfError.hpp"
shared_ptr<XdmfSparseMatrix>
XdmfSparseMatrix::New(const unsigned int numberRows,
const unsigned int numberColumns)
{
shared_ptr<XdmfSparseMatrix> p(new XdmfSparseMatrix(numberRows,
numberColumns));
return p;
}
XdmfSparseMatrix::XdmfSparseMatrix(const unsigned int numberRows,
const unsigned int numberColumns) :
mColumnIndex(XdmfArray::New()),
mName(""),
mNumberColumns(numberColumns),
mNumberRows(numberRows),
mRowPointer(XdmfArray::New()),
mValues(XdmfArray::New())
{
mRowPointer->resize<unsigned int>(mNumberRows + 1, 0);
}
XdmfSparseMatrix::~XdmfSparseMatrix()
{
}
const std::string XdmfSparseMatrix::ItemTag = "SparseMatrix";
shared_ptr<XdmfArray>
XdmfSparseMatrix::getColumnIndex()
{
return mColumnIndex;
}
std::map<std::string, std::string>
XdmfSparseMatrix::getItemProperties() const
{
std::map<std::string, std::string> sparseMatrixProperties;
sparseMatrixProperties.insert(std::make_pair("Name", mName));
std::stringstream numberRowsString;
numberRowsString << mNumberRows;
sparseMatrixProperties.insert(std::make_pair("NumberRows",
numberRowsString.str()));
std::stringstream numberColumnsString;
numberColumnsString << mNumberColumns;
sparseMatrixProperties.insert(std::make_pair("NumberColumns",
numberColumnsString.str()));
return sparseMatrixProperties;
}
std::string
XdmfSparseMatrix::getItemTag() const
{
return ItemTag;
}
std::string
XdmfSparseMatrix::getName() const
{
return mName;
}
unsigned int
XdmfSparseMatrix::getNumberColumns() const
{
return mNumberColumns;
}
unsigned int
XdmfSparseMatrix::getNumberRows() const
{
return mNumberRows;
}
shared_ptr<XdmfArray>
XdmfSparseMatrix::getRowPointer()
{
return mRowPointer;
}
shared_ptr<XdmfArray>
XdmfSparseMatrix::getValues()
{
return mValues;
}
std::string
XdmfSparseMatrix::getValuesString() const
{
std::stringstream toReturn;
for(unsigned int i=0; i<mNumberRows; ++i) {
unsigned int index = 0;
for(unsigned int j=mRowPointer->getValue<unsigned int>(i);
j<mRowPointer->getValue<unsigned int>(i+1);
++j) {
const unsigned int k = mColumnIndex->getValue<unsigned int>(j);
while(index++ < k) {
toReturn << "0.0, ";
}
toReturn << mValues->getValue<double>(j) << ", ";
}
while(index++ < mNumberColumns) {
toReturn << "0.0, ";
}
toReturn << std::endl;
}
return toReturn.str();
}
void
XdmfSparseMatrix::populateItem(const std::map<std::string, std::string> & itemProperties,
const std::vector<shared_ptr<XdmfItem> > & childItems,
const XdmfCoreReader * const reader)
{
XdmfItem::populateItem(itemProperties, childItems, reader);
std::map<std::string, std::string>::const_iterator name =
itemProperties.find("Name");
if(name != itemProperties.end()) {
mName = name->second;
}
else {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfSparseMatrix::populateItem");
}
std::map<std::string, std::string>::const_iterator numberRows =
itemProperties.find("NumberRows");
if(numberRows != itemProperties.end()) {
mNumberRows = std::atoi(numberRows->second.c_str());
}
else {
XdmfError::message(XdmfError::FATAL,
"'NumberRows' not found in itemProperties in "
"XdmfSparseMatrix::populateItem");
}
std::map<std::string, std::string>::const_iterator numberColumns =
itemProperties.find("NumberColumns");
if(numberColumns != itemProperties.end()) {
mNumberColumns = std::atoi(numberColumns->second.c_str());
}
else {
XdmfError::message(XdmfError::FATAL,
"'NumberColumns' not found in itemProperties in "
"XdmfSparseMatrix::populateItem");
}
std::vector<shared_ptr<XdmfArray> > arrayVector;
arrayVector.reserve(3);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
arrayVector.push_back(array);
}
}
if(arrayVector.size() < 3) {
XdmfError::message(XdmfError::FATAL,
"Expected 3 arrays attached to "
"XdmfSparseMatrix::populateItem");
}
mRowPointer = arrayVector[0];
mColumnIndex = arrayVector[1];
mValues = arrayVector[2];
}
void
XdmfSparseMatrix::setColumnIndex(const shared_ptr<XdmfArray> columnIndex)
{
mColumnIndex = columnIndex;
}
void
XdmfSparseMatrix::setName(const std::string & name)
{
mName = name;
}
void
XdmfSparseMatrix::setRowPointer(const shared_ptr<XdmfArray> rowPointer)
{
mRowPointer = rowPointer;
}
void
XdmfSparseMatrix::setValues(const shared_ptr<XdmfArray> values)
{
mValues = values;
}
void
XdmfSparseMatrix::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
{
XdmfItem::traverse(visitor);
mRowPointer->accept(visitor);
mColumnIndex->accept(visitor);
mValues->accept(visitor);
}
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfSparseMatrix.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 XDMFSPARSEMATRIX_HPP_
#define XDMFSPARSEMATRIX_HPP_
// Includes
#include "XdmfCore.hpp"
#include "XdmfArray.hpp"
/**
* @brief Sparse matrix implemented as compressed row storage.
*
* An XdmfSparseMatrix provides routines for interacting with a sparse
* matrix. It is stored internally in compressed row storage.
*/
class XDMFCORE_EXPORT XdmfSparseMatrix : public XdmfItem {
public:
/**
* Create a new XdmfSparseMatrix.
*
* @param numberRows number of rows in matrix.
* @param numberColumns number of columns in matrix.
*
* @return constructed XdmfSparseMatrix.
*/
static shared_ptr<XdmfSparseMatrix> New(const unsigned int numberRows,
const unsigned int numberColumns);
virtual ~XdmfSparseMatrix();
LOKI_DEFINE_VISITABLE(XdmfSparseMatrix, XdmfItem);
static const std::string ItemTag;
/**
* Get the column index array.
*
* @return array containing column indices for nonzero entries of
* matrix. This is the same size as values.
*/
shared_ptr<XdmfArray> getColumnIndex();
std::map<std::string, std::string> getItemProperties() const;
std::string getItemTag() const;
/**
* Get the name of the sparse matrix.
*
* @return a string containing the name of the sparse matrix.
*/
std::string getName() const;
/**
* Get the number of columns in the sparse matrix.
*
* @return the number of columns in the sparse matrix.
*/
unsigned int getNumberColumns() const;
/**
* Get the number of rows in the sparse matrix.
*
* @return the number of rows in the sparse matrix.
*/