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
mName = name->second;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
mCenter = XdmfAttributeCenter::New(itemProperties);
......
......@@ -81,14 +81,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
}
const std::string & centerVal = center->second;
......@@ -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;
}
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
// 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;
}
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
// unreachable
return shared_ptr<const XdmfAttributeType>();
}
......
......@@ -44,14 +44,9 @@ 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;
}
shared_ptr<XdmfTopologyCurvilinear>
p(new XdmfTopologyCurvilinear(curvilinearGrid));
return p;
}
unsigned int
......@@ -74,12 +69,7 @@ public:
XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
mCurvilinearGrid(curvilinearGrid)
{
try {
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
catch (XdmfError e) {
throw e;
}
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
const XdmfCurvilinearGrid * const mCurvilinearGrid;
......@@ -110,14 +100,9 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
return 0;
}
......@@ -134,14 +119,9 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
return 0;
}
......@@ -167,14 +147,9 @@ public:
collectedProperties["Type"] = "2DSMesh";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getProperties");
}
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::map<std::string, std::string> geometryProperties;
mType->getProperties(geometryProperties);
return geometryProperties;
}
std::string
......
......@@ -67,14 +67,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'GeometryType' in itemProperties "
"in XdmfGeometryType::New");
}
const std::string & typeVal = type->second;
......@@ -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;
}
XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' "
"in XdmfGeometryType::New");
return shared_ptr<const XdmfGeometryType>();
}
......
......@@ -65,14 +65,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not in itemProperties in "
"XdmfGridCollectionType::New");
}
const std::string & typeVal = type->second;
......@@ -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;
}
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not of 'None', 'Spatial', or "
"'Temporal' in XdmfGridCollectionType::New");
// unreachable
return shared_ptr<const XdmfGridCollectionType>();
}
......
This diff is collapsed.
......@@ -176,25 +176,15 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Expected 3 arrays attached to "
"XdmfMap::populateItem");
}
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;
}
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap:: populateItem");
}
// check if any arrays have values in memory - if so, they need to be
......@@ -273,13 +263,8 @@ XdmfMap::read()
remoteTaskCount &&
localNodeCount ==
remoteNodeCount)){
try {
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in XdmfMap::read");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in XdmfMap::read");
}
shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
......@@ -349,14 +334,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap::setHeavyDataControllers");
}
mRemoteTaskIdsControllers = remoteTaskIdsControllers;
mLocalNodeIdsControllers = localNodeIdsControllers;
......
......@@ -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;
}
return XdmfCoreReader::read(filePath);
}
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;
}
return XdmfCoreReader::read(filePath, xPath);
}
......@@ -119,14 +119,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Number of dimensions not 2 or 3 in"
" XdmfGeometryTypeRectilinear::getProperties");
}
}
......@@ -206,14 +201,9 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
return 0;
}
......@@ -230,14 +220,9 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
return 0;
}
......@@ -263,14 +248,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Number of dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getProperties");
}
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,14 +194,9 @@ public:
return 12;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
return 0;
}
......@@ -220,14 +212,9 @@ public:
return 6;
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
}
return 0;
}
......@@ -252,14 +239,9 @@ public:
collectedProperties["Type"] = "2DCoRectMesh";
}
else {
try {
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getProperties");
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -88,14 +88,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfSet::populateItem");
}
mType = XdmfSetType::New(itemProperties);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
......
......@@ -79,14 +79,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'SetType' found in itemProperties "
"in XdmfSetType::New");
}
const std::string & typeVal = type->second;
......@@ -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;
}
XdmfError::message(XdmfError::FATAL,
"Type not of 'None', 'Node', 'Cell', 'Face', or "
"'Edge' in XdmfSetType::New");
// unreachable
return shared_ptr<const XdmfSetType>();
}
......
......@@ -78,14 +78,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"'Value' not in itemProperties in "
"XdmfTime::populateItem");
}
}
......
......@@ -79,14 +79,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Invalid topology type id found in connectivity "
"when parsing mixed topology.");
}
if(topologyType == XdmfTopologyType::Polyvertex()) {
const unsigned int numberPolyvertexElements =
......
......@@ -590,14 +590,9 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'TopologyType' found in "
"itemProperties in XdmfTopologyType::New");
}
std::string typeVal = type->second;
std::transform(typeVal.begin(),
......@@ -618,27 +613,17 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYLINE' selected in XdmfTopologyType::New");
}
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;
}
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYGON' selected in XdmfTopologyType::New");
}
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;
}
XdmfError::message(XdmfError::FATAL,
"Invalid Type selected in XdmfTopologyType::New");
// unreachable
return shared_ptr<const XdmfTopologyType>();
}
......
......@@ -142,15 +142,10 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Inconsistent brick, dimension, and origin sizes when"
"converting regular grid to unstructured grid in "
"XdmfUnstructuredGrid constructor");
}
bool releaseOrigin = false;
......@@ -180,15 +175,10 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Cannot convert regular grid of dimensions not 2 or 3 "
"to XdmfUnstructuredGrid in XdmfUnstructuredGrid "
"constructor");
}
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,13 +805,8 @@ 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;
}
XdmfError::message(XdmfError::FATAL,
"Array of unsupported type in XdmfArray::initialize");
}
}
......@@ -964,28 +959,18 @@ 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;
}
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");
}
else if (!(numInserted.size() == startIndex.size()
&& startIndex.size() == this->getDimensions().size()
&& this->getDimensions().size() == arrayStride.size())) {
try {