Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

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

added tests for functions and removed warnings during splitting algorithm

parent 273290a2
...@@ -1489,9 +1489,20 @@ XdmfHDF5Writer::write(XdmfArray & array, ...@@ -1489,9 +1489,20 @@ XdmfHDF5Writer::write(XdmfArray & array,
fapl); fapl);
} }
hid_t dataset = H5Dopen(mImpl->mHDF5Handle, htri_t testingSet = H5Lexists(mImpl->mHDF5Handle,
dataSetPath.str().c_str(), dataSetPath.str().c_str(),
H5P_DEFAULT); H5P_DEFAULT);
hid_t dataset = 0;
if (testingSet == 0) {
dataset = -1;
}
else {
dataset = H5Dopen(mImpl->mHDF5Handle,
dataSetPath.str().c_str(),
H5P_DEFAULT);
}
//hid_t checkspace = H5S_ALL; //hid_t checkspace = H5S_ALL;
//checkspace = H5Dget_space(dataset); //checkspace = H5Dget_space(dataset);
......
...@@ -20,6 +20,7 @@ ADD_TEST_CXX(TestXdmfMap) ...@@ -20,6 +20,7 @@ ADD_TEST_CXX(TestXdmfMap)
ADD_TEST_CXX(TestXdmfReader) ADD_TEST_CXX(TestXdmfReader)
ADD_TEST_CXX(TestXdmfRegularGrid) ADD_TEST_CXX(TestXdmfRegularGrid)
ADD_TEST_CXX(TestXdmfRectilinearGrid) ADD_TEST_CXX(TestXdmfRectilinearGrid)
ADD_TEST_CXX(XdmfPostFixCalc)
ADD_TEST_CXX(TestXdmfSet) ADD_TEST_CXX(TestXdmfSet)
ADD_TEST_CXX(TestXdmfTime) ADD_TEST_CXX(TestXdmfTime)
ADD_TEST_CXX(TestXdmfTopology) ADD_TEST_CXX(TestXdmfTopology)
...@@ -68,6 +69,7 @@ CLEAN_TEST_CXX(TestXdmfRectilinearGrid ...@@ -68,6 +69,7 @@ CLEAN_TEST_CXX(TestXdmfRectilinearGrid
CLEAN_TEST_CXX(TestXdmfRegularGrid CLEAN_TEST_CXX(TestXdmfRegularGrid
TestXdmfRegularGrid1.xmf TestXdmfRegularGrid1.xmf
TestXdmfRegularGrid2.xmf) TestXdmfRegularGrid2.xmf)
CLEAN_TEST_CXX(XdmfPostFixCalc)
CLEAN_TEST_CXX(TestXdmfSet) CLEAN_TEST_CXX(TestXdmfSet)
CLEAN_TEST_CXX(TestXdmfTime) CLEAN_TEST_CXX(TestXdmfTime)
CLEAN_TEST_CXX(TestXdmfTopology) CLEAN_TEST_CXX(TestXdmfTopology)
...@@ -82,4 +84,4 @@ CLEAN_TEST_CXX(TestXdmfWriter ...@@ -82,4 +84,4 @@ CLEAN_TEST_CXX(TestXdmfWriter
CLEAN_TEST_CXX(TestXdmfWriterHDF5ThenXML) CLEAN_TEST_CXX(TestXdmfWriterHDF5ThenXML)
CLEAN_TEST_CXX(TestXdmfXPath CLEAN_TEST_CXX(TestXdmfXPath
XdmfXPath1.xmf XdmfXPath1.xmf
XdmfXPath2.xmf) XdmfXPath2.xmf)
\ No newline at end of file
...@@ -65,14 +65,14 @@ int main(int, char **) ...@@ -65,14 +65,14 @@ int main(int, char **)
writtenArray->release(); writtenArray->release();
writtenArray->read(); writtenArray->read();
printf("after read\n"); std::cout << "after read" << std::endl;
printf("array size = %d\n", writtenArray->getSize()); std::cout << "array size = " << writtenArray->getSize() << std::endl;
assert(writtenArray->getSize() == 9000000); assert(writtenArray->getSize() == 9000000);
for (int i = 0; i < writtenArray->getSize(); i++) for (int i = 0; i < writtenArray->getSize(); i++)
{ {
if (i != writtenArray->getValue<int>(i)) if (i != writtenArray->getValue<int>(i))
{ {
printf("%d doesn't match %d\n", i, writtenArray->getValue<int>(i)); std::cout << i << " doesn't match " << writtenArray->getValue<int>(i) << std::endl;
} }
assert(i == writtenArray->getValue<int>(i)); assert(i == writtenArray->getValue<int>(i));
} }
......
...@@ -36,7 +36,12 @@ std::map<std::string, shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArra ...@@ -36,7 +36,12 @@ std::map<std::string, shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArra
int main(int, char **) int main(int, char **)
{ {
XdmfArray::addFunction("MAX", maximum); XdmfArray::addFunction("MAX", maximum);
XdmfArray::addCalculation('@', invChunk, 2); XdmfArray::addOperation('&', invChunk, 2);
XdmfArray::addOperation('!', invChunk, 2);
XdmfArray::addOperation('^', invChunk, 2);
XdmfArray::addOperation('>', invChunk, 2);
XdmfArray::addOperation('<', invChunk, 2);
XdmfArray::addOperation('@', invChunk, 2);
functions["AVE"] = ave; functions["AVE"] = ave;
//sometimes typecasts are required, sometimes they cause errors //sometimes typecasts are required, sometimes they cause errors
...@@ -55,7 +60,10 @@ int main(int, char **) ...@@ -55,7 +60,10 @@ int main(int, char **)
double answer = parse(problemToSolve, variableTable); double answer = parse(problemToSolve, variableTable);
printf("%f\n", answer); std::cout << answer << std::endl;
//unless the calculation is fully written out it won't equal properly
assert(answer == 2*25+2*3+(double)2048/3+(double)8/5+4+100+6+25);
//std::string arrayExpression = "A|B#C|D"; //std::string arrayExpression = "A|B#C|D";
std::string arrayExpression = "MAX(2,(AVE(A@B)#AVE(C|D)))"; std::string arrayExpression = "MAX(2,(AVE(A@B)#AVE(C|D)))";
...@@ -93,37 +101,50 @@ int main(int, char **) ...@@ -93,37 +101,50 @@ int main(int, char **)
arrayVariable["D"] = testArray4; arrayVariable["D"] = testArray4;
arrayVariable["E"] = testArray5; arrayVariable["E"] = testArray5;
printf("before parsing\n"); std::cout << "before parsing" << std::endl;
shared_ptr<XdmfArray> answerArray; shared_ptr<XdmfArray> answerArray;
answerArray = parse(arrayExpression, arrayVariable); answerArray = parse(arrayExpression, arrayVariable);
printf("after parsing\n"); std::cout << "after parsing" << std::endl;
std::cout << "answer array = " << answerArray->getValuesString() << std::endl;
assert(answerArray->getValuesString().compare("3.5") == 0);
std::cout << "array size = " << answerArray->getSize() << std::endl;
assert(answerArray->getSize() == 1);
printf("answer array = %s\n", answerArray->getValuesString()); std::cout << "interlace" << std::endl;
printf("array size = %d\n", answerArray->getSize()); answerArray = XdmfArray::evaluateOperation(testArray1, testArray5, '#');
std::cout << "answer array = " << answerArray->getValuesString() << std::endl;
printf("interlace\n"); assert(answerArray->getValuesString().compare("1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 5 5 5") == 0);
answerArray = XdmfArray::evaluateCalculation(testArray1, testArray5, '#');
printf("answer array = %s\n", answerArray->getValuesString());
printf("chunk\n");
answerArray = XdmfArray::evaluateCalculation(testArray1, testArray5, '|');
printf("answer array = %s\n", answerArray->getValuesString());
printf("inverse chunk\n");
answerArray = XdmfArray::evaluateCalculation(testArray1, testArray5, '@');
printf("answer array = %s\n", answerArray->getValuesString());
printf("after parsing\n"); std::cout << "chunk" << std::endl;
answerArray = XdmfArray::evaluateOperation(testArray1, testArray5, '|');
std::cout << "answer array = " << answerArray->getValuesString() << std::endl;
printf("answer array = %s\n", answerArray->getValuesString()); assert(answerArray->getValuesString().compare("1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 5 5 5 5 5 5 5") == 0);
printf("array size = %d\n", answerArray->getSize());
std::cout << "inverse chunk" << std::endl;
answerArray = XdmfArray::evaluateOperation(testArray1, testArray5, '@');
std::cout << "answer array = " << answerArray->getValuesString() << std::endl;
assert(answerArray->getValuesString().compare("5 5 5 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1 1") == 0);
answerArray = XdmfArray::evaluateExpression(arrayExpression, arrayVariable); answerArray = XdmfArray::evaluateExpression(arrayExpression, arrayVariable);
printf("after parsing\n"); std::cout << "after parsing" << std::endl;
std::cout << "answer array = " << answerArray->getValuesString() << std::endl;
assert(answerArray->getValuesString().compare("3.5") == 0);
std::cout << "array size = " << answerArray->getSize() << std::endl;
printf("answer array = %s\n", answerArray->getValuesString()); assert(answerArray->getSize() == 1);
printf("array size = %d\n", answerArray->getSize());
return 0; return 0;
} }
...@@ -175,7 +196,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -175,7 +196,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
{ {
if (functions.find(expression.substr(valueStart, i + 1 - valueStart)) == functions.end()) if (functions.find(expression.substr(valueStart, i + 1 - valueStart)) == functions.end())
{ {
printf("Error: Invalid Variable or Function: %s\n", expression.substr(valueStart, i + 1 - valueStart)); std::cout << "Error: Invalid Variable or Function: " << expression.substr(valueStart, i + 1 - valueStart) << std::endl;
return 0; return 0;
} }
else else
...@@ -184,7 +205,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -184,7 +205,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
//check if next character is an open parenthesis //check if next character is an open parenthesis
if (expression[i+1] != '(') if (expression[i+1] != '(')
{ {
printf("Error: No values supplied to function %s\n", expression.substr(valueStart, i + 1 - valueStart)); std::cout << "Error: No values supplied to function " << expression.substr(valueStart, i + 1 - valueStart) << std::endl;
return 0; return 0;
} }
//if it is grab the string between paranthesis //if it is grab the string between paranthesis
...@@ -244,7 +265,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -244,7 +265,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
if (valueStack.size() < 2)//must be at least two values for this loop to work properly if (valueStack.size() < 2)//must be at least two values for this loop to work properly
{ {
//error, not enough values //error, not enough values
printf("Error: Not Enough Values\n"); std::cout << "Error: Not Enough Values" << std::endl;
return 0; return 0;
} }
else else
...@@ -275,7 +296,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -275,7 +296,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
if (valueStack.size() < 2)//must be at least two values for this loop to work properly if (valueStack.size() < 2)//must be at least two values for this loop to work properly
{ {
//error, not enough values //error, not enough values
printf("Error: Not Enough Values\n"); std::cout << "Error: Not Enough Values" << std::endl;
return 0; return 0;
} }
else else
...@@ -310,14 +331,14 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -310,14 +331,14 @@ double parse(std::string expression, std::map<std::string, double> variables)
if (valueStack.size() < 2)//must be at least two values for this loop to work properly if (valueStack.size() < 2)//must be at least two values for this loop to work properly
{ {
//error, not enough values //error, not enough values
printf("Error: Not Enough Values\n"); std::cout << "Error: Not Enough Values" << std::endl;
return 0; return 0;
} }
else else
{ {
if(operationStack.top() == '(') if(operationStack.top() == '(')
{ {
printf("Warning: Unpaired Parenthesis\n"); std::cout << "Warning: Unpaired Parenthesis" << std::endl;
operationStack.pop(); operationStack.pop();
} }
else else
...@@ -329,7 +350,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -329,7 +350,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
if (operationStack.size() == 0) if (operationStack.size() == 0)
{ {
//error, not enough operations //error, not enough operations
printf("Error: Not Enough Operators\n"); std::cout << "Error: Not Enough Operators" << std::endl;
return 0; return 0;
} }
else else
...@@ -344,7 +365,7 @@ double parse(std::string expression, std::map<std::string, double> variables) ...@@ -344,7 +365,7 @@ double parse(std::string expression, std::map<std::string, double> variables)
//throw error if there's extra operations //throw error if there's extra operations
if (operationStack.size() > 0) if (operationStack.size() > 0)
{ {
printf("Warning: Left Over Operators\n"); std::cout << "Warning: Left Over Operators" << std::endl;
} }
return valueStack.top(); return valueStack.top();
...@@ -447,7 +468,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -447,7 +468,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
{ {
if (arrayFunctions.find(expression.substr(valueStart, i + 1 - valueStart)) == arrayFunctions.end()) if (arrayFunctions.find(expression.substr(valueStart, i + 1 - valueStart)) == arrayFunctions.end())
{ {
printf("Error: Invalid Variable or Function\n"); std::cout << "Error: Invalid Variable or Function" << std::endl;
return XdmfArray::New(); return XdmfArray::New();
} }
else else
...@@ -456,7 +477,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -456,7 +477,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
//check if next character is an open parenthesis //check if next character is an open parenthesis
if (expression[i+1] != '(') if (expression[i+1] != '(')
{ {
printf("Error: No Values Supplied to Function %s\n", expression.substr(valueStart, i + 1 - valueStart)); std::cout << "Error: No Values Supplied to Function " << expression.substr(valueStart, i + 1 - valueStart) << std::endl;
return XdmfArray::New(); return XdmfArray::New();
} }
//if it is grab the string between paranthesis //if it is grab the string between paranthesis
...@@ -546,7 +567,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -546,7 +567,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
if (valueStack.size() < 2)//must be at least two values for this loop to work properly if (valueStack.size() < 2)//must be at least two values for this loop to work properly
{ {
//error, not enough values //error, not enough values
printf("Error: Not Enough Values\n"); std::cout << "Error: Not Enough Values" << std::endl;
return XdmfArray::New(); return XdmfArray::New();
} }
else else
...@@ -581,13 +602,13 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -581,13 +602,13 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
{ {
if(operationStack.top() == '(') if(operationStack.top() == '(')
{ {
printf("Warning: Unpaired Parenthesis\n"); std::cout << "Warning: Unpaired Parenthesis" << std::endl;
operationStack.pop(); operationStack.pop();
} }
else if (valueStack.size() < 2)//must be at least two values for this loop to work properly else if (valueStack.size() < 2)//must be at least two values for this loop to work properly
{ {
//error, not enough values //error, not enough values
printf("Error: Not Enough Values\n"); std::cout << "Error: Not Enough Values" << std::endl;
return XdmfArray::New(); return XdmfArray::New();
} }
else else
...@@ -599,7 +620,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -599,7 +620,7 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
if (operationStack.size() == 0) if (operationStack.size() == 0)
{ {
//error, not enough operations //error, not enough operations
printf("Error: Not Enough Operators\n"); std::cout << "Error: Not Enough Operators" << std::endl;
return XdmfArray::New(); return XdmfArray::New();
} }
else else
...@@ -613,12 +634,12 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared ...@@ -613,12 +634,12 @@ shared_ptr<XdmfArray> parse(std::string expression, std::map<std::string, shared
//throw error if there's extra operations //throw error if there's extra operations
if (operationStack.size() > 0) if (operationStack.size() > 0)
{ {
printf("Warning: Left Over Operators\n"); std::cout << "Warning: Left Over Operators" << std::endl;
} }
if (valueStack.size() > 1) if (valueStack.size() > 1)
{ {
printf("Warning: Left Over Values\n"); std::cout << "Warning: Left Over Values" << std::endl;
} }
return valueStack.top(); return valueStack.top();
......
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