Commit e08245f2 authored by Payton Oliveri (Cont ARL/CISD) poliveri's avatar Payton Oliveri (Cont ARL/CISD) poliveri Committed by Brian Panneton
Browse files

Added XdmfError Replaced asserts with XdmfError::messages

parent 0aa88318
......@@ -12,6 +12,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
#include <XdmfError.hpp>
#include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp>
#ifdef XDMF_BUILD_DSM
......
......@@ -24,6 +24,7 @@
#include "XdmfAttribute.hpp"
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfError.hpp"
boost::shared_ptr<XdmfAttribute>
XdmfAttribute::New()
......@@ -92,7 +93,7 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second;
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL,"'Name' not found in itemProperties in XdmfAttribute::populateItem");
}
mCenter = XdmfAttributeCenter::New(itemProperties);
......
......@@ -22,6 +22,7 @@
/*****************************************************************************/
#include "XdmfAttributeCenter.hpp"
#include "XdmfError.hpp"
// Supported XdmfAttributeCenters
boost::shared_ptr<const XdmfAttributeCenter>
......@@ -96,10 +97,10 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
return Node();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Center not of 'Grid','Cell','Face','Edge','Node' in XdmfAttributeCenter::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "'Center' not found in itemProperties in XdmfAttributeCenter::New");
return boost::shared_ptr<const XdmfAttributeCenter>();
}
......
......@@ -22,6 +22,7 @@
/*****************************************************************************/
#include "XdmfAttributeType.hpp"
#include "XdmfError.hpp"
// Supported XdmfAttributeTypes
boost::shared_ptr<const XdmfAttributeType>
......@@ -121,10 +122,10 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
return GlobalId();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Type not of 'None','Scalar','Vector','Tensor','Matrix','Tensor6', or 'GlobalId' in XdmfAttributeType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'AttributeType' found in itemProperties in XdmfAttributeType::New");
return boost::shared_ptr<const XdmfAttributeType>();
}
......
......@@ -27,6 +27,7 @@
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
#include "XdmfError.hpp"
/**
* PIMPL
......@@ -108,7 +109,7 @@ public:
collectedProperties["Type"] = "2DSMesh";
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Grid dimensions not 2 or 3 in XdmfTopologyTypeCurvilinear::getProperties");
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -22,6 +22,7 @@
/*****************************************************************************/
#include "XdmfGeometryType.hpp"
#include "XdmfError.hpp"
// Supported XdmfGeometryTypes
boost::shared_ptr<const XdmfGeometryType>
......@@ -80,10 +81,10 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
return XY();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' in XdmfGeometryType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'GeometryType' in itemProperties in XdmfGeometryType::New");
return boost::shared_ptr<const XdmfGeometryType>();
}
......
......@@ -22,6 +22,7 @@
/*****************************************************************************/
#include "XdmfGridCollectionType.hpp"
#include "XdmfError.hpp"
// Supported XdmfGridCollectionTypes
boost::shared_ptr<const XdmfGridCollectionType>
......@@ -74,10 +75,10 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
return Temporal();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'CollectionType' not of 'None', 'Spatial', or 'Temporal' in XdmfGridCollectionType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "'CollectionType' not in itemProperties in XdmfGridCollectionType::New");
return boost::shared_ptr<const XdmfGridCollectionType>();
}
......
......@@ -26,6 +26,7 @@
#include "XdmfGridCollectionType.hpp"
#include "XdmfHeavyDataController.hpp"
#include "XdmfMap.hpp"
#include "XdmfError.hpp"
boost::shared_ptr<XdmfMap>
XdmfMap::New()
......@@ -167,9 +168,11 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
arrayVector.push_back(array);
}
}
assert(arrayVector.size() == 3);
assert(arrayVector[0]->getSize() == arrayVector[1]->getSize() &&
arrayVector[0]->getSize() == arrayVector[2]->getSize());
if(arrayVector.size() != 3)
XdmfError::message(XdmfError::FATAL, "Length of array vector not equal to 3 in XdmfMap::populateItem");
if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() &&
arrayVector[0]->getSize() == arrayVector[2]->getSize()))
XdmfError::message(XdmfError::FATAL, "Length of individual array vectors not equal in XdmfMap::populateItem");
bool needToRead = false;
for(std::vector<boost::shared_ptr<XdmfArray> >::const_iterator iter =
arrayVector.begin();
......@@ -206,10 +209,11 @@ XdmfMap::read()
if(mLocalNodeIdsController &&
mRemoteTaskIdsController &&
mRemoteLocalNodeIdsController) {
assert(mLocalNodeIdsController->getSize() ==
if(!(mLocalNodeIdsController->getSize() ==
mRemoteTaskIdsController->getSize() &&
mLocalNodeIdsController->getSize() ==
mRemoteLocalNodeIdsController->getSize());
mRemoteLocalNodeIdsController->getSize()))
XdmfError::message(XdmfError::FATAL, "Number of local nodes not equal to number of remote tasks or nodes in XdmfMap::read");
boost::shared_ptr<XdmfArray> globalNodeIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> taskIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
......@@ -245,10 +249,11 @@ XdmfMap::setHeavyDataControllers(boost::shared_ptr<XdmfHeavyDataController> loca
boost::shared_ptr<XdmfHeavyDataController> remoteTaskIdsController,
boost::shared_ptr<XdmfHeavyDataController> remoteLocalNodeIdsController)
{
assert(localNodeIdsController->getSize() ==
if(!(localNodeIdsController->getSize() ==
remoteTaskIdsController->getSize() &&
localNodeIdsController->getSize() ==
remoteLocalNodeIdsController->getSize());
remoteLocalNodeIdsController->getSize()))
XdmfError::message(XdmfError::FATAL, "Number of local nodes not equal to number of remote tasks or nodes in XdmfMap::read");
mLocalNodeIdsController = localNodeIdsController;
mRemoteTaskIdsController = remoteTaskIdsController;
mRemoteLocalNodeIdsController = remoteLocalNodeIdsController;
......
......@@ -28,6 +28,7 @@
#include "XdmfRectilinearGrid.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
#include "XdmfError.hpp"
/**
* PIMPL
......@@ -118,7 +119,7 @@ public:
collectedProperties["Type"] = "VXVY";
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in XdmfGeometryTypeRectilinear::getProperties");
}
}
......@@ -207,7 +208,7 @@ public:
collectedProperties["Type"] = "2DRectMesh";
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in XdmfTopologyTypeRectilinear::getProperties");
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -28,6 +28,7 @@
#include "XdmfRegularGrid.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
#include "XdmfError.hpp"
/**
* PIMPL
......@@ -114,7 +115,7 @@ public:
collectedProperties["Type"] = "ORIGIN_DXDY";
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties");
}
}
......@@ -203,7 +204,7 @@ public:
collectedProperties["Type"] = "2DCoRectMesh";
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfTopologyTypeRegular::getProperties");
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -25,6 +25,7 @@
#include "XdmfHDF5Controller.hpp"
#include "XdmfSet.hpp"
#include "XdmfSetType.hpp"
#include "XdmfError.hpp"
XDMF_CHILDREN_IMPLEMENTATION(XdmfSet, XdmfAttribute, Attribute, Name)
......@@ -86,7 +87,7 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
mName = name->second;
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in XdmfSet::populateItem");
}
mType = XdmfSetType::New(itemProperties);
for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter =
......
......@@ -22,6 +22,7 @@
/*****************************************************************************/
#include "XdmfSetType.hpp"
#include "XdmfError.hpp"
// Supported XdmfSetTypes
boost::shared_ptr<const XdmfSetType>
......@@ -94,10 +95,10 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
return Edge();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Type not of 'None', 'Node', 'Cell', 'Face', or 'Edge' in XdmfSetType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'SetType' found in itemProperties in XdmfSetType::New");
return boost::shared_ptr<const XdmfSetType>();
}
......
......@@ -23,6 +23,7 @@
#include <sstream>
#include "XdmfTime.hpp"
#include "XdmfError.hpp"
boost::shared_ptr<XdmfTime>
XdmfTime::New(const double & value)
......@@ -76,7 +77,7 @@ XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties
mValue = atof(value->second.c_str());
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'Value' not in itemProperties in XdmfTime::populateItem");
}
}
......
......@@ -24,6 +24,7 @@
#include <cctype>
#include <sstream>
#include "XdmfTopologyType.hpp"
#include "XdmfError.hpp"
// Supported XdmfTopologyTypes
boost::shared_ptr<const XdmfTopologyType>
......@@ -287,7 +288,7 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
if(nodesPerElement != itemProperties.end()) {
return Polygon(atoi(nodesPerElement->second.c_str()));
}
assert(false);
XdmfError::message(XdmfError::FATAL, "'NodesPerElement' not in itemProperties and type 'POLYGON' selected in XdmfTopologyType::New");
}
else if(typeVal.compare("TRIANGLE") == 0) {
return Triangle();
......@@ -341,10 +342,10 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
return Mixed();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Invalid Type selected in XdmfTopologyType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "Neither 'Type' nor 'TopologyType' found in itemProperties in XdmfTopologyType::New");
return boost::shared_ptr<const XdmfTopologyType>();
}
......
......@@ -29,6 +29,7 @@
#include "XdmfHeavyDataController.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfVisitor.hpp"
#include "XdmfError.hpp"
class XdmfArray::Clear : public boost::static_visitor<void> {
public:
......@@ -599,7 +600,7 @@ XdmfArray::initialize(const boost::shared_ptr<const XdmfArrayType> arrayType,
this->release();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Array of unsupported type in XdmfArray::initialize");
}
}
......@@ -676,7 +677,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
contentVal = content->second;
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'Content' not found in itemProperties in XdmfArray::populateItem");
}
std::map<std::string, std::string>::const_iterator dimensions =
......@@ -690,7 +691,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
}
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'Dimensions' not found in itemProperties in XdmfArray::populateItem");
}
std::map<std::string, std::string>::const_iterator format =
......@@ -700,7 +701,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
std::map<std::string, std::string>::const_iterator xmlDir =
itemProperties.find("XMLDir");
if(xmlDir == itemProperties.end()) {
assert(false);
XdmfError::message(XdmfError::FATAL, "'XMLDir' not found in itemProperties in XdmfArray::populateItem");
}
size_t colonLocation = contentVal.find(":");
if(colonLocation != std::string::npos) {
......@@ -725,7 +726,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
mDimensions);
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "':' not found in content in XdmfArray::populateItem -- double check an HDF5 data set is specified for the file");
}
}
else if(format->second.compare("XML") == 0) {
......@@ -742,11 +743,11 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
}
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Neither 'HDF' nor 'XML' specified as 'Format' in XdmfArray::populateItem");
}
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "'Format' not found in itemProperties in XdmfArray::populateItem");
}
std::map<std::string, std::string>::const_iterator name =
......
......@@ -23,6 +23,7 @@
#include <sstream>
#include "XdmfArrayType.hpp"
#include "XdmfError.hpp"
// Supported XdmfArrayTypes
boost::shared_ptr<const XdmfArrayType>
......@@ -163,10 +164,10 @@ XdmfArrayType::New(const std::map<std::string, std::string> & itemProperties)
return UInt32();
}
else {
assert(false);
XdmfError::message(XdmfError::FATAL, "Type not one of accepted values: "+typeVal+" in XdmfArrayType::New");
}
}
assert(false);
XdmfError::message(XdmfError::FATAL, "Type unset because neither 'DataType' nor 'NumberType' found in itemProperties in XdmfArrayType::New");
return boost::shared_ptr<const XdmfArrayType>();
}
......
......@@ -11,6 +11,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#include <XdmfCore.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
#include <XdmfError.hpp>
#include <XdmfHeavyDataController.hpp>
#include <XdmfHeavyDataWriter.hpp>
#include <XdmfHDF5Controller.hpp>
......@@ -277,6 +278,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%template() Loki::Visitor<XdmfItem>;
%include XdmfCore.hpp
%include XdmfError.hpp
%include XdmfItem.hpp
%include XdmfItemProperty.hpp
%include XdmfVisitor.hpp
......
......@@ -29,6 +29,7 @@
#include "XdmfCoreReader.hpp"
#include "XdmfItem.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfError.hpp"
/**
* PIMPL
......@@ -69,7 +70,7 @@ public:
mDocument = xmlReadFile(filePath.c_str(), NULL, 0);
if(mDocument == NULL) {
assert(false);
XdmfError::message(XdmfError::FATAL, "xmlReadFile could not read "+filePath+" in XdmfCoreReader::XdmfCoreReaderImpl::openFile");
}
mXPathContext = xmlXPtrNewContext(mDocument, NULL, NULL);
......@@ -156,7 +157,7 @@ public:
itemProperties,
childItems);
if(newItem == NULL) {
assert(false);
XdmfError::message(XdmfError::FATAL, "mItemFactory failed to createItem in XdmfCoreReader::XdmfCoreReaderImpl::readSingleNode");
}
newItem->populateItem(itemProperties, childItems, mCoreReader);
......
......@@ -26,6 +26,8 @@ XdmfError::message(Level level, std::string msg)
{
if(level<=XdmfError::getLevel())
XdmfError::WriteToStream(msg);
if(level == XdmfError::FATAL)
exit(1);
}
void
......
......@@ -4,9 +4,9 @@
#include <iostream>
#include <sstream>
#include <Xdmf.hpp>
#include "XdmfCore.hpp"
class XDMF_EXPORT XdmfError
class XDMFCORE_EXPORT XdmfError
{
public:
XdmfError();
......
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