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

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
......@@ -38,6 +38,30 @@ int main(int, char **)
//#initialization end
//#getDataSetPath begin
std::string exampleSetPath = exampleController->getDataSetPath();
//#getDataSetPath end
//#getDataspaceDimensions begin
std::vector<unsigned int> exampleDataspaceDimensions = exampleController->getDataspaceDimensions();
//#getDataspaceDimensions end
//#getStart begin
std::vector<unsigned int> exampleStart = exampleController->getStart();
//#getStart end
//#getStride begin
std::vector<unsigned int> exampleStride = exampleController->getStride();
//#getStride end
//#setMaxOpenedFiles begin
XdmfHDF5Controller::setMaxOpenedFiles(2);
......
......@@ -42,30 +42,24 @@ int main(int, char **)
//#initialization end
//#getDataSetPath begin
std::string exampleSetPath = exampleController->getDataSetPath();
//#getDataSetPath end
//#getDimensions begin
std::vector<unsigned int> exampleDimensions = exampleController->getDimensions();
//#getDimensions end
//#getDataspaceDimensions begin
std::vector<unsigned int> exampleDataspaceDimensions = exampleController->getDataspaceDimensions();
//#getDataspaceDimensions end
//#getFilePath begin
std::string exampleFilePath = exampleController->getFilePath();
//#getFilePath end
//#getDescriptor begin
std::string exampleDescriptor = exampleController->getDescriptor();
//#getDescriptor end
//#getName begin
std::string exampleName = exampleController->getName();
......@@ -92,18 +86,6 @@ int main(int, char **)
//#read end
//#getStart begin
std::vector<unsigned int> exampleStart = exampleController->getStart();
//#getStart end
//#getStride begin
std::vector<unsigned int> exampleStride = exampleController->getStride();
//#getStride end
//#setArrayOffset begin
unsigned int newArrayOffset = 5;//default is 0
......
......@@ -71,6 +71,7 @@ if __name__ == "__main__":
#//ClosePort begin
if id == 0:
exampleWriter.getServerBuffer().GetComm().ClosePort()
#//ClosePort end
......@@ -270,7 +270,7 @@ if __name__ == "__main__":
dimensionVector.push_back(4)
writtenArray.initializeAsInt32(dimensionVector)
for i in range (0, 20):
writtenArray.insert(i, i + 1)
writtenArray.insertAsInt32(i, i + 1)
readArray = XdmfArray.New()
readDimensionVector = UInt32Vector()
readDimensionVector.push_back(6)
......
......@@ -13,6 +13,18 @@ if __name__ == "__main__":
#//getName end
#//getIsSigned begin
isSigned = XdmfArrayType.UInt8().getIsSigned()
#//getIsSigned end
#//getIsFloat begin
isFloat = XdmfArrayType.UInt8().getIsFloat()
#//getIsFloat end
#//getType begin
exampleArray = XdmfArray.New()
......
......@@ -37,6 +37,30 @@ if __name__ == "__main__":
#//initialization end
#//getDataSetPath begin
examplePath = exampleController.getDataSetPath()
#//getDataSetPath end
#//getDataspaceDimensions begin
exampleDataspaceDimensions = exampleController.getDataspaceDimensions()
#//getDataspaceDimensions end
#//getStart begin
exampleStart = exampleController.getStart()
#//getStart end
#//getStride begin
exampleStride = exampleController.getStride()
#//getStride end
#//setMaxOpenedFiles begin
XdmfHDF5Controller.setMaxOpenedFiles(2)
......@@ -54,3 +78,4 @@ if __name__ == "__main__":
XdmfHDF5Controller.closeFiles()
#//closeFiles end
......@@ -39,30 +39,24 @@ if __name__ == "__main__":
#//initialization end
#//getDataSetPath begin
examplePath = exampleController.getDataSetPath()
#//getDataSetPath end
#//getDimensions begin
exampleDimensions = exampleController.getDimensions()
#//getDimensions end
#//getDataspaceDimensions begin
exampleDataspaceDimensions = exampleController.getDataspaceDimensions()
#//getDataspaceDimensions end
#//getFilePath begin
examplePath = exampleController.getFilePath()
#//getFilePath end
#//getDescriptor begin
exampleDescriptor = exampleController.getDescriptor()
#//getDescriptor end
#//getName begin
exampleName = exampleController.getName()
......@@ -89,18 +83,6 @@ if __name__ == "__main__":
#//read end
#//getStart begin
exampleStart = exampleController.getStart()
#//getStart end
#//getStride begin
exampleStride = exampleController.getStride()
#//getStride end
#//setArrayOffset begin
newArrayOffset = 5#default is 0
......
......@@ -229,7 +229,7 @@ int main(int, char **)
std::cout << "The topology's tag: " << untopology->getItemTag().c_str() << std::endl;
if (untopology->getType() == XdmfTopologyType::Hexahedron())
{
std::cout "This topology is a hexahedron" << std::endl;
std::cout << "This topology is a hexahedron" << std::endl;
}
else
{
......@@ -255,7 +255,7 @@ int main(int, char **)
}
outputInformation = ungeometry->getInformation(0);
std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl;
std::cout << "Contains " << ungeometry->getNumberPoints() << " points\n", ungeometry->getNumberPoints() << std::endl;
std::cout << "Contains " << ungeometry->getNumberPoints() << " points\n" << ungeometry->getNumberPoints() << std::endl;
std::cout << "Contains the values: " << ungeometry->getValuesString().c_str() << std::endl;
......
......@@ -5,8 +5,8 @@ int main(int, char **)
{
// Test != and == operators
assert(XdmfAttributeType::Scalar() == XdmfAttributeType::Scalar());
assert(XdmfAttributeType::Scalar() == XdmfAttributeType::Vector() == false);
assert(XdmfAttributeType::Scalar() != XdmfAttributeType::Scalar() == false);
assert((XdmfAttributeType::Scalar() == XdmfAttributeType::Vector()) == false);
assert((XdmfAttributeType::Scalar() != XdmfAttributeType::Scalar()) == false);
assert(XdmfAttributeType::Scalar() != XdmfAttributeType::Vector());
shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
......
......@@ -6,8 +6,8 @@ int main(int, char **)
{
// Test != and == operators
assert(XdmfGeometryType::XYZ() == XdmfGeometryType::XYZ());
assert(XdmfGeometryType::XYZ() == XdmfGeometryType::XY() == false);
assert(XdmfGeometryType::XYZ() != XdmfGeometryType::XYZ() == false);
assert((XdmfGeometryType::XYZ() == XdmfGeometryType::XY()) == false);
assert((XdmfGeometryType::XYZ() != XdmfGeometryType::XYZ()) == false);
assert(XdmfGeometryType::XYZ() != XdmfGeometryType::XY());
shared_ptr<XdmfGeometry> geometry = XdmfGeometry::New();
......
......@@ -12,10 +12,10 @@ int main(int, char **)
// Test != and == operators
assert(XdmfGridCollectionType::Spatial() ==
XdmfGridCollectionType::Spatial());
assert(XdmfGridCollectionType::Spatial() ==
XdmfGridCollectionType::Temporal() == false);
assert(XdmfGridCollectionType::Spatial() !=
XdmfGridCollectionType::Spatial() == false);
assert((XdmfGridCollectionType::Spatial() ==
XdmfGridCollectionType::Temporal()) == false);
assert((XdmfGridCollectionType::Spatial() !=
XdmfGridCollectionType::Spatial()) == false);
assert(XdmfGridCollectionType::Spatial() !=
XdmfGridCollectionType::Temporal());
......
......@@ -117,8 +117,8 @@ int main(int, char **)
const std::vector<unsigned int> count(2, 2);
const std::vector<unsigned int> dataSpaceSize(2, 3);
shared_ptr<XdmfHeavyDataController> controller =
readArray2->getHeavyDataController();
shared_ptr<XdmfHDF5Controller> controller =
shared_dynamic_cast<XdmfHDF5Controller>(readArray2->getHeavyDataController());
assert(controller);
shared_ptr<XdmfHDF5Controller> hyperslabController =
......
......@@ -6,8 +6,8 @@ int main(int, char **)
{
// Test != and == operators
assert(XdmfSetType::Node() == XdmfSetType::Node());
assert(XdmfSetType::Node() == XdmfSetType::Cell() == false);
assert(XdmfSetType::Node() != XdmfSetType::Node() == false);
assert((XdmfSetType::Node() == XdmfSetType::Cell()) == false);
assert((XdmfSetType::Node() != XdmfSetType::Node()) == false);
assert(XdmfSetType::Node() != XdmfSetType::Cell());
shared_ptr<XdmfSet> set = XdmfSet::New();
......
......@@ -76,5 +76,22 @@ int main(int, char **)
assert(readSubsetHolder->getValuesString().compare(subsetHolder->getValuesString()) == 0);
shared_ptr<XdmfArray> referenceArray2 = XdmfArray::New();
for (unsigned int i = 10; i < 37; ++i)
{
referenceArray2->pushBack(i);
}
referenceArray2->resize(initDimensions, 0);
testSubset->setReferenceArray(referenceArray2);
std::string changedSubsetOutput = testSubset->read()->getValuesString();
std::cout << "after changing reference Array: " << changedSubsetOutput << std::endl;
assert(changedSubsetOutput.compare("10 12 16 18 28 30 34 36") == 0);
return 0;
}
......@@ -10,10 +10,10 @@ int main(int, char **)
{
// Test != and == operators
assert(XdmfTopologyType::Hexahedron() == XdmfTopologyType::Hexahedron());
assert(XdmfTopologyType::Hexahedron() ==
XdmfTopologyType::Tetrahedron() == false);
assert(XdmfTopologyType::Hexahedron() !=
XdmfTopologyType::Hexahedron() == false);
assert((XdmfTopologyType::Hexahedron() ==
XdmfTopologyType::Tetrahedron()) == false);
assert((XdmfTopologyType::Hexahedron() !=
XdmfTopologyType::Hexahedron()) == false);
assert(XdmfTopologyType::Hexahedron() != XdmfTopologyType::Tetrahedron());
shared_ptr<XdmfTopology> top = XdmfTopology::New();
......@@ -31,7 +31,7 @@ int main(int, char **)
shared_ptr<const XdmfTopologyType> polygon12 = XdmfTopologyType::Polygon(12);
assert(polygon == polygon6);
assert(polygon == polygon12 == false);
assert((polygon == polygon12) == false);
shared_ptr<XdmfTopology> polyTop = XdmfTopology::New();
setPolyTopology(polyTop);
......
......@@ -18,11 +18,12 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
shared_ptr<XdmfArray> calculation(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2, char operation);
shared_ptr<XdmfArray> invChunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2);
shared_ptr<XdmfArray> function(std::vector<shared_ptr<XdmfArray> > valueVector, std::string functionName);
shared_ptr<XdmfArray> subtract(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2);
shared_ptr<XdmfArray> sum(std::vector<shared_ptr<XdmfArray> > values);
shared_ptr<XdmfArray> ave(std::vector<shared_ptr<XdmfArray> > values);
shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values);
std::string validDigitChars = "1234567890.";
std::string validDigitChars = "-1234567890.";
std::string validVariableChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_:.";
//std::map<std::string, double (*)(std::vector<double>)> functions = boost::assign::map_list_of ("SUM", sum) ("AVE", ave);
......@@ -147,6 +148,56 @@ int main(int, char **)
assert(answerArray->getSize() == 1);
// - is a special case since it can be considered a negative sign
XdmfFunction::addOperation('-', subtract, 2);
std::map<std::string, shared_ptr<XdmfArray> > minusVariable;
std::string minusExpression = "-5--5";
shared_ptr<XdmfArray> minusResult = XdmfFunction::evaluateExpression(minusExpression, minusVariable);
std::cout << "result of minus equation = " << minusResult->getValuesString() << std::endl;
assert(strcmp("0", minusResult->getValuesString().c_str()) == 0);
shared_ptr<XdmfArray> minusTest1 = XdmfArray::New();
minusTest1->pushBack<int>(-5);
minusVariable["A"] = minusTest1;
minusExpression = "-5-A";
minusResult = XdmfFunction::evaluateExpression(minusExpression, minusVariable);
std::cout << "result of minus equation = " << minusResult->getValuesString() << std::endl;
assert(strcmp("0", minusResult->getValuesString().c_str()) == 0);
minusExpression = "A--5";
minusResult = XdmfFunction::evaluateExpression(minusExpression, minusVariable);
std::cout << "result of minus equation = " << minusResult->getValuesString() << std::endl;
assert(strcmp("0", minusResult->getValuesString().c_str()) == 0);
minusExpression = "MAX(-5, -4, -3, -2, -1)";
minusResult = XdmfFunction::evaluateExpression(minusExpression, minusVariable);
std::cout << "result of negative equation = " << minusResult->getValuesString() << std::endl;
assert(strcmp("-1", minusResult->getValuesString().c_str()) == 0);
shared_ptr<XdmfArray> minusTest2 = XdmfArray::New();
minusTest2->pushBack<int>(13);
shared_ptr<XdmfArray> minusTestResult = subtract(minusTest1, minusTest2);
std::cout << "result of subtract function = " << minusTestResult->getValuesString() << std::endl;
return 0;
}
......@@ -156,7 +207,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
std::stack<char> operationStack;
std::string validOperationChars = "+-*/()^"; //will be global at some point, all supported operations
int operationPriority [validOperationChars.size()];
int * operationPriority = new int[validOperationChars.size()]();
//list the priorities for the operations, based on the order of operations
//the index of the corresponding operation in validOperationChars is the same as the index of its priority in this array
operationPriority[0] = 1;//+
......@@ -427,7 +478,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
std::stack<char> operationStack;
std::string validOperationChars = "|#()@"; //will be global at some point, all supported operations
int operationPriority [validOperationChars.size()];
int * operationPriority = new int[validOperationChars.size()]();
//list the priorities for the operations, based on the order of operations
//the index of the corresponding operation in validOperationChars is the same as the index of its priority in this array
operationPriority[0] = 2;//|
......@@ -1116,3 +1167,49 @@ shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values)
return returnArray;
}
}
shared_ptr<XdmfArray> subtract(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
shared_ptr<const XdmfArrayType> returnType = XdmfArrayType::comparePrecision(val1->getArrayType(), val2->getArrayType());
for (unsigned int i = 0; i < val1->getSize() && i < val2->getSize(); ++i)
{
if (returnType == XdmfArrayType::UInt8())
{
returnArray->insert(i, val1->getValue<unsigned char>(i) - val2->getValue<unsigned char>(i));
}
else if (returnType == XdmfArrayType::UInt16())
{
returnArray->insert(i, val1->getValue<unsigned short>(i) - val2->getValue<unsigned short>(i));
}
else if (returnType == XdmfArrayType::UInt32())
{
returnArray->insert(i, val1->getValue<unsigned int>(i) - val2->getValue<unsigned int>(i));
}
else if (returnType == XdmfArrayType::Int8())
{
returnArray->insert(i, val1->getValue<char>(i) - val2->getValue<char>(i));
}
else if (returnType == XdmfArrayType::Int16())
{
returnArray->insert(i, val1->getValue<short>(i) - val2->getValue<short>(i));
}
else if (returnType == XdmfArrayType::Int32())
{
returnArray->insert(i, val1->getValue<int>(i) - val2->getValue<int>(i));
}
else if (returnType == XdmfArrayType::Int64())
{
returnArray->insert(i, val1->getValue<long>(i) - val2->getValue<long>(i));
}
else if (returnType == XdmfArrayType::Float32())
{
returnArray->insert(i, val1->getValue<float>(i) - val2->getValue<float>(i));
}
else if (returnType == XdmfArrayType::Float64())
{
returnArray->insert(i, val1->getValue<double>(i) - val2->getValue<double>(i));
}
}
return returnArray;
}
......@@ -7,7 +7,7 @@ ADD_TEST_PYTHON_DEPENDENCIES("")
# Add any pythonpath directories that the python tests may need
# Note: PYTHON_TEST_PYTHONPATH is also set in core
ADD_TEST_PYTHON_PYTHONPATH("")
ADD_TEST_PYTHON_PYTHONPATH("${PYTHON_INCLUDE_MPI4PY_DIR}/../..")
# Add any python tests here:
# Note: We don't want to use a foreach loop to test the files incase we
......
This diff is collapsed.
......@@ -89,8 +89,12 @@ class XdmfHDF5WriterDSM;
/**
* Geometry Type
*/
#define XDMF_GEOMETRY_TYPE_XYZ 301
#define XDMF_GEOMETRY_TYPE_XY 302
#ifndef XDMF_GEOMETRY_TYPE_XYZ
#define XDMF_GEOMETRY_TYPE_XYZ 301
#endif
#ifndef XDMF_GEOMETRY_TYPE_XY
#define XDMF_GEOMETRY_TYPE_XY 302
#endif
/**
* Grid Collection Type
......@@ -129,7 +133,15 @@ class XdmfHDF5WriterDSM;
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729 525
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000 526
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331 527
#define XDMF_TOPOLOGY_TYPE_MIXED 528
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_64 528
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_125 529
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_216 530
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_343 531
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_512 532
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_729 533
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1000 534
#define XDMF_TOPOLOGY_TYPE_HEXAHEDRON_SPECTRAL_1331 535
#define XDMF_TOPOLOGY_TYPE_MIXED 536
/**
* Set Type
......@@ -183,9 +195,6 @@ class XdmfHDF5WriterDSM;
#define XdmfWriteToDSM xdmfwritetodsm_
#define XdmfWriteHDF5 xdmfwritehdf5_
#define XdmfInitHDF5 xdmfinithdf5_
#define XdmfGetMaxOpenedFiles xdmfgetmaxopenedfiles_
#define XdmfSetMaxOpenedFiles xdmfsetmaxopenedfiles_
#define XdmfCloseOpenedHDF5Files xdmfcloseopenedhdf5files_
#define XdmfSetTopologyPolyline xdmfsettopologypolyline_
#define XdmfSetTopologyPolygon xdmfsettopologypolygon_
#define XdmfRetrieveNumDomainGridCollections xdmfretrievenumdomaingridcollections_
......
......@@ -26,8 +26,6 @@ PROGRAM XdmfFortranExample
filename = 'nested_output.xmf'//CHAR(0)
buffersize = 16/commsize
if (buffersize < 1) then
buffersize = 1
endif
......@@ -39,6 +37,8 @@ PROGRAM XdmfFortranExample
CALL MPI_COMM_RANK(MPI_COMM_WORLD, id, ierr)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, commsize, ierr)
buffersize = 16/commsize
!! Cores 1 to size-1 are blocked by the initialization of the server.
!! When the server finishes they are released and allowed to progress.
CALL XDMFINITDSMSERVER(obj, "dsm"//CHAR(0), MPI_COMM_WORLD, bufferSize, 1, commsize-1)
......@@ -53,7 +53,9 @@ PROGRAM XdmfFortranExample
CALL MPI_BARRIER(interComm, ierr)
if (id == 0) then
CALL XDMFCLOSEDSMPORT(obj)
endif
CALL XDMFCLOSE(obj)
......
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