Commit 7f5d7003 authored by Andrew J. Burns's avatar Andrew J. Burns Committed by Andrew J. Burns (Cont

Rework of HeavyDataController and HDF5Controller to remove extra code and move...

Rework of HeavyDataController and HDF5Controller to remove extra code and move HeavyDataController away from being too dependent on hdf5 style
XdmfFunction now supports negative numbers in addition to the - operator
Reworked the interaction between array references and reading
Cleaned up some warnings that showed up in pedantic
Adjusted mpi tests to test against the MPIEXEC variable as opposed to hard calling mpirun
Still needs to be changed to work better with Cray mpi style execution
Updates to XdmfArrayType to allow for signed and floating point checking
General test and Documentation updates
parent 975536e3
...@@ -92,6 +92,9 @@ if(XDMF_WRAP_PYTHON) ...@@ -92,6 +92,9 @@ if(XDMF_WRAP_PYTHON)
#Enables DSM #Enables DSM
if (XDMF_BUILD_DSM) if (XDMF_BUILD_DSM)
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM) set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM)
if (XDMF_BUILD_DSM_THREADS)
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DXDMF_BUILD_DSM_THREADS)
endif (XDMF_BUILD_DSM_THREADS)
endif (XDMF_BUILD_DSM) endif (XDMF_BUILD_DSM)
set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON) set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON)
set(swig_extra_generated_files "") set(swig_extra_generated_files "")
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
virtual ~XdmfAttribute(); virtual ~XdmfAttribute();
LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfArray); LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfArray)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
......
...@@ -132,7 +132,7 @@ public: ...@@ -132,7 +132,7 @@ public:
virtual ~XdmfCurvilinearGrid(); virtual ~XdmfCurvilinearGrid();
LOKI_DEFINE_VISITABLE(XdmfCurvilinearGrid, XdmfGrid); LOKI_DEFINE_VISITABLE(XdmfCurvilinearGrid, XdmfGrid)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
......
...@@ -70,13 +70,13 @@ public: ...@@ -70,13 +70,13 @@ public:
virtual ~XdmfDomain(); virtual ~XdmfDomain();
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem)
XDMF_CHILDREN(XdmfDomain, XdmfGridCollection, GridCollection, Name); XDMF_CHILDREN(XdmfDomain, XdmfGridCollection, GridCollection, Name)
XDMF_CHILDREN(XdmfDomain, XdmfGraph, Graph, Name); XDMF_CHILDREN(XdmfDomain, XdmfGraph, Graph, Name)
XDMF_CHILDREN(XdmfDomain, XdmfCurvilinearGrid, CurvilinearGrid, Name); XDMF_CHILDREN(XdmfDomain, XdmfCurvilinearGrid, CurvilinearGrid, Name)
XDMF_CHILDREN(XdmfDomain, XdmfRectilinearGrid, RectilinearGrid, Name); XDMF_CHILDREN(XdmfDomain, XdmfRectilinearGrid, RectilinearGrid, Name)
XDMF_CHILDREN(XdmfDomain, XdmfRegularGrid, RegularGrid, Name); XDMF_CHILDREN(XdmfDomain, XdmfRegularGrid, RegularGrid, Name)
XDMF_CHILDREN(XdmfDomain, XdmfUnstructuredGrid, UnstructuredGrid, Name); XDMF_CHILDREN(XdmfDomain, XdmfUnstructuredGrid, UnstructuredGrid, Name)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
virtual ~XdmfGeometry(); virtual ~XdmfGeometry();
LOKI_DEFINE_VISITABLE(XdmfGeometry, XdmfArray); LOKI_DEFINE_VISITABLE(XdmfGeometry, XdmfArray)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -66,8 +66,8 @@ public: ...@@ -66,8 +66,8 @@ public:
virtual ~XdmfGraph(); virtual ~XdmfGraph();
LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix); LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix)
XDMF_CHILDREN(XdmfGraph, XdmfAttribute, Attribute, Name); XDMF_CHILDREN(XdmfGraph, XdmfAttribute, Attribute, Name)
static const std::string ItemTag; static const std::string ItemTag;
std::string getItemTag() const; std::string getItemTag() const;
......
...@@ -57,10 +57,10 @@ public: ...@@ -57,10 +57,10 @@ public:
virtual ~XdmfGrid() = 0; virtual ~XdmfGrid() = 0;
LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem)
XDMF_CHILDREN(XdmfGrid, XdmfAttribute, Attribute, Name); XDMF_CHILDREN(XdmfGrid, XdmfAttribute, Attribute, Name)
XDMF_CHILDREN(XdmfGrid, XdmfSet, Set, Name); XDMF_CHILDREN(XdmfGrid, XdmfSet, Set, Name)
XDMF_CHILDREN(XdmfGrid, XdmfMap, Map, Name); XDMF_CHILDREN(XdmfGrid, XdmfMap, Map, Name)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
virtual ~XdmfGridCollection(); virtual ~XdmfGridCollection();
LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid); LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
virtual ~XdmfMap(); virtual ~XdmfMap();
LOKI_DEFINE_VISITABLE(XdmfMap, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfMap, XdmfItem)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
virtual ~XdmfRectilinearGrid(); virtual ~XdmfRectilinearGrid();
LOKI_DEFINE_VISITABLE(XdmfRectilinearGrid, XdmfGrid); LOKI_DEFINE_VISITABLE(XdmfRectilinearGrid, XdmfGrid)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
......
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
virtual ~XdmfRegularGrid(); virtual ~XdmfRegularGrid();
LOKI_DEFINE_VISITABLE(XdmfRegularGrid, XdmfGrid); LOKI_DEFINE_VISITABLE(XdmfRegularGrid, XdmfGrid)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
......
...@@ -71,8 +71,8 @@ public: ...@@ -71,8 +71,8 @@ public:
virtual ~XdmfSet(); virtual ~XdmfSet();
LOKI_DEFINE_VISITABLE(XdmfSet, XdmfArray); LOKI_DEFINE_VISITABLE(XdmfSet, XdmfArray)
XDMF_CHILDREN(XdmfSet, XdmfAttribute, Attribute, Name); XDMF_CHILDREN(XdmfSet, XdmfAttribute, Attribute, Name)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
virtual ~XdmfTime(); virtual ~XdmfTime();
LOKI_DEFINE_VISITABLE(XdmfTime, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfTime, XdmfItem)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
virtual ~XdmfTopology(); virtual ~XdmfTopology();
LOKI_DEFINE_VISITABLE(XdmfTopology, XdmfArray); LOKI_DEFINE_VISITABLE(XdmfTopology, XdmfArray)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
/* */ /* */
/*****************************************************************************/ /*****************************************************************************/
#include <boost/assign.hpp>
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
#include <limits> #include <limits>
#include <sstream> #include <sstream>
...@@ -706,13 +705,23 @@ XdmfArray::getItemTag() const ...@@ -706,13 +705,23 @@ XdmfArray::getItemTag() const
std::string std::string
XdmfArray::getName() const XdmfArray::getName() const
{ {
if (mName.c_str() == NULL) {
return "";
}
else {
return mName; return mName;
}
} }
XdmfArray::ReadMode XdmfArray::ReadMode
XdmfArray::getReadMode() const XdmfArray::getReadMode() const
{ {
if (mReadMode) {
return mReadMode; return mReadMode;
}
else {
return XdmfArray::Controller;
}
} }
unsigned int unsigned int
...@@ -725,7 +734,13 @@ XdmfArray::getSize() const ...@@ -725,7 +734,13 @@ XdmfArray::getSize() const
shared_ptr<XdmfArrayReference> shared_ptr<XdmfArrayReference>
XdmfArray::getReference() XdmfArray::getReference()
{ {
if (mReference) {
return mReference; return mReference;
}
else {
// Returning arbitrary Reference since one isn't defined
return shared_ptr<XdmfArrayReference>();
}
} }
void * void *
...@@ -1246,11 +1261,18 @@ XdmfArray::readController() ...@@ -1246,11 +1261,18 @@ XdmfArray::readController()
returnDimensions.push_back(dimTotal/controllerDimensionSubtotal); returnDimensions.push_back(dimTotal/controllerDimensionSubtotal);
mDimensions = returnDimensions; mDimensions = returnDimensions;
} }
else if (mHeavyDataControllers.size() == 1) { else if (mHeavyDataControllers.size() == 1 && mHeavyDataControllers[0]->getArrayOffset() == 0) {
this->release(); this->release();
mHeavyDataControllers[0]->read(this); mHeavyDataControllers[0]->read(this);
mDimensions = mHeavyDataControllers[0]->getDimensions(); mDimensions = mHeavyDataControllers[0]->getDimensions();
} }
else if (mHeavyDataControllers.size() == 1 && mHeavyDataControllers[0]->getArrayOffset() > 0) {
this->release();
shared_ptr<XdmfArray> tempArray = XdmfArray::New();
mHeavyDataControllers[0]->read(tempArray.get());
this->insert(mHeavyDataControllers[0]->getArrayOffset(), tempArray, 0, mHeavyDataControllers[0]->getSize(), 1, 1);
mDimensions = mHeavyDataControllers[0]->getDimensions();
}
} }
void void
...@@ -1289,7 +1311,12 @@ XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newControl ...@@ -1289,7 +1311,12 @@ XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newControl
void void
XdmfArray::setName(const std::string & name) XdmfArray::setName(const std::string & name)
{ {
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name; mName = name;
}
} }
void void
......
...@@ -128,8 +128,8 @@ public: ...@@ -128,8 +128,8 @@ public:
virtual ~XdmfArray(); virtual ~XdmfArray();
LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem)
XDMF_CHILDREN(XdmfArray, XdmfHeavyDataController, HeavyDataController, Name); XDMF_CHILDREN(XdmfArray, XdmfHeavyDataController, HeavyDataController, Name)
static const std::string ItemTag; static const std::string ItemTag;
/** /**
...@@ -316,7 +316,7 @@ public: ...@@ -316,7 +316,7 @@ public:
* *
* @return A string containing the name of the array. * @return A string containing the name of the array.
*/ */
std::string getName() const; virtual std::string getName() const;
/** /**
* Gets the method this array will be written/read. * Gets the method this array will be written/read.
...@@ -1218,7 +1218,7 @@ public: ...@@ -1218,7 +1218,7 @@ public:
* *
* @param name Name of the array to set. * @param name Name of the array to set.
*/ */
void setName(const std::string & name); virtual void setName(const std::string & name);
/** /**
* Sets the method this array will be written/read. * Sets the method this array will be written/read.
......
...@@ -46,9 +46,14 @@ XdmfArrayReference::getConstructedProperties() ...@@ -46,9 +46,14 @@ XdmfArrayReference::getConstructedProperties()
} }
std::string std::string
XdmfArrayReference::getConstructedType() XdmfArrayReference::getConstructedType() const
{ {
if (mConstructedType.c_str() != NULL) {
return mConstructedType; return mConstructedType;
}
else {
return "";
}
} }
void void
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
virtual ~XdmfArrayReference(); virtual ~XdmfArrayReference();
LOKI_DEFINE_VISITABLE(XdmfArrayReference, XdmfItem); LOKI_DEFINE_VISITABLE(XdmfArrayReference, XdmfItem)
/** /**
* Gets the properties of the array that the reference will generate when read from file. * Gets the properties of the array that the reference will generate when read from file.
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
* *
* @return The tag of the type to be generated * @return The tag of the type to be generated
*/ */
std::string getConstructedType(); std::string getConstructedType() const;
/** /**
* Parses the reference and generates an array containing the values that * Parses the reference and generates an array containing the values that
...@@ -127,7 +127,7 @@ public: ...@@ -127,7 +127,7 @@ public:
* *
* @return The array generated by the reference * @return The array generated by the reference
*/ */
virtual shared_ptr<XdmfArray> read() = 0; virtual shared_ptr<XdmfArray> read() const = 0;
/** /**
* Sets the properties of array that the reference will generate when read from file. * Sets the properties of array that the reference will generate when read from file.
......
...@@ -30,84 +30,86 @@ ...@@ -30,84 +30,86 @@
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Uninitialized() XdmfArrayType::Uninitialized()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("None", 0)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("None", 0, XdmfArrayType::Unsigned));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Int8() XdmfArrayType::Int8()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Char", 1)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Char", 1, XdmfArrayType::Signed));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Int16() XdmfArrayType::Int16()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Short", 2)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Short", 2, XdmfArrayType::Signed));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Int32() XdmfArrayType::Int32()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Int", 4)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Int", 4, XdmfArrayType::Signed));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Int64() XdmfArrayType::Int64()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Int", 8)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Int", 8, XdmfArrayType::Signed));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Float32() XdmfArrayType::Float32()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Float", 4)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Float", 4, XdmfArrayType::Float));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::Float64() XdmfArrayType::Float64()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Float", 8)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("Float", 8, XdmfArrayType::Float));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::UInt8() XdmfArrayType::UInt8()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UChar", 1)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UChar", 1, XdmfArrayType::Unsigned));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::UInt16() XdmfArrayType::UInt16()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UShort", 2)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UShort", 2, XdmfArrayType::Unsigned));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::UInt32() XdmfArrayType::UInt32()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UInt", 4)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("UInt", 4, XdmfArrayType::Unsigned));
return p; return p;
} }
shared_ptr<const XdmfArrayType> shared_ptr<const XdmfArrayType>
XdmfArrayType::String() XdmfArrayType::String()
{ {
static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("String", 0)); static shared_ptr<const XdmfArrayType> p(new XdmfArrayType("String", 0, XdmfArrayType::Unsigned));
return p; return p;
} }
XdmfArrayType::XdmfArrayType(const std::string & name, XdmfArrayType::XdmfArrayType(const std::string & name,
const unsigned int precision) : const unsigned int precision,
const Format typeFormat) :
mName(name), mName(name),
mPrecision(precision) mPrecision(precision),
mTypeFormat(typeFormat)
{ {
std::stringstream precisionString; std::stringstream precisionString;
precisionString << precision; precisionString << precision;
...@@ -374,6 +376,29 @@ XdmfArrayType::getName() const ...@@ -374,6 +376,29 @@ XdmfArrayType::getName() const
return mName; return mName;
} }
bool
XdmfArrayType::getIsFloat() const
{
if (mTypeFormat == XdmfArrayType::Float) {
return true;
}
else {
return false;
}
}
bool
XdmfArrayType::getIsSigned() const
{
if (mTypeFormat == XdmfArrayType::Float ||
mTypeFormat == XdmfArrayType::Signed) {
return true;
}
else {
return false;
}
}
void void
XdmfArrayType::getProperties(std::map<std::string, std::string> & collectedProperties) const XdmfArrayType::getProperties(std::map<std::string, std::string> & collectedProperties) const
{ {
......
...@@ -71,6 +71,12 @@ public: ...@@ -71,6 +71,12 @@ public:
friend class XdmfArray; friend class XdmfArray;
enum Format {
Unsigned,
Signed,
Float
};
// Supported XdmfArrayTypes // Supported XdmfArrayTypes
static shared_ptr<const XdmfArrayType> Uninitialized(); static shared_ptr<const XdmfArrayType> Uninitialized();
static shared_ptr<const XdmfArrayType> Int8(); static shared_ptr<const XdmfArrayType> Int8();
...@@ -148,6 +154,48 @@ public: ...@@ -148,6 +154,48 @@ public:
*/ */
std::string getName() const; std::string getName() const;
/**
* Gets whether the data type is floating point or not.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArrayType.cpp
* @skipline //#getIsFloat
* @until //#getIsFloat
*
* Python
*
* @dontinclude XdmfExampleArrayType.py
* @skipline #//getIsFloat
* @until #//getIsFloat
*
* @return Whether the data type is signed.
*/
bool getIsFloat() const;
/**
* Gets whether the data type is signed or not.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArrayType.cpp
* @skipline //#getIsSigned
* @until //#getIsSigned
*
* Python
*
* @dontinclude XdmfExampleArrayType.py
* @skipline #//getIsSigned
* @until #//getIsSigned
*
* @return Whether the data type is signed.
*/
bool getIsSigned() const;
void void
getProperties(std::map<std::string, std::string> & collectedProperties) const; getProperties(std::map<std::string, std::string> & collectedProperties) const;
...@@ -164,7 +212,8 @@ protected: ...@@ -164,7 +212,8 @@ protected:
* construct. * construct.
*/ */
XdmfArrayType(const std::string & name, XdmfArrayType(const std::string & name,
const unsigned int precision); const unsigned int precision,
const Format typeFormat);
private: private:
...@@ -177,6 +226,7 @@ private: ...@@ -177,6 +226,7 @@ private:
const std::string mName; const std::string mName;
const unsigned int mPrecision;