Commit af08f056 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

fixed test errors and added new version of XdmfError

parent 0b37c6e9
......@@ -91,7 +91,6 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfDomain.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGraph.hpp>
#include <XdmfGrid.hpp>
#include <XdmfGridCollection.hpp>
#include <XdmfGridCollectionType.hpp>
......@@ -227,10 +226,15 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include std_set.i
%include std_map.i
%include std_vector.i
#ifdef XDMF_BUILD_DSM
%include mpi4py/mpi4py.i
%mpi4py_typemap(Comm, MPI_Comm);
#endif
%template(XdmfMapNodeIdSet) std::set<int>;
%template(XdmfMapNodeIdMap) std::map<int, std::set<int> >;
%template(XdmfMapMap) std::map<int, std::map<int, std::set<int> > >;
......
......@@ -94,9 +94,14 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
mName = name->second;
}
else {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
try {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfAttribute::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
mCenter = XdmfAttributeCenter::New(itemProperties);
......
......@@ -81,9 +81,14 @@ 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()) {
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
try {
XdmfError::message(XdmfError::FATAL,
"'Center' not found in itemProperties in "
"XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & centerVal = center->second;
......@@ -103,9 +108,14 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
return Edge();
}
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
try {
XdmfError::message(XdmfError::FATAL,
"Center not of 'Grid','Cell','Face','Edge','Node' "
"in XdmfAttributeCenter::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfAttributeCenter>();
}
......
......@@ -100,9 +100,14 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
type = itemProperties.find("AttributeType");
}
if(type == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'AttributeType' found in "
"itemProperties in XdmfAttributeType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'AttributeType' found in "
"itemProperties in XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
......@@ -128,10 +133,15 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
return NoAttributeType();
}
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Type not of 'None','Scalar','Vector','Tensor', "
"'Matrix','Tensor6', or 'GlobalId' in "
"XdmfAttributeType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfAttributeType>();
}
......
......@@ -44,9 +44,14 @@ public:
static shared_ptr<XdmfTopologyCurvilinear>
New(const XdmfCurvilinearGrid * const curvilinearGrid)
{
shared_ptr<XdmfTopologyCurvilinear>
p(new XdmfTopologyCurvilinear(curvilinearGrid));
return p;
try {
shared_ptr<XdmfTopologyCurvilinear>
p(new XdmfTopologyCurvilinear(curvilinearGrid));
return p;
}
catch (XdmfError e) {
throw e;
}
}
unsigned int
......@@ -69,7 +74,12 @@ public:
XdmfTopologyCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
mCurvilinearGrid(curvilinearGrid)
{
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
try {
this->setType(XdmfTopologyTypeCurvilinear::New(curvilinearGrid));
}
catch (XdmfError e) {
throw e;
}
}
const XdmfCurvilinearGrid * const mCurvilinearGrid;
......@@ -100,9 +110,14 @@ public:
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -119,9 +134,14 @@ public:
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -147,9 +167,14 @@ public:
collectedProperties["Type"] = "2DSMesh";
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getProperties");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -23,6 +23,7 @@
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
#include "XdmfError.hpp"
shared_ptr<XdmfGeometry> XdmfGeometry::New()
{
......@@ -45,9 +46,14 @@ const std::string XdmfGeometry::ItemTag = "Geometry";
std::map<std::string, std::string>
XdmfGeometry::getItemProperties() const
{
std::map<std::string, std::string> geometryProperties;
mType->getProperties(geometryProperties);
return geometryProperties;
try {
std::map<std::string, std::string> geometryProperties;
mType->getProperties(geometryProperties);
return geometryProperties;
}
catch (XdmfError e) {
throw e;
}
}
std::string
......
......@@ -67,9 +67,14 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("GeometryType");
}
if(type == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'GeometryType' in itemProperties "
"in XdmfGeometryType::New");
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;
......@@ -83,8 +88,13 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
return XY();
}
XdmfError::message(XdmfError::FATAL, "Type not 'None', 'XYZ', or 'XY' "
"in XdmfGeometryType::New");
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,9 +65,14 @@ 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()) {
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not in itemProperties in "
"XdmfGridCollectionType::New");
try {
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not in itemProperties in "
"XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
}
const std::string & typeVal = type->second;
......@@ -81,9 +86,14 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
return Temporal();
}
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not of 'None', 'Spatial', or "
"'Temporal' in XdmfGridCollectionType::New");
try {
XdmfError::message(XdmfError::FATAL,
"'CollectionType' not of 'None', 'Spatial', or "
"'Temporal' in XdmfGridCollectionType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfGridCollectionType>();
}
......
This diff is collapsed.
......@@ -168,15 +168,25 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
if(arrayVector.size() != 0) {
if(arrayVector.size() != 3) {
XdmfError::message(XdmfError::FATAL,
"Expected 3 arrays attached to "
"XdmfMap::populateItem");
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())) {
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap:: populateItem");
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
......@@ -256,8 +266,13 @@ XdmfMap::read()
remoteTaskCount &&
localNodeCount ==
remoteNodeCount)){
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in XdmfMap::read");
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();
......@@ -326,10 +341,16 @@ XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController>
if(!(localNodeCount ==
remoteTaskCount &&
localNodeCount ==
remoteNodeCount))
XdmfError::message(XdmfError::FATAL,
"Arrays must be of equal size in "
"XdmfMap::setHeavyDataControllers");
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;
......
......@@ -23,6 +23,7 @@
#include "XdmfItemFactory.hpp"
#include "XdmfReader.hpp"
#include "XdmfError.hpp"
shared_ptr<XdmfReader>
XdmfReader::New()
......@@ -45,12 +46,22 @@ XdmfReader::~XdmfReader()
shared_ptr<XdmfItem>
XdmfReader::read(const std::string & filePath) const
{
return XdmfCoreReader::read(filePath);
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
{
return XdmfCoreReader::read(filePath, xPath);
try {
return XdmfCoreReader::read(filePath, xPath);
}
catch (XdmfError e) {
throw e;
}
}
......@@ -119,7 +119,12 @@ public:
collectedProperties["Type"] = "VXVY";
}
else {
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in XdmfGeometryTypeRectilinear::getProperties");
try {
XdmfError::message(XdmfError::FATAL, "Number of dimensions not 2 or 3 in XdmfGeometryTypeRectilinear::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
}
......@@ -199,9 +204,14 @@ public:
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -218,9 +228,14 @@ public:
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -246,9 +261,14 @@ public:
collectedProperties["Type"] = "2DRectMesh";
}
else {
XdmfError::message(XdmfError::FATAL,
"Number of dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getProperties");
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,7 +114,12 @@ public:
collectedProperties["Type"] = "ORIGIN_DXDY";
}
else {
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties");
try {
XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
}
......@@ -192,9 +197,14 @@ public:
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -210,9 +220,14 @@ public:
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
try {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
}
catch (XdmfError e) {
throw e;
}
}
return 0;
}
......@@ -237,9 +252,14 @@ public:
collectedProperties["Type"] = "2DCoRectMesh";
}
else {
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getProperties");
try {
XdmfError::message(XdmfError::FATAL,
"Dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getProperties");
}
catch (XdmfError e) {
throw e;
}
}
collectedProperties["Dimensions"] = dimensions->getValuesString();
}
......
......@@ -88,9 +88,14 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
mName = name->second;
}
else {
XdmfError::message(XdmfError::FATAL,
"'Name' not found in itemProperties in "
"XdmfSet::populateItem");
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 =
......
......@@ -79,9 +79,14 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("SetType");
}
if(type == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'SetType' found in itemProperties "
"in XdmfSetType::New");
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;
......@@ -101,9 +106,14 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
return NoSetType();
}
XdmfError::message(XdmfError::FATAL,
"Type not of 'None', 'Node', 'Cell', 'Face', or "
"'Edge' in XdmfSetType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Type not of 'None', 'Node', 'Cell', 'Face', or "
"'Edge' in XdmfSetType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfSetType>();
}
......
......@@ -78,9 +78,14 @@ XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties
mValue = atof(value->second.c_str());
}
else {
XdmfError::message(XdmfError::FATAL,
"'Value' not in itemProperties in "
"XdmfTime::populateItem");
try {
XdmfError::message(XdmfError::FATAL,
"'Value' not in itemProperties in "
"XdmfTime::populateItem");
}
catch (XdmfError e) {
throw e;
}
}
}
......
......@@ -79,9 +79,14 @@ XdmfTopology::getNumberElements() const
const shared_ptr<const XdmfTopologyType> topologyType =
XdmfTopologyType::New(id);
if(topologyType == NULL) {
XdmfError::message(XdmfError::FATAL,
"Invalid topology type id found in connectivity "
"when parsing mixed topology.");
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 =
......
......@@ -513,9 +513,14 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
type = itemProperties.find("TopologyType");
}
if(type == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'TopologyType' found in "
"itemProperties in XdmfTopologyType::New");
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(),
......@@ -536,17 +541,27 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
if(nodesPerElement != itemProperties.end()) {
return Polyline(atoi(nodesPerElement->second.c_str()));
}
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYLINE' selected in XdmfTopologyType::New");
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()));
}
XdmfError::message(XdmfError::FATAL,
"'NodesPerElement' not in itemProperties and type "
"'POLYGON' selected in XdmfTopologyType::New");
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();
......@@ -645,8 +660,13 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
return Mixed();
}
XdmfError::message(XdmfError::FATAL,
"Invalid Type selected in XdmfTopologyType::New");
try {
XdmfError::message(XdmfError::FATAL,
"Invalid Type selected in XdmfTopologyType::New");
}
catch (XdmfError e) {
throw e;
}
return shared_ptr<const XdmfTopologyType>();
}
......
......@@ -142,10 +142,15 @@ XdmfUnstructuredGrid::XdmfUnstructuredGrid(const shared_ptr<XdmfRegularGrid> reg
if(dimensions->getSize() != brickSize->getSize() ||
dimensions->getSize() != origin->getSize()) {
XdmfError::message(XdmfError::FATAL,
"Inconsistent brick, dimension, and origin sizes when"
"converting regular grid to unstructured grid in "
"XdmfUnstructuredGrid constructor");
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;
......@@ -175,10 +180,15 @@ XdmfUnstructuredGrid::XdmfUnstructuredGrid(const shared_ptr<XdmfRegularGrid> reg
topologyType = XdmfTopologyType::Hexahedron();
}
else {
XdmfError::message(XdmfError::FATAL,
"Cannot convert regular grid of dimensions not 2 or 3 "
"to XdmfUnstructuredGrid in XdmfUnstructuredGrid "
"constructor");
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);
......
This diff is collapsed.
......@@ -512,6 +512,8 @@ public: