Commit 31b424c7 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Get Java wrapping working again. Add curvilinear grid.

parent 42286d09
......@@ -135,6 +135,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfGrid
XdmfGridCollection
XdmfGridCollectionType
XdmfGridCurvilinear
XdmfGridRectilinear
XdmfGridRegular
XdmfItemFactory
......
......@@ -98,13 +98,29 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
}
}
// Swig+Java will automatically create 'getter' functions for static
// variables in a class (in this case the ItemTag member variable).
// This happens to conflict with the getters that Xdmf implements to
// override the otherwise virtual functions of the parent class. Here,
// we ask swig to ignore the static variable (thereby removing direct
// access to the variable, but leaving access to our getter function
// Ignore const overloaded methods
%ignore XdmfDomain::getGrid(const unsigned int) const;
%ignore XdmfDomain::getGrid(const std::string &) const;
%ignore XdmfDomain::getGridCollection(const unsigned int) const;
%ignore XdmfDomain::getGridCollection(const std::string &) const;
%ignore XdmfGrid::getAttribute(const unsigned int) const;
%ignore XdmfGrid::getAttribute(const std::string &) const;
%ignore XdmfGrid::getGeometry() const;
%ignore XdmfGrid::getMap() const;
%ignore XdmfGrid::getSet(const unsigned int) const;
%ignore XdmfGrid::getSet(const std::string &) const;
%ignore XdmfGrid::getTime() const;
%ignore XdmfGrid::getTopology() const;
%ignore XdmfGridRectilinear::getCoordinates(const unsigned int) const;
%ignore XdmfGridRectilinear::getCoordinates() const;
%ignore XdmfGridRectilinear::getDimensions() const;
%ignore XdmfGridRegular::getBrickSize() const;
%ignore XdmfGridRegular::getDimensions() const;
%ignore XdmfGridRegular::getOrigin() const;
%ignore XdmfSet::getAttribute(const unsigned int) const;
%ignore XdmfSet::getAttribute(const std::string &) const;
// Ignore ItemTags
%ignore XdmfAttribute::ItemTag;
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
......@@ -117,29 +133,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%ignore XdmfTime::ItemTag;
%ignore XdmfTopology::ItemTag;
// Swig+Java does not like 2 functions with the same prototype that
// simply return const/non-const versions of the same type. We
// ask Swig to ignore one of the two getter functions. We may
// have to change this to rename the function to a new name such
// that we preserve the ability to get a constant variable
%rename(getAttributeUIntConst) XdmfSet::getAttribute(unsigned int const) const;
%rename(getAttributeStrConst) XdmfSet::getAttribute(std::string const &) const;
%ignore XdmfDomain::getGrid(const unsigned int index) const;
%ignore XdmfDomain::getGridCollection(unsigned int const) const;
%ignore XdmfGrid::getAttribute(const unsigned int index) const;
%ignore XdmfGrid::getAttribute(const std::string & name) const;
%ignore XdmfGrid::getSet(const unsigned int index) const;
%ignore XdmfGrid::getSet(const std::string & name) const;
%ignore XdmfGrid::getGeometry() const;
%ignore XdmfGrid::getTime() const;
%ignore XdmfGrid::getTopology() const;
%ignore XdmfGridCollection::getGrid(const unsigned int index) const;
%ignore XdmfGridCollection::insert(const boost::shared_ptr<XdmfInformation> information);
%ignore XdmfGrid::getMap() const;
%ignore XdmfSet::getHDF5Controller() const;
%pragma(java) jniclasscode=%{
static
{
......
/*
* XdmfGridCurvilinear.cpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#include <cmath>
#include "XdmfArray.hpp"
#include "XdmfGridCurvilinear.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
/**
* PIMPL
*/
class XdmfGridCurvilinear::XdmfGridCurvilinearImpl {
public:
class XdmfTopologyCurvilinear : public XdmfTopology
{
public:
static boost::shared_ptr<XdmfTopologyCurvilinear> New(const XdmfGridCurvilinear * const curvilinearGrid)
{
boost::shared_ptr<XdmfTopologyCurvilinear> p(new XdmfTopologyCurvilinear(curvilinearGrid));
return p;
}
unsigned int getNumberElements() const
{
const boost::shared_ptr<const XdmfArray> dimensions = mCurvilinearGrid->getDimensions();
if(dimensions->getSize() == 0)
{
return 0;
}
unsigned int toReturn = 1;
for(unsigned int i=0; i<dimensions->getSize(); ++i)
{
toReturn *= (dimensions->getValue<unsigned int>(i) - 1);
}
return toReturn;
}
private:
XdmfTopologyCurvilinear(const XdmfGridCurvilinear * const curvilinearGrid) :
mCurvilinearGrid(curvilinearGrid)
{
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
const XdmfGridCurvilinear * const mCurvilinearGrid;
};
class XdmfTopologyTypeCurvilinear : public XdmfTopologyType
{
public:
static boost::shared_ptr<const XdmfTopologyTypeCurvilinear> New(const XdmfGridCurvilinear * const curvilinearGrid)
{
boost::shared_ptr<const XdmfTopologyTypeCurvilinear> p(new XdmfTopologyTypeCurvilinear(curvilinearGrid));
return p;
}
unsigned int getNodesPerElement() const
{
// 2^Dimensions
// e.g. 1D = 2 nodes per element and 2D = 4 nodes per element.
return (unsigned int)std::pow(2, (double)mCurvilinearGrid->getDimensions()->getSize());
}
void getProperties(std::map<std::string, std::string> & collectedProperties) const
{
boost::shared_ptr<const XdmfArray> dimensions = mCurvilinearGrid->getDimensions();
if(dimensions->getSize() == 3)
{
collectedProperties["Type"] = "3DSMesh";
}
else if(dimensions->getSize() == 2)
{
collectedProperties["Type"] = "2DSMesh";
}
else
{
assert(false);
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
private:
XdmfTopologyTypeCurvilinear(const XdmfGridCurvilinear * const curvilinearGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured),
mCurvilinearGrid(curvilinearGrid)
{
}
const XdmfGridCurvilinear * const mCurvilinearGrid;
};
XdmfGridCurvilinearImpl(const boost::shared_ptr<XdmfArray> numPoints) :
mDimensions(numPoints)
{
}
boost::shared_ptr<XdmfArray> mDimensions;
};
boost::shared_ptr<XdmfGridCurvilinear> XdmfGridCurvilinear::New(const unsigned int xNumPoints, const unsigned int yNumPoints)
{
boost::shared_ptr<XdmfArray> numPoints = XdmfArray::New();
numPoints->resize<unsigned int>(2);
numPoints->insert(0, xNumPoints);
numPoints->insert(1, yNumPoints);
boost::shared_ptr<XdmfGridCurvilinear> p(new XdmfGridCurvilinear(numPoints));
return p;
}
boost::shared_ptr<XdmfGridCurvilinear> XdmfGridCurvilinear::New(const unsigned int xNumPoints, const unsigned int yNumPoints,
const unsigned int zNumPoints)
{
boost::shared_ptr<XdmfArray> numPoints = XdmfArray::New();
numPoints->resize<unsigned int>(3);
numPoints->insert(0, xNumPoints);
numPoints->insert(1, yNumPoints);
numPoints->insert(2, zNumPoints);
boost::shared_ptr<XdmfGridCurvilinear> p(new XdmfGridCurvilinear(numPoints));
return p;
}
boost::shared_ptr<XdmfGridCurvilinear> XdmfGridCurvilinear::New(const boost::shared_ptr<XdmfArray> numPoints)
{
boost::shared_ptr<XdmfGridCurvilinear> p(new XdmfGridCurvilinear(numPoints));
return p;
}
XdmfGridCurvilinear::XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints) :
mImpl(new XdmfGridCurvilinearImpl(numPoints))
{
this->setTopology(XdmfGridCurvilinearImpl::XdmfTopologyCurvilinear::New(this));
}
XdmfGridCurvilinear::~XdmfGridCurvilinear()
{
delete mImpl;
}
const std::string XdmfGridCurvilinear::ItemTag = "Grid";
boost::shared_ptr<XdmfArray> XdmfGridCurvilinear::getDimensions()
{
return boost::const_pointer_cast<XdmfArray>(static_cast<const XdmfGridCurvilinear &>(*this).getDimensions());
}
boost::shared_ptr<const XdmfArray> XdmfGridCurvilinear::getDimensions() const
{
return mImpl->mDimensions;
}
void XdmfGridCurvilinear::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader)
{
XdmfGrid::populateItem(itemProperties, childItems, reader);
for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
{
if(boost::shared_ptr<XdmfGridCurvilinear> curvilinearGrid = boost::shared_dynamic_cast<XdmfGridCurvilinear>(*iter))
{
mImpl->mDimensions = curvilinearGrid->getDimensions();
}
}
}
void XdmfGridCurvilinear::setDimensions(const boost::shared_ptr<XdmfArray> dimensions)
{
mImpl->mDimensions = dimensions;
}
#ifndef XDMFGRIDCURVILINEAR_HPP_
#define XDMFGRIDCURVILINEAR_HPP_
// Includes
#include "XdmfGrid.hpp"
/**
* @brief A curvilinear (or structured) grid consisting of cells and points arranged on a regular lattice in space.
*
* XdmfGridCurvilinear represents a mesh of cells and points arranged with regular topology in space. A curvilinear grid
* contains regular topology but irregular geometry.
*
* In order to define a curvilinear grid, the dimensions of the grid must be supplied and the coordinates of each point
* must be specified.
*
*/
class XdmfGridCurvilinear : public XdmfGrid {
public:
/**
* Create a new curvilinear grid (Two dimensional).
*
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
*
* @return constructed curvilinear grid.
*/
static boost::shared_ptr<XdmfGridCurvilinear> New(const unsigned int xNumPoints, const unsigned int yNumPoints);
/**
* Create a new curvilinear grid (Three dimensional).
*
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
* @param yNumPoints the number of points in the z direction.
*
* @return constructed curvilinear grid.
*/
static boost::shared_ptr<XdmfGridCurvilinear> New(const unsigned int xNumPoints, const unsigned int yNumPoints,
const unsigned int zNumPounts);
/**
* Create a new curvilinear grid (N dimensional).
*
* @param numPoints the number of points in each direction.
*
* @return constructed curvilinear grid.
*/
static boost::shared_ptr<XdmfGridCurvilinear> New(const boost::shared_ptr<XdmfArray> numPoints);
virtual ~XdmfGridCurvilinear();
LOKI_DEFINE_VISITABLE(XdmfGridCurvilinear, XdmfGrid)
static const std::string ItemTag;
/**
* Get the dimensions of the grid, the number of points in each direction.
*
* @return XdmfArray containing dimensions of this grid.
*/
boost::shared_ptr<XdmfArray> getDimensions();
/**
* Get the dimensions of the grid, the number of points in each direction (const version).
*
* @return XdmfArray containing the dimensions of this grid.
*/
boost::shared_ptr<const XdmfArray> getDimensions() const;
/**
* Set the dimensions of the grid, the number of points in each direction.
*
* @param dimensions the dimension of the grid.
*/
void setDimensions(const boost::shared_ptr<XdmfArray> dimensions);
protected:
XdmfGridCurvilinear(const boost::shared_ptr<XdmfArray> numPoints);
void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader);
private:
/**
* PIMPL
*/
class XdmfGridCurvilinearImpl;
XdmfGridCurvilinear(const XdmfGridCurvilinear & grid); // Not implemented.
void operator=(const XdmfGridCurvilinear & grid); // Not implemented.
XdmfGridCurvilinearImpl * mImpl;
};
#endif /* XDMFGRIDRECTILINEAR_HPP_ */
......@@ -63,7 +63,7 @@ public:
this->setType(XdmfGeometryTypeRectilinear::New(mRectilinearGrid));
}
XdmfGridRectilinear * const mRectilinearGrid;
const XdmfGridRectilinear * const mRectilinearGrid;
};
class XdmfGeometryTypeRectilinear : public XdmfGeometryType
......@@ -87,11 +87,11 @@ public:
const unsigned int dimensions = this->getDimensions();
if(dimensions == 3)
{
collectedProperties["Type"] = "ORIGIN_DXDYDZ";
collectedProperties["Type"] = "VXVYVZ";
}
else if(dimensions == 2)
{
collectedProperties["Type"] = "ORIGIN_DXDY";
collectedProperties["Type"] = "VXVY";
}
else
{
......@@ -103,7 +103,7 @@ public:
XdmfGeometryTypeRectilinear(const XdmfGridRectilinear * const rectilinearGrid) :
XdmfGeometryType("", 0),
mRectilinearGrid(mRectilinearGrid)
mRectilinearGrid(rectilinearGrid)
{
}
......@@ -296,8 +296,11 @@ void XdmfGridRectilinear::populateItem(const std::map<std::string, std::string>
{
if(boost::shared_ptr<XdmfGridRectilinear> rectilinearGrid = boost::shared_dynamic_cast<XdmfGridRectilinear>(*iter))
{
this->setCoordinates(rectilinearGrid->getCoordinates());
break;
if(rectilinearGrid->getGeometry()->getType()->getDimensions() > 0)
{
this->setCoordinates(rectilinearGrid->getCoordinates());
break;
}
}
}
}
......
......@@ -5,7 +5,7 @@
#include "XdmfGrid.hpp"
/**
* @brief A mesh consisting of cells and points arranged on a regular lattice in space.
* @brief A rectilinear grid consisting of cells and points arranged on a regular lattice in space.
*
* XdmfGridRectilinear represents a mesh of cells and point arranged on a regular lattice in space.
* Points are arranged along coordinate axes, but the spacing between points may vary.
......
......@@ -208,44 +208,44 @@ public:
};
boost::shared_ptr<XdmfGridRegular> XdmfGridRegular::New(const double brickSizeX, const double brickSizeY, const unsigned int numPointsX,
const unsigned int numPointsY, const double originX, const double originY)
boost::shared_ptr<XdmfGridRegular> XdmfGridRegular::New(const double xBrickSize, const double yBrickSize, const unsigned int xNumPoints,
const unsigned int yNumPoints, const double xOrigin, const double yOrigin)
{
boost::shared_ptr<XdmfArray> brickSize = XdmfArray::New();
brickSize->resize<double>(2);
brickSize->insert(0, brickSizeX);
brickSize->insert(1, brickSizeY);
brickSize->insert(0, xBrickSize);
brickSize->insert(1, yBrickSize);
boost::shared_ptr<XdmfArray> numPoints = XdmfArray::New();
numPoints->resize<unsigned int>(2);
numPoints->insert(0, numPointsX);
numPoints->insert(1, numPointsY);
numPoints->insert(0, xNumPoints);
numPoints->insert(1, yNumPoints);
boost::shared_ptr<XdmfArray> origin = XdmfArray::New();
origin->resize<double>(2);
origin->insert(0, originX);
origin->insert(1, originY);
origin->insert(0, xOrigin);
origin->insert(1, yOrigin);
boost::shared_ptr<XdmfGridRegular> p(new XdmfGridRegular(brickSize, numPoints, origin));
return p;
}
boost::shared_ptr<XdmfGridRegular> XdmfGridRegular::New(const double brickSizeX, const double brickSizeY, const double brickSizeZ,
const unsigned int numPointsX, const unsigned int numPointsY, const unsigned int numPointsZ,
const double originX, const double originY, const double originZ)
boost::shared_ptr<XdmfGridRegular> XdmfGridRegular::New(const double xBrickSize, const double yBrickSize, const double zBrickSize,
const unsigned int xNumPoints, const unsigned int yNumPoints, const unsigned int zNumPoints,
const double xOrigin, const double yOrigin, const double zOrigin)
{
boost::shared_ptr<XdmfArray> brickSize = XdmfArray::New();
brickSize->resize<double>(3);
brickSize->insert(0, brickSizeX);
brickSize->insert(1, brickSizeY);
brickSize->insert(2, brickSizeZ);
brickSize->insert(0, xBrickSize);
brickSize->insert(1, yBrickSize);
brickSize->insert(2, zBrickSize);
boost::shared_ptr<XdmfArray> numPoints = XdmfArray::New();
numPoints->resize<unsigned int>(3);
numPoints->insert(0, numPointsX);
numPoints->insert(1, numPointsY);
numPoints->insert(2, numPointsZ);
numPoints->insert(0, xNumPoints);
numPoints->insert(1, yNumPoints);
numPoints->insert(2, zNumPoints);
boost::shared_ptr<XdmfArray> origin = XdmfArray::New();
origin->resize<double>(3);
origin->insert(0, originX);
origin->insert(1, originY);
origin->insert(2, originZ);
origin->insert(0, xOrigin);
origin->insert(1, yOrigin);
origin->insert(2, zOrigin);
boost::shared_ptr<XdmfGridRegular> p(new XdmfGridRegular(brickSize, numPoints, origin));
return p;
}
......
......@@ -5,7 +5,7 @@
#include "XdmfGrid.hpp"
/**
* @brief A mesh consisting of congruent points arranged regularly in space.
* @brief A regular grid consisting of congruent points arranged regularly in space.
*
* XdmfGridRegular represents a regular mesh of congruent points arranged in space.
* In order to define a regular grid, three sets of terms need to be supplied:
......@@ -21,36 +21,36 @@ public:
/**
* Create a new structured grid (Two dimensional).
*
* @param brickSizeX the size of the brick in the x direction.
* @param brickSizeY the size of the brick in the y direction.
* @param numPointsX the number of points in the x direction.
* @param numPointsY the number of points in the y direction.
* @param originX the x coordinate of the origin.
* @param originY the y coordinate of the origin.
* @param xBrickSize the size of the brick in the x direction.
* @param yBrickSize the size of the brick in the y direction.
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
* @param xOrigin the x coordinate of the origin.
* @param yOrigin the y coordinate of the origin.
*
* @return constructed structured grid.
*/
static boost::shared_ptr<XdmfGridRegular> New(const double brickSizeX, const double brickSizeY, const unsigned int numPointsX,
const unsigned int numPointsY, const double originX, const double originY);
static boost::shared_ptr<XdmfGridRegular> New(const double xBrickSize, const double yBrickSize, const unsigned int xNumPoints,
const unsigned int yNumPoints, const double xOrigin, const double yOrigin);
/**
* Create a new structured grid (Three dimensional).
*
* @param brickSizeX the size of the brick in the x direction.
* @param brickSizeY the size of the brick in the y direction.
* @param brickSizeZ the size of the brick in the z direction.
* @param numPointsX the number of points in the x direction.
* @param numPointsY the number of points in the y direction.
* @param numPointsZ the number of points in the z direction.
* @param originX the x coordinate of the origin.
* @param originY the y coordinate of the origin.
* @param originZ the z coordinate of the origin.
* @param xBrickSize the size of the brick in the x direction.
* @param yBrickSize the size of the brick in the y direction.
* @param zBrickSize the size of the brick in the z direction.
* @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction.
* @param zNumPoints the number of points in the z direction.
* @param xOrigin the x coordinate of the origin.
* @param yOrigin the y coordinate of the origin.
* @param zOrigin the z coordinate of the origin.
*
* @return constructed structured grid.
*/
static boost::shared_ptr<XdmfGridRegular> New(const double brickSizeX, const double brickSizeY, const double brickSizeZ,
const unsigned int numPointsX, const unsigned int numPointsY, const unsigned int numPointsZ,
const double originX, const double originY, const double originZ);
static boost::shared_ptr<XdmfGridRegular> New(const double xBrickSize, const double yBrickSize, const double zBrickSize,
const unsigned int xNumPoints, const unsigned int yNumPoints, const unsigned int zNumPoints,
const double xOrigin, const double yOrigin, const double zOrigin);
/**
* Create a new structured grid (N dimensional).
......
......@@ -5,6 +5,8 @@
#include "XdmfGeometryType.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfGridCurvilinear.hpp"
#include "XdmfGridRectilinear.hpp"
#include "XdmfGridRegular.hpp"
#include "XdmfInformation.hpp"
#include "XdmfItemFactory.hpp"
......@@ -80,6 +82,18 @@ boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & item
}
return boost::shared_ptr<XdmfItem>();
}
else if(typeVal.compare("VXVY") == 0 || typeVal.compare("VXVYVZ") == 0)
{
std::vector<boost::shared_ptr<XdmfArray> > coordinateValues;
for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
{
if(boost::shared_ptr<XdmfArray> array = boost::shared_dynamic_cast<XdmfArray>(*iter))
{
coordinateValues.push_back(array);
}
}
return XdmfGridRectilinear::New(coordinateValues);
}
}
return XdmfGeometry::New();
}
......@@ -96,10 +110,19 @@ boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & item
// Find out what kind of grid we have
for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
{
if(boost::shared_ptr<XdmfGridRegular> regularGrid = boost::shared_dynamic_cast<XdmfGridRegular>(*iter))
if(boost::shared_ptr<XdmfGridCurvilinear> curvilinear = boost::shared_dynamic_cast<XdmfGridCurvilinear>(*iter))
{
return XdmfGridCurvilinear::New(0, 0);
}
else if(boost::shared_ptr<XdmfGridRegular> regularGrid = boost::shared_dynamic_cast<XdmfGridRegular>(*iter))
{
return XdmfGridRegular::New(0, 0, 0, 0, 0, 0);
}
else if(boost::shared_ptr<XdmfGridRectilinear> rectilinearGrid = boost::shared_dynamic_cast<XdmfGridRectilinear>(*iter))
{
std::vector<boost::shared_ptr<XdmfArray> > coordinateValues;
return XdmfGridRectilinear::New(coordinateValues);
}
}
return XdmfGrid::New();
}
......@@ -132,7 +155,8 @@ boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & item
{
std::string typeVal = type->second;
std::transform(typeVal.begin(), typeVal.end(), typeVal.begin(), (int(*)(int))std::toupper);
if(typeVal.compare("2DCORECTMESH") == 0 || typeVal.compare("3DCORECTMESH") == 0)
if(typeVal.compare("2DCORECTMESH") == 0 || typeVal.compare("3DCORECTMESH") == 0
|| typeVal.compare("2DSMESH") == 0 || typeVal.compare("3DSMESH") == 0)
{
boost::shared_ptr<XdmfArray> dimensionsArray = XdmfArray::New();
std::string dimensionsString = "";
......@@ -146,8 +170,21 @@ boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & item
{
dimensionsArray->pushBack<unsigned int>(atoi((*iter).c_str()));
}
return XdmfGridRegular::New(boost::shared_ptr<XdmfArray>(), dimensionsArray, boost::shared_ptr<XdmfArray>());
if(typeVal.compare("2DCORECTMESH") == 0 || typeVal.compare("3DCORECTMESH") == 0)
{
return XdmfGridRegular::New(boost::shared_ptr<XdmfArray>(), dimensionsArray, boost::shared_ptr<XdmfArray>());
}
else
{
return XdmfGridCurvilinear::New(dimensionsArray);
}
}
else if(typeVal.compare("2DRECTMESH") == 0 || typeVal.compare("3DRECTMESH") == 0)
{
std::vector<boost::shared_ptr<XdmfArray> > coordinateValues;
return XdmfGridRectilinear::New(coordinateValues);
}
}
return XdmfTopology::New();
}
......
......@@ -2,7 +2,7 @@
#define XDMFMAP_HPP_
// Forward Declarations
class XdmfAttribute;
class XdmfArray;
class XdmfGridCollection;
// Includes
......@@ -11,6 +11,15 @@ class XdmfGridCollection;
/**
* @brief Boundary communicator map for partitioned spatial collections.
*
* Provides mechanism for mapping nodes across partition boundaries. Each partitioned grid contains its own map, mapping its own nodes
* to all other nodes in the global system.
*
* There are two methods for constructing XdmfMaps:
* Call New() providing no parameters will construct an empty map. The map can be filled manually with subsequent insert commands.
* Call New(const std::vector<boost::shared_ptr<XdmfAttribute> > & globalNodeIds) will construct XdmfMaps for each grid in an entire
* global system. Each entry in the vector contains the globalNodeIds for that partition. The function takes these global node ids
* to construct the proper XdmfMaps.
*
*/
class XdmfMap : public XdmfItem {
......@@ -23,6 +32,13 @@ public:
*/
static boost::shared_ptr<XdmfMap> New();
/**
* Create XdmfMaps for each grid in a domain decomposed mesh. Each entry in the globalNodeIds vector contains the global node ids
* for that partition.
*
* @param globalNodeIds a vector of attributes containing globalNodeId values for each partition to be mapped.
* @return constructed XdmfMaps for each partition. The size of the vector will be the same as the globalNodeIds vector.
*/
static std::vector<boost::shared_ptr<XdmfMap> > New(const std::vector<boost::shared_ptr<XdmfAttribute> > & globalNodeIds);
virtual ~XdmfMap();
......@@ -32,6 +48,9 @@ public:
std::map<std::string, std::string> getItemProperties() const;
/**
* Given a local node id return a map containing equivalent remote node ids
*/
std::map<unsigned int, unsigned int> getRemoteNodeIds(const unsigned int localNodeId);
std::string getItemTag() const;
......@@ -51,7 +70,7 @@ public:
void read();
/**
* Release all data held in memory. The HDF5Controllers remains attached.
* Release all data held in memory. The HDF5Controllers remain attached.
*/
void release();
......
......@@ -10,6 +10,8 @@
#include "XdmfSet.hpp"
#include "XdmfSetType.hpp"
XDMF_CHILDREN_IMPLEMENTATION(XdmfSet, XdmfAttribute, Attribute, Name)
boost::shared_ptr<XdmfSet> XdmfSet::New()
{
boost::shared_ptr<XdmfSet> p(new XdmfSet());
......@@ -28,37 +30,6 @@ XdmfSet::~XdmfSet()
const std::string XdmfSet::ItemTag = "Set";
boost::shared_ptr<XdmfAttribute> XdmfSet::getAttribute(const unsigned int index)
{
return boost::const_pointer_cast<XdmfAttribute>(static_cast<const XdmfSet &>(*this).getAttribute(index));
}
boost::shared_ptr<const XdmfAttribute> XdmfSet::getAttribute(const unsigned int index) const
{
if(index < mAttributes.size())
{
return mAttributes[index];
}
return boost::shared_ptr<XdmfAttribute>();
}
boost::shared_ptr<XdmfAttribute> XdmfSet::getAttribute(const std::string & name)
{
return boost::const_pointer_cast<XdmfAttribute>(static_cast<const XdmfSet &>(*this).getAttribute(name));
}
boost::shared_ptr<const XdmfAttribute> XdmfSet::getAttribute(const std::string & name) const
{
for(std::vector<boost::shared_ptr<XdmfAttribute> >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter)
{
if((*iter)->getName().compare(name) == 0)
{
return *iter;
}
}