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

Formatting changes and removing warnings

parent 03e031e0
......@@ -54,7 +54,7 @@ XdmfGraph::getItemTag() const
unsigned int
XdmfGraph::getNumberNodes() const
{
//The number of nodes is equal to the number of rows or columns. Either will work.
// The number of nodes is equal to the number of rows or columns. Either will work.
return this->getNumberRows();
}
......
......@@ -219,19 +219,18 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
}
else {
//this needs to be changed to account for controllers being a vector now
mRemoteTaskIdsControllers.clear();
for (unsigned int i = 0; i < arrayVector[0]->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < arrayVector[0]->getNumberHeavyDataControllers(); ++i)
{
mRemoteTaskIdsControllers.push_back(arrayVector[0]->getHeavyDataController(i));
}
mLocalNodeIdsControllers.clear();
for (unsigned int i = 0; i < arrayVector[1]->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < arrayVector[1]->getNumberHeavyDataControllers(); ++i)
{
mLocalNodeIdsControllers.push_back(arrayVector[1]->getHeavyDataController(i));
}
mRemoteLocalNodeIdsControllers.clear();
for (unsigned int i = 0; i < arrayVector[2]->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < arrayVector[2]->getNumberHeavyDataControllers(); ++i)
{
mRemoteLocalNodeIdsControllers.push_back(arrayVector[2]->getHeavyDataController(i));
}
......@@ -247,17 +246,17 @@ XdmfMap::read()
mRemoteLocalNodeIdsControllers.size() > 0) {
unsigned int localNodeCount = 0;
for (unsigned int i = 0; i< mLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i< mLocalNodeIdsControllers.size(); ++i)
{
localNodeCount += mLocalNodeIdsControllers[i]->getSize();
}
unsigned int remoteTaskCount = 0;
for (unsigned int i = 0; i< mRemoteTaskIdsControllers.size(); i++)
for (unsigned int i = 0; i< mRemoteTaskIdsControllers.size(); ++i)
{
remoteTaskCount += mRemoteTaskIdsControllers[i]->getSize();
}
unsigned int remoteNodeCount = 0;
for (unsigned int i = 0; i< mRemoteLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i< mRemoteLocalNodeIdsControllers.size(); ++i)
{
remoteNodeCount += mRemoteLocalNodeIdsControllers[i]->getSize();
}
......@@ -280,21 +279,21 @@ XdmfMap::read()
shared_ptr<XdmfArray> remoteLocalNodeIds = XdmfArray::New();
mRemoteTaskIdsControllers[0]->read(remoteTaskIds.get());
for (unsigned int i = 1; i < mRemoteTaskIdsControllers.size(); i++)
for (unsigned int i = 1; i < mRemoteTaskIdsControllers.size(); ++i)
{
shared_ptr<XdmfArray> tempArray = XdmfArray::New();
mRemoteTaskIdsControllers[i]->read(tempArray.get());
remoteTaskIds->insert(remoteTaskIds->getSize(), tempArray, 0, tempArray->getSize());
}
mLocalNodeIdsControllers[0]->read(localNodeIds.get());
for (unsigned int i = 1; i < mLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 1; i < mLocalNodeIdsControllers.size(); ++i)
{
shared_ptr<XdmfArray> tempArray = XdmfArray::New();
mLocalNodeIdsControllers[i]->read(tempArray.get());
localNodeIds->insert(localNodeIds->getSize(), tempArray, 0, tempArray->getSize());
}
mRemoteLocalNodeIdsControllers[0]->read(remoteLocalNodeIds.get());
for (unsigned int i = 1; i < mRemoteLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 1; i < mRemoteLocalNodeIdsControllers.size(); ++i)
{
shared_ptr<XdmfArray> tempArray = XdmfArray::New();
mRemoteLocalNodeIdsControllers[i]->read(tempArray.get());
......@@ -324,17 +323,17 @@ XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController>
std::vector<shared_ptr<XdmfHeavyDataController> > remoteLocalNodeIdsControllers)
{
unsigned int localNodeCount = 0;
for (unsigned int i = 0; i< localNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i< localNodeIdsControllers.size(); ++i)
{
localNodeCount += localNodeIdsControllers[i]->getSize();
}
unsigned int remoteTaskCount = 0;
for (unsigned int i = 0; i< remoteTaskIdsControllers.size(); i++)
for (unsigned int i = 0; i< remoteTaskIdsControllers.size(); ++i)
{
remoteTaskCount += remoteTaskIdsControllers[i]->getSize();
}
unsigned int remoteNodeCount = 0;
for (unsigned int i = 0; i< remoteLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i< remoteLocalNodeIdsControllers.size(); ++i)
{
remoteNodeCount += remoteLocalNodeIdsControllers[i]->getSize();
}
......@@ -396,15 +395,15 @@ XdmfMap::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
}
}
for (unsigned int i = 0; i < mRemoteTaskIdsControllers.size(); i++)
for (unsigned int i = 0; i < mRemoteTaskIdsControllers.size(); ++i)
{
remoteTaskIds->insert(mRemoteTaskIdsControllers[i]);
}
for (unsigned int i = 0; i < mLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i < mLocalNodeIdsControllers.size(); ++i)
{
localNodeIds->insert(mLocalNodeIdsControllers[i]);
}
for (unsigned int i = 0; i < mRemoteLocalNodeIdsControllers.size(); i++)
for (unsigned int i = 0; i < mRemoteLocalNodeIdsControllers.size(); ++i)
{
remoteLocalNodeIds->insert(mRemoteLocalNodeIdsControllers[i]);
}
......@@ -417,15 +416,15 @@ XdmfMap::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
mRemoteTaskIdsControllers.clear();
mRemoteLocalNodeIdsControllers.clear();
for (unsigned int i = 0; i < remoteTaskIds->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < remoteTaskIds->getNumberHeavyDataControllers(); ++i)
{
mRemoteTaskIdsControllers.push_back(remoteTaskIds->getHeavyDataController(i));
}
for (unsigned int i = 0; i < localNodeIds->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < localNodeIds->getNumberHeavyDataControllers(); ++i)
{
mLocalNodeIdsControllers.push_back(localNodeIds->getHeavyDataController(i));
}
for (unsigned int i = 0; i < remoteLocalNodeIds->getNumberHeavyDataControllers(); i++)
for (unsigned int i = 0; i < remoteLocalNodeIds->getNumberHeavyDataControllers(); ++i)
{
mRemoteLocalNodeIdsControllers.push_back(remoteLocalNodeIds->getHeavyDataController(i));
}
......
......@@ -38,13 +38,13 @@
std::string XdmfArray::mSupportedOperations = "|#()";
const std::string XdmfArray::mValidVariableChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_:.";
const std::string XdmfArray::mValidDigitChars = "-1234567890.";
//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
// 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
int XdmfArray::mOperationPriority [8] = {2, 1, 0, 0};
//the higher the value, the earlier the operation is evaluated in the order of operations
//with the exception of parenthesis which are evaluated as soon as the closing parenthesis is found
// the higher the value, the earlier the operation is evaluated in the order of operations
// with the exception of parenthesis which are evaluated as soon as the closing parenthesis is found
//note, it doesn't handle overloaded functions well. Will generate errors unless overload methods are typecast.
// note, it doesn't handle overloaded functions well. Will generate errors unless overload methods are typecast.
std::map<std::string, shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >)> XdmfArray::arrayFunctions = boost::assign::map_list_of ("SUM", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))XdmfArray::sum) ("AVE", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))XdmfArray::ave);
std::map<char, shared_ptr<XdmfArray> (*)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>)> XdmfArray::operations = boost::assign::map_list_of ('|', XdmfArray::chunk) ('#', XdmfArray::interlace);
......@@ -539,7 +539,7 @@ public:
{
if(mArray->mHeavyDataControllers.size()>0) {
int total = 0;
for (unsigned int i = 0; i < mArray->mHeavyDataControllers.size(); i++) {
for (unsigned int i = 0; i < mArray->mHeavyDataControllers.size(); ++i) {
total += mArray->mHeavyDataControllers[i]->getSize();
}
return total;
......@@ -586,6 +586,53 @@ XdmfArray::~XdmfArray()
const std::string XdmfArray::ItemTag = "DataItem";
int
XdmfArray::addFunction(std::string name, shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >))
{
// check to ensure that the name has valid characters
for (unsigned int i = 0; i < name.size(); ++i) {
// if the character is not found in the list of valid characters
if (mValidVariableChars.find(name[i]) == std::string::npos) {
// then throw an error
try {
XdmfError::message(XdmfError::FATAL,
"Error: Function Name Contains Invalid Character(s)");
}
catch (XdmfError e) {
throw e;
}
}
}
size_t origsize = arrayFunctions.size();
arrayFunctions[name] = functionref;
// if no new functions were added
if (origsize == arrayFunctions.size()) {
// toss a warning, it's nice to let people know that they're doing this
try {
XdmfError::message(XdmfError::WARNING,
"Warning: Function Overwritten");
}
catch (XdmfError e) {
throw e;
}
}
return arrayFunctions.size();
}
shared_ptr<XdmfArray>
XdmfArray::ave(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;
}
void
XdmfArray::clear()
{
......@@ -594,6 +641,17 @@ XdmfArray::clear()
mDimensions.clear();
}
shared_ptr<XdmfArray>
XdmfArray::chunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
{
// join chunk (add the new array to the end of the first one)
// joins into new array and returns it
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->insert(0, val1, 0, val1->getSize(), 1, 1);
returnArray->insert(val1->getSize(), val2, 0, val2->getSize(), 1, 1);
return returnArray;
}
void
XdmfArray::erase(const unsigned int index)
{
......@@ -603,35 +661,41 @@ XdmfArray::erase(const unsigned int index)
mDimensions.clear();
}
//This function and the functions it depends on are reimplemented in XdmfCore.i in order to properly interface with python.
//There are differences between the versions, but the overall algorithm remains mostly the same.
// This function and the functions it depends on are reimplemented in XdmfCore.i in order to properly interface with python.
// There are differences between the versions, but the overall algorithm remains mostly the same.
shared_ptr<XdmfArray>
XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shared_ptr<XdmfArray> > variables)
{
std::stack<shared_ptr<XdmfArray> > valueStack;
std::stack<char> operationStack;
//string is parsed left to right
//elements of the same priority are evaluated right to left
for (unsigned int i = 0; i < expression.size(); i++) {
// string is parsed left to right
// elements of the same priority are evaluated right to left
for (unsigned int i = 0; i < expression.size(); ++i) {
if (mValidDigitChars.find(expression[i]) != std::string::npos) {//found to be a digit
//progress until a non-digit is found
// progress until a non-digit is found
int valueStart = i;
while (mValidDigitChars.find(expression[i + 1]) != std::string::npos) {
i++;
if (i + 1 < expression.size()) {
while (mValidDigitChars.find(expression[i+1]) != std::string::npos) {
i++;
}
}
//push back to the value stack
// push back to the value stack
shared_ptr<XdmfArray> valueArray = XdmfArray::New();
valueArray->insert(0, atof(expression.substr(valueStart, i + 1 - valueStart).c_str()));//use this to convert to double
// use this to convert to double
valueArray->insert(0, atof(expression.substr(valueStart, i + 1 - valueStart).c_str()));
valueStack.push(valueArray);
}
else if (mValidVariableChars.find(expression[i]) != std::string::npos) {//found to be a variable
else if (mValidVariableChars.find(expression[i]) != std::string::npos) {
// found to be a variable
int valueStart = i;
//progress until a nonvariable value is found
while (mValidVariableChars.find(expression[i + 1]) != std::string::npos) {
i++;
// progress until a nonvariable value is found
if (i+1 < expression.size()){
while (mValidVariableChars.find(expression[i+1]) != std::string::npos) {
i++;
}
}
//convert to equivalent
// convert to equivalent
if (variables.find(expression.substr(valueStart, i + 1 - valueStart)) == variables.end()) {
if (arrayFunctions.find(expression.substr(valueStart, i + 1 - valueStart)) == arrayFunctions.end()) {
try {
......@@ -644,17 +708,24 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
}
else {
std::string currentFunction = expression.substr(valueStart, i + 1 - valueStart);
//check if next character is an open parenthesis
if (expression[i+1] != '(') {
try {
XdmfError::message(XdmfError::FATAL,
"Error: No values supplied to function " + expression.substr(valueStart, i + 1 - valueStart));
}
catch (XdmfError e) {
throw e;
// check if next character is an open parenthesis
if (i+1 >= expression.size()) {
if (expression[i+1] != '(') {
try {
XdmfError::message(XdmfError::FATAL,
"Error: No values supplied to function " + expression.substr(valueStart, i + 1 - valueStart));
}
catch (XdmfError e) {
throw e;
}
}
}
//if it is grab the string between paranthesis
// if it is grab the string between paranthesis
if (i + 2 >= expression.size()) {
XdmfError::message(XdmfError::FATAL,
"Error: Missing closing parethesis to function " + expression.substr(valueStart, i + 1 - valueStart));
}
i = i + 2;
valueStart = i;
int numOpenParenthesis = 0;
......@@ -669,12 +740,12 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
}
std::string functionParameters = expression.substr(valueStart, i - valueStart);
std::vector<shared_ptr<XdmfArray> > parameterVector;
//split that string at commas
// split that string at commas
size_t parameterSplit = 0;
while (parameterSplit != std::string::npos) {
parameterSplit = 0;
parameterSplit = functionParameters.find_first_of(",", parameterSplit);
//feed the substrings to the parse function
// feed the substrings to the parse function
if (parameterSplit == std::string::npos) {
parameterVector.push_back(evaluateExpression(functionParameters, variables));
}
......@@ -687,17 +758,19 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
}
}
else {
//push equivalent to value stack
// push equivalent to value stack
valueStack.push(variables.find(expression.substr(valueStart, i + 1 - valueStart))->second);
}
}
else if (mSupportedOperations.find(expression[i]) != std::string::npos) {//found to be an operation
//pop operations off the stack until one of a lower or equal importance is found
else if (mSupportedOperations.find(expression[i]) != std::string::npos) {
// found to be an operation
// pop operations off the stack until one of a lower or equal importance is found
if (operationStack.size() > 0) {
if (expression[i] == ')') {
//to close a parenthesis pop off all operations until another parentheis is found
// to close a parenthesis pop off all operations until another parentheis is found
while (operationStack.size() > 0 && operationStack.top() != '(') {
if (valueStack.size() < 2) {//must be at least two values for this loop to work properly
// must be at least two values for this loop to work properly
if (valueStack.size() < 2) {
try {
XdmfError::message(XdmfError::FATAL,
"Error: Not Enough Values in evaluateExpression");
......@@ -718,16 +791,17 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
operationStack.pop();
}
else if (expression[i] == '(') {
//just add it if it's a start parenthesis
//nothing happens here in that case
//addition happens after the if statement
// just add it if it's a start parenthesis
// nothing happens here in that case
// addition happens after the if statement
}
else {
int operationLocation = getOperationPriority(expression[i]);
int topOperationLocation = getOperationPriority(operationStack.top());
//see order of operations to determine importance
// see order of operations to determine importance
while (operationStack.size() > 0 && operationLocation < topOperationLocation) {
if (valueStack.size() < 2) {//must be at least two values for this loop to work properly
// must be at least two values for this loop to work properly
if (valueStack.size() < 2) {
try {
XdmfError::message(XdmfError::FATAL,
"Error: Not Enough Values in evaluateExpression");
......@@ -752,14 +826,14 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
}
}
if (expression[i] != ')') {
//add the operation to the operation stack
// add the operation to the operation stack
operationStack.push(expression[i]);
}
}
//if not a value or operation the character is ignored
// if not a value or operation the character is ignored
}
//empty what's left in the stacks before finishing
// empty what's left in the stacks before finishing
while (valueStack.size() > 1 && operationStack.size() > 0) {
if (valueStack.size() < 2) {//must be at least two values for this loop to work properly
try {
......@@ -802,7 +876,7 @@ XdmfArray::evaluateExpression(std::string expression, std::map<std::string, shar
}
}
//throw error if there's extra operations
// throw error if there's extra operations
if (operationStack.size() > 0) {
try {
XdmfError::message(XdmfError::WARNING,
......@@ -849,10 +923,12 @@ XdmfArray::addOperation(char newoperator, shared_ptr<XdmfArray>(*operationref)(s
throw e;
}
}
//give warning if the operation already exists
// give warning if the operation already exists
size_t origsize = operations.size();
operations[newoperator] = operationref;//place reference in the associated location
if (origsize == operations.size()) {//it's nice to let people know they're doing this so they don't get surprised about changes in behavior
// place reference in the associated location
operations[newoperator] = operationref;
// it's nice to let people know they're doing this so they don't get surprised about changes in behavior
if (origsize == operations.size()) {
try {
XdmfError::message(XdmfError::WARNING,
"Warning: Function Overwritten");
......@@ -860,14 +936,14 @@ XdmfArray::addOperation(char newoperator, shared_ptr<XdmfArray>(*operationref)(s
catch (XdmfError e) {
throw e;
}
//overwrite the existing info for that operation
//add the priority to the specified location in the priority array
// overwrite the existing info for that operation
// add the priority to the specified location in the priority array
size_t priorityLocation = mSupportedOperations.find(newoperator);
mOperationPriority[priorityLocation] = priority;
}
else {
//create new operation
//as long as the operation isn't a valid function character
// create new operation
// as long as the operation isn't a valid function character
if (mValidVariableChars.find(newoperator) != std::string::npos || mValidDigitChars.find(newoperator) != std::string::npos) {
try {
XdmfError::message(XdmfError::FATAL,
......@@ -877,12 +953,14 @@ XdmfArray::addOperation(char newoperator, shared_ptr<XdmfArray>(*operationref)(s
throw e;
}
}
else { //build the operation
//add operation to the supported character string
else {
// build the operation
// add operation to the supported character string
mSupportedOperations.push_back(newoperator);
unsigned int priorityArraySize = sizeof(mOperationPriority)/sizeof(int);
if (mSupportedOperations.size()-1 > priorityArraySize) {//first check to see if the priority array is large enough
//if it isn't make it bigger, double size should be fine
// first check to see if the priority array is large enough
if (mSupportedOperations.size()-1 > priorityArraySize) {
// if it isn't make it bigger, double size should be fine
int newArray [priorityArraySize*2];
std::copy(mOperationPriority, mOperationPriority+(priorityArraySize-1), newArray);
*mOperationPriority = *newArray;
......@@ -894,469 +972,95 @@ XdmfArray::addOperation(char newoperator, shared_ptr<XdmfArray>(*operationref)(s
return operations.size();
}
// this is how you use references to functions
shared_ptr<XdmfArray>
XdmfArray::chunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
XdmfArray::evaluateFunction(std::vector<shared_ptr<XdmfArray> > valueVector, std::string functionName)
{
//join chunk (add the new array to the end of the first one)
//joins into new array and returns it
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->insert(0, val1, 0, val1->getSize(), 1, 1);
returnArray->insert(val1->getSize(), val2, 0, val2->getSize(), 1, 1);
return returnArray;
if (arrayFunctions.find(functionName) != arrayFunctions.end()) {
return (*(shared_ptr<XdmfArray>(*)(std::vector<shared_ptr<XdmfArray> >))arrayFunctions[functionName])(valueVector);
}
else {
return shared_ptr<XdmfArray>();
}
}
shared_ptr<XdmfArray>
XdmfArray::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
shared_ptr<const XdmfArrayType>
XdmfArray::getArrayType() const
{
//join interlace (evenly space the second array within the first one)
//builds a new array
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
//resize to the combined size of both arrays
//determining what type to class it as in order to not lose data, and to still have the smallest data type of the two
shared_ptr<const XdmfArrayType> arrayType1 = val1->getArrayType();
shared_ptr<const XdmfArrayType> arrayType2 = val2->getArrayType();
if (arrayType1 == XdmfArrayType::Int8()) {
//if floats reclass as floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float32()) {
float sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float64()) {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
//if uints reclass as ints of the appropriate size
else if (arrayType2 == XdmfArrayType::Int64() || arrayType2 == XdmfArrayType::UInt32()) {
long sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Int32() || arrayType2 == XdmfArrayType::UInt16()) {
int sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Int16() || arrayType2 == XdmfArrayType::UInt8()) {
short sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
char sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
if (mHeavyDataControllers.size()>0) {
return boost::apply_visitor(GetArrayType(mHeavyDataControllers[0]),
mArray);
}
else if (arrayType1 == XdmfArrayType::Int16()) {
//if floats reclass as floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float32()) {
float sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float64()) {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
//if uints reclass as ints of the appropriate size
else if (arrayType2 == XdmfArrayType::Int64() || arrayType2 == XdmfArrayType::UInt32()) {
long sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Int32() || arrayType2 == XdmfArrayType::UInt16()) {
int sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else
{
short sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
return boost::apply_visitor(GetArrayType(shared_ptr<XdmfHDF5Controller>()),
mArray);
}
else if (arrayType1 == XdmfArrayType::Int32()) {
//if floats reclass as floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float32()) {
float sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float64()) {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
//if uints reclass as ints of the appropriate size
else if (arrayType2 == XdmfArrayType::Int64() || arrayType2 == XdmfArrayType::UInt32()) {
long sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
int sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
unsigned int
XdmfArray::getCapacity() const
{
return boost::apply_visitor(GetCapacity(),
mArray);
}
std::vector<unsigned int>
XdmfArray::getDimensions() const
{
if(mDimensions.size() == 0) {
if(!this->isInitialized() && mHeavyDataControllers.size() > 0) {
std::vector<unsigned int> returnDimensions;
std::vector<unsigned int> tempDimensions;
// find the controller with the most dimensions
int dimControllerIndex = 0;
unsigned int dimSizeMax = 0;
unsigned int dimTotal = 0;
for (unsigned int i = 0; i < mHeavyDataControllers.size(); ++i) {
dimTotal += mHeavyDataControllers[i]->getSize();
if (mHeavyDataControllers[i]->getSize() > dimSizeMax) {
dimSizeMax = mHeavyDataControllers[i]->getSize();
dimControllerIndex = i;
}
}
// total up the size of the lower dimensions
int controllerDimensionSubtotal = 1;
for (unsigned int i = 0; i < mHeavyDataControllers[dimControllerIndex]->getDimensions().size() - 1; ++i) {
returnDimensions.push_back(mHeavyDataControllers[dimControllerIndex]->getDimensions()[i]);
controllerDimensionSubtotal *= mHeavyDataControllers[dimControllerIndex]->getDimensions()[i];
}
// divide the total contained by the dimensions by the size of the lower dimensions
returnDimensions.push_back(dimTotal/controllerDimensionSubtotal);
return returnDimensions;
}
const unsigned int size = this->getSize();
return std::vector<unsigned int>(1, size);
}
else if (arrayType1 == XdmfArrayType::Int64()) {
//if floats reclass as floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float32()) {
float sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float64()) {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
//if uints reclass as ints of the appropriate size
else {
long sampleValue = 0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
return mDimensions;
}
std::string
XdmfArray::getDimensionsString() const
{
const std::vector<unsigned int> dimensions = this->getDimensions();
return GetValuesString(dimensions.size()).getValuesString(&dimensions[0],
dimensions.size());
}
std::map<std::string, std::string>
XdmfArray::getItemProperties() const
{
std::map<std::string, std::string> arrayProperties;
if(mHeavyDataControllers.size()>0) {
arrayProperties.insert(std::make_pair("Format",
mHeavyDataControllers[0]->getName()));
}
else if (arrayType1 == XdmfArrayType::Float32()) {
//use floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else if (arrayType2 == XdmfArrayType::Float64()) {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
float sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
arrayProperties.insert(std::make_pair("Format", "XML"));
}
else if (arrayType1 == XdmfArrayType::Float64()) {
//use floats of the appropriate size
if (arrayType2 == XdmfArrayType::String()) {
//string is the only compatible type here
std::string sampleValue = "";
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}
else {
double sampleValue = 0.0;
returnArray->resize(val1->getSize()+val2->getSize(), sampleValue);
}