Commit 40a27f65 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add Name property to XdmfArray and accessor functions for getting and...

ENH: Add Name property to XdmfArray and accessor functions for getting and setting the name.  If no name is specified it is not written to XML.  Modify test to verify reading and writing is working.
parent f6d3e7c5
......@@ -189,7 +189,7 @@ void XdmfGrid::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
void XdmfGrid::setName(const std::string & name)
{
mName= name;
mName = name;
}
void XdmfGrid::setTopology(const boost::shared_ptr<XdmfTopology> topology)
......
......@@ -309,6 +309,7 @@ XdmfArray::XdmfArray() :
mHaveArrayPointer(false),
mArrayPointerNumValues(0),
mHDF5Controller(boost::shared_ptr<XdmfHDF5Controller>()),
mName(""),
mTmpReserveSize(0)
{
std::cout << "Created Array " << this << std::endl;
......@@ -384,10 +385,14 @@ std::map<std::string, std::string> XdmfArray::getItemProperties() const
{
arrayProperties["Format"] = "XML";
}
boost::shared_ptr<const XdmfArrayType> type = this->getType();
std::stringstream size;
size << this->getSize();
arrayProperties["Dimensions"] = size.str();
if(mName.compare("") != 0)
{
arrayProperties["Name"] = mName;
}
boost::shared_ptr<const XdmfArrayType> type = this->getType();
type->getProperties(arrayProperties);
return arrayProperties;
}
......@@ -397,6 +402,11 @@ std::string XdmfArray::getItemTag() const
return ItemTag;
}
std::string XdmfArray::getName() const
{
return mName;
}
unsigned int XdmfArray::getSize() const
{
if(mHaveArray)
......@@ -575,6 +585,15 @@ void XdmfArray::populateItem(const std::map<std::string, std::string> & itemProp
{
assert(false);
}
std::map<std::string, std::string>::const_iterator name = itemProperties.find("Name");
if(name != itemProperties.end())
{
mName = name->second;
}
else
{
mName = "";
}
}
void XdmfArray::read()
......@@ -626,6 +645,11 @@ void XdmfArray::setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hd
mHDF5Controller = hdf5Controller;
}
void XdmfArray::setName(const std::string & name)
{
mName = name;
}
void XdmfArray::swap(const boost::shared_ptr<XdmfArray> array)
{
ArrayVariant tmpArray = array->mArray;
......
......@@ -115,6 +115,13 @@ public:
*/
boost::shared_ptr<const XdmfHDF5Controller> getHDF5Controller() const;
/**
* Get the name of the array.
*
* @return a string containing the name of the array.
*/
std::string getName() const;
/**
* Get the number of values stored in this array.
*
......@@ -237,6 +244,13 @@ public:
*/
void setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hdf5Controller);
/**
* Set the name of the array.
*
* @param name a string containing the name to set.
*/
void setName(const std::string & name);
/**
* Sets the values of this array to the values stored in the arrayPointer array. No copy is made. Modifications to the array are
* not permitted through the XdmfArray API. Any calls through the XdmfArray API to modify the array (i.e. any non-const function)
......@@ -385,6 +399,7 @@ private:
bool mHaveArray;
bool mHaveArrayPointer;
boost::shared_ptr<XdmfHDF5Controller> mHDF5Controller;
std::string mName;
unsigned int mTmpReserveSize;
};
......
......@@ -247,5 +247,9 @@ int main(int argc, char* argv[])
array8->reserve(50);
assert(array8->getCapacity() >= 50);
assert(array8->getName().compare("") == 0);
array8->setName("BLAH");
assert(array8->getName().compare("BLAH") == 0);
return 0;
}
......@@ -34,6 +34,7 @@ public:
0.1, 0.1, -1.1, 1.1, 0.1, -1.1, 3.1, 0.1, -2.1, 0.1, 1.1, -1.1, 1.1, 1.1, -1.1, 3.1, 2.1, -2.1};
grid->getGeometry()->setType(XdmfGeometryType::XYZ());
grid->getGeometry()->getArray()->copyValues(0, &points[0], 36);
grid->getGeometry()->getArray()->setName("Geom 1");
// Set Topology
int connectivity[] = {0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment