Commit 4f65d6c6 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Rename get/set ItemProperties for conciseness. e.g. getAttributeCenter...

ENH: Rename get/set ItemProperties for conciseness.  e.g. getAttributeCenter ---> getCenter .  This follows
what is done for XdmfArray (getType).
parent 68d4ee41
......@@ -24,16 +24,11 @@ XdmfAttribute::~XdmfAttribute()
const std::string XdmfAttribute::ItemTag = "Attribute";
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttribute::getAttributeCenter() const
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttribute::getCenter() const
{
return mAttributeCenter;
}
boost::shared_ptr<const XdmfAttributeType> XdmfAttribute::getAttributeType() const
{
return mAttributeType;
}
std::map<std::string, std::string> XdmfAttribute::getItemProperties() const
{
std::map<std::string, std::string> attributeProperties;
......@@ -53,6 +48,11 @@ std::string XdmfAttribute::getName() const
return mName;
}
boost::shared_ptr<const XdmfAttributeType> XdmfAttribute::getType() const
{
return mAttributeType;
}
void XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
std::map<std::string, std::string>::const_iterator name = itemProperties.find("Name");
......@@ -70,17 +70,17 @@ void XdmfAttribute::populateItem(const std::map<std::string, std::string> & item
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfAttribute::setAttributeCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter)
void XdmfAttribute::setCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter)
{
mAttributeCenter = attributeCenter;
}
void XdmfAttribute::setAttributeType(const boost::shared_ptr<const XdmfAttributeType> attributeType)
void XdmfAttribute::setName(const std::string & name)
{
mAttributeType = attributeType;
mName= name;
}
void XdmfAttribute::setName(const std::string & name)
void XdmfAttribute::setType(const boost::shared_ptr<const XdmfAttributeType> attributeType)
{
mName= name;
mAttributeType = attributeType;
}
......@@ -29,14 +29,8 @@ public:
*
* @return XdmfAttributeCenter of the attribute.
*/
boost::shared_ptr<const XdmfAttributeCenter> getAttributeCenter() const;
boost::shared_ptr<const XdmfAttributeCenter> getCenter() const;
/**
* Get the XdmfAttributeType associated with this attribute.
*
* @return XdmfAttributeType of the attribute.
*/
boost::shared_ptr<const XdmfAttributeType> getAttributeType() const;
std::map<std::string, std::string> getItemProperties() const;
......@@ -50,18 +44,18 @@ public:
std::string getName() const;
/**
* Set the XdmfAttributeCenter associated with this attribute.
* Get the XdmfAttributeType associated with this attribute.
*
* @param attributeCenter the XdmfAttributeCenter to set.
* @return XdmfAttributeType of the attribute.
*/
void setAttributeCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter);
boost::shared_ptr<const XdmfAttributeType> getType() const;
/**
* Set the XdmfAttributeType associated with this attribute.
* Set the XdmfAttributeCenter associated with this attribute.
*
* @param attributeType XdmfAttributeType to set.
* @param attributeCenter the XdmfAttributeCenter to set.
*/
void setAttributeType(const boost::shared_ptr<const XdmfAttributeType> attributeType);
void setCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter);
/**
* Set the name of the attribute.
......@@ -70,6 +64,13 @@ public:
*/
void setName(const std::string & name);
/**
* Set the XdmfAttributeType associated with this attribute.
*
* @param attributeType XdmfAttributeType to set.
*/
void setType(const boost::shared_ptr<const XdmfAttributeType> attributeType);
protected:
XdmfAttribute();
......@@ -81,8 +82,8 @@ private:
void operator=(const XdmfAttribute & attribute); // Not implemented.
std::string mName;
boost::shared_ptr<const XdmfAttributeType> mAttributeType;
boost::shared_ptr<const XdmfAttributeCenter> mAttributeCenter;
boost::shared_ptr<const XdmfAttributeType> mAttributeType;
};
#endif /* XDMFATTRIBUTE_HPP_ */
......@@ -23,11 +23,6 @@ XdmfGeometry::~XdmfGeometry()
const std::string XdmfGeometry::ItemTag = "Geometry";
boost::shared_ptr<const XdmfGeometryType> XdmfGeometry::getGeometryType() const
{
return mGeometryType;
}
std::map<std::string, std::string> XdmfGeometry::getItemProperties() const
{
std::map<std::string, std::string> geometryProperties;
......@@ -49,13 +44,18 @@ unsigned int XdmfGeometry::getNumberPoints() const
return this->getArray()->getSize() / mGeometryType->getDimensions();
}
boost::shared_ptr<const XdmfGeometryType> XdmfGeometry::getType() const
{
return mGeometryType;
}
void XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
mGeometryType = XdmfGeometryType::New(itemProperties);
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfGeometry::setGeometryType(const boost::shared_ptr<const XdmfGeometryType> geometryType)
void XdmfGeometry::setType(const boost::shared_ptr<const XdmfGeometryType> geometryType)
{
mGeometryType = geometryType;
}
......@@ -24,13 +24,6 @@ public:
LOKI_DEFINE_VISITABLE(XdmfGeometry, XdmfDataItem)
static const std::string ItemTag;
/**
* Get the XdmfGeometryType associated with this geometry.
*
* @return XdmfGeometryType of this geometry.
*/
boost::shared_ptr<const XdmfGeometryType> getGeometryType() const;
std::map<std::string, std::string> getItemProperties() const;
std::string getItemTag() const;
......@@ -40,12 +33,19 @@ public:
*/
unsigned int getNumberPoints() const;
/**
* Get the XdmfGeometryType associated with this geometry.
*
* @return XdmfGeometryType of this geometry.
*/
boost::shared_ptr<const XdmfGeometryType> getType() const;
/**
* Set the XdmfGeometryType associated with this geometry.
*
* @param geometryType the XdmfGeometryType to set.
*/
void setGeometryType(const boost::shared_ptr<const XdmfGeometryType> geometryType);
void setType(const boost::shared_ptr<const XdmfGeometryType> geometryType);
protected:
......
......@@ -36,11 +36,6 @@ boost::shared_ptr<const XdmfGrid> XdmfGridCollection::getGrid(const unsigned int
return mGrids[index];
}
boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getGridCollectionType() const
{
return mCollectionType;
}
std::map<std::string, std::string> XdmfGridCollection::getItemProperties() const
{
std::map<std::string, std::string> collectionProperties;
......@@ -55,6 +50,11 @@ unsigned int XdmfGridCollection::getNumberOfGrids() const
return mGrids.size();
}
boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() const
{
return mCollectionType;
}
void XdmfGridCollection::insert(const boost::shared_ptr<XdmfGrid> grid)
{
mGrids.push_back(grid);
......@@ -86,7 +86,7 @@ void XdmfGridCollection::removeGrid(const unsigned int index)
mGrids.erase(mGrids.begin() + index);
}
void XdmfGridCollection::setGridCollectionType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType)
void XdmfGridCollection::setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType)
{
mCollectionType = collectionType;
}
......
......@@ -41,13 +41,6 @@ public:
*/
boost::shared_ptr<const XdmfGrid> getGrid(const unsigned int index) const;
/**
* Get the XdmfGridCollectionType associated with this grid collection.
*
* @return XdmfGridCollectionType of this collection.
*/
boost::shared_ptr<const XdmfGridCollectionType> getGridCollectionType() const;
std::map<std::string, std::string> getItemProperties() const;
/**
......@@ -57,6 +50,13 @@ public:
*/
unsigned int getNumberOfGrids() const;
/**
* Get the XdmfGridCollectionType associated with this grid collection.
*
* @return XdmfGridCollectionType of this collection.
*/
boost::shared_ptr<const XdmfGridCollectionType> getType() const;
/**
* Insert a grid into this collection.
*
......@@ -76,7 +76,7 @@ public:
*
* @param collectionType the XdmfGridCollectionType to set.
*/
void setGridCollectionType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
void setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
......
......@@ -48,7 +48,7 @@ unsigned int XdmfTopology::getNumberElements() const
return this->getArray()->getSize() / mTopologyType->getNodesPerElement();
}
boost::shared_ptr<const XdmfTopologyType> XdmfTopology::getTopologyType() const
boost::shared_ptr<const XdmfTopologyType> XdmfTopology::getType() const
{
return mTopologyType;
}
......@@ -59,7 +59,7 @@ void XdmfTopology::populateItem(const std::map<std::string, std::string> & itemP
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfTopology::setTopologyType(const boost::shared_ptr<const XdmfTopologyType> topologyType)
void XdmfTopology::setType(const boost::shared_ptr<const XdmfTopologyType> topologyType)
{
mTopologyType = topologyType;
}
......@@ -40,14 +40,14 @@ public:
*
* @return XdmfTopologyType of the topology.
*/
boost::shared_ptr<const XdmfTopologyType> getTopologyType() const;
boost::shared_ptr<const XdmfTopologyType> getType() const;
/**
* Set the XdmfTopologyType associated with this topology.
*
* @param topologyType the XdmfTopologyType to set.
*/
void setTopologyType(const boost::shared_ptr<const XdmfTopologyType> topologyType);
void setType(const boost::shared_ptr<const XdmfTopologyType> topologyType);
protected:
......
......@@ -10,9 +10,9 @@ int main(int argc, char* argv[])
assert(XdmfAttributeType::Scalar() != XdmfAttributeType::Vector());
boost::shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
assert(attribute->getAttributeType() == XdmfAttributeType::NoAttributeType());
attribute->setAttributeType(XdmfAttributeType::Scalar());
assert(attribute->getAttributeType() == XdmfAttributeType::Scalar());
assert(attribute->getType() == XdmfAttributeType::NoAttributeType());
attribute->setType(XdmfAttributeType::Scalar());
assert(attribute->getType() == XdmfAttributeType::Scalar());
return 0;
}
......@@ -9,12 +9,12 @@ int main(int argc, char* argv[])
assert(XdmfGeometryType::XYZ() != XdmfGeometryType::XYZ() == false);
assert(XdmfGeometryType::XYZ() != XdmfGeometryType::XY());
boost::shared_ptr<XdmfGeometry> geom = XdmfGeometry::New();
assert(geom->getGeometryType() == XdmfGeometryType::NoGeometryType());
assert(geom->getGeometryType()->getDimensions() == 0);
geom->setGeometryType(XdmfGeometryType::XYZ());
assert(geom->getGeometryType() == XdmfGeometryType::XYZ());
assert(geom->getGeometryType()->getDimensions() == 3);
boost::shared_ptr<XdmfGeometry> geometry = XdmfGeometry::New();
assert(geometry->getType() == XdmfGeometryType::NoGeometryType());
assert(geometry->getType()->getDimensions() == 0);
geometry->setType(XdmfGeometryType::XYZ());
assert(geometry->getType() == XdmfGeometryType::XYZ());
assert(geometry->getType()->getDimensions() == 3);
return 0;
}
......@@ -32,8 +32,8 @@ int main(int argc, char* argv[])
gridCollection->insert(childGrid1);
gridCollection->insert(childGrid2);
gridCollection->setGridCollectionType(XdmfGridCollectionType::Temporal());
assert(gridCollection->getGridCollectionType() == XdmfGridCollectionType::Temporal());
gridCollection->setType(XdmfGridCollectionType::Temporal());
assert(gridCollection->getType() == XdmfGridCollectionType::Temporal());
boost::shared_ptr<XdmfWriter> writer = XdmfWriter::New("TestXdmfGridCollection1.xmf");
gridCollection->accept(writer);
......
......@@ -3,7 +3,7 @@
void setPolyTopology(boost::shared_ptr<XdmfTopology> polyTop)
{
polyTop->setTopologyType(XdmfTopologyType::Polygon(6));
polyTop->setType(XdmfTopologyType::Polygon(6));
}
int main(int argc, char* argv[])
......@@ -15,12 +15,12 @@ int main(int argc, char* argv[])
assert(XdmfTopologyType::Hexahedron() != XdmfTopologyType::Tetrahedron());
boost::shared_ptr<XdmfTopology> top = XdmfTopology::New();
assert(top->getTopologyType() == XdmfTopologyType::NoTopologyType());
assert(top->getTopologyType()->getNodesPerElement() == 0);
assert(top->getType() == XdmfTopologyType::NoTopologyType());
assert(top->getType()->getNodesPerElement() == 0);
top->setTopologyType(XdmfTopologyType::Hexahedron());
assert(top->getTopologyType() == XdmfTopologyType::Hexahedron());
assert(top->getTopologyType()->getNodesPerElement() == 8);
top->setType(XdmfTopologyType::Hexahedron());
assert(top->getType() == XdmfTopologyType::Hexahedron());
assert(top->getType()->getNodesPerElement() == 8);
boost::shared_ptr<const XdmfTopologyType> polygon = XdmfTopologyType::Polygon(6);
boost::shared_ptr<const XdmfTopologyType> polygon6 = XdmfTopologyType::Polygon(6);
......@@ -31,7 +31,7 @@ int main(int argc, char* argv[])
boost::shared_ptr<XdmfTopology> polyTop = XdmfTopology::New();
setPolyTopology(polyTop);
assert(polyTop->getTopologyType()->getNodesPerElement() == 6);
assert(polyTop->getType()->getNodesPerElement() == 6);
return 0;
}
......@@ -32,28 +32,28 @@ public:
// Set Geometry
double points[] = {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,
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()->setGeometryType(XdmfGeometryType::XYZ());
grid->getGeometry()->setType(XdmfGeometryType::XYZ());
grid->getGeometry()->getArray()->copyValues(0, &points[0], 36);
// Set Topology
int connectivity[] = {0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10};
grid->getTopology()->setTopologyType(XdmfTopologyType::Hexahedron());
grid->getTopology()->setType(XdmfTopologyType::Hexahedron());
grid->getTopology()->getArray()->copyValues(0, &connectivity[0], 16);
// Add Node Attribute
boost::shared_ptr<XdmfAttribute> nodalAttribute = XdmfAttribute::New();
int nodeValues[] = {100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700};
nodalAttribute->setName("Nodal Attribute");
nodalAttribute->setAttributeType(XdmfAttributeType::Scalar());
nodalAttribute->setAttributeCenter(XdmfAttributeCenter::Node());
nodalAttribute->setType(XdmfAttributeType::Scalar());
nodalAttribute->setCenter(XdmfAttributeCenter::Node());
nodalAttribute->getArray()->copyValues(0, &nodeValues[0], 12);
// Add Cell Attribute
boost::shared_ptr<XdmfAttribute> cellAttribute = XdmfAttribute::New();
int cellValues[] = {100, 200};
cellAttribute->setName("Cell Attribute");
cellAttribute->setAttributeType(XdmfAttributeType::Scalar());
cellAttribute->setAttributeCenter(XdmfAttributeCenter::Cell());
cellAttribute->setType(XdmfAttributeType::Scalar());
cellAttribute->setCenter(XdmfAttributeCenter::Cell());
cellAttribute->getArray()->copyValues(0, &cellValues[0], 2);
// Add Node Set
......
......@@ -9,24 +9,24 @@ if __name__ == "__main__":
points = [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,
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().setGeometryType(XdmfGeometryType.XYZ())
grid.getGeometry().setType(XdmfGeometryType.XYZ())
grid.getGeometry().getArray().copyValuesAsFloat64(0, points)
connectivity = [0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10]
grid.getTopology().setTopologyType(XdmfTopologyType.Hexahedron())
grid.getTopology().setType(XdmfTopologyType.Hexahedron())
grid.getTopology().getArray().copyValuesAsInt32(0, connectivity)
nodalAttribute = XdmfAttribute.New()
nodalAttribute.setName("Nodal Attribute")
nodalAttribute.setAttributeType(XdmfAttributeType.Scalar())
nodalAttribute.setAttributeCenter(XdmfAttributeCenter.Node())
nodalAttribute.setType(XdmfAttributeType.Scalar())
nodalAttribute.setCenter(XdmfAttributeCenter.Node())
nodeVals = [100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700]
nodalAttribute.getArray().copyValuesAsFloat64(0, nodeVals)
cellAttribute = XdmfAttribute.New()
cellAttribute.setName("Cell Attribute")
cellAttribute.setAttributeType(XdmfAttributeType.Scalar())
cellAttribute.setAttributeCenter(XdmfAttributeCenter.Cell())
cellAttribute.setType(XdmfAttributeType.Scalar())
cellAttribute.setCenter(XdmfAttributeCenter.Cell())
cellVals = [100, 200]
cellAttribute.getArray().copyValuesAsFloat64(0, cellVals)
......
......@@ -10,24 +10,24 @@ if __name__ == "__main__":
points = [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,
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().setGeometryType(XdmfGeometryType.XYZ())
grid.getGeometry().setType(XdmfGeometryType.XYZ())
grid.getGeometry().getArray().copyValuesAsFloat64(0, points)
connectivity = [0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10]
grid.getTopology().setTopologyType(XdmfTopologyType.Hexahedron())
grid.getTopology().setType(XdmfTopologyType.Hexahedron())
grid.getTopology().getArray().copyValuesAsInt32(0, connectivity)
nodalAttribute = XdmfAttribute.New()
nodalAttribute.setName("Nodal Attribute")
nodalAttribute.setAttributeType(XdmfAttributeType.Scalar())
nodalAttribute.setAttributeCenter(XdmfAttributeCenter.Node())
nodalAttribute.setType(XdmfAttributeType.Scalar())
nodalAttribute.setCenter(XdmfAttributeCenter.Node())
nodeVals = [100, 200, 300, 300, 400, 500, 300, 400, 500, 500, 600, 700]
nodalAttribute.getArray().copyValuesAsFloat64(0, nodeVals)
cellAttribute = XdmfAttribute.New()
cellAttribute.setName("Cell Attribute")
cellAttribute.setAttributeType(XdmfAttributeType.Scalar())
cellAttribute.setAttributeCenter(XdmfAttributeCenter.Cell())
cellAttribute.setType(XdmfAttributeType.Scalar())
cellAttribute.setCenter(XdmfAttributeCenter.Cell())
cellVals = [100, 200]
cellAttribute.getArray().copyValuesAsFloat64(0, cellVals)
......
......@@ -61,7 +61,7 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
int metisElementType;
int numNodesPerElement;
boost::shared_ptr<const XdmfTopologyType> topologyType = gridToPartition->getTopology()->getTopologyType();
boost::shared_ptr<const XdmfTopologyType> topologyType = gridToPartition->getTopology()->getType();
if(topologyType == XdmfTopologyType::Triangle() || topologyType == XdmfTopologyType::Triangle_6())
{
metisElementType = 1;
......@@ -176,7 +176,7 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
bool generateGlobalNodeIds = !globalNodeIds;
boost::shared_ptr<XdmfGridCollection> partitionedGrids = XdmfGridCollection::New();
partitionedGrids->setGridCollectionType(XdmfGridCollectionType::Spatial());
partitionedGrids->setType(XdmfGridCollectionType::Spatial());
if(!gridToPartition->getGeometry()->getArray()->isInitialized())
{
......@@ -199,9 +199,9 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
partitionedGrids->insert(partitioned);
// Fill in geometry for this partition
partitioned->getGeometry()->setGeometryType(gridToPartition->getGeometry()->getGeometryType());
partitioned->getGeometry()->setType(gridToPartition->getGeometry()->getType());
boost::shared_ptr<XdmfArray> geometryVals = partitioned->getGeometry()->getArray();
unsigned int numDimensions = partitioned->getGeometry()->getGeometryType()->getDimensions();
unsigned int numDimensions = partitioned->getGeometry()->getType()->getDimensions();
geometryVals->initialize(gridToPartition->getGeometry()->getArray()->getType());
geometryVals->resize<unsigned int>(currNodeMap.size() * numDimensions);
......@@ -217,7 +217,7 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
}
// Fill in topology for this partition
partitioned->getTopology()->setTopologyType(gridToPartition->getTopology()->getTopologyType());
partitioned->getTopology()->setType(gridToPartition->getTopology()->getType());
boost::shared_ptr<XdmfArray> topologyVals = partitioned->getTopology()->getArray();
topologyVals->initialize(gridToPartition->getTopology()->getArray()->getType());
topologyVals->resize<unsigned int>(currElemIds.size() * topologyType->getNodesPerElement());
......@@ -244,8 +244,8 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
{
globalNodeIds = XdmfAttribute::New();
globalNodeIds->setName("GlobalNodeId");
globalNodeIds->setAttributeType(XdmfAttributeType::GlobalId());
globalNodeIds->setAttributeCenter(XdmfAttributeCenter::Node());
globalNodeIds->setType(XdmfAttributeType::GlobalId());
globalNodeIds->setCenter(XdmfAttributeCenter::Node());
boost::shared_ptr<XdmfArray> globalNodeIdsVals = globalNodeIds->getArray();
globalNodeIdsVals->resize<unsigned int>(currNodeMap.size());
......@@ -285,21 +285,21 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
boost::shared_ptr<XdmfGrid> partitioned = partitionedGrids->getGrid(partitionId);
partitionId++;
boost::shared_ptr<XdmfAttribute> createdAttribute;
if(currAttribute->getAttributeCenter() == XdmfAttributeCenter::Grid())
if(currAttribute->getCenter() == XdmfAttributeCenter::Grid())
{
if(partitionId == 0)
{
createdAttribute = currAttribute;
}
}
else if(currAttribute->getAttributeCenter() == XdmfAttributeCenter::Cell() ||
currAttribute->getAttributeCenter() == XdmfAttributeCenter::Face() ||
currAttribute->getAttributeCenter() == XdmfAttributeCenter::Edge())
else if(currAttribute->getCenter() == XdmfAttributeCenter::Cell() ||
currAttribute->getCenter() == XdmfAttributeCenter::Face() ||
currAttribute->getCenter() == XdmfAttributeCenter::Edge())
{
createdAttribute = XdmfAttribute::New();
createdAttribute->setName(currAttribute->getName());
createdAttribute->setAttributeCenter(currAttribute->getAttributeCenter());
createdAttribute->setAttributeType(currAttribute->getAttributeType());
createdAttribute->setCenter(currAttribute->getCenter());
createdAttribute->setType(currAttribute->getType());
unsigned int index = 0;
unsigned int numValsPerComponent = currAttribute->getArray()->getSize() / gridToPartition->getTopology()->getNumberElements();
createdAttribute->getArray()->initialize(currAttribute->getArray()->getType());
......@@ -310,12 +310,12 @@ boost::shared_ptr<XdmfGridCollection> XdmfPartitioner::partition(const boost::sh
index += numValsPerComponent;
}
}
else if(currAttribute->getAttributeCenter() == XdmfAttributeCenter::Node())
else if(currAttribute->getCenter() == XdmfAttributeCenter::Node())
{
createdAttribute = XdmfAttribute::New();
createdAttribute->setName(currAttribute->getName());
createdAttribute->setAttributeCenter(currAttribute->getAttributeCenter());
createdAttribute->setAttributeType(currAttribute->getAttributeType());
createdAttribute->setCenter(currAttribute->getCenter());
createdAttribute->setType(currAttribute->getType());
createdAttribute->getArray()->initialize(currAttribute->getArray()->getType());
createdAttribute->getArray()->resize<unsigned int>(currNodeMap.size());
for(std::map<unsigned int, unsigned int>::const_iterator iter = currNodeMap.begin(); iter != currNodeMap.end(); ++iter)
......
......@@ -92,8 +92,8 @@ public:
{
boost::shared_ptr<XdmfGrid> toReturn = XdmfGrid::New();
toReturn->setName(gridToConvert->getName());
toReturn->getGeometry()->setGeometryType(gridToConvert->getGeometry()->getGeometryType());
toReturn->getTopology()->setTopologyType(XdmfTopologyType::Hexahedron_64());
toReturn->getGeometry()->setType(gridToConvert->getGeometry()->getType());
toReturn->getTopology()->setType(XdmfTopologyType::Hexahedron_64());
boost::shared_ptr<XdmfArray> newPoints = toReturn->getGeometry()->getArray();
newPoints->initialize(gridToConvert->getGeometry()->getArray()->getType());
......@@ -339,7 +339,7 @@ public:
toReturn->setName(gridToConvert->getName());
toReturn->setGeometry(gridToConvert->getGeometry());
toReturn->getTopology()->setTopologyType(XdmfTopologyType::Hexahedron());
toReturn->getTopology()->setType(XdmfTopologyType::Hexahedron());
boost::shared_ptr<XdmfArray> oldConnectivity = gridToConvert->getTopology()->getArray();
boost::shared_ptr<XdmfArray> newConnectivity = toReturn->getTopology()->getArray();
......@@ -576,11 +576,11 @@ public:
for(unsigned int i=0; i<gridToConvert->getNumberOfAttributes(); ++i)
{
boost::shared_ptr<XdmfAttribute> currAttribute = gridToConvert->getAttribute(i);
if(currAttribute->getAttributeCenter() == XdmfAttributeCenter::Node())
if(currAttribute->getCenter() == XdmfAttributeCenter::Node())
{
toReturn->insert(currAttribute);
}
else if(currAttribute->getAttributeCenter() == XdmfAttributeCenter::Cell())
else if(currAttribute->getCenter() == XdmfAttributeCenter::Cell())
{
if(!currAttribute->getArray()->isInitialized())
{
......@@ -589,8 +589,8 @@ public:
boost::shared_ptr<XdmfAttribute> newAttribute = XdmfAttribute::New();
newAttribute->setName(currAttribute->getName());
newAttribute->setAttributeType(currAttribute->getAttributeType());
newAttribute->setAttributeCenter(currAttribute->getAttributeCenter());
newAttribute->setType(currAttribute->getType());
newAttribute->setCenter(currAttribute->getCenter());
boost::shared_ptr<XdmfArray> vals = newAttribute->getArray();
vals->initialize(currAttribute->getArray()->getType());
......@@ -608,14 +608,14 @@ public:
boost::shared_ptr<XdmfGrid> XdmfTopologyConverter::convert(const boost::shared_ptr<XdmfGrid> gridToConvert, const boost::shared_ptr<const XdmfTopologyType> topologyType) const
{
boost::shared_ptr<const XdmfTopologyType> topologyTypeToConvert = gridToConvert->getTopology()->getTopologyType();
boost::shared_ptr<const XdmfTopologyType> topologyTypeToConvert = gridToConvert->getTopology()->getType();
if(topologyTypeToConvert == topologyType)
{
// No conversion necessary
return gridToConvert;
}
if(gridToConvert->getGeometry()->getGeometryType() != XdmfGeometryType::XYZ())
if(gridToConvert->getGeometry()->getType() != XdmfGeometryType::XYZ())
{
assert(false);
}
......
......@@ -17,6 +17,7 @@ class XdmfTopologyType;
*
* Currently supported conversions:
* Hexahedron to Hexahedron_64
* Hexahedron_64 to Hexahedron
*/
class XdmfTopologyConverter : public XdmfObject {
......
......@@ -19,11 +19,11 @@ int main(int argc, char* argv[])
// Create Hexahedron Grid
boost::shared_ptr<XdmfGrid> hexGrid = XdmfGrid::New();
double hexPoints[24] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1};
hexGrid->getGeometry()->setGeometryType(XdmfGeometryType::XYZ());
hexGrid->getGeometry()->setType(XdmfGeometryType::XYZ());
hexGrid->getGeometry()->getArray()->resize<double>(24, 0);
hexGrid->getGeometry()->getArray()->copyValues(0, hexPoints, 24);
unsigned int hexConn[8] = {0, 1, 2, 3, 4, 5, 6, 7};
hexGrid->getTopology()->setTopologyType(XdmfTopologyType::Hexahedron());
hexGrid->getTopology()->setType(XdmfTopologyType::Hexahedron());
hexGrid->getTopology()->getArray()->resize<unsigned int>(8, 0);
hexGrid->getTopology()->getArray()->copyValues(0, hexConn, 8);
......@@ -32,7 +32,7 @@ int main(int argc, char* argv[])
*/
boost::shared_ptr<XdmfGrid> hex64Grid = converter->convert(hexGrid, XdmfTopologyType::Hexahedron_64());
assert(hex64Grid->getGeometry()->getGeometryType() == XdmfGeometryType::XYZ());
assert(hex64Grid->getGeometry()->getType() == XdmfGeometryType::XYZ());
assert(hex64Grid->getGeometry()->getNumberPoints() == 64);
double expectedPoints[192] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0.333333333333333, 0, 0, 0.666666666666667, 0, 0, 1, 0.333333333333333,
0, 1, 0.666666666666667, 0, 0.666666666666667, 1, 0, 0.333333333333333, 1, 0, 0, 0.666666666666667, 0, 0, 0.333333333333333, 0,
......@@ -55,7 +55,7 @@ int main(int argc, char* argv[])
{
assert(fabs(expectedPoints[i] - hex64Grid->getGeometry()->getArray()->getValueCopy<double>(i)) < epsilon);
}
assert(hex64Grid->getTopology()->getTopologyType() == XdmfTopologyType::Hexahedron_64());
assert(hex64Grid->getTopology()->getType() == XdmfTopologyType::Hexahedron_64());
assert(hex64Grid->getTopology()->getNumberElements() == 1);
for(unsigned int i=0; i<64; ++i)
{
......@@ -66,13 +66,13 @@ int main(int argc, char* argv[])
* Hexahedron_64 to Hexahedron
*/
boost::shared_ptr<XdmfGrid> newHexGrid = converter->convert(hex64Grid, XdmfTopologyType::Hexahedron());
assert(newHexGrid->getGeometry()->getGeometryType() == XdmfGeometryType::XYZ());
assert(newHexGrid->getGeometry()->getType() == XdmfGeometryType::XYZ());
assert(newHexGrid->getGeometry()->getNumberPoints() == 64);
for(unsigned int i=0; i<192; ++i)
{
assert(fabs(expectedPoints[i] - newHexGrid->getGeometry()->getArray()->getValueCopy<double>(i)) < epsilon);
}
assert(newHexGrid->getTopology()->getTopologyType() == XdmfTopologyType::Hexahedron());
assert(newHexGrid->getTopology()->getType() == XdmfTopologyType::Hexahedron());
assert(newHexGrid->getTopology()->getNumberElements() == 27);
return 0;
......
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