Commit dc68e15b authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Remove unneccesary try catch blocks.

Add HDF5 tree writer test.
parent 55717ca0
...@@ -94,14 +94,9 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope ...@@ -94,14 +94,9 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second; mName = name->second;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in "
"'Name' not found in itemProperties in " "XdmfAttribute::populateItem");
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
mCenter = XdmfAttributeCenter::New(itemProperties); mCenter = XdmfAttributeCenter::New(itemProperties);
......
...@@ -81,14 +81,9 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti ...@@ -81,14 +81,9 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
std::map<std::string, std::string>::const_iterator center = std::map<std::string, std::string>::const_iterator center =
itemProperties.find("Center"); itemProperties.find("Center");
if(center == itemProperties.end()) { if(center == itemProperties.end()) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'Center' not found in itemProperties in "
"'Center' not found in itemProperties in " "XdmfAttributeCenter::New");
"XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
} }
const std::string & centerVal = center->second; const std::string & centerVal = center->second;
...@@ -108,15 +103,11 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti ...@@ -108,15 +103,11 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
return Edge(); return Edge();
} }
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Center not of 'Grid','Cell','Face','Edge','Node' "
"Center not of 'Grid','Cell','Face','Edge','Node' " "in XdmfAttributeCenter::New");
"in XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfAttributeCenter>(); return shared_ptr<const XdmfAttributeCenter>();
} }
......
...@@ -127,16 +127,12 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties ...@@ -127,16 +127,12 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
return NoAttributeType(); return NoAttributeType();
} }
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Type not of 'None','Scalar','Vector','Tensor', "
"Type not of 'None','Scalar','Vector','Tensor', " "'Matrix','Tensor6', or 'GlobalId' in "
"'Matrix','Tensor6', or 'GlobalId' in " "XdmfAttributeType::New");
"XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfAttributeType>(); return shared_ptr<const XdmfAttributeType>();
} }
......
...@@ -44,14 +44,9 @@ public: ...@@ -44,14 +44,9 @@ public:
static shared_ptr<XdmfTopologyCurvilinear> static shared_ptr<XdmfTopologyCurvilinear>
New(const XdmfCurvilinearGrid * const curvilinearGrid) New(const XdmfCurvilinearGrid * const curvilinearGrid)
{ {
try { shared_ptr<XdmfTopologyCurvilinear>
shared_ptr<XdmfTopologyCurvilinear> p(new XdmfTopologyCurvilinear(curvilinearGrid));
p(new XdmfTopologyCurvilinear(curvilinearGrid)); return p;
return p;
}
catch (XdmfError e) {
throw e;
}
} }
unsigned int unsigned int
...@@ -74,12 +69,7 @@ public: ...@@ -74,12 +69,7 @@ public:
XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) : XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
mCurvilinearGrid(curvilinearGrid) mCurvilinearGrid(curvilinearGrid)
{ {
try { this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
catch (XdmfError e) {
throw e;
}
} }
const XdmfCurvilinearGrid * const mCurvilinearGrid; const XdmfCurvilinearGrid * const mCurvilinearGrid;
...@@ -110,14 +100,9 @@ public: ...@@ -110,14 +100,9 @@ public:
return 12; return 12;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeCurvilinear::getEdgesPerElement");
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -134,14 +119,9 @@ public: ...@@ -134,14 +119,9 @@ public:
return 6; return 6;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeCurvilinear::getFacesPerElement");
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -167,14 +147,9 @@ public: ...@@ -167,14 +147,9 @@ public:
collectedProperties["Type"] = "2DSMesh"; collectedProperties["Type"] = "2DSMesh";
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeCurvilinear::getProperties");
"XdmfTopologyTypeCurvilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
} }
collectedProperties["Dimensions"] = dimensions->getValuesString(); collectedProperties["Dimensions"] = dimensions->getValuesString();
} }
......
...@@ -46,14 +46,9 @@ const std::string XdmfGeometry::ItemTag = "Geometry"; ...@@ -46,14 +46,9 @@ const std::string XdmfGeometry::ItemTag = "Geometry";
std::map<std::string, std::string> std::map<std::string, std::string>
XdmfGeometry::getItemProperties() const XdmfGeometry::getItemProperties() const
{ {
try { std::map<std::string, std::string> geometryProperties;
std::map<std::string, std::string> geometryProperties; mType->getProperties(geometryProperties);
mType->getProperties(geometryProperties); return geometryProperties;
return geometryProperties;
}
catch (XdmfError e) {
throw e;
}
} }
std::string std::string
......
...@@ -67,14 +67,9 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -67,14 +67,9 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("GeometryType"); type = itemProperties.find("GeometryType");
} }
if(type == itemProperties.end()) { if(type == itemProperties.end()) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'GeometryType' in itemProperties "
"Neither 'Type' nor 'GeometryType' in itemProperties " "in XdmfGeometryType::New");
"in XdmfGeometryType::New");
}
catch (XdmfError e) {
throw e;
}
} }
const std::string & typeVal = type->second; const std::string & typeVal = type->second;
...@@ -88,13 +83,8 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -88,13 +83,8 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
return XY(); return XY();
} }
try { XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' "
XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' " "in XdmfGeometryType::New");
"in XdmfGeometryType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfGeometryType>(); return shared_ptr<const XdmfGeometryType>();
} }
......
...@@ -65,14 +65,9 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope ...@@ -65,14 +65,9 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
std::map<std::string, std::string>::const_iterator type = std::map<std::string, std::string>::const_iterator type =
itemProperties.find("CollectionType"); itemProperties.find("CollectionType");
if(type == itemProperties.end()) { if(type == itemProperties.end()) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'CollectionType' not in itemProperties in "
"'CollectionType' not in itemProperties in " "XdmfGridCollectionType::New");
"XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
} }
const std::string & typeVal = type->second; const std::string & typeVal = type->second;
...@@ -86,15 +81,11 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope ...@@ -86,15 +81,11 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
return Temporal(); return Temporal();
} }
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'CollectionType' not of 'None', 'Spatial', or "
"'CollectionType' not of 'None', 'Spatial', or " "'Temporal' in XdmfGridCollectionType::New");
"'Temporal' in XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfGridCollectionType>(); return shared_ptr<const XdmfGridCollectionType>();
} }
......
This diff is collapsed.
...@@ -176,25 +176,15 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties, ...@@ -176,25 +176,15 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
if(arrayVector.size() != 0) { if(arrayVector.size() != 0) {
if(arrayVector.size() != 3) { if(arrayVector.size() != 3) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Expected 3 arrays attached to "
"Expected 3 arrays attached to " "XdmfMap::populateItem");
"XdmfMap::populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() && if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() &&
arrayVector[0]->getSize() == arrayVector[2]->getSize())) { arrayVector[0]->getSize() == arrayVector[2]->getSize())) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in "
"Arrays must be of equal size in " "XdmfMap:: populateItem");
"XdmfMap:: populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
// check if any arrays have values in memory - if so, they need to be // check if any arrays have values in memory - if so, they need to be
...@@ -273,13 +263,8 @@ XdmfMap::read() ...@@ -273,13 +263,8 @@ XdmfMap::read()
remoteTaskCount && remoteTaskCount &&
localNodeCount == localNodeCount ==
remoteNodeCount)){ remoteNodeCount)){
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in XdmfMap::read");
"Arrays must be of equal size in XdmfMap::read");
}
catch (XdmfError e) {
throw e;
}
} }
shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New(); shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
...@@ -349,14 +334,9 @@ XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController> ...@@ -349,14 +334,9 @@ XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController>
remoteTaskCount && remoteTaskCount &&
localNodeCount == localNodeCount ==
remoteNodeCount)) { remoteNodeCount)) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Arrays must be of equal size in "
"Arrays must be of equal size in " "XdmfMap::setHeavyDataControllers");
"XdmfMap::setHeavyDataControllers");
}
catch (XdmfError e) {
throw e;
}
} }
mRemoteTaskIdsControllers = remoteTaskIdsControllers; mRemoteTaskIdsControllers = remoteTaskIdsControllers;
mLocalNodeIdsControllers = localNodeIdsControllers; mLocalNodeIdsControllers = localNodeIdsControllers;
......
...@@ -46,22 +46,12 @@ XdmfReader::~XdmfReader() ...@@ -46,22 +46,12 @@ XdmfReader::~XdmfReader()
shared_ptr<XdmfItem> shared_ptr<XdmfItem>
XdmfReader::read(const std::string & filePath) const XdmfReader::read(const std::string & filePath) const
{ {
try { return XdmfCoreReader::read(filePath);
return XdmfCoreReader::read(filePath);
}
catch (XdmfError e) {
throw e;
}
} }
std::vector<shared_ptr<XdmfItem> > std::vector<shared_ptr<XdmfItem> >
XdmfReader::read(const std::string & filePath, XdmfReader::read(const std::string & filePath,
const std::string & xPath) const const std::string & xPath) const
{ {
try { return XdmfCoreReader::read(filePath, xPath);
return XdmfCoreReader::read(filePath, xPath);
}
catch (XdmfError e) {
throw e;
}
} }
...@@ -119,14 +119,9 @@ public: ...@@ -119,14 +119,9 @@ public:
collectedProperties["Type"] = "VXVY"; collectedProperties["Type"] = "VXVY";
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in"
"Number of dimensions not 2 or 3 in" " XdmfGeometryTypeRectilinear::getProperties");
" XdmfGeometryTypeRectilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
} }
} }
...@@ -206,14 +201,9 @@ public: ...@@ -206,14 +201,9 @@ public:
return 12; return 12;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeRectilinear::getEdgesPerElement");
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -230,14 +220,9 @@ public: ...@@ -230,14 +220,9 @@ public:
return 6; return 6;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeRectilinear::getFacesPerElement");
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -263,14 +248,9 @@ public: ...@@ -263,14 +248,9 @@ public:
collectedProperties["Type"] = "2DRectMesh"; collectedProperties["Type"] = "2DRectMesh";
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in "
"Number of dimensions not 2 or 3 in " "XdmfTopologyTypeRectilinear::getProperties");
"XdmfTopologyTypeRectilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
} }
collectedProperties["Dimensions"] = dimensions->getValuesString(); collectedProperties["Dimensions"] = dimensions->getValuesString();
} }
......
...@@ -114,12 +114,9 @@ public: ...@@ -114,12 +114,9 @@ public:
collectedProperties["Type"] = "ORIGIN_DXDY"; collectedProperties["Type"] = "ORIGIN_DXDY";
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties"); "Dimensions not 2 or 3 in "
} "XdmfGeometryTypeRegular::getProperties");
catch (XdmfError e) {
throw e;
}
} }
} }
...@@ -197,14 +194,9 @@ public: ...@@ -197,14 +194,9 @@ public:
return 12; return 12;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeRegular::getEdgesPerElement");
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -220,14 +212,9 @@ public: ...@@ -220,14 +212,9 @@ public:
return 6; return 6;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in "
"Grid dimensions not 2 or 3 in " "XdmfTopologyTypeRegular::getFacesPerElement");
"XdmfTopologyTypeRegular::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
} }
return 0; return 0;
} }
...@@ -252,14 +239,9 @@ public: ...@@ -252,14 +239,9 @@ public:
collectedProperties["Type"] = "2DCoRectMesh"; collectedProperties["Type"] = "2DCoRectMesh";
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in "
"Dimensions not 2 or 3 in " "XdmfTopologyTypeRegular::getProperties");
"XdmfTopologyTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
} }
collectedProperties["Dimensions"] = dimensions->getValuesString(); collectedProperties["Dimensions"] = dimensions->getValuesString();
} }
......
...@@ -88,14 +88,9 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties, ...@@ -88,14 +88,9 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
mName = name->second; mName = name->second;
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in "
"'Name' not found in itemProperties in " "XdmfSet::populateItem");
"XdmfSet::populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
mType = XdmfSetType::New(itemProperties); mType = XdmfSetType::New(itemProperties);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter = for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
......
...@@ -79,14 +79,9 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -79,14 +79,9 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("SetType"); type = itemProperties.find("SetType");
} }
if(type == itemProperties.end()) { if(type == itemProperties.end()) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'SetType' found in itemProperties "
"Neither 'Type' nor 'SetType' found in itemProperties " "in XdmfSetType::New");
"in XdmfSetType::New");
}
catch (XdmfError e) {
throw e;
}
} }
const std::string & typeVal = type->second; const std::string & typeVal = type->second;
...@@ -106,15 +101,11 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -106,15 +101,11 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
return NoSetType(); return NoSetType();
} }
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Type not of 'None', 'Node', 'Cell', 'Face', or "
"Type not of 'None', 'Node', 'Cell', 'Face', or " "'Edge' in XdmfSetType::New");
"'Edge' in XdmfSetType::New");
}
catch (XdmfError e) {
throw e;
}
// unreachable
return shared_ptr<const XdmfSetType>(); return shared_ptr<const XdmfSetType>();
} }
......
...@@ -78,14 +78,9 @@ XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties ...@@ -78,14 +78,9 @@ XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties
mValue = atof(value->second.c_str()); mValue = atof(value->second.c_str());
} }
else { else {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "'Value' not in itemProperties in "
"'Value' not in itemProperties in " "XdmfTime::populateItem");
"XdmfTime::populateItem");
}
catch (XdmfError e) {
throw e;
}
} }
} }
......
...@@ -79,14 +79,9 @@ XdmfTopology::getNumberElements() const ...@@ -79,14 +79,9 @@ XdmfTopology::getNumberElements() const
const shared_ptr<const XdmfTopologyType> topologyType = const shared_ptr<const XdmfTopologyType> topologyType =
XdmfTopologyType::New(id); XdmfTopologyType::New(id);
if(topologyType == NULL) { if(topologyType == NULL) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Invalid topology type id found in connectivity "
"Invalid topology type id found in connectivity " "when parsing mixed topology.");
"when parsing mixed topology.");
}
catch (XdmfError e) {
throw e;
}
} }
if(topologyType == XdmfTopologyType::Polyvertex()) { if(topologyType == XdmfTopologyType::Polyvertex()) {
const unsigned int numberPolyvertexElements = const unsigned int numberPolyvertexElements =
......
...@@ -590,14 +590,9 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -590,14 +590,9 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("TopologyType"); type = itemProperties.find("TopologyType");
} }
if(type == itemProperties.end()) { if(type == itemProperties.end()) {
try { XdmfError::message(XdmfError::FATAL,
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'TopologyType' found in "
"Neither 'Type' nor 'TopologyType' found in " "itemProperties in XdmfTopologyType::New");
"itemProperties in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
} }
std::string typeVal = type->second; std::string typeVal = type->second;
std::transform(typeVal.begin(), std::transform(typeVal.begin(),
...@@ -618,27 +613,17 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -618,27 +613,17 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
if(nodesPerElement != itemProperties.end()) {