Commit dc68e15b authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Remove unneccesary try catch blocks.

Add HDF5 tree writer test.
parent 55717ca0
......@@ -94,15 +94,10 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
mCenter = XdmfAttributeCenter::New(itemProperties);
mType = XdmfAttributeType::New(itemProperties);
......
......@@ -81,15 +81,10 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
std::map<std::string, std::string>::const_iterator center =
itemProperties.find("Center");
if(center == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & centerVal = center->second;
if(centerVal.compare("Node") == 0) {
......@@ -108,15 +103,11 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
return Edge();
}
try {
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfAttributeCenter>();
}
......
......@@ -127,16 +127,12 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
return NoAttributeType();
}
try {
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfAttributeType>();
}
......
......@@ -44,15 +44,10 @@ public:
static shared_ptr<XdmfTopologyCurvilinear>
New(const XdmfCurvilinearGrid * const curvilinearGrid)
{
try {
shared_ptr<XdmfTopologyCurvilinear>
p(new XdmfTopologyCurvilinear(curvilinearGrid));
return p;
}
catch (XdmfError e) {
throw e;
}
}
unsigned int
getNumberElements() const
......@@ -74,13 +69,8 @@ public:
XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
mCurvilinearGrid(curvilinearGrid)
{
try {
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
catch (XdmfError e) {
throw e;
}
}
const XdmfCurvilinearGrid * const mCurvilinearGrid;
};
......@@ -110,15 +100,10 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -134,15 +119,10 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -167,15 +147,10 @@ public:
collectedProperties["Type"] = "2DSMesh";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -46,14 +46,9 @@ const std::string XdmfGeometry::ItemTag = "Geometry";
std::map<std::string, std::string>
XdmfGeometry::getItemProperties() const
{
try {
std::map<std::string, std::string> geometryProperties;
mType->getProperties(geometryProperties);
return geometryProperties;
}
catch (XdmfError e) {
throw e;
}
}
std::string
......
......@@ -67,15 +67,10 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("GeometryType");
}
if(type == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'GeometryType' in itemProperties "
"in XdmfGeometryType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
if(typeVal.compare("None") == 0) {
......@@ -88,13 +83,8 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
return XY();
}
try {
XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' "
"in XdmfGeometryType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfGeometryType>();
}
......
......@@ -65,15 +65,10 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
std::map<std::string, std::string>::const_iterator type =
itemProperties.find("CollectionType");
if(type == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not in itemProperties in "
"XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
if(typeVal.compare("None") == 0) {
......@@ -86,15 +81,11 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
return Temporal();
}
try {
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not of 'None', 'Spatial', or "
"'Temporal' in XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfGridCollectionType>();
}
......
......@@ -26,6 +26,7 @@
#include "XdmfAttribute.hpp"
#include "XdmfCurvilinearGrid.hpp"
#include "XdmfDomain.hpp"
#include "XdmfError.hpp"
#include "XdmfFunction.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
......@@ -41,7 +42,6 @@
#include "XdmfTime.hpp"
#include "XdmfTopology.hpp"
#include "XdmfUnstructuredGrid.hpp"
#include "XdmfError.hpp"
shared_ptr<XdmfItemFactory>
XdmfItemFactory::New()
......@@ -63,7 +63,6 @@ XdmfItemFactory::createItem(const std::string & itemTag,
const std::map<std::string, std::string> & itemProperties,
const std::vector<shared_ptr<XdmfItem> > & childItems) const
{
try {
shared_ptr<XdmfItem> newItem =
XdmfCoreItemFactory::createItem(itemTag, itemProperties, childItems);
......@@ -229,8 +228,4 @@ XdmfItemFactory::createItem(const std::string & itemTag,
return XdmfTopology::New();
}
return shared_ptr<XdmfItem>();
}
catch (XdmfError e) {
throw e;
}
}
......@@ -176,26 +176,16 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
if(arrayVector.size() != 0) {
if(arrayVector.size() != 3) {
try {
XdmfError::message(XdmfError::FATAL,
"Expected 3 arrays attached to "
"XdmfMap::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() &&
arrayVector[0]->getSize() == arrayVector[2]->getSize())) {
try {
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap:: populateItem");
}
catch (XdmfError e) {
throw e;
}
}
// check if any arrays have values in memory - if so, they need to be
// read into map
......@@ -273,14 +263,9 @@ XdmfMap::read()
remoteTaskCount &&
localNodeCount ==
remoteNodeCount)){
try {
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in XdmfMap::read");
}
catch (XdmfError e) {
throw e;
}
}
shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
......@@ -349,15 +334,10 @@ XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController>
remoteTaskCount &&
localNodeCount ==
remoteNodeCount)) {
try {
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap::setHeavyDataControllers");
}
catch (XdmfError e) {
throw e;
}
}
mRemoteTaskIdsControllers = remoteTaskIdsControllers;
mLocalNodeIdsControllers = localNodeIdsControllers;
mRemoteLocalNodeIdsControllers = remoteLocalNodeIdsControllers;
......
......@@ -46,22 +46,12 @@ XdmfReader::~XdmfReader()
shared_ptr<XdmfItem>
XdmfReader::read(const std::string & filePath) const
{
try {
return XdmfCoreReader::read(filePath);
}
catch (XdmfError e) {
throw e;
}
}
std::vector<shared_ptr<XdmfItem> >
XdmfReader::read(const std::string & filePath,
const std::string & xPath) const
{
try {
return XdmfCoreReader::read(filePath, xPath);
}
catch (XdmfError e) {
throw e;
}
}
......@@ -119,15 +119,10 @@ public:
collectedProperties["Type"] = "VXVY";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Number of dimensions not 2 or 3 in"
" XdmfGeometryTypeRectilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
}
private:
......@@ -206,15 +201,10 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -230,15 +220,10 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -263,15 +248,10 @@ public:
collectedProperties["Type"] = "2DRectMesh";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Number of dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -114,12 +114,9 @@ public:
collectedProperties["Type"] = "ORIGIN_DXDY";
}
else {
try {
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfGeometryTypeRegular::getProperties");
}
}
......@@ -197,15 +194,10 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -220,15 +212,10 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -252,15 +239,10 @@ public:
collectedProperties["Type"] = "2DCoRectMesh";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -88,15 +88,10 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
mName = name->second;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfSet::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
mType = XdmfSetType::New(itemProperties);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
......
......@@ -79,15 +79,10 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("SetType");
}
if(type == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'SetType' found in itemProperties "
"in XdmfSetType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
if(typeVal.compare("Node") == 0) {
......@@ -106,15 +101,11 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
return NoSetType();
}
try {
XdmfError::message(XdmfError::FATAL,
"Type not of 'None', 'Node', 'Cell', 'Face', or "
"'Edge' in XdmfSetType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfSetType>();
}
......
......@@ -78,15 +78,10 @@ XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties
mValue = atof(value->second.c_str());
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"'Value' not in itemProperties in "
"XdmfTime::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
}
void
......
......@@ -79,15 +79,10 @@ XdmfTopology::getNumberElements() const
const shared_ptr<const XdmfTopologyType> topologyType =
XdmfTopologyType::New(id);
if(topologyType == NULL) {
try {
XdmfError::message(XdmfError::FATAL,
"Invalid topology type id found in connectivity "
"when parsing mixed topology.");
}
catch (XdmfError e) {
throw e;
}
}
if(topologyType == XdmfTopologyType::Polyvertex()) {
const unsigned int numberPolyvertexElements =
this->getValue<unsigned int>(index + 1);
......
......@@ -590,15 +590,10 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("TopologyType");
}
if(type == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'TopologyType' found in "
"itemProperties in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
}
std::string typeVal = type->second;
std::transform(typeVal.begin(),
typeVal.end(),
......@@ -618,28 +613,18 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
if(nodesPerElement != itemProperties.end()) {
return Polyline(atoi(nodesPerElement->second.c_str()));
}
try {
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYLINE' selected in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
}
else if(typeVal.compare("POLYGON") == 0) {
if(nodesPerElement != itemProperties.end()) {
return Polygon(atoi(nodesPerElement->second.c_str()));
}
try {
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYGON' selected in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
}
else if(typeVal.compare("TRIANGLE") == 0) {
return Triangle();
}
......@@ -737,14 +722,10 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
return Mixed();
}
try {
XdmfError::message(XdmfError::FATAL,
"Invalid Type selected in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfTopologyType>();
}
......
......@@ -142,16 +142,11 @@ XdmfUnstructuredGrid::XdmfUnstructuredGrid(const shared_ptr<XdmfRegularGrid> reg
if(dimensions->getSize() != brickSize->getSize() ||
dimensions->getSize() != origin->getSize()) {
try {
XdmfError::message(XdmfError::FATAL,
"Inconsistent brick, dimension, and origin sizes when"
"converting regular grid to unstructured grid in "
"XdmfUnstructuredGrid constructor");
}
catch (XdmfError e) {
throw e;
}
}
bool releaseOrigin = false;
bool releaseBrickSize = false;
......@@ -180,16 +175,11 @@ XdmfUnstructuredGrid::XdmfUnstructuredGrid(const shared_ptr<XdmfRegularGrid> reg
topologyType = XdmfTopologyType::Hexahedron();
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Cannot convert regular grid of dimensions not 2 or 3 "
"to XdmfUnstructuredGrid in XdmfUnstructuredGrid "
"constructor");
}
catch (XdmfError e) {
throw e;
}
}
mGeometry->setType(geometryType);
mTopology->setType(topologyType);
......
......@@ -50,8 +50,8 @@ namespace {
itemProperties.find("XMLDir");
if(xmlDir == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'XMLDir' not found in itemProperties in "
"XdmfArray::populateItem");
"'XMLDir' not found in itemProperties when "
"building full heavy data path");
}
std::stringstream newHeavyDataPath;
newHeavyDataPath << xmlDir->second << filePath;
......@@ -805,14 +805,9 @@ XdmfArray::initialize(const shared_ptr<const XdmfArrayType> & arrayType,
this->release();
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Array of unsupported type in XdmfArray::initialize");
}
catch (XdmfError e) {
throw e;
}
}
}
void
......@@ -964,29 +959,19 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex,
if (!(values->getDimensions().size() == valuesStartIndex.size()
&& valuesStartIndex.size() == numValues.size()
&& numValues.size() == valuesStride.size())) {
try {
XdmfError::message(XdmfError::FATAL,
"Error: Number of starts, strides, and/or values "
"retrieved does not match up with the dimensions "
"of the array being retrieved from");
}
catch (XdmfError e) {
throw e;
}
}
else if (!(numInserted.size() == startIndex.size()
&& startIndex.size() == this->getDimensions().size()
&& this->getDimensions().size() == arrayStride.size())) {
try {
XdmfError::message(XdmfError::FATAL,
"Error: Number of starts, strides, and/or values "
"written does not match up with the dimensions "
"of the array being inserted into");
}
catch (XdmfError e) {
throw e;
}
}
}
}
......@@ -1019,15 +1004,10 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
std::map<std::string, std::string>::const_iterator content =
itemProperties.find("Content");
if(content == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"'Content' not found in itemProperties in "
"XdmfArray::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
unsigned int contentIndex;
......@@ -1056,15 +1036,10 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
std::map<std::string, std::string>::const_iterator dimensions =
itemProperties.find("Dimensions");
if(dimensions == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"'Dimensions' not found in itemProperties in "
"XdmfArray::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
boost::tokenizer<> tokens(dimensions->second);
for(boost::tokenizer<>::const_iterator iter = tokens.begin();
......@@ -1076,15 +1051,10 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
std::map<std::string, std::string>::const_iterator format =
itemProperties.find("Format");
if(format == itemProperties.end()) {
try {
XdmfError::message(XdmfError::FATAL,
"'Format' not found in itemProperties in "
"XdmfArray::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & formatVal = format->second;
if(formatVal.compare("HDF") == 0) {
......@@ -1093,16 +1063,11 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
while (contentIndex < contentVals.size()) {
size_t colonLocation = contentVals[contentIndex].find(":");
if(colonLocation == std::string::npos) {
try {
XdmfError::message(XdmfError::FATAL,
"':' not found in content in "
"XdmfArray::populateItem -- double check an HDF5 "
"data set is specified for the file");