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

Improving test output

parent 7863e933
......@@ -65,6 +65,10 @@ MACRO(ADD_TEST_FORTRAN executable)
IF(EXISTS ${fortran_source_dir}/${executable}.f90)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f90)
IF(EXISTS ${fortran_source_dir}/${executable}.F90)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.F90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.F90)
GET_PROPERTY(fortran_dependencies GLOBAL PROPERTY FORTRAN_TEST_DEPENDENCIES)
GET_PROPERTY(fortran_ldpath GLOBAL PROPERTY FORTRAN_TEST_LDPATH)
......@@ -128,6 +132,10 @@ MACRO(ADD_MPI_TEST_FORTRAN script files)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f90)
IF(EXISTS ${fortran_source_dir}/${executable}.F90)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.F90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.F90)
GET_PROPERTY(fortran_dependencies GLOBAL PROPERTY FORTRAN_TEST_DEPENDENCIES)
GET_PROPERTY(fortran_ldpath GLOBAL PROPERTY FORTRAN_TEST_LDPATH)
GET_PROPERTY(fortran_path GLOBAL PROPERTY FORTRAN_TEST_PATH)
......
......@@ -59,6 +59,11 @@ if(XDMF_BUILD_DSM)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
# intel compiler requires an extra tag for CXX_FLAGS in order to properly build
STRING(REGEX MATCH "icpc" IS_INTEL "${CMAKE_CXX_COMPILER}")
if (NOT "${IS_INTEL}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_IGNORE_CXX_SEEK")
endif (NOT "${IS_INTEL}" STREQUAL "")
endif(MPI_FOUND)
option(XDMF_BUILD_DSM_THREADS ON)
if (XDMF_WRAP_PYTHON)
......
......@@ -72,7 +72,12 @@ XdmfAttribute::getItemTag() const
std::string
XdmfAttribute::getName() const
{
return mName;
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
}
shared_ptr<const XdmfAttributeType>
......@@ -125,7 +130,12 @@ XdmfAttribute::setCenter(const shared_ptr<const XdmfAttributeCenter> center)
void
XdmfAttribute::setName(const std::string & name)
{
mName= name;
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
}
void
......
......@@ -223,7 +223,10 @@ XdmfCurvilinearGrid::XdmfCurvilinearGrid(const shared_ptr<XdmfArray> numPoints)
XdmfCurvilinearGrid::~XdmfCurvilinearGrid()
{
delete mImpl;
if (mImpl) {
delete mImpl;
}
mImpl = NULL;
}
const std::string XdmfCurvilinearGrid::ItemTag = "Grid";
......@@ -238,6 +241,9 @@ XdmfCurvilinearGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfCurvilinearGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
return mImpl->mDimensions;
}
......@@ -269,6 +275,9 @@ XdmfCurvilinearGrid::populateItem(const std::map<std::string, std::string> & ite
void
XdmfCurvilinearGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions;
}
......
......@@ -33,6 +33,7 @@ shared_ptr<XdmfGeometry> XdmfGeometry::New()
}
XdmfGeometry::XdmfGeometry() :
XdmfArray(),
mNumberPoints(0),
mType(XdmfGeometryType::NoGeometryType())
{
......
......@@ -35,7 +35,8 @@ XdmfGraph::New(const unsigned int numberNodes)
XdmfGraph::XdmfGraph(const unsigned int numberNodes) :
XdmfSparseMatrix(numberNodes,
numberNodes)
numberNodes),
mTime(shared_ptr<XdmfTime>())
{
}
......@@ -51,6 +52,19 @@ XdmfGraph::getItemTag() const
return ItemTag;
}
shared_ptr<XdmfTime>
XdmfGraph::getTime()
{
return boost::const_pointer_cast<XdmfTime>
(static_cast<const XdmfGraph &>(*this).getTime());
}
shared_ptr<const XdmfTime>
XdmfGraph::getTime() const
{
return mTime;
}
unsigned int
XdmfGraph::getNumberNodes() const
{
......@@ -77,6 +91,12 @@ XdmfGraph::populateItem(const std::map<std::string, std::string> & itemPropertie
}
}
void
XdmfGraph::setTime(const shared_ptr<XdmfTime> time)
{
mTime = time;
}
void
XdmfGraph::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
{
......
......@@ -72,10 +72,16 @@ public:
std::string getItemTag() const;
shared_ptr<XdmfTime> getTime();
shared_ptr<const XdmfTime> getTime() const;
unsigned int getNumberNodes() const;
using XdmfSparseMatrix::insert;
void setTime(const shared_ptr<XdmfTime> time);
void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
protected:
......@@ -91,6 +97,8 @@ private:
XdmfGraph(const XdmfGraph &); // Not implemented.
void operator=(const XdmfGraph &); // Not implemented.
shared_ptr<XdmfTime> mTime;
};
#ifdef _WIN32
......
......@@ -73,7 +73,12 @@ XdmfGrid::getItemTag() const
std::string
XdmfGrid::getName() const
{
return mName;
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
}
shared_ptr<XdmfTime>
......@@ -143,7 +148,12 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties
void
XdmfGrid::setName(const std::string & name)
{
mName = name;
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
}
void
......
......@@ -324,7 +324,10 @@ XdmfRectilinearGrid::XdmfRectilinearGrid(const std::vector<shared_ptr<XdmfArray>
XdmfRectilinearGrid::~XdmfRectilinearGrid()
{
delete mImpl;
if (mImpl) {
delete mImpl;
}
mImpl = NULL;
}
const std::string XdmfRectilinearGrid::ItemTag = "Grid";
......@@ -340,6 +343,9 @@ XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex)
shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
if(axisIndex < mImpl->mCoordinates.size()) {
return mImpl->mCoordinates[axisIndex];
}
......@@ -355,6 +361,9 @@ XdmfRectilinearGrid::getCoordinates()
const std::vector<shared_ptr<XdmfArray> >
XdmfRectilinearGrid::getCoordinates() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
return mImpl->mCoordinates;
}
......@@ -368,6 +377,9 @@ XdmfRectilinearGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
shared_ptr<XdmfArray> dimensions = XdmfArray::New();
dimensions->reserve(mImpl->mCoordinates.size());
for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter =
......@@ -404,6 +416,9 @@ void
XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
const shared_ptr<XdmfArray> axisCoordinates)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
if(mImpl->mCoordinates.size() <= axisIndex) {
mImpl->mCoordinates.reserve(axisIndex + 1);
unsigned int numArraysToInsert =
......@@ -418,5 +433,8 @@ XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
void
XdmfRectilinearGrid::setCoordinates(const std::vector<shared_ptr<XdmfArray> > axesCoordinates)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
mImpl->mCoordinates = axesCoordinates;
}
......@@ -353,7 +353,10 @@ XdmfRegularGrid::XdmfRegularGrid(const shared_ptr<XdmfArray> brickSize,
XdmfRegularGrid::~XdmfRegularGrid()
{
delete mImpl;
if (mImpl) {
delete mImpl;
}
mImpl = NULL;
}
const std::string XdmfRegularGrid::ItemTag = "Grid";
......@@ -368,6 +371,9 @@ XdmfRegularGrid::getBrickSize()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getBrickSize() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mBrickSize;
}
......@@ -381,6 +387,9 @@ XdmfRegularGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mDimensions;
}
......@@ -394,6 +403,9 @@ XdmfRegularGrid::getOrigin()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getOrigin() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mOrigin;
}
......@@ -428,17 +440,26 @@ XdmfRegularGrid::populateItem(const std::map<std::string, std::string> & itemPro
void
XdmfRegularGrid::setBrickSize(const shared_ptr<XdmfArray> brickSize)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mBrickSize = brickSize;
}
void
XdmfRegularGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions;
}
void
XdmfRegularGrid::setOrigin(const shared_ptr<XdmfArray> origin)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mOrigin = origin;
}
......@@ -67,7 +67,12 @@ XdmfSet::getItemTag() const
std::string
XdmfSet::getName() const
{
return mName;
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
}
shared_ptr<const XdmfSetType>
......@@ -112,7 +117,12 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
void
XdmfSet::setName(const std::string & name)
{
mName = name;
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
}
void
......
......@@ -71,22 +71,46 @@ XdmfCoreItemFactory::createItem(const std::string & itemTag,
else {
expressionToParse = expression->second;
}
std::map<std::string, std::string>::const_iterator variableNames =
itemProperties.find("VariableNames");
std::vector<std::string> nameVector;
std::string variableList = variableNames->second;
size_t barSplit = 0;
std::string subcontent;
while (barSplit != std::string::npos) {
barSplit = 0;
barSplit = variableList.find_first_of("|", barSplit);
if (barSplit == std::string::npos) {
subcontent = variableList;
}
else {
subcontent = variableList.substr(0, barSplit);
variableList = variableList.substr(barSplit+1);
barSplit++;
}
nameVector.push_back(subcontent);
}
std::map<std::string, shared_ptr<XdmfArray> > variableCollection;
for (unsigned int i = 0; i < childItems.size(); ++i) {
try {
shared_ptr<XdmfArray> tempArray =
shared_dynamic_cast<XdmfArray>(childItems[i]);
if (tempArray->getName().compare("") != 0)
{
variableCollection[tempArray->getName()] = tempArray;
tempArray->read();
for (unsigned int i = 0; i < childItems.size() && i < nameVector.size(); ++i) {
if (nameVector[i].compare("") != 0) {
if (shared_ptr<XdmfArray> array =
shared_dynamic_cast<XdmfArray>(childItems[i])) {
variableCollection[nameVector[i]] = array;
array->read();
}
else {
XdmfError::message(XdmfError::FATAL,
"Error: Function passed non-Array item");
}
}
catch (...) {
XdmfError::message(XdmfError::FATAL,
"Error: Function passed non-Array item");
}
}
shared_ptr<XdmfArray> parsedArray = shared_ptr<XdmfArray>();
parsedArray = XdmfFunction::evaluateExpression(expressionToParse,
variableCollection);
......
......@@ -114,11 +114,11 @@ std::map<std::string, shared_ptr<XdmfFunction::XdmfFunctionInternal> >
XdmfFunction::abs))
("ABS_TOKEN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs))
("ARCCOS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
("ACOS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arccos))
("ARCSIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
("ASIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arcsin))
("ARCTAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
("ATAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arctan))
("AVE", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::average))
......@@ -349,15 +349,15 @@ XdmfFunction::arctan(std::vector<shared_ptr<XdmfArray> > values)
shared_ptr<XdmfArray>
XdmfFunction::average(std::vector<shared_ptr<XdmfArray> > values)
{
double total = sum(values)->getValue<double>(0);;
int totalSize = 0;
for (unsigned int i = 0; i < values.size(); ++i)
{
totalSize += values[i]->getSize();
}
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->insert(0, total/totalSize);
return returnArray;
double total = sum(values)->getValue<double>(0);;
int totalSize = 0;
for (unsigned int i = 0; i < values.size(); ++i)
{
totalSize += values[i]->getSize();
}
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->insert(0, total/totalSize);
return returnArray;
}
shared_ptr<XdmfArray>
......@@ -520,7 +520,7 @@ XdmfFunction::evaluateExpression(std::string expression,
}
}
// Found to be a digit
if (mValidDigitChars.find(expression[i]) != std::string::npos||
if (mValidDigitChars.find(expression[i]) != std::string::npos ||
(expression[i] == '-' && hyphenIsDigit)) {
// Progress until a non-digit is found
int valueStart = i;
......@@ -776,6 +776,16 @@ XdmfFunction::getItemProperties() const
functionProperties[constructedIt->first] = constructedIt->second;
}
std::stringstream variableStream;
for (std::map<std::string, shared_ptr<XdmfArray> >::const_iterator variableIter = mVariableList.begin();
variableIter != mVariableList.end();
++variableIter) {
variableStream << "|" << variableIter->first;
}
functionProperties["VariableNames"] = variableStream.str();
return functionProperties;
}
......@@ -1157,7 +1167,6 @@ XdmfFunction::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
for (std::map<std::string, shared_ptr<XdmfArray> >::iterator it = mVariableList.begin();
it != mVariableList.end();
++it) {
it->second->setName(it->first);
it->second->accept(visitor);
}
}
......@@ -130,6 +130,28 @@ public:
static const std::string ItemTag;
/**
* Takes the first array provided and returns an array containing
* the absolute value equivalent of that array.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#abs
* @until //#abs
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//abs
* @until #//abs
*
* @param values A vector containing the array to be used
* @return An XdmfArray containing the absolute value
* equivalent of the first array
*/
static shared_ptr<XdmfArray> abs(std::vector<shared_ptr<XdmfArray> > values);
/*
......@@ -279,12 +301,112 @@ public:
shared_ptr<XdmfOperationInternal> newOperation,
int priority);
/**
* Takes the arrays provided adds them together, returning the result.
*
* If the first array has one value an array is generated adding
* it to each value of the second array.
*
* If the second array has one value. That value is added to
* all values in the first array.
*
* If both arrays have the same number of values, the
* value of the first array is added to the value of the second array
* with the same index.
*
* An error is thrown if the array sizes are both large than 1
* and do not match.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#addition
* @until //#addition
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//addition
* @until #//addition
*
* @param values A vector containing the array to be used
* @return An XdmfArray containing the sums
* of the values of the arrays
*/
static shared_ptr<XdmfArray> addition(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2);
/**
* Takes the first array provided and returns an array containing
* the arcsin of all the values in that array.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#arcsin
* @until //#arcsin
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//arcsin
* @until #//arcsin
*
* @param values A vector containing the array to be used
* @return An XdmfArray containing the arcsin of the
* values of the first array
*/
static shared_ptr<XdmfArray> arcsin(std::vector<shared_ptr<XdmfArray> > values);
/**
* Takes the first array provided and returns an array containing
* the arccos of all the values in that array.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#arccos
* @until //#arccos
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//arccos
* @until #//arccos
*
* @param values A vector containing the array to be used
* @return An XdmfArray containing the arccos of the