From a72f40077b1d8b7eca88b4c591db53e95523cd06 Mon Sep 17 00:00:00 2001 From: "Andrew J. Burns (Cont" Date: Thu, 6 Jun 2013 09:58:32 -0400 Subject: [PATCH] Formatting changes and removing warnings --- XdmfGraph.cpp | 2 +- XdmfMap.cpp | 37 +- core/XdmfArray.cpp | 1386 +- core/XdmfArray.hpp | 390 +- core/XdmfCore.i | 1 + core/XdmfCoreReader.cpp | 100 +- core/XdmfError.cpp | 4 +- core/XdmfHDF5Writer.cpp | 91 +- core/XdmfSparseMatrix.cpp | 4 +- core/XdmfWriter.cpp | 41 +- core/tests/Cxx/TestXdmfError.cpp | 2 +- examples/Cxx/ExampleXdmfArray.cpp | 6 +- examples/Cxx/ExampleXdmfDSM.cpp | 86 +- examples/Cxx/ExampleXdmfDSMSelfcontained.cpp | 22 +- examples/Cxx/ExampleXdmfWrite.cpp | 6 +- tests/Cxx/ExampleXdmfEdit.cpp | 420 +- tests/Cxx/ExampleXdmfRead.cpp | 392 +- tests/Cxx/ExampleXdmfWrite.cpp | 9 +- tests/Cxx/HugeReadArray.cpp | 2 +- tests/Cxx/ReadArray.cpp | 10 +- tests/Cxx/TestXdmfGraph.cpp | 2 - tests/Cxx/XdmfPostFixCalc.cpp | 12 +- tests/Python/WriteTime.py | 14 +- utils/XdmfFortran.cpp | 11172 ++++++++--------- utils/XdmfFortran.hpp | 20 +- 25 files changed, 6455 insertions(+), 7776 deletions(-) diff --git a/XdmfGraph.cpp b/XdmfGraph.cpp index 45a207c3..5b43a6a7 100644 --- a/XdmfGraph.cpp +++ b/XdmfGraph.cpp @@ -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(); } diff --git a/XdmfMap.cpp b/XdmfMap.cpp index 7357616b..7e0a6ae1 100644 --- a/XdmfMap.cpp +++ b/XdmfMap.cpp @@ -219,19 +219,18 @@ XdmfMap::populateItem(const std::map & 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 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 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 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 tempArray = XdmfArray::New(); mRemoteLocalNodeIdsControllers[i]->read(tempArray.get()); @@ -324,17 +323,17 @@ XdmfMap::setHeavyDataControllers(std::vector std::vector > 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 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 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)); } diff --git a/core/XdmfArray.cpp b/core/XdmfArray.cpp index fbaac402..d2ec73e2 100644 --- a/core/XdmfArray.cpp +++ b/core/XdmfArray.cpp @@ -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::vector >)> XdmfArray::arrayFunctions = boost::assign::map_list_of ("SUM", (shared_ptr (*)(std::vector >))XdmfArray::sum) ("AVE", (shared_ptr (*)(std::vector >))XdmfArray::ave); std::map (*)(shared_ptr, shared_ptr)> 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(*functionref)(std::vector >)) +{ + // 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::ave(std::vector > values) +{ + double total = sum(values)->getValue(0);; + int totalSize = 0; + for (unsigned int i = 0; i < values.size(); ++i) + { + totalSize += values[i]->getSize(); + } + shared_ptr returnArray = XdmfArray::New(); + returnArray->insert(0, total/totalSize); + return returnArray; +} + void XdmfArray::clear() { @@ -594,6 +641,17 @@ XdmfArray::clear() mDimensions.clear(); } +shared_ptr +XdmfArray::chunk(shared_ptr val1, shared_ptr val2) +{ + // join chunk (add the new array to the end of the first one) + // joins into new array and returns it + shared_ptr 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::evaluateExpression(std::string expression, std::map > variables) { std::stack > valueStack; std::stack 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 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= 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 > 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::mapsecond); } } - 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 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 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 0) { try { XdmfError::message(XdmfError::WARNING, @@ -849,10 +923,12 @@ XdmfArray::addOperation(char newoperator, shared_ptr(*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(*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(*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(*operationref)(s return operations.size(); } +// this is how you use references to functions shared_ptr -XdmfArray::chunk(shared_ptr val1, shared_ptr val2) +XdmfArray::evaluateFunction(std::vector > 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 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(*)(std::vector >))arrayFunctions[functionName])(valueVector); + } + else { + return shared_ptr(); + } } -shared_ptr -XdmfArray::interlace(shared_ptr val1, shared_ptr val2) +shared_ptr +XdmfArray::getArrayType() const { - //join interlace (evenly space the second array within the first one) - //builds a new array - shared_ptr 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 arrayType1 = val1->getArrayType(); - shared_ptr 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()), + 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 +XdmfArray::getDimensions() const +{ + if(mDimensions.size() == 0) { + if(!this->isInitialized() && mHeavyDataControllers.size() > 0) { + std::vector returnDimensions; + std::vector 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(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 dimensions = this->getDimensions(); + return GetValuesString(dimensions.size()).getValuesString(&dimensions[0], + dimensions.size()); +} + +std::map +XdmfArray::getItemProperties() const +{ + std::map 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); - } - } - else if (arrayType1 == XdmfArrayType::UInt8()) { - //if int are used reclass as int of the larger size - if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16()) { - short sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::Int32()) { - int sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::Int64()) { - long sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - //if floats are used, reclass as floats of the appropriate size - 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 are used, adjust size as required - else if (arrayType2 == XdmfArrayType::UInt8()) { - unsigned char sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::UInt16()) { - unsigned short sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::UInt32()) { - unsigned int sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::String()) { - //string is the only compatible type here - std::string sampleValue = ""; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - } - else if (arrayType1 == XdmfArrayType::UInt16()) { - //if int are used reclass as int of the larger size - if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16() || arrayType2 == XdmfArrayType::Int32()) { - int sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::Int64()) { - long sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - //if floats are used, reclass as floats of the appropriate size - 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 are used, adjust size as required - else if (arrayType2 == XdmfArrayType::UInt8() || arrayType2 == XdmfArrayType::UInt16()) { - unsigned short sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::UInt32()) { - unsigned int sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::String()) { - //string is the only compatible type here - std::string sampleValue = ""; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - } - else if (arrayType1 == XdmfArrayType::UInt32()) { - //if int are used reclass as int of the larger size - if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16() || arrayType2 == XdmfArrayType::Int32() || arrayType2 == XdmfArrayType::Int64()) { - long sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - //if floats are used, reclass as floats of the appropriate size - 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 are used, adjust size as required - else if (arrayType2 == XdmfArrayType::UInt8() || arrayType2 == XdmfArrayType::UInt16() || arrayType2 == XdmfArrayType::UInt32()) { - unsigned int sampleValue = 0; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - else if (arrayType2 == XdmfArrayType::String()) { - //string is the only compatible type here - std::string sampleValue = ""; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - } - else if (arrayType1 == XdmfArrayType::String()) { - //string is the only compatible type here - std::string sampleValue = ""; - returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); - } - //determine ratio of array sizes - int arrayRatio1 = (int)floor(static_cast(val1->getSize())/val2->getSize()); - int arrayRatio2 = (int)floor(static_cast(val2->getSize())/val1->getSize()); - if (arrayRatio1 < 1) { - arrayRatio1 = 1; - } - if (arrayRatio2 < 1) { - arrayRatio2 = 1; - } - //stride is equal to the ratios rounded up and added together - int stride = arrayRatio1+arrayRatio2; - int arrayExcess1 = 0; - int arrayExcess2 = 0; - for (int i = 0; i < stride; i++) { - //add the values of each array, using strides to interlace and starting index to offset - //first array gets the first value of the new array - if (igetSize()/arrayRatio1; - if (((amountWritten * arrayRatio1) + i) < (int)val1->getSize()) { - amountWritten++; - } - if (amountWritten > floor(val2->getSize()/arrayRatio2)) { - arrayExcess1 += amountWritten - (int)floor(val2->getSize()/arrayRatio2); - amountWritten = (int)floor(val2->getSize()/arrayRatio2); - } - returnArray->insert(i, val1, i, amountWritten, stride, arrayRatio1); - } - else { //second array takes the rest - int amountWritten = val2->getSize()/arrayRatio2; - if (((amountWritten * arrayRatio2) + i) < (int)val2->getSize()) { - amountWritten++; - } - if (amountWritten > floor(val1->getSize()/arrayRatio1)) { - arrayExcess2 += amountWritten - (int)floor(val1->getSize()/arrayRatio1); - amountWritten = (int)floor(val1->getSize()/arrayRatio1); - } - returnArray->insert(i, val2, i-arrayRatio1, amountWritten, stride, arrayRatio2); - } - } - if (arrayExcess1 > 0) { - returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess1, val1, 0, arrayExcess1, 1, 1); - } - else if (arrayExcess2 > 0) { - returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess2, val2, 0, arrayExcess2, 1, 1); - } - returnArray->resize(val1->getSize()+val2->getSize(), 0); - //after all inserts are done, add the excess values to the end of the array? Possibly do during the initial insert process? - return returnArray; -} - -//this is how you use references to functions -shared_ptr -XdmfArray::evaluateFunction(std::vector > valueVector, std::string functionName) -{ - if (arrayFunctions.find(functionName) != arrayFunctions.end()) { - return (*(shared_ptr(*)(std::vector >))arrayFunctions[functionName])(valueVector); - } - else { - return shared_ptr(); - } -} - -int -XdmfArray::addFunction(std::string name, shared_ptr(*functionref)(std::vector >)) -{ - //check to ensure that the name has valid characters - for (unsigned int i = 0; i < name.size(); i++) { - if (mValidVariableChars.find(name[i]) == std::string::npos) {//if the character is not found in the list of valid characters - //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 (origsize == arrayFunctions.size()) {//if no new functions were added - //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::sum(std::vector > values) -{ - double total = 0.0; - for (unsigned int i = 0; i < values.size(); i++) { - for (unsigned int j = 0; j < values[i]->getSize(); j++) { - total += values[i]->getValue(j); - } - } - shared_ptr returnArray = XdmfArray::New(); - returnArray->insert(0, total); - return returnArray; -} - -shared_ptr -XdmfArray::ave(std::vector > values) -{ - double total = sum(values)->getValue(0);; - int totalSize = 0; - for (unsigned int i = 0; i < values.size(); i++) - { - totalSize += values[i]->getSize(); - } - shared_ptr returnArray = XdmfArray::New(); - returnArray->insert(0, total/totalSize); - return returnArray; -} - -shared_ptr -XdmfArray::getArrayType() const -{ - if (mHeavyDataControllers.size()>0) { - return boost::apply_visitor(GetArrayType(mHeavyDataControllers[0]), - mArray); - } - else { - return boost::apply_visitor(GetArrayType(shared_ptr()), - mArray); - } -} - -unsigned int -XdmfArray::getCapacity() const -{ - return boost::apply_visitor(GetCapacity(), - mArray); -} - -std::vector -XdmfArray::getDimensions() const -{ - if(mDimensions.size() == 0) { - if(!this->isInitialized() && mHeavyDataControllers.size() > 0) { - std::vector returnDimensions; - std::vector 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(1, size); - } - return mDimensions; -} - -std::string -XdmfArray::getDimensionsString() const -{ - const std::vector dimensions = this->getDimensions(); - return GetValuesString(dimensions.size()).getValuesString(&dimensions[0], - dimensions.size()); -} - -std::map -XdmfArray::getItemProperties() const -{ - std::map arrayProperties; - if(mHeavyDataControllers.size()>0) { - arrayProperties.insert(std::make_pair("Format", - mHeavyDataControllers[0]->getName())); - } - else { - arrayProperties.insert(std::make_pair("Format", "XML")); - } - arrayProperties.insert(std::make_pair("Dimensions", - this->getDimensionsString())); - if(mName.compare("") != 0) { - arrayProperties.insert(std::make_pair("Name", mName)); + arrayProperties.insert(std::make_pair("Dimensions", + this->getDimensionsString())); + if(mName.compare("") != 0) { + arrayProperties.insert(std::make_pair("Name", mName)); } shared_ptr type = this->getArrayType(); type->getProperties(arrayProperties); @@ -1405,22 +1109,22 @@ XdmfArray::getSupportedFunctions() { std::vector returnVector; for (std::map(*)(std::vector >)>::iterator functionWalker = arrayFunctions.begin(); - functionWalker != arrayFunctions.end(); functionWalker++) { + functionWalker != arrayFunctions.end(); ++functionWalker) { returnVector.push_back(functionWalker->first); } return returnVector; } const std::string -XdmfArray::getValidVariableChars() +XdmfArray::getValidDigitChars() { - return mValidVariableChars; + return mValidDigitChars; } const std::string -XdmfArray::getValidDigitChars() +XdmfArray::getValidVariableChars() { - return mValidDigitChars; + return mValidVariableChars; } void * @@ -1465,8 +1169,8 @@ XdmfArray::getHeavyDataController() const void XdmfArray::setHeavyDataController(shared_ptr newController) { - //since this is replacing the previous version which was designed to completely replace the controller of the array - //it will clear the current controllers before adding the new one in + // since this is replacing the previous version which was designed to completely replace the controller of the array + // it will clear the current controllers before adding the new one in mHeavyDataControllers.clear(); mHeavyDataControllers.push_back(newController); } @@ -1505,169 +1209,478 @@ XdmfArray::initialize(const shared_ptr arrayType, else if(arrayType == XdmfArrayType::String()) { this->initialize(size); } - else if(arrayType == XdmfArrayType::Uninitialized()) { - this->release(); + else if(arrayType == XdmfArrayType::Uninitialized()) { + this->release(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Array of unsupported type in XdmfArray::initialize"); + } + catch (XdmfError e) { + throw e; + } + } +} + +void +XdmfArray::initialize(const shared_ptr arrayType, + const std::vector & dimensions) +{ + mDimensions = dimensions; + const unsigned int size = std::accumulate(dimensions.begin(), + dimensions.end(), + 1, + std::multiplies()); + return this->initialize(arrayType, size); +} + +void +XdmfArray::insert(const unsigned int startIndex, + const shared_ptr values, + const unsigned int valuesStartIndex, + const unsigned int numValues, + const unsigned int arrayStride, + const unsigned int valuesStride) +{ + boost::apply_visitor(InsertArray(this, + startIndex, + valuesStartIndex, + numValues, + arrayStride, + valuesStride, + mDimensions, + values), + mArray); +} + + +void +XdmfArray::insert(const std::vector startIndex, + const shared_ptr values, + const std::vector valuesStartIndex, + const std::vector numValues, + const std::vector numInserted, + const std::vector arrayStride, + const std::vector valuesStride) +{ + // ensuring dimensions match up when pulling data + if ((values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size()) + && (numInserted.size() == startIndex.size() && startIndex.size() == mDimensions.size() && mDimensions.size() == arrayStride.size())) { + // pull data from values + std::vector dimTotalVector; + unsigned int dimTotal = 1; + for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { + dimTotalVector.push_back(dimTotal); + dimTotal *= values->getDimensions()[i]; + } + std::vector indexVector; + for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { + indexVector.push_back(0); + } + shared_ptr holderArray = XdmfArray::New(); + unsigned int holderoffset = 0; + // end when the last index is incremented + while (indexVector[indexVector.size()-1] < 1) { + // initialize the section of the array you're pulling from + unsigned int startTotal = 0; + dimTotal = 1; + for (unsigned int i = 0; i < values->getDimensions().size(); ++i) { + // stride doesn't factor in to the first dimension since it's being used with the insert call + if (i == 0) { + startTotal += valuesStartIndex[i] * dimTotal; + } + else { + startTotal += valuesStartIndex[i] * dimTotal + valuesStride[i] * dimTotal * indexVector[i-1]; + } + dimTotal *= values->getDimensions()[i]; + } + // insert the subsection + holderArray->insert(holderoffset, values, startTotal, numValues[0], 1, valuesStride[0]); + holderoffset+=numValues[0]; + // increment up the vector + bool increment = true; + for (unsigned int i = 0; i < indexVector.size() && increment; ++i) { + indexVector[i]++; + // to keep the loop from breaking at the end + if (i+1 < numValues.size()) { + if (indexVector[i] >= numValues[i+1]) { + indexVector[i] = indexVector[i] % numValues[i+1]; + } + else { + increment = false; + } + } + } + } + // values being inserted retrieved + // use an variation of the last loop to insert into this array + + indexVector.clear(); + for (unsigned int i = 0; i < this->getDimensions().size(); ++i) { + indexVector.push_back(0); + } + holderoffset = 0; + // end when the last index is incremented + while (indexVector[indexVector.size()-1] < 1) { + // initialize the section of the array you're pulling from + unsigned int startTotal = 0; + dimTotal = 1; + for (unsigned int i = 0; i < this->getDimensions().size(); ++i) { + if (i == 0) {// stride doesn't factor in to the first dimension since it's being used with the insert call + startTotal += startIndex[i] * dimTotal; + } + else { + startTotal += startIndex[i] * dimTotal + arrayStride[i] * dimTotal * indexVector[i-1]; + } + dimTotal *= this->getDimensions()[i]; + } + // insert the subsection + this->insert(startTotal, holderArray, holderoffset, numInserted[0], arrayStride[0], 1); + holderoffset+=numInserted[0]; + // increment up the vector + bool increment = true; + for (unsigned int i = 0; i < indexVector.size() && increment; ++i) { + indexVector[i]++; + if (i+1 < numInserted.size()) {// to keep the loop from breaking at the end + if (indexVector[i] >= numInserted[i+1]) { + indexVector[i] = indexVector[i] % numInserted[i+1]; + } + else { + increment = false; + } + } + } + } + } + else { + // throw an error + if (!(values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size())) { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Number of starts, strides, and/or values retrieved does not match up with the dimensions of the array being retrieved from"); + } + catch (XdmfError e) { + throw e; + } + } + else if (!(numInserted.size() == startIndex.size() && startIndex.size() == mDimensions.size() && mDimensions.size() == arrayStride.size())) { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Number of starts, strides, and/or values written does not match up with the dimensions of the array being inserted into"); + } + catch (XdmfError e) { + throw e; + } + } + } +} + +shared_ptr +XdmfArray::interlace(shared_ptr val1, shared_ptr val2) +{ + // join interlace (evenly space the second array within the first one) + // builds a new array + shared_ptr 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 arrayType1 = val1->getArrayType(); + shared_ptr 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); + } + } + 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 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); + } + } + 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); + } + } + 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 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); + } + } + else if (arrayType1 == XdmfArrayType::UInt8()) { + // if int are used reclass as int of the larger size + if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16()) { + short sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::Int32()) { + int sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::Int64()) { + long sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + // if floats are used, reclass as floats of the appropriate size + 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 are used, adjust size as required + else if (arrayType2 == XdmfArrayType::UInt8()) { + unsigned char sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::UInt16()) { + unsigned short sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::UInt32()) { + unsigned int sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::String()) { + // string is the only compatible type here + std::string sampleValue = ""; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } } - else { - try { - XdmfError::message(XdmfError::FATAL, - "Array of unsupported type in XdmfArray::initialize"); + else if (arrayType1 == XdmfArrayType::UInt16()) { + // if int are used reclass as int of the larger size + if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16() || arrayType2 == XdmfArrayType::Int32()) { + int sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } - catch (XdmfError e) { - throw e; + else if (arrayType2 == XdmfArrayType::Int64()) { + long sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + // if floats are used, reclass as floats of the appropriate size + 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 are used, adjust size as required + else if (arrayType2 == XdmfArrayType::UInt8() || arrayType2 == XdmfArrayType::UInt16()) { + unsigned short sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::UInt32()) { + unsigned int sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + else if (arrayType2 == XdmfArrayType::String()) { + // string is the only compatible type here + std::string sampleValue = ""; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } } -} - -void -XdmfArray::initialize(const shared_ptr arrayType, - const std::vector & dimensions) -{ - mDimensions = dimensions; - const unsigned int size = std::accumulate(dimensions.begin(), - dimensions.end(), - 1, - std::multiplies()); - return this->initialize(arrayType, size); -} - -void -XdmfArray::insert(const unsigned int startIndex, - const shared_ptr values, - const unsigned int valuesStartIndex, - const unsigned int numValues, - const unsigned int arrayStride, - const unsigned int valuesStride) -{ - boost::apply_visitor(InsertArray(this, - startIndex, - valuesStartIndex, - numValues, - arrayStride, - valuesStride, - mDimensions, - values), - mArray); -} - - -void -XdmfArray::insert(const std::vector startIndex, - const shared_ptr values, - const std::vector valuesStartIndex, - const std::vector numValues, - const std::vector numInserted, - const std::vector arrayStride, - const std::vector valuesStride) -{ - if ((values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size()) - && (numInserted.size() == startIndex.size() && startIndex.size() == mDimensions.size() && mDimensions.size() == arrayStride.size())) {//ensuring dimensions match up when pulling data - //pull data from values - std::vector dimTotalVector; - unsigned int dimTotal = 1; - for (unsigned int i = 0; i < values->getDimensions().size(); i++) { - dimTotalVector.push_back(dimTotal); - dimTotal *= values->getDimensions()[i]; + else if (arrayType1 == XdmfArrayType::UInt32()) { + // if int are used reclass as int of the larger size + if (arrayType2 == XdmfArrayType::Int8() || arrayType2 == XdmfArrayType::Int16() || arrayType2 == XdmfArrayType::Int32() || arrayType2 == XdmfArrayType::Int64()) { + long sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } - std::vector indexVector; - for (unsigned int i = 0; i < values->getDimensions().size(); i++) { - indexVector.push_back(0); + // if floats are used, reclass as floats of the appropriate size + else if (arrayType2 == XdmfArrayType::Float32()) { + float sampleValue = 0.0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } - shared_ptr holderArray = XdmfArray::New(); - unsigned int holderoffset = 0; - while (indexVector[indexVector.size()-1] < 1) {//end when the last index is incremented - //initialize the section of the array you're pulling from - unsigned int startTotal = 0; - dimTotal = 1; - for (unsigned int i = 0; i < values->getDimensions().size(); i++) { - if (i == 0) {//stride doesn't factor in to the first dimension since it's being used with the insert call - startTotal += valuesStartIndex[i] * dimTotal; - } - else { - startTotal += valuesStartIndex[i] * dimTotal + valuesStride[i] * dimTotal * indexVector[i-1]; - } - dimTotal *= values->getDimensions()[i]; - } - //insert the subsection - holderArray->insert(holderoffset, values, startTotal, numValues[0], 1, valuesStride[0]); - holderoffset+=numValues[0]; - //increment up the vector - bool increment = true; - for (unsigned int i = 0; i < indexVector.size() && increment; i++) { - indexVector[i]++; - if (i+1 < numValues.size()) {//to keep the loop from breaking at the end - if (indexVector[i] >= numValues[i+1]) { - indexVector[i] = indexVector[i] % numValues[i+1]; - } - else { - increment = false; - } - } - } + else if (arrayType2 == XdmfArrayType::Float64()) { + double sampleValue = 0.0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } - //values being inserted retrieved - //use an variation of the last loop to insert into this array - - indexVector.clear(); - for (unsigned int i = 0; i < this->getDimensions().size(); i++) { - indexVector.push_back(0); + // if uints are used, adjust size as required + else if (arrayType2 == XdmfArrayType::UInt8() || arrayType2 == XdmfArrayType::UInt16() || arrayType2 == XdmfArrayType::UInt32()) { + unsigned int sampleValue = 0; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } - holderoffset = 0; - while (indexVector[indexVector.size()-1] < 1) {//end when the last index is incremented - //initialize the section of the array you're pulling from - unsigned int startTotal = 0; - dimTotal = 1; - for (unsigned int i = 0; i < this->getDimensions().size(); i++) { - if (i == 0) {//stride doesn't factor in to the first dimension since it's being used with the insert call - startTotal += startIndex[i] * dimTotal; - } - else { - startTotal += startIndex[i] * dimTotal + arrayStride[i] * dimTotal * indexVector[i-1]; - } - dimTotal *= this->getDimensions()[i]; - } - //insert the subsection - this->insert(startTotal, holderArray, holderoffset, numInserted[0], arrayStride[0], 1); - holderoffset+=numInserted[0]; - //increment up the vector - bool increment = true; - for (unsigned int i = 0; i < indexVector.size() && increment; i++) { - indexVector[i]++; - if (i+1 < numInserted.size()) {//to keep the loop from breaking at the end - if (indexVector[i] >= numInserted[i+1]) { - indexVector[i] = indexVector[i] % numInserted[i+1]; - } - else { - increment = false; - } - } - } + else if (arrayType2 == XdmfArrayType::String()) { + // string is the only compatible type here + std::string sampleValue = ""; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); } } - else { - //throw an error - if (!(values->getDimensions().size() == valuesStartIndex.size() && valuesStartIndex.size() == numValues.size() && numValues.size() == valuesStride.size())) { - try { - XdmfError::message(XdmfError::FATAL, - "Error: Number of starts, strides, and/or values retrieved does not match up with the dimensions of the array being retrieved from"); + else if (arrayType1 == XdmfArrayType::String()) { + // string is the only compatible type here + std::string sampleValue = ""; + returnArray->resize(val1->getSize()+val2->getSize(), sampleValue); + } + // determine ratio of array sizes + int arrayRatio1 = (int)floor(static_cast(val1->getSize())/val2->getSize()); + int arrayRatio2 = (int)floor(static_cast(val2->getSize())/val1->getSize()); + if (arrayRatio1 < 1) { + arrayRatio1 = 1; + } + if (arrayRatio2 < 1) { + arrayRatio2 = 1; + } + // stride is equal to the ratios rounded up and added together + int stride = arrayRatio1+arrayRatio2; + int arrayExcess1 = 0; + int arrayExcess2 = 0; + for (int i = 0; i < stride; ++i) { + // add the values of each array, using strides to interlace and starting index to offset + // first array gets the first value of the new array + if (igetSize()/arrayRatio1; + if (((amountWritten * arrayRatio1) + i) < (int)val1->getSize()) { + amountWritten++; } - catch (XdmfError e) { - throw e; + if (amountWritten > floor(val2->getSize()/arrayRatio2)) { + arrayExcess1 += amountWritten - (int)floor(val2->getSize()/arrayRatio2); + amountWritten = (int)floor(val2->getSize()/arrayRatio2); } + returnArray->insert(i, val1, i, amountWritten, stride, arrayRatio1); } - else if (!(numInserted.size() == startIndex.size() && startIndex.size() == mDimensions.size() && mDimensions.size() == arrayStride.size())) { - try { - XdmfError::message(XdmfError::FATAL, - "Error: Number of starts, strides, and/or values written does not match up with the dimensions of the array being inserted into"); + else { + // second array takes the rest + int amountWritten = val2->getSize()/arrayRatio2; + if (((amountWritten * arrayRatio2) + i) < (int)val2->getSize()) { + amountWritten++; } - catch (XdmfError e) { - throw e; + if (amountWritten > floor(val1->getSize()/arrayRatio1)) { + arrayExcess2 += amountWritten - (int)floor(val1->getSize()/arrayRatio1); + amountWritten = (int)floor(val1->getSize()/arrayRatio1); } + returnArray->insert(i, val2, i-arrayRatio1, amountWritten, stride, arrayRatio2); } } + if (arrayExcess1 > 0) { + returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess1, val1, 0, arrayExcess1, 1, 1); + } + else if (arrayExcess2 > 0) { + returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess2, val2, 0, arrayExcess2, 1, 1); + } + returnArray->resize(val1->getSize()+val2->getSize(), 0); + // after all inserts are done, add the excess values to the end of the array? Possibly do during the initial insert process? + return returnArray; } - bool XdmfArray::isInitialized() const { @@ -1687,7 +1700,7 @@ XdmfArray::populateItem(const std::map & itemPropertie const std::vector > & childItems, const XdmfCoreReader * const reader) { - //This inserts any XdmfInformation in childItems into the object. + // This inserts any XdmfInformation in childItems into the object. XdmfItem::populateItem(itemProperties, childItems, reader); const shared_ptr arrayType = @@ -1706,7 +1719,7 @@ XdmfArray::populateItem(const std::map & itemPropertie } } - //this was originally a constant, but the compiler doesn't like creating vectors of constant strings. + // this was originally a constant, but the compiler doesn't like creating vectors of constant strings. std::vector contentVals; contentVals.push_back(content->second); @@ -1783,21 +1796,23 @@ XdmfArray::populateItem(const std::map & itemPropertie std::string hdf5Path = contentVals[contentIndex].substr(0, colonLocation); std::string dataSetPath = contentVals[contentIndex].substr(colonLocation+1); - //parse dimensions from the content + // parse dimensions from the content std::vector contentDims; if (contentVals.size() > contentIndex+1) { - //this is the string that contains the dimensions + // this is the string that contains the dimensions boost::tokenizer<> dimtokens(contentVals[contentIndex+1]); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentDims.push_back(atoi((*iter).c_str())); } - contentStep = 2;//if this works then the dimension content should be skipped over + contentStep = 2; + // if this works then the dimension content should be skipped over } - else {//if it fails then it means that the next content is not a dimension string - //in this case it is assumed that the controller will have dimensions equal to the array - for (unsigned int j = 0; j < mDimensions.size(); j++) { + else { + // if it fails then it means that the next content is not a dimension string + // in this case it is assumed that the controller will have dimensions equal to the array + for (unsigned int j = 0; j < mDimensions.size(); ++j) { contentDims.push_back(mDimensions[j]); } contentStep = 1; @@ -1865,40 +1880,45 @@ XdmfArray::populateItem(const std::map & itemPropertie void XdmfArray::read() { - if(mHeavyDataControllers.size() > 0) { + if(mHeavyDataControllers.size() > 1) { this->release(); - for (unsigned int i = 0; i < mHeavyDataControllers.size(); i++) { + for (unsigned int i = 0; i < mHeavyDataControllers.size(); ++i) { shared_ptr tempArray = XdmfArray::New(); mHeavyDataControllers[i]->read(tempArray.get()); unsigned int dimTotal = 1; - for (unsigned int j = 0; j < mHeavyDataControllers[i]->getDimensions().size(); j++) { + for (unsigned int j = 0; j < mHeavyDataControllers[i]->getDimensions().size(); ++j) { dimTotal *= mHeavyDataControllers[i]->getDimensions()[j]; } this->insert(mHeavyDataControllers[i]->getArrayOffset(), tempArray, 0, dimTotal, 1, 1); } std::vector returnDimensions; std::vector tempDimensions; - //find the controller with the most dimensions + // 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++) { + 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 + // total up the size of the lower dimensions int controllerDimensionSubtotal = 1; - for (unsigned int i = 0; i < mHeavyDataControllers[dimControllerIndex]->getDimensions().size() - 1; i++) { + 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 + // divide the total contained by the dimensions by the size of the lower dimensions returnDimensions.push_back(dimTotal/controllerDimensionSubtotal); mDimensions = returnDimensions; } + else if (mHeavyDataControllers.size() == 1) { + this->release(); + mHeavyDataControllers[0]->read(this); + mDimensions = mHeavyDataControllers[0]->getDimensions(); + } } void @@ -1923,6 +1943,20 @@ XdmfArray::setName(const std::string & name) mName = name; } +shared_ptr +XdmfArray::sum(std::vector > values) +{ + double total = 0.0; + for (unsigned int i = 0; i < values.size(); ++i) { + for (unsigned int j = 0; j < values[i]->getSize(); ++j) { + total += values[i]->getValue(j); + } + } + shared_ptr returnArray = XdmfArray::New(); + returnArray->insert(0, total); + return returnArray; +} + void XdmfArray::swap(const shared_ptr array) { diff --git a/core/XdmfArray.hpp b/core/XdmfArray.hpp index 64193a73..cb9774ad 100644 --- a/core/XdmfArray.hpp +++ b/core/XdmfArray.hpp @@ -124,6 +124,98 @@ public: XDMF_CHILDREN(XdmfArray, XdmfHeavyDataController, HeavyDataController, Name); static const std::string ItemTag; + /** + * Adds an operation to the list of viable operators. + * + * Example of Use: + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline prepend + * @skipline main + * @skipline addOperation + * @skipline return + * @until } + * @skipline prepend + * @until } + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline prepend + * @until val2.getSize + * @skipline return + * @skipline __main__ + * @skipline addOperation + * + * @param newoperator the character to be associated with the provided binary operation + * @param functionref a pointer to the function to be associated with the provided operator + * @param priority used to determine order of operations the higher the value the earlier it is evaluated + */ + static int addOperation(char newoperator, shared_ptr(*functionref)(shared_ptr, shared_ptr), int priority); + + /* + * adds a specified function to the list of functions used while evaluating strings + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline maximum + * @skipline main + * @skipline addFunction + * @skipline return + * @until } + * @skipline maximum + * @until else + * @skipline { + * @until returnArray; + * @skipline } + * @until } + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline maximum + * @until else + * @skipline maxVal + * @until pushBackAsFloat + * @skipline return + * @skipline __main__ + * @skipline addFunction + * + * @param name A string to be associated with the provided function during string evaluation + * @param functionref A pointer to the function to be associated with the given string + * @return The total number of functions currently associated + */ + static int addFunction(std::string name, shared_ptr(*functionref)(std::vector >)); + + /** + * Averages the values contained in all the provided arrays. + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline valueArray1 + * @until valueVector + * @skipline valueArray1 + * @until valueArray2 + * @skipline ave + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline valueArray1 + * @until valueVector + * @skipline valueArray1 + * @until valueArray2 + * @skipline ave + * + * @param values a vector containing the arrays to be used + * @return an XdmfArray containing one value which is the average of all values contained within the provided arrays + */ + static shared_ptr ave(std::vector > values); + /** * Remove all values from this array. * @@ -143,6 +235,31 @@ public: */ void clear(); + /** + * Joins the two provided arrays together end to end. + * + * Example of Use: + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline valueArray1 + * @until (6) + * @skipline chunk + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline valueArray1 + * @until (6) + * @skipline chunk + * + * @param val1 the first array being evaluated + * @param val2 the second array being evaluated + * @return the arrays joined end to end + */ + static shared_ptr chunk(shared_ptr val1, shared_ptr val2); + /** * Remove a value from this array. * @@ -165,12 +282,6 @@ public: */ void erase(const unsigned int index); - - - - - - /** * Evaluates an expression based on the list of variables provided. * A list of valid operations is retrievable from the getSupportedOperations static method. @@ -256,86 +367,6 @@ public: */ static shared_ptr evaluateOperation(shared_ptr val1, shared_ptr val2, char operation); - /** - * Adds an operation to the list of viable operators. - * - * Example of Use: - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline prepend - * @skipline main - * @skipline addOperation - * @skipline return - * @until } - * @skipline prepend - * @until } - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline prepend - * @until val2.getSize - * @skipline return - * @skipline __main__ - * @skipline addOperation - * - * @param newoperator the character to be associated with the provided binary operation - * @param functionref a pointer to the function to be associated with the provided operator - * @param priority used to determine order of operations the higher the value the earlier it is evaluated - */ - static int addOperation(char newoperator, shared_ptr(*functionref)(shared_ptr, shared_ptr), int priority); - - /** - * Joins the two provided arrays together end to end. - * - * Example of Use: - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline valueArray1 - * @until (6) - * @skipline chunk - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline valueArray1 - * @until (6) - * @skipline chunk - * - * @param val1 the first array being evaluated - * @param val2 the second array being evaluated - * @return the arrays joined end to end - */ - static shared_ptr chunk(shared_ptr val1, shared_ptr val2); - - /** - * Joins the two provided arrays while interspercing their values evenly. - * Example of Use: - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline valueArray1 - * @until (6) - * @skipline interlace - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline valueArray1 - * @until (6) - * @skipline interlace - * - * @param val1 the first array being evaluated - * @param val2 the second array being evaluated - * @return the interlaced arrays - */ - static shared_ptr interlace(shared_ptr val1, shared_ptr val2); - /** * Evaluates the function specified using the vector of XdmfArrays provided. * None of the XdmfArrays provided are modified during the evaluation process. @@ -374,99 +405,6 @@ public: */ static shared_ptr evaluateFunction(std::vector > valueVector, std::string functionName); - /* - * adds a specified function to the list of functions used while evaluating strings - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline maximum - * @skipline main - * @skipline addFunction - * @skipline return - * @until } - * @skipline maximum - * @until else - * @skipline { - * @until returnArray; - * @skipline } - * @until } - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline maximum - * @until else - * @skipline maxVal - * @until pushBackAsFloat - * @skipline return - * @skipline __main__ - * @skipline addFunction - * - * @param name A string to be associated with the provided function during string evaluation - * @param functionref A pointer to the function to be associated with the given string - * @return The total number of functions currently associated - */ - static int addFunction(std::string name, shared_ptr(*functionref)(std::vector >)); - - /** - * Adds together all the values contained in the provided arrays. - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline valueArray1 - * @until valueVector - * @skipline valueArray1 - * @until valueArray2 - * @skipline sum - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline valueArray1 - * @until valueVector - * @skipline valueArray1 - * @until valueArray2 - * @skipline sum - * - * @param values a vector containing the arrays to be used - * @return an XdmfArray containing one value which is the total of all the values contained within the provided arrays - */ - static shared_ptr sum(std::vector > values); - - /** - * Averages the values contained in all the provided arrays. - * - * C++ - * - * @dontinclude ExampleXdmfArray.cpp - * @skipline valueArray1 - * @until valueVector - * @skipline valueArray1 - * @until valueArray2 - * @skipline ave - * - * Python - * - * @dontinclude XdmfExampleArray.py - * @skipline valueArray1 - * @until valueVector - * @skipline valueArray1 - * @until valueArray2 - * @skipline ave - * - * @param values a vector containing the arrays to be used - * @return an XdmfArray containing one value which is the average of all values contained within the provided arrays - */ - static shared_ptr ave(std::vector > values); - - - - - - - /** * Get the data type of this array. * @@ -579,10 +517,6 @@ public: */ std::string getName() const; - - - - /** * Gets the priority of operation whose associated character is provided. Returns -1 if the operation is not supported. * The higher the value the earlier that operation is evaluated during evaluateExpression. @@ -604,12 +538,6 @@ public: */ static int getOperationPriority(char operation); - - - - - - /** * Get the number of values stored in this array. * @@ -631,10 +559,6 @@ public: */ unsigned int getSize() const; - - - - /** * Gets a string that contains all the characters of the supported operations. * Parenthesis are included for grouping purposes in expressions. @@ -677,47 +601,43 @@ public: /** * Gets a string that contains all strings that are viable for use when mapping - * to shared pointers of XdmfArrays for the evaluateExpression function. + * to scalars (which are stored in XdmfArrays of size 1) for the evaluateExpression function. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfArray.cpp - * @skipline getValidVariableChars + * @skipline getValidDigitChars * * Python * * @dontinclude XdmfExampleArray.py - * @skipline getValidVariableChars + * @skipline getValidDigitChars * - * @return a string containing all valid variable characters + * @return a string containing all valid variable characters */ - static const std::string getValidVariableChars(); + static const std::string getValidDigitChars(); /** * Gets a string that contains all strings that are viable for use when mapping - * to scalars (which are stored in XdmfArrays of size 1) for the evaluateExpression function. + * to shared pointers of XdmfArrays for the evaluateExpression function. * * Example of Use: * * C++ * * @dontinclude ExampleXdmfArray.cpp - * @skipline getValidDigitChars + * @skipline getValidVariableChars * * Python * * @dontinclude XdmfExampleArray.py - * @skipline getValidDigitChars + * @skipline getValidVariableChars * - * @return a string containing all valid variable characters + * @return a string containing all valid variable characters */ - static const std::string getValidDigitChars(); - - - - + static const std::string getValidVariableChars(); /** * Get a copy of a single value stored in this array. @@ -754,7 +674,7 @@ public: * * @dontinclude ExampleXdmfArray.cpp * @skipline New - * @skipline initArray + * @skipline storeArray * @skipline exampleArray * @until {0,2,4,6,8,5,3,7,4,9} * @@ -1095,6 +1015,30 @@ public: const unsigned int arrayStride = 1, const unsigned int valuesStride = 1); + /** + * Joins the two provided arrays while interspercing their values evenly. + * Example of Use: + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline valueArray1 + * @until (6) + * @skipline interlace + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline valueArray1 + * @until (6) + * @skipline interlace + * + * @param val1 the first array being evaluated + * @param val2 the second array being evaluated + * @return the interlaced arrays + */ + static shared_ptr interlace(shared_ptr val1, shared_ptr val2); + /** * Returns whether the array is initialized (contains values in * memory). @@ -1447,6 +1391,32 @@ public: template void setValuesInternal(const shared_ptr > array); + /** + * Adds together all the values contained in the provided arrays. + * + * C++ + * + * @dontinclude ExampleXdmfArray.cpp + * @skipline valueArray1 + * @until valueVector + * @skipline valueArray1 + * @until valueArray2 + * @skipline sum + * + * Python + * + * @dontinclude XdmfExampleArray.py + * @skipline valueArray1 + * @until valueVector + * @skipline valueArray1 + * @until valueArray2 + * @skipline sum + * + * @param values a vector containing the arrays to be used + * @return an XdmfArray containing one value which is the total of all the values contained within the provided arrays + */ + static shared_ptr sum(std::vector > values); + /** * Exchange the contents of the vector with the contents of this * array. No copy is made. The internal arrays are swapped. @@ -1511,7 +1481,7 @@ public: * @skipline initArray * @skipline insert * @skipline swapArray - * @until exampleArray + * @until swap( * @skipline // * * Python @@ -1521,7 +1491,7 @@ public: * @skipline initArray * @skipline insert * @skipline swapArray - * @until exampleArray + * @until swap( * @skipline # * * @param array a smart pointer to a vector to exchange values with. diff --git a/core/XdmfCore.i b/core/XdmfCore.i index cd9bae94..22635f32 100644 --- a/core/XdmfCore.i +++ b/core/XdmfCore.i @@ -950,6 +950,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i %include XdmfItem.hpp %include XdmfItemProperty.hpp %include XdmfSparseMatrix.hpp +%include XdmfSystemUtils.hpp %include XdmfVisitor.hpp %include XdmfHeavyDataController.hpp %include XdmfHeavyDataWriter.hpp diff --git a/core/XdmfCoreReader.cpp b/core/XdmfCoreReader.cpp index f895b041..370b40d9 100644 --- a/core/XdmfCoreReader.cpp +++ b/core/XdmfCoreReader.cpp @@ -182,16 +182,17 @@ public: } else if (xmlStrcmp(currNode->name, (xmlChar*)"Function") == 0) { - //function handling goes here + // function handling goes here xmlNodePtr childNode = currNode->children; std::string arraySubType = ""; - //get Array Subtype, if any + // get Array Subtype, if any xmlAttrPtr currAttribute = currNode->properties; while (currAttribute != NULL) { if (xmlStrcmp(currAttribute->name, (xmlChar*)"Type") == 0 ) { arraySubType = (char*)currAttribute->children->content; - break;//uses the first type found + break; + // uses the first type found } } @@ -199,7 +200,7 @@ public: while (childNode != NULL) { if (xmlStrcmp(childNode->name, (xmlChar*)"Expression") == 0){ - //store expression + // store expression xmlAttrPtr childAttribute = childNode->properties; while (childAttribute != NULL) { if(xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) { @@ -223,13 +224,13 @@ public: } } - //two seperate loops to allow for different orders and multiple variable sets + // two seperate loops to allow for different orders and multiple variable sets childNode = currNode->children; std::map > variableCollection; while (childNode != NULL) { if (xmlStrcmp(childNode->name, (xmlChar*)"Variable") == 0) { - //store child variables + // store child variables xmlNodePtr childVariable = childNode->children; while (childVariable != NULL) { @@ -245,31 +246,31 @@ public: std::map typeMap; while (childAttribute != NULL) { - //the variable type of the array + // the variable type of the array if (xmlStrcmp(childAttribute->name, (xmlChar*)"DataType") == 0) { typeMap["DataType"] = (char*)childAttribute->children->content; } - //the precision of the variable type (only used for long and double) + // the precision of the variable type (only used for long and double) else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Precision") == 0) { typeMap["Precision"] = (char*)childAttribute->children->content; } - //the key or mapped string for the variable + // the key or mapped string for the variable else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Key") == 0) { childKey = (char*)childAttribute->children->content; } - //text based xml data + // text based xml data else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) { dataString = (char*)childAttribute->children->content; } - //an x pointer to another XdmfArray + // an x pointer to another XdmfArray else if (xmlStrcmp(childAttribute->name, (xmlChar*)"XPointer") == 0) { childXPointer = childAttribute->children->content; } - //used in conjunction with Xpointers to reference objects in a different file + // used in conjunction with Xpointers to reference objects in a different file else if (xmlStrcmp(childAttribute->name, (xmlChar*)"href") == 0) { childhref = childAttribute->children->content; } - //path to hdf5 data sets and the dimensions of those sets + // path to hdf5 data sets and the dimensions of those sets else if (xmlStrcmp(childAttribute->name, (xmlChar*)"hdf5") == 0) { childhdf5 = (char*)childAttribute->children->content; } @@ -314,7 +315,7 @@ public: dataType = XdmfArrayType::Uninitialized(); } - //if xpointer grab item at that location + // if xpointer grab item at that location if (childXPointer) { xmlXPathContextPtr context = mXPathContext; @@ -337,17 +338,20 @@ public: xmlXPathObjectPtr result = xmlXPtrEval(childXPointer, context); if(result && !xmlXPathNodeSetIsEmpty(result->nodesetval)) { for(int i=0; inodesetval->nodeNr; ++i) { - //there should only be one item being returned here - //place into a new vector + // there should only be one item being returned here + // place into a new vector std::vector > pointedItems; this->readSingleNode(result->nodesetval->nodeTab[i], pointedItems); try { - childArray = shared_dynamic_cast(pointedItems[0]);//try to cast it as an array + // try to cast it as an array + childArray = shared_dynamic_cast(pointedItems[0]); } - catch (...) {//if that doesn't work throw an error + catch (...) { + // if that doesn't work throw an error try { + // because we should only be working with arrays XdmfError::message(XdmfError::FATAL, - "Error: Variable not Equivalent to an Array");//because we should only be working with arrays + "Error: Variable not Equivalent to an Array"); } catch (XdmfError e) { throw e; @@ -362,11 +366,11 @@ public: xmlXPathFreeContext(context); } } - //if hdf5 create controllers and attach it + // if hdf5 create controllers and attach it else if (childhdf5.compare("") != 0) { - //parse the hdf5 controllers + // parse the hdf5 controllers std::vector controllerParts; - //split the content based on "|" characters + // split the content based on "|" characters size_t barSplit = 0; std::string splitString(childhdf5); std::string subcontent; @@ -385,7 +389,7 @@ public: controllerParts.push_back(subcontent); } - //insert those controllers into the childArray + // insert those controllers into the childArray int hdf5step = 2; for (unsigned int i = 0; i < controllerParts.size(); i = i + hdf5step) { size_t colonLocation = controllerParts[i].find(":"); @@ -406,18 +410,19 @@ public: std::vector contentDims; if (i + 1 < controllerParts.size()){ - //this is the string that contains the dimensions + // this is the string that contains the dimensions boost::tokenizer<> dimtokens(controllerParts[i + 1]); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); iter != dimtokens.end(); ++iter) { contentDims.push_back(atoi((*iter).c_str())); } - hdf5step = 2;//if this works then the dimension content should be skipped over + hdf5step = 2;// if this works then the dimension content should be skipped over } - else {//if it fails then it means that the next content is not a dimension string - //in this case an error should be thrown, formatting error - //because there is no base array to pull dimensions from + else { + // if it fails then it means that the next content is not a dimension string + // in this case an error should be thrown, formatting error + // because there is no base array to pull dimensions from try { XdmfError::message(XdmfError::FATAL, "Error: Improper HDF5 Format"); @@ -436,9 +441,9 @@ public: contentDims)); } } - //if xml parse strait to insert + // if xml parse strait to insert else if (dataString.compare("") != 0) { - //parse the data into tokens + // parse the data into tokens childArray->initialize(dataType, 0); unsigned int index = 0; boost::char_separator sep(" \t\n"); @@ -448,7 +453,7 @@ public: iter = tokens.begin(); iter != tokens.end(); ++iter, ++index) { - //insert those tokens into the childArray + // insert those tokens into the childArray childArray->insert(index, *iter); } } @@ -457,13 +462,13 @@ public: iter = tokens.begin(); iter != tokens.end(); ++iter, ++index) { - //insert those tokens into the childArray + // insert those tokens into the childArray childArray->insert(index, atof((*iter).c_str())); } } } - //parse the value into the array + // parse the value into the array if (childKey.compare("") != 0){ if (variableCollection.find(childKey) != variableCollection.end()) { try { @@ -499,23 +504,25 @@ public: catch (XdmfError e) { throw e; } - //the properties and children aren't really needed to generate the object, but the factory still requires them. + // the properties and children aren't really needed to generate the object, but the factory still requires them. std::map newArrayProperties; std::vector > newArrayChildren; shared_ptr returnArray = XdmfArray::New(); - if (arraySubType.compare("") == 0) {//if no type is specified an array is generated + if (arraySubType.compare("") == 0) { + // if no type is specified an array is generated arraySubType = "DataItem"; } - //this should generate an item that corresponds to the tag provided, the casting ensures that it is a subtype of array - //using a factory to be able to build things outside of core + // this should generate an item that corresponds to the tag provided, the casting ensures that it is a subtype of array + // using a factory to be able to build things outside of core returnArray = shared_dynamic_cast(mItemFactory->createItem( arraySubType, newArrayProperties, newArrayChildren)); - if (!returnArray) {//if the specified tag fails to generate an item then reclass as an array + if (!returnArray) { + // if the specified tag fails to generate an item then reclass as an array arraySubType = "DataItem"; returnArray = shared_dynamic_cast(mItemFactory->createItem( arraySubType, @@ -550,13 +557,15 @@ public: readSingleNode(const xmlNodePtr currNode, std::vector > & myItems) { - //check to see if the node is already in the Xpath + // check to see if the node is already in the Xpath std::map >::const_iterator iter = mXPathMap.find(currNode); - if(iter != mXPathMap.end()) {//if it is grab it from the previously stored items + // if it is grab it from the previously stored items + if(iter != mXPathMap.end()) { myItems.push_back(iter->second); } - else {//otherwise, generate it from the node + else { + // otherwise, generate it from the node std::map itemProperties; xmlNodePtr childNode = currNode->children; @@ -565,17 +574,14 @@ public: while(childNode != NULL) { if(childNode->type == XML_TEXT_NODE && childNode->content) { const char * content = (char*)childNode->content; - - - // determine if content is whitespace bool whitespace = true; const char * contentPtr = content; - //step through to end of pointer + // step through to end of pointer while(contentPtr != NULL) { - //if not a whitespace character, break + // if not a whitespace character, break if(!isspace(*contentPtr++)) { whitespace = false; break; @@ -587,7 +593,7 @@ public: itemProperties.insert(std::make_pair("XMLDir", mXMLDir)); } - //split the content based on "|" characters + // split the content based on "|" characters size_t barSplit = 0; std::string splitString(content); std::string subcontent; diff --git a/core/XdmfError.cpp b/core/XdmfError.cpp index 9a2585e6..3232ec30 100644 --- a/core/XdmfError.cpp +++ b/core/XdmfError.cpp @@ -68,8 +68,8 @@ XdmfError::setBuffer(std::streambuf* buf) *** Private Static Functions *** ********************************/ -//automatically writes the message to the provided buffer -//by default this is basically a print statement +// automatically writes the message to the provided buffer +// by default this is basically a print statement void XdmfError::WriteToStream(std::string msg) { diff --git a/core/XdmfHDF5Writer.cpp b/core/XdmfHDF5Writer.cpp index 6eae3c4b..605f9c8f 100644 --- a/core/XdmfHDF5Writer.cpp +++ b/core/XdmfHDF5Writer.cpp @@ -82,7 +82,6 @@ public: // Perhaps we should throw a warning. closeFile(); } - // Save old error handler and turn off error handling for now H5E_auto_t old_func; void * old_client_data; @@ -93,6 +92,7 @@ public: mOpenFile.assign(filePath); + if(H5Fis_hdf5(filePath.c_str()) > 0) { mHDF5Handle = H5Fopen(filePath.c_str(), H5F_ACC_RDWR, @@ -103,6 +103,7 @@ public: toReturn = numObjects; } else { + //this is where it currently fails mHDF5Handle = H5Fcreate(filePath.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, @@ -279,7 +280,7 @@ XdmfHDF5Writer::visit(XdmfItem & item, mImpl->mDepth++; //This is similar to the algorithm for writing XPaths //shouldn't be a problem if XPaths are turned off because all this does is avoid writing an object twice - //if it was written once then all instances of the object should have the ocntroller + //if it was written once then all instances of the object should have the controller std::set::iterator checkWritten = mImpl->mWrittenItems.find(&item); if (checkWritten == mImpl->mWrittenItems.end()) { mImpl->mWrittenItems.insert(&item); @@ -304,6 +305,8 @@ XdmfHDF5Writer::write(XdmfArray & array, hid_t datatype = -1; bool closeDatatype = false; + const unsigned int hdf5Overhead = 800;//base size of an hdf5 file is 800 + //determining data type if(array.isInitialized()) { if(array.getArrayType() == XdmfArrayType::Int8()) { @@ -373,7 +376,7 @@ XdmfHDF5Writer::write(XdmfArray & array, std::vector > previousControllers; //hold the controllers in order to base the new controllers on them - for(unsigned int i = 0; i < array.getNumberHeavyDataControllers(); i++) { + for(unsigned int i = 0; i < array.getNumberHeavyDataControllers(); ++i) { previousControllers.push_back(array.getHeavyDataController(i)); } @@ -404,10 +407,10 @@ XdmfHDF5Writer::write(XdmfArray & array, int controllerIndexOffset = 0; - for(unsigned int i = 0; i < previousControllers.size(); i++)// it is assumed that the array will have at least one controller, if it didn't have one a temporary one was generated + for(unsigned int i = 0; i < previousControllers.size(); ++i)// it is assumed that the array will have at least one controller, if it didn't have one a temporary one was generated { if (mMode == Append) {//append only cares about the last controller, so add the rest back in - for (; i < previousControllers.size() - 1; i++) { + for (; i < previousControllers.size() - 1; ++i) { array.insert(previousControllers[i]); } } @@ -489,7 +492,7 @@ XdmfHDF5Writer::write(XdmfArray & array, unsigned int containedInController = 1; - for (unsigned int j = 0; j < dataspaceDimensions.size(); j++) { + for (unsigned int j = 0; j < dataspaceDimensions.size(); ++j) { containedInController *= dataspaceDimensions[j]; } hssize_t hyperslabSize = 0; @@ -541,7 +544,7 @@ XdmfHDF5Writer::write(XdmfArray & array, fileSize = fileSize - checksize;//remove previous set's size, since it's overwritten } if (fileSize == 0) { - fileSize += 800; + fileSize += hdf5Overhead; } } else if (mMode == Hyperslab) { @@ -549,12 +552,12 @@ XdmfHDF5Writer::write(XdmfArray & array, } } if (fileSize == 0) { - fileSize += 800; + fileSize += hdf5Overhead; } fclose(checkFile); } else if (previousDataSize == 0) { - fileSize += 800;//base size of an hdf5 file is 800 + fileSize += hdf5Overhead; } // close stream and release buffer //check size to see if it's within range @@ -567,7 +570,7 @@ XdmfHDF5Writer::write(XdmfArray & array, if (mMode == Hyperslab) { remainingValues += 1; sizeArrayIndex += 1; - for (unsigned int j = 0; j < dataspaceDimensions[j]; j++) { + for (unsigned int j = 0; j < dataspaceDimensions[j]; ++j) { remainingValues *= dataspaceDimensions[j]; sizeArrayIndex *= dimensions[j]; } @@ -583,7 +586,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //if remaining size is less than available space, just write all of what's left //calculate remaining size unsigned int remainingSize = 0; - for (unsigned int j = sizeArrayIndex; j < array.getSize(); j++) { + for (unsigned int j = sizeArrayIndex; j < array.getSize(); ++j) { remainingSize += array.getValue(j).size() * 8; } if (mMode == Hyperslab) { @@ -594,7 +597,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //if the array hasn't been split if (amountAlreadyWritten == 0) { //just pass all data to the partial vectors - for (unsigned int j = 0; j < dimensions.size(); j++) {//done using a loop so that data is copied, not referenced + for (unsigned int j = 0; j < dimensions.size(); ++j) {//done using a loop so that data is copied, not referenced partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -605,7 +608,7 @@ XdmfHDF5Writer::write(XdmfArray & array, int dimensionIndex = previousDimensions.size() - 1; //loop previous dimensions in int j = 0; - for (j = 0; j < dimensionIndex; j++) { + for (j = 0; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -622,7 +625,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //total up number of blocks for the higher dimesions and subtract the amount already written unsigned int dimensiontotal = dimensions[j]; unsigned int dataspacetotal = dataspaceDimensions[j]; - for (unsigned int k = j + 1; k < dimensions.size(); k++) { + for (unsigned int k = j + 1; k < dimensions.size(); ++k) { dimensiontotal *= dimensions[k]; dataspacetotal *= dataspaceDimensions[k]; } @@ -646,7 +649,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //total up number of blocks for the higher dimesions and subtract the amount already written //since it isn't hyperslab dimensions and dataspacedimensions should be the same unsigned int dimensiontotal = dimensions[j]; - for (unsigned int k = j + 1; k < dimensions.size(); k++) { + for (unsigned int k = j + 1; k < dimensions.size(); ++k) { dimensiontotal *= dimensions[k]; } if (previousDimensions.size() > 0) { @@ -676,7 +679,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //see if it will fit in the next file //if it will just go to the next file //otherwise split it. - if (remainingSize + 800 > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { + if (remainingSize + hdf5Overhead > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { if (mImpl->mAllowSplitDataSets) { //figure out the size of the largest block that will fit. unsigned int blockSizeSubtotal = 0; @@ -689,7 +692,7 @@ XdmfHDF5Writer::write(XdmfArray & array, dimensionSizeTotal *= dimensions[dimensionIndex]; previousBlockSize = blockSizeSubtotal; blockSizeSubtotal = 0; - for (unsigned int k = 0; k < dimensionSizeTotal; k++) { + for (unsigned int k = 0; k < dimensionSizeTotal; ++k) { if (amountAlreadyWritten + k > array.getSize()) { try { XdmfError::message(XdmfError::FATAL, @@ -710,7 +713,7 @@ XdmfHDF5Writer::write(XdmfArray & array, unsigned int numBlocks = usableSpace / blockSizeSubtotal;//this should be less than the current value for the dimension //add dimensions as required. unsigned int j = 0; - for (; j < dimensionIndex; j++) { + for (; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -747,7 +750,7 @@ XdmfHDF5Writer::write(XdmfArray & array, } else { //just pass all data to the partial vectors - for (unsigned int j = 0; j < dimensions.size(); j++) {//done using a loop so that data is copied, not referenced + for (unsigned int j = 0; j < dimensions.size(); ++j) {//done using a loop so that data is copied, not referenced partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -761,7 +764,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //see if the remaining data will fit in the next file //if yes, skip to it //if no, split - if (remainingSize + 800 > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { + if (remainingSize + hdf5Overhead > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { //figure out the size of the largest block that will fit. unsigned int blockSizeSubtotal = 0; unsigned int tempTotal = 0; @@ -773,7 +776,7 @@ XdmfHDF5Writer::write(XdmfArray & array, dimensionSizeTotal *= dimensions[dimensionIndex]; tempTotal = blockSizeSubtotal; blockSizeSubtotal = 0; - for (unsigned int k = 0; k < dimensionSizeTotal; k++) { + for (unsigned int k = 0; k < dimensionSizeTotal; ++k) { if (amountAlreadyWritten + k > array.getSize()) { try { XdmfError::message(XdmfError::FATAL, @@ -791,7 +794,7 @@ XdmfHDF5Writer::write(XdmfArray & array, dimensionIndex--; blockSizeSubtotal = tempTotal; unsigned int j = 0; - for (; j < dimensionIndex; j++) { + for (; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -866,13 +869,13 @@ XdmfHDF5Writer::write(XdmfArray & array, unsigned int remainingValues = 0; if (mMode == Hyperslab) { remainingValues += 1; - for (unsigned int j = 0; j < dataspaceDimensions.size(); j++) { + for (unsigned int j = 0; j < dataspaceDimensions.size(); ++j) { remainingValues *= dataspaceDimensions[j]; } } else { remainingValues += 1; - for (unsigned int j = 0; j < dimensions.size(); j++) { + for (unsigned int j = 0; j < dimensions.size(); ++j) { remainingValues *= dimensions[j]; } } @@ -886,7 +889,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //if the array hasn't been split if (amountAlreadyWritten == 0) { //just pass all data to the partial vectors - for (unsigned int j = 0; j < dimensions.size(); j++) {//done using a loop so that data is copied, not referenced + for (unsigned int j = 0; j < dimensions.size(); ++j) {//done using a loop so that data is copied, not referenced partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -897,7 +900,7 @@ XdmfHDF5Writer::write(XdmfArray & array, int dimensionIndex = previousDimensions.size() - 1; //loop previous dimensions in int j = 0; - for (j = 0; j < dimensionIndex; j++) { + for (j = 0; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -914,7 +917,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //total up number of blocks for the higher dimesions and subtract the amount already written unsigned int dimensiontotal = dimensions[j]; unsigned int dataspacetotal = dataspaceDimensions[j]; - for (unsigned int k = j + 1; k < dimensions.size(); k++) { + for (unsigned int k = j + 1; k < dimensions.size(); ++k) { dimensiontotal *= dimensions[k]; dataspacetotal *= dataspaceDimensions[k]; } @@ -938,7 +941,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //total up number of blocks for the higher dimesions and subtract the amount already written //since it isn't hyperslab dimensions and dataspacedimensions should be the same unsigned int dimensiontotal = dimensions[j]; - for (unsigned int k = j + 1; k < dimensions.size(); k++) { + for (unsigned int k = j + 1; k < dimensions.size(); ++k) { dimensiontotal *= dimensions[k]; } if (previousDimensions.size() > 0) { @@ -968,7 +971,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //see if it will fit in the next file //if it will just go to the next file //otherwise split it. - if ((remainingValues * dataItemSize) + 800 > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { + if ((remainingValues * dataItemSize) + hdf5Overhead > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { if (mImpl->mAllowSplitDataSets) { //figure out the size of the largest block that will fit. unsigned int blockSizeSubtotal = 1; @@ -985,7 +988,7 @@ XdmfHDF5Writer::write(XdmfArray & array, unsigned int numBlocks = usableSpace / blockSizeSubtotal;//this should be less than the current value for the dimension //add dimensions as required. unsigned int j = 0; - for (j = 0; j < dimensionIndex; j++) { + for (j = 0; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -1022,7 +1025,7 @@ XdmfHDF5Writer::write(XdmfArray & array, } else { //just pass all data to the partial vectors - for (unsigned int j = 0; j < dimensions.size(); j++) {//done using a loop so that data is copied, not referenced + for (unsigned int j = 0; j < dimensions.size(); ++j) {//done using a loop so that data is copied, not referenced partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -1036,7 +1039,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //see if it will fit in the next file //if it will just go to the next file //otherwise split it. - if ((remainingValues * dataItemSize) + 800 > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { + if ((remainingValues * dataItemSize) + hdf5Overhead > mImpl->mHDF5FileSizeLimit*(1024*1024) && usableSpace > 0) { unsigned int blockSizeSubtotal = 1; unsigned int dimensionIndex = 0; //find the dimension that was split @@ -1048,7 +1051,7 @@ XdmfHDF5Writer::write(XdmfArray & array, dimensionIndex--; blockSizeSubtotal /= dataspaceDimensions[dimensionIndex]; unsigned int j = 0; - for (j = 0; j < dimensionIndex; j++) { + for (j = 0; j < dimensionIndex; ++j) { partialStarts.push_back(start[j]); partialStrides.push_back(stride[j]); partialDimensions.push_back(dimensions[j]); @@ -1119,12 +1122,12 @@ XdmfHDF5Writer::write(XdmfArray & array, if (partialDimensions.size() > 0) {//building the array to be written int containedInDimensions = 1;//count moved - for (unsigned int j = 0 ; j < partialDimensions.size(); j++) { + for (unsigned int j = 0 ; j < partialDimensions.size(); ++j) { containedInDimensions *= partialDimensions[j]; } int containedInPriorDimensions = controllerIndexOffset;//starting index int startOffset = 1; - for (unsigned int j = 0; j < previousDimensions.size(); j++) { + for (unsigned int j = 0; j < previousDimensions.size(); ++j) { startOffset *= previousDimensions[j]; } if (previousDimensions.size() == 0) { @@ -1132,7 +1135,7 @@ XdmfHDF5Writer::write(XdmfArray & array, } containedInPriorDimensions += startOffset; int dimensionTotal = 1; - for (unsigned int j = 0; j < dimensions.size(); j++) { + for (unsigned int j = 0; j < dimensions.size(); ++j) { dimensionTotal *= dimensions[j]; } if (containedInDimensions > 0) { @@ -1193,7 +1196,7 @@ XdmfHDF5Writer::write(XdmfArray & array, } else if (closeDatatype) {//closeDatatype is only true if strings are being used partialArray->initialize(XdmfArrayType::String(), 0); - for (int j = containedInPriorDimensions; j < containedInPriorDimensions + containedInDimensions; j++) { + for (int j = containedInPriorDimensions; j < containedInPriorDimensions + containedInDimensions; ++j) { partialArray->pushBack(array.getValue(j)); } } @@ -1215,7 +1218,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //so use that since the dimensions should be equal to the dataspace dimensions in all other variations //total up written data space unsigned int writtenDataSpace = 1; - for (unsigned int j = 0; j < partialDataSizes.size(); j++) { + for (unsigned int j = 0; j < partialDataSizes.size(); ++j) { writtenDataSpace *= partialDataSizes[j]; } amountAlreadyWritten += writtenDataSpace; @@ -1233,14 +1236,14 @@ XdmfHDF5Writer::write(XdmfArray & array, } else if (previousDimensions.size() < partialDimensions.size()) { unsigned int overflowDimensions = 1; - for (unsigned int j = previousDimensions.size() - 1; j < partialDimensions.size(); j++) { + for (unsigned int j = previousDimensions.size() - 1; j < partialDimensions.size(); ++j) { overflowDimensions *= partialDimensions[j]; } previousDimensions[previousDimensions.size()-1] += overflowDimensions; } else if (previousDimensions.size() > partialDimensions.size()) { unsigned int overflowDimensions = 1; - for (unsigned int j = partialDimensions.size() - 1; j < previousDimensions.size(); j++) { + for (unsigned int j = partialDimensions.size() - 1; j < previousDimensions.size(); ++j) { overflowDimensions *= previousDimensions[j]; } previousDimensions.resize(partialDimensions.size()); @@ -1252,14 +1255,14 @@ XdmfHDF5Writer::write(XdmfArray & array, } else if (previousDataSizes.size() < partialDataSizes.size()) { unsigned int overflowDataSizes = 1; - for (unsigned int j = previousDataSizes.size() - 1; j < partialDataSizes.size(); j++) { + for (unsigned int j = previousDataSizes.size() - 1; j < partialDataSizes.size(); ++j) { overflowDataSizes *= partialDataSizes[j]; } previousDataSizes[previousDataSizes.size()-1] += overflowDataSizes; } else if (previousDataSizes.size() > partialDataSizes.size()) { unsigned int overflowDataSizes = 1; - for (unsigned int j = partialDataSizes.size() - 1; j < previousDataSizes.size(); j++) { + for (unsigned int j = partialDataSizes.size() - 1; j < previousDataSizes.size(); ++j) { overflowDataSizes *= previousDataSizes[j]; } previousDataSizes.resize(partialDataSizes.size()); @@ -1428,7 +1431,7 @@ XdmfHDF5Writer::write(XdmfArray & array, else if (closeDatatype) {//closeDatatype is only true if strings are being used partialArray->initialize(XdmfArrayType::String(), 0); //transfering via loop because the getValues function is not fully tested with strings - for (j = controllerIndexOffset; j < controllerIndexOffset + heavyDataController->getSize() && j < array.getSize(); j++){ + for (j = controllerIndexOffset; j < controllerIndexOffset + heavyDataController->getSize() && j < array.getSize(); ++j){ partialArray->pushBack(array.getValue(j)); } } @@ -1466,7 +1469,7 @@ XdmfHDF5Writer::write(XdmfArray & array, //loop based on the amount of blocks split from the array. - for (unsigned int writeIndex = 0; writeIndex < arraysWritten.size(); writeIndex++) { + for (unsigned int writeIndex = 0; writeIndex < arraysWritten.size(); ++writeIndex) { //this is the section where the data is written to hdf5 //if you want to change the writer to write to a different data format, do it here diff --git a/core/XdmfSparseMatrix.cpp b/core/XdmfSparseMatrix.cpp index 3ae21c8d..7ae9d8a6 100644 --- a/core/XdmfSparseMatrix.cpp +++ b/core/XdmfSparseMatrix.cpp @@ -202,8 +202,8 @@ XdmfSparseMatrix::populateItem(const std::map & itemPr } if(arrayVector.size() < 3) { - //The three required arrays are for the row pointer, column index, and the contained values. - //Without these arrays the object can't be properly built. + // The three required arrays are for the row pointer, column index, and the contained values. + // Without these arrays the object can't be properly built. try { XdmfError::message(XdmfError::FATAL, "Expected 3 arrays attached to " diff --git a/core/XdmfWriter.cpp b/core/XdmfWriter.cpp index ce14e7c8..0df47eb1 100644 --- a/core/XdmfWriter.cpp +++ b/core/XdmfWriter.cpp @@ -73,6 +73,7 @@ public: { mXPath.clear(); + //this section writes to file std::ofstream fileStream; if(!mStream) { fileStream.open(mXMLFilePath.c_str()); @@ -96,7 +97,7 @@ public: xmlFreeDoc(mXMLDocument); xmlCleanupParser(); - + if(mHeavyDataWriter->getMode() == XdmfHeavyDataWriter::Default) { mHeavyDataWriter->closeFile(); } @@ -285,6 +286,7 @@ XdmfWriter::visit(XdmfArray & array, const bool isSubclassed = array.getItemTag().compare(XdmfArray::ItemTag) != 0; + if(isSubclassed) { try { this->visit(dynamic_cast(array), visitor); @@ -294,10 +296,10 @@ XdmfWriter::visit(XdmfArray & array, } } + if(array.getSize() > 0 && !(mImpl->mLastXPathed && isSubclassed)) { std::vector xmlTextValues; - //adjust for multifile write // Take care of writing to single heavy data file (Default behavior) if(!array.isInitialized() && array.getHeavyDataController(0) && array.getHeavyDataController(0)->getFilePath().compare(mImpl->mHeavyDataWriter->getFilePath()) != 0 && @@ -307,36 +309,42 @@ XdmfWriter::visit(XdmfArray & array, if(array.getHeavyDataController(0) || array.getSize() > mImpl->mLightDataLimit) { - //this case is for if the data is smaller than the limit - //create case for when data is over the limit // Write values to heavy data - try { + + try {// this takes about half the time needed mImpl->mHeavyDataWriter->visit(array, mImpl->mHeavyDataWriter); } catch (XdmfError e) { throw e; } + std::stringstream valuesStream; - for(unsigned int i = 0; i < array.getNumberHeavyDataControllers(); i++) { + for(unsigned int i = 0; i < array.getNumberHeavyDataControllers(); ++i) { std::string heavyDataPath = array.getHeavyDataController(i)->getFilePath(); size_t index = heavyDataPath.find_last_of("/\\"); - if(index != std::string::npos) {//if path is not a folder - const std::string heavyDataDir = heavyDataPath.substr(0, index + 1);//put the directory path into this variable - if(mImpl->mXMLFilePath.find(heavyDataDir) == 0) {//if the directory is in the XML File Path + if(index != std::string::npos) { + // if path is not a folder + // put the directory path into this variable + const std::string heavyDataDir = heavyDataPath.substr(0, index + 1); + // if the directory is in the XML File Path + if(mImpl->mXMLFilePath.find(heavyDataDir) == 0) { heavyDataPath = heavyDataPath.substr(heavyDataDir.size(), - heavyDataPath.size() - heavyDataDir.size());//pull the file off of the end and place it in the DataPath - }//otherwise the full path is required + heavyDataPath.size() - heavyDataDir.size()); + // pull the file off of the end and place it in the DataPath + } + // otherwise the full path is required } std::stringstream dimensionStream; - for (unsigned int j = 0; j < array.getHeavyDataController(i)->getDimensions().size(); j++) { + for (unsigned int j = 0; j < array.getHeavyDataController(i)->getDimensions().size(); ++j) { dimensionStream << array.getHeavyDataController(i)->getDimensions()[j]; if (j < array.getHeavyDataController(i)->getDimensions().size() - 1) { dimensionStream << " "; } } - valuesStream.str(std::string());//clear the stream + // clear the stream + valuesStream.str(std::string()); if (array.getNumberHeavyDataControllers() > 1) { valuesStream << heavyDataPath << ":" << array.getHeavyDataController(i)->getDataSetPath() @@ -366,7 +374,7 @@ XdmfWriter::visit(XdmfArray & array, array.swap(arrayToWrite); mImpl->mXMLCurrentNode = mImpl->mXMLCurrentNode->last; this->visit(dynamic_cast(*arrayToWrite.get()), visitor); - for(unsigned int i = 0; imXMLCurrentNode->last, xmlNewText((xmlChar*)xmlTextValues[i].c_str())); } @@ -375,7 +383,7 @@ XdmfWriter::visit(XdmfArray & array, } else { this->visit(dynamic_cast(array), visitor); - for(unsigned int i = 0; imXMLCurrentNode->last, xmlNewText((xmlChar*)xmlTextValues[i].c_str())); } @@ -415,7 +423,7 @@ XdmfWriter::visit(XdmfItem & item, XdmfInformation & xpathinfo = dynamic_cast(item); if (xpathinfo.getKey() == "XIncludes") { shared_ptr outputinfo; - for (unsigned int i = 0; i < xpathinfo.getNumberInformations(); i++) { + for (unsigned int i = 0; i < xpathinfo.getNumberInformations(); ++i) { mImpl->mXPathCount++; outputinfo = xpathinfo.getInformation(i); mImpl->mXMLCurrentNode = xmlNewChild(mImpl->mXMLCurrentNode, @@ -509,6 +517,7 @@ XdmfWriter::visit(XdmfItem & item, } else { // Not inserted before --- need to write all data and traverse. + mImpl->mXMLCurrentNode = xmlNewChild(mImpl->mXMLCurrentNode, NULL, (xmlChar *)tag.c_str(), diff --git a/core/tests/Cxx/TestXdmfError.cpp b/core/tests/Cxx/TestXdmfError.cpp index e0453e0c..684311c7 100644 --- a/core/tests/Cxx/TestXdmfError.cpp +++ b/core/tests/Cxx/TestXdmfError.cpp @@ -50,7 +50,7 @@ int main(int, char **) catch (XdmfError e) { //a print statement is redundant since the error message is sent to cout - //printf("The error message is:\n%s\n", e.what()); + //std::cout << "The error message is:\n" << e.what() << std::endl; } return 0; diff --git a/examples/Cxx/ExampleXdmfArray.cpp b/examples/Cxx/ExampleXdmfArray.cpp index d168fb4f..d5dfb855 100644 --- a/examples/Cxx/ExampleXdmfArray.cpp +++ b/examples/Cxx/ExampleXdmfArray.cpp @@ -189,7 +189,7 @@ int main(int, char **) dimensionVector.push_back(5); dimensionVector.push_back(4); writtenArray->initialize(dimensionVector); - for (int i = 0; i < 20; i++) + for (int i = 0; i < 20; ++i) { writtenArray->insert(i, i + 1); } @@ -234,9 +234,9 @@ shared_ptr maximum(std::vector > values) else { double maxVal = values[0]->getValue(0); - for (int i = 0; i < values.size(); i++) + for (int i = 0; i < values.size(); ++i) { - for (int j = 0; j < values[i]->getSize(); j++) + for (int j = 0; j < values[i]->getSize(); ++j) { if (maxVal < values[i]->getValue(j)) { diff --git a/examples/Cxx/ExampleXdmfDSM.cpp b/examples/Cxx/ExampleXdmfDSM.cpp index 1b071375..b8647673 100644 --- a/examples/Cxx/ExampleXdmfDSM.cpp +++ b/examples/Cxx/ExampleXdmfDSM.cpp @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) array->initialize(0);//this is required to write if (id == 0) { - for (unsigned int i = 0; i < 4*size; i++) + for (unsigned int i = 0; i < 4*size; ++i) { array->pushBack(i); } @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) dsmBuffer); array->insert(readController); - for (unsigned int i = 0; igetDimensions(); - for (int j=0; jgetSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetStride(); - for (int j=0; jinsert(readController); - for (unsigned int i =1; igetDimensions(); - for (int j=0; jgetSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetStride(); - for (int j=0; j array = XdmfArray::New(); array->initialize(0); - for(unsigned int i = 0; i <= id; i++) + for(unsigned int i = 0; i <= id; ++i) { array->pushBack(id); } int startindex = 0; - for (unsigned int i = 0; i <= id; i++) + for (unsigned int i = 0; i <= id; ++i) { startindex += i; } int datacount = 0; - for (unsigned int i = 0; i < size; i++) + for (unsigned int i = 0; i < size; ++i) { datacount = datacount + i + 1; } @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) writeDataSizeVector, dsmBuffer); array->insert(readController); - for (unsigned int i = 0; i < size; i++) + for (unsigned int i = 0; i < size; ++i) { MPI_Barrier(comm); if (id == i) @@ -250,26 +250,26 @@ int main(int argc, char *argv[]) std::cout << "filepath = " << readController->getFilePath() << std::endl; outputVector = readController->getDataspaceDimensions(); std::cout << "Data space dimensions" << std::endl; - for (int j=0; jgetDimensions(); - for (int j=0; jgetSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetStride(); - for (int j=0; j array = XdmfArray::New(); array->initialize(0); - for (unsigned int i = 1; i<=4; i++) + for (unsigned int i = 1; i<=4; ++i) { array->pushBack(id*i); } @@ -312,7 +312,7 @@ int main(int argc, char *argv[]) writeDataSizeVector, dsmBuffer); array->insert(readController); - for (unsigned int i = 0; i < size; i++) + for (unsigned int i = 0; i < size; ++i) { MPI_Barrier(comm); if (id == i) @@ -323,26 +323,26 @@ int main(int argc, char *argv[]) std::cout << "filepath = " << readController->getFilePath() << std::endl; outputVector = readController->getDataspaceDimensions(); std::cout << "Data space dimensions" << std::endl; - for (int j=0; jgetDimensions(); - for (int j=0; jgetSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetStride(); - for (int j=0; jgetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readArray->getHeavyDataController(0)->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; jgetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readArray->getHeavyDataController(0)->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; jgetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; jgetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readController->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; j testArray = XdmfArray::New(); - for (unsigned int i = 1; i <= 4; i++) + for (unsigned int i = 1; i <= 4; ++i) { testArray->pushBack(i*id); } @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) testArray->insert(writeController); - for (unsigned int i = 0; igetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = testArray->getHeavyDataController(0)->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; jgetHeavyDataController(0)->getDimensions(); - for (int j=0; jgetHeavyDataController(0)->getSize() << std::endl; std::cout << "Controller starts" << std::endl; outputVector = readArray->getHeavyDataController(0)->getStart(); - for (int j=0; jgetHeavyDataController(0)->getStride(); - for (int j=0; jinsert(mapcollection[i]); } @@ -226,14 +226,14 @@ int main(int, char **) primaryDomain->accept(exampleWriter); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); - for (int i = 0; i <= 408; i++) + for (int i = 0; i <= 408; ++i) {//overflow occurs a little after the end of this loop primaryDomain->accept(exampleHeavyWriter); } exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Default); primaryDomain->accept(exampleHeavyWriter); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); - for (int i = 0; i<5; i++) + for (int i = 0; i<5; ++i) {//this loop covers the overflow of the fileSizeLimit primaryDomain->accept(exampleHeavyWriter); } diff --git a/tests/Cxx/ExampleXdmfEdit.cpp b/tests/Cxx/ExampleXdmfEdit.cpp index 8a0b111b..d98ffd81 100644 --- a/tests/Cxx/ExampleXdmfEdit.cpp +++ b/tests/Cxx/ExampleXdmfEdit.cpp @@ -31,29 +31,29 @@ int main(int, char **) */ shared_ptr primaryDomain = shared_dynamic_cast(exampleReader->read("testoutput.xmf")); shared_ptr outputInformation = primaryDomain->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("The Domain's tag is: %s\n", primaryDomain->getItemTag().c_str()); + std::cout << "Key:" << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "The Domain's tag is: " << primaryDomain->getItemTag().c_str() << std::endl; shared_ptr gridHolder = primaryDomain->getGridCollection(0); - printf("The Grid Collection's tag is: %s\n", gridHolder->getItemTag().c_str()); - printf("The Grid Collection's name is: %s\n", gridHolder->getName().c_str()); + std::cout << "The Grid Collection's tag is: " << gridHolder->getItemTag().c_str() << std::endl; + std::cout << "The Grid Collection's name is: " << gridHolder->getName().c_str() << std::endl; outputInformation = gridHolder->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); + std::cout << "Key:" << outputInformation->getKey().c_str() <<"\nValue:" << outputInformation->getValue().c_str() << std::endl; std::map::iterator outputwalker = gridHolder->getItemProperties().begin(); - for (;outputwalker!=gridHolder->getItemProperties().end(); outputwalker++) + for (;outputwalker!=gridHolder->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } if (gridHolder->getType() == XdmfGridCollectionType::Spatial()) { - printf("This is a spatial grid collection\n"); + std::cout << "This is a spatial grid collection" << std::endl; } else { - printf("This is not a spatial grid collection\n"); + std::cout << "This is not a spatial grid collection" << std::endl; } @@ -75,66 +75,66 @@ int main(int, char **) std::set remoteIDset; std::set::iterator remoteWalker; - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = gridHolder->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - printf("Unstructured Grid\n"); + std::cout << "Unstructured Grid" << std::endl; shared_ptr ungrid = gridHolder->getUnstructuredGrid(0); - printf("The Unstructured Grid's tag is: %s\n", ungrid->getItemTag().c_str()); - printf("The Unstructured Grid's name is: %s\n", ungrid->getName().c_str()); + std::cout << "The Unstructured Grid's tag is: " << ungrid->getItemTag().c_str() << std::endl; + std::cout << "The Unstructured Grid's name is: " << ungrid->getName().c_str() << std::endl; outputwalker = ungrid->getItemProperties().begin(); - for (;outputwalker!=ungrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=ungrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - printf("The Unstructured Grid's time is: %f\n", ungrid->getTime()->getValue()); + std::cout << "The Unstructured Grid's time is: " << ungrid->getTime()->getValue() << std::endl; i=0; - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = ungrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } @@ -142,539 +142,539 @@ int main(int, char **) shared_ptr readSet; shared_ptr readAttribute; - for (i=0; i < ungrid->getNumberSets(); i++) + for (i=0; i < ungrid->getNumberSets(); ++i) { readSet = ungrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: %s\n" << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar\n" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node\n" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node\n" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < ungrid->getNumberAttributes(); i++) + for (i = 0; i < ungrid->getNumberAttributes(); ++i) { readAttribute = ungrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Unstructured Topology\n"); + std::cout << "Unstructured Topology" << std::endl; shared_ptr untopology = ungrid->getTopology(); if (!untopology->isInitialized()) { untopology->read(); } - printf("The topology's tag: %s\n", untopology->getItemTag().c_str()); + std::cout << "The topology's tag: " << untopology->getItemTag().c_str() << std::endl; if (untopology->getType() == XdmfTopologyType::Hexahedron()) { - printf("This topology is a hexahedron\n"); + std::cout << "This topology is a hexahedron" << std::endl; } else { - printf("This topology is not a hexahedron\n"); + std::cout << "This topology is not a hexahedron" << std::endl; } - printf("Contains %d elements\n", untopology->getNumberElements()); - printf("Contains the values: %s\n", untopology->getValuesString().c_str()); + std::cout << "Contains " << untopology->getNumberElements() << " elements" << std::endl; + std::cout << "Contains the values: " << untopology->getValuesString().c_str() << std::endl; - printf("Unstructured Geometry\n"); + std::cout << "Unstructured Geometry" << std::endl; shared_ptr ungeometry = ungrid->getGeometry(); if (!ungeometry->isInitialized()) { ungeometry->read(); } - printf("The geometry's tag: %s\n", ungeometry->getItemTag().c_str()); + std::cout << "The geometry's tag: " << ungeometry->getItemTag().c_str() << std::endl; if (ungeometry->getType() == XdmfGeometryType::XYZ()) { - printf("This geometry is XYZ\n"); + std::cout << "This geometry is XYZ" << std::endl; } else { - printf("This geometry is not XYZ\n"); + std::cout << "This geometry is not XYZ" << std::endl; } outputInformation = ungeometry->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("Contains %d points\n", ungeometry->getNumberPoints()); - printf("Contains the values: %s\n", ungeometry->getValuesString().c_str()); + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "Contains " << ungeometry->getNumberPoints() << " points" << std::endl; + std::cout << "Contains the values: " << ungeometry->getValuesString().c_str() << std::endl; - printf("Curvilinear Grid\n"); + std::cout << "Curvilinear Grid" << std::endl; shared_ptr curvgrid = gridHolder->getCurvilinearGrid(0); - printf("The Curvilinear Grid's tag is: %s\n", curvgrid->getItemTag().c_str()); - printf("The Curvilinear Grid's name is: %s\n", curvgrid->getName().c_str()); + std::cout << "The Curvilinear Grid's tag is: " << curvgrid->getItemTag().c_str() << std::endl; + std::cout << "The Curvilinear Grid's name is: " << curvgrid->getName().c_str() << std::endl; outputwalker = curvgrid->getItemProperties().begin(); - for (;outputwalker!=curvgrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=curvgrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } outputInformation = curvgrid->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("The Curvilinear Grid's time is: %f\n", curvgrid->getTime()->getValue()); - for (i=0; igetNumberMaps(); i++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "The Curvilinear Grid's time is: " << curvgrid->getTime()->getValue() << std::endl; + for (i=0; igetNumberMaps(); ++i) { readMap = curvgrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < curvgrid->getNumberSets(); i++) + for (i=0; i < curvgrid->getNumberSets(); ++i) { readSet = curvgrid->getSet(i); if (!readSet->isInitialized()); { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: %s\n" << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < curvgrid->getNumberAttributes(); i++) + for (i = 0; i < curvgrid->getNumberAttributes(); ++i) { readAttribute = curvgrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Curvilinear Dimensions\n"); + std::cout << "Curvilinear Dimensions" << std::endl; shared_ptr curvdimensions = curvgrid->getDimensions(); if (!curvdimensions->isInitialized()) { curvdimensions->read(); } - printf("The dimensions' tag: %s\n", curvdimensions->getItemTag().c_str()); - printf("Contains the values: %s\n", curvdimensions->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << curvdimensions->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << curvdimensions->getValuesString().c_str() << std::endl; - printf("Curvilinear Geometry\n"); + std::cout << "Curvilinear Geometry" << std::endl; shared_ptr curvgeometry = curvgrid->getGeometry(); if (!curvgeometry->isInitialized()) { curvgeometry->read(); } - printf("The geometry's tag: %s\n", curvgeometry->getItemTag().c_str()); + std::cout << "The geometry's tag: " << curvgeometry->getItemTag().c_str() << std::endl; if (curvgeometry->getType() == XdmfGeometryType::XYZ()) { - printf("This geometry is XYZ\n"); + std::cout << "This geometry is XYZ" << std::endl; } else { - printf("This geometry is not XYZ\n"); + std::cout << "This geometry is not XYZ" << std::endl; } outputInformation = curvgeometry->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("Contains %d points\n", curvgeometry->getNumberPoints()); - printf("Contains the values: %s\n", curvgeometry->getValuesString().c_str()); + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "Contains " << curvgeometry->getNumberPoints() << " points" << std::endl; + std::cout << "Contains the values: " << curvgeometry->getValuesString().c_str() << std::endl; - printf("Rectilinear Grid\n"); + std::cout << "Rectilinear Grid" << std::endl; shared_ptr rectgrid = gridHolder->getRectilinearGrid(0); - printf("The Rectilinear Grid's tag is: %s\n", rectgrid->getItemTag().c_str()); - printf("The Rectilinear Grid's name is: %s\n", rectgrid->getName().c_str()); - printf("The Rectilinear Grid's time is: %f\n", rectgrid->getTime()->getValue()); + std::cout << "The Rectilinear Grid's tag is: " << rectgrid->getItemTag().c_str() << std::endl; + std::cout << "The Rectilinear Grid's name is: " << rectgrid->getName().c_str() << std::endl; + std::cout << "The Rectilinear Grid's time is: " << rectgrid->getTime()->getValue() << std::endl; outputwalker = rectgrid->getItemProperties().begin(); - for (; outputwalker!=rectgrid->getItemProperties().end(); outputwalker++) + for (; outputwalker!=rectgrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = rectgrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < rectgrid->getNumberSets(); i++) + for (i=0; i < rectgrid->getNumberSets(); ++i) { readSet = rectgrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() <<"\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < rectgrid->getNumberAttributes(); i++) + for (i = 0; i < rectgrid->getNumberAttributes(); ++i) { readAttribute = rectgrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Rectilinear Dimensions\n"); + std::cout << "Rectilinear Dimensions" << std::endl; shared_ptr rectdimensions = rectgrid->getDimensions(); if (!rectdimensions->isInitialized()) { rectdimensions->read(); } - printf("The dimensions' tag: %s\n", rectdimensions->getItemTag().c_str()); - printf("Contains the values: %s\n", rectdimensions->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << rectdimensions->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << rectdimensions->getValuesString().c_str() << std::endl; - printf("Rectilinear Coordinates\n"); + std::cout << "Rectilinear Coordinates" << std::endl; std::vector > rectcoordinates = rectgrid->getCoordinates(); - printf("Contains the values: \n"); - for (i=0;iisInitialized()) { rectcoordinates[i]->read(); } - printf("%s\n", rectcoordinates[i]->getValuesString().c_str()); + std::cout << rectcoordinates[i]->getValuesString().c_str() << std::endl; } - printf("Regular Grid\n"); + std::cout << "Regular Grid" << std::endl; shared_ptr reggrid = gridHolder->getRegularGrid(0); - printf("The Regular Grid's tag is: %s\n", reggrid->getItemTag().c_str()); - printf("The Regular Grid's name is: %s\n", reggrid->getName().c_str()); + std::cout << "The Regular Grid's tag is: " << reggrid->getItemTag().c_str() << std::endl; + std::cout << "The Regular Grid's name is: " << reggrid->getName().c_str() << std::endl; outputwalker = reggrid->getItemProperties().begin(); - for (;outputwalker!=reggrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=reggrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - printf("The Regular Grid's time is: %f\n", reggrid->getTime()->getValue()); - for (i=0; igetNumberMaps(); i++) + std::cout << "The Regular Grid's time is: " << reggrid->getTime()->getValue() << std::endl; + for (i=0; igetNumberMaps(); ++i) { readMap = reggrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < reggrid->getNumberSets(); i++) + for (i=0; i < reggrid->getNumberSets(); ++i) { readSet = reggrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < reggrid->getNumberAttributes(); i++) + for (i = 0; i < reggrid->getNumberAttributes(); ++i) { readAttribute = reggrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Regular Brick Size\n"); + std::cout << "Regular Brick Size" << std::endl; shared_ptr regbricksize = reggrid->getBrickSize(); if (!regbricksize->isInitialized()) { regbricksize->read(); } - printf("The brick's tag: %s\n", regbricksize->getItemTag().c_str()); - printf("Contains the values: %s\n", regbricksize->getValuesString().c_str()); + std::cout << "The brick's tag: " << regbricksize->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regbricksize->getValuesString().c_str() << std::endl; - printf("Regular Number of Points\n"); + std::cout << "Regular Number of Points" << std::endl; shared_ptr regnumpoints = reggrid->getDimensions(); if (!regnumpoints->isInitialized()) { regnumpoints->read(); } - printf("The dimensions' tag: %s\n", regnumpoints->getItemTag().c_str()); - printf("Contains the values: %s\n", regnumpoints->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << regnumpoints->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regnumpoints->getValuesString().c_str() << std::endl; - printf("Regular Origin\n"); + std::cout << "Regular Origin" << std::endl; shared_ptr regorigin = reggrid->getOrigin(); if (!regorigin->isInitialized()) { regorigin->read(); } - printf("The origin's tag: %s\n", regorigin->getItemTag().c_str()); - printf("Contains the values: %s\n", regorigin->getValuesString().c_str()); + std::cout << "The origin's tag: " << regorigin->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regorigin->getValuesString().c_str() << std::endl; @@ -683,34 +683,34 @@ int main(int, char **) primaryDomain->getInformation(0)->setKey("Edited"); primaryDomain->getInformation(0)->setValue("This file is the edited version"); - printf("edited domain information\n"); + std::cout << "edited domain information" << std::endl; shared_ptr unglobalIDs = ungrid->getAttribute(0); int newIDs1 [] = {5,2,8,7,9,1}; unglobalIDs->insert(0, newIDs1, 6, 1, 1); - printf("edited unstructured attribute: %s\n", unglobalIDs->getValuesString()); + std::cout << "edited unstructured attribute: " << unglobalIDs->getValuesString() << std::endl; shared_ptr unset = ungrid->getSet(0); double newunsetdata [] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 0.23}; unset->insert(0, newunsetdata, 10, 1, 1); - printf("edited unstructured set: %s\n", unset->getValuesString()); + std::cout << "edited unstructured set: " << unset->getValuesString() << std::endl; untopology = ungrid->getTopology(); int untoposize = untopology->getSize(); int untopologydata [untoposize]; untopology->getValues(0, untopologydata, untopology->getSize(), 1, 1); - for (i=0; i < untopology->getSize(); i++) + for (i=0; i < untopology->getSize(); ++i) { untopologydata[i] = untopologydata[i] + 1; } untopology->insert(0, untopologydata, untopology->getSize(), 1, 1); - printf("edited unstructured topology: %s\n", untopology->getValuesString()); + std::cout << "edited unstructured topology: " << untopology->getValuesString() << std::endl; ungeometry = ungrid->getGeometry(); int ungeosize = ungeometry->getSize(); double ungeometrydata [ungeosize]; ungeometry->getValues(0, ungeometrydata, ungeometry->getSize(), 1, 1); - for (i=0; igetSize();i++) + for (i=0; igetSize(); ++i) { ungeometrydata[i] = ungeometrydata[i] + 1; } @@ -725,12 +725,12 @@ int main(int, char **) int curvgeosize = curvgeometry->getSize(); double curvgeometrydata [curvgeosize]; curvgeometry->getValues(0, curvgeometrydata, curvgeometry->getSize(), 1, 1); - for (i = 0; igetSize(); i++) + for (i = 0; igetSize(); ++i) { curvgeometrydata[i] = curvgeometrydata[i] + 1; } curvgeometry->insert(0, curvgeometrydata, curvgeometry->getSize(), 1, 1); - for (i = 0; i < 3; i++) + for (i = 0; i < 3; ++i) { curvgeometry->pushBack(curvgeometry->getSize()); } @@ -739,7 +739,7 @@ int main(int, char **) int curvdimensionsize = curvdimensions->getSize(); int curvdimensiondata [curvdimensionsize]; curvdimensions->getValues(0, curvdimensiondata, curvdimensions->getSize(), 1, 1); - for (i = 0; i< curvdimensions->getSize(); i++) + for (i = 0; i< curvdimensions->getSize(); ++i) { curvdimensiondata[i] = curvdimensiondata[i] + 1; } @@ -754,7 +754,7 @@ int main(int, char **) int rectdimensionsize = rectdimensions->getSize(); int rectdimensiondata [rectdimensionsize]; rectdimensions->getValues(0, rectdimensiondata, rectdimensions->getSize(), 1, 1); - for (i = 0; i < rectdimensions->getSize(); i++) + for (i = 0; i < rectdimensions->getSize(); ++i) { rectdimensiondata[i] = rectdimensiondata[i] + 1; } @@ -762,7 +762,7 @@ int main(int, char **) std::vector > rectcoordinatevector = rectgrid->getCoordinates(); shared_ptr coordinateaxis; - for (i=0;igetSize(); @@ -786,7 +786,7 @@ int main(int, char **) int regbrickdatasize = regbricksize->getSize(); double brickdata [regbrickdatasize]; regbricksize->getValues(0, brickdata, regbricksize->getSize(), 1, 1); - for (i = 0; i < regbricksize->getSize(); i++) + for (i = 0; i < regbricksize->getSize(); ++i) { brickdata[i] = brickdata[i] + 1; } @@ -797,7 +797,7 @@ int main(int, char **) int regdimensionssize = regdimensions->getSize(); int regdimensiondata [regdimensionssize]; regdimensions->getValues(0, regdimensiondata, regdimensions->getSize(), 1, 1); - for (i = 0; i < regdimensions->getSize(); i++) + for (i = 0; i < regdimensions->getSize(); ++i) { regdimensiondata[i] = regdimensiondata[i] + 1; } @@ -808,7 +808,7 @@ int main(int, char **) int regoriginsize = regorigin->getSize(); double regorigindata [regoriginsize]; regorigin->getValues(0, regorigindata, regorigin->getSize(), 1, 1); - for (i = 0; i < regorigin->getSize(); i++) + for (i = 0; i < regorigin->getSize(); ++i) { regorigindata[i] = regorigindata[i] + 1; } @@ -817,7 +817,7 @@ int main(int, char **) shared_ptr exampleHeavyWriter = XdmfHDF5Writer::New("editedtestoutput.h5"); shared_ptr exampleWriter = XdmfWriter::New("editedtestoutput.xmf", exampleHeavyWriter); - exampleHeavyWriter->setFileSizeLimit(1); + //exampleHeavyWriter->setFileSizeLimit(1); primaryDomain->accept(exampleHeavyWriter); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Overwrite); primaryDomain->accept(exampleWriter); diff --git a/tests/Cxx/ExampleXdmfRead.cpp b/tests/Cxx/ExampleXdmfRead.cpp index 576e48a5..d7b4079b 100644 --- a/tests/Cxx/ExampleXdmfRead.cpp +++ b/tests/Cxx/ExampleXdmfRead.cpp @@ -24,7 +24,7 @@ int main(int, char **) { - printf("Program Started\n"); + std::cout << "Program Started" << std::endl; shared_ptr exampleReader = XdmfReader::New(); /* @@ -33,29 +33,29 @@ int main(int, char **) shared_ptr primaryDomain = shared_dynamic_cast(exampleReader->read("testoutput.xmf")); //shared_ptr primaryDomain = shared_dynamic_cast(exampleReader->read("editedtestoutput.xmf")); shared_ptr outputInformation = primaryDomain->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("The Domain's tag is: %s\n", primaryDomain->getItemTag().c_str()); + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "The Domain's tag is: " << primaryDomain->getItemTag().c_str() << std::endl; shared_ptr gridHolder = primaryDomain->getGridCollection(0); - printf("The Grid Collection's tag is: %s\n", gridHolder->getItemTag().c_str()); - printf("The Grid Collection's name is: %s\n", gridHolder->getName().c_str()); + std::cout << "The Grid Collection's tag is: " << gridHolder->getItemTag().c_str() << std::endl; + std::cout << "The Grid Collection's name is: " << gridHolder->getName().c_str() << std::endl; outputInformation = gridHolder->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::cout; std::map::iterator outputwalker = gridHolder->getItemProperties().begin(); - for (;outputwalker!=gridHolder->getItemProperties().end(); outputwalker++) + for (;outputwalker!=gridHolder->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } if (gridHolder->getType() == XdmfGridCollectionType::Spatial()) { - printf("This is a spatial grid collection\n"); + std::cout << "This is a spatial grid collection" << std::endl; } else { - printf("This is not a spatial grid collection\n"); + std::cout << "This is not a spatial grid collection" << std::endl; } @@ -77,66 +77,66 @@ int main(int, char **) std::set remoteIDset; std::set::iterator remoteWalker; - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = gridHolder->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - printf("Unstructured Grid\n"); + std::cout << "Unstructured Grid" << std::endl; shared_ptr ungrid = gridHolder->getUnstructuredGrid(0); - printf("The Unstructured Grid's tag is: %s\n", ungrid->getItemTag().c_str()); - printf("The Unstructured Grid's name is: %s\n", ungrid->getName().c_str()); + std::cout << "The Unstructured Grid's tag is: " << ungrid->getItemTag().c_str() << std::endl; + std::cout << "The Unstructured Grid's name is: " << ungrid->getName().c_str() << std::endl; outputwalker = ungrid->getItemProperties().begin(); - for (;outputwalker!=ungrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=ungrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - printf("The Unstructured Grid's time is: %f\n", ungrid->getTime()->getValue()); + std::cout << "The Unstructured Grid's time is: " << ungrid->getTime()->getValue() << std::endl; i=0; - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = ungrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } @@ -144,533 +144,533 @@ int main(int, char **) shared_ptr readSet; shared_ptr readAttribute; - for (i=0; i < ungrid->getNumberSets(); i++) + for (i=0; i < ungrid->getNumberSets(); ++i) { readSet = ungrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < ungrid->getNumberAttributes(); i++) + for (i = 0; i < ungrid->getNumberAttributes(); ++i) { readAttribute = ungrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Unstructured Topology\n"); + std::cout << "Unstructured Topology" << std::endl; shared_ptr untopology = ungrid->getTopology(); if (!untopology->isInitialized()) { untopology->read(); } - printf("The topology's tag: %s\n", untopology->getItemTag().c_str()); + std::cout << "The topology's tag: " << untopology->getItemTag().c_str() << std::endl; if (untopology->getType() == XdmfTopologyType::Hexahedron()) { - printf("This topology is a hexahedron\n"); + std::cout "This topology is a hexahedron" << std::endl; } else { - printf("This topology is not a hexahedron\n"); + std::cout << "This topology is not a hexahedron" << std::endl; } - printf("Contains %d elements\n", untopology->getNumberElements()); - printf("Contains the values: %s\n", untopology->getValuesString().c_str()); + std::cout << "Contains " << untopology->getNumberElements() << " elements" << std::endl; + std::cout << "Contains the values: " << untopology->getValuesString().c_str() << std::endl; - printf("Unstructured Geometry\n"); + std::cout << "Unstructured Geometry" << std::endl; shared_ptr ungeometry = ungrid->getGeometry(); if (!ungeometry->isInitialized()) { ungeometry->read(); } - printf("The geometry's tag: %s\n", ungeometry->getItemTag().c_str()); + std::cout << "The geometry's tag: " << ungeometry->getItemTag().c_str() << std::endl; if (ungeometry->getType() == XdmfGeometryType::XYZ()) { - printf("This geometry is XYZ\n"); + std::cout << "This geometry is XYZ" << std::endl; } else { - printf("This geometry is not XYZ\n"); + std::cout << "This geometry is not XYZ" << std::endl; } outputInformation = ungeometry->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("Contains %d points\n", ungeometry->getNumberPoints()); - printf("Contains the values: %s\n", ungeometry->getValuesString().c_str()); + 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 the values: " << ungeometry->getValuesString().c_str() << std::endl; - printf("Curvilinear Grid\n"); + std::cout << "Curvilinear Grid" << std::endl; shared_ptr curvgrid = gridHolder->getCurvilinearGrid(0); - printf("The Curvilinear Grid's tag is: %s\n", curvgrid->getItemTag().c_str()); - printf("The Curvilinear Grid's name is: %s\n", curvgrid->getName().c_str()); + std::cout << "The Curvilinear Grid's tag is: " << curvgrid->getItemTag().c_str() << std::endl; + std::cout << "The Curvilinear Grid's name is: " << curvgrid->getName().c_str() << std::endl; outputwalker = curvgrid->getItemProperties().begin(); - for (;outputwalker!=curvgrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=curvgrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } outputInformation = curvgrid->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("The Curvilinear Grid's time is: %f\n", curvgrid->getTime()->getValue()); - for (i=0; igetNumberMaps(); i++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "The Curvilinear Grid's time is: " << curvgrid->getTime()->getValue() << std::endl; + for (i=0; igetNumberMaps(); ++i) { readMap = curvgrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < curvgrid->getNumberSets(); i++) + for (i=0; i < curvgrid->getNumberSets(); ++i) { readSet = curvgrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: "<< outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < curvgrid->getNumberAttributes(); i++) + for (i = 0; i < curvgrid->getNumberAttributes(); ++i) { readAttribute = curvgrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Curvilinear Dimensions\n"); + std::cout << "Curvilinear Dimensions" << std::endl; shared_ptr curvdimensions = curvgrid->getDimensions(); if (!curvdimensions->isInitialized()) { curvdimensions->read(); } - printf("The dimensions' tag: %s\n", curvdimensions->getItemTag().c_str()); - printf("Contains the values: %s\n", curvdimensions->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << curvdimensions->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << curvdimensions->getValuesString().c_str() << std::endl; - printf("Curvilinear Geometry\n"); + std::cout << "Curvilinear Geometry" << std::endl; shared_ptr curvgeometry = curvgrid->getGeometry(); if (!curvgeometry->isInitialized()) { curvgeometry->read(); } - printf("The geometry's tag: %s\n", curvgeometry->getItemTag().c_str()); + std::cout << "The geometry's tag: " << curvgeometry->getItemTag().c_str() << std::endl; if (curvgeometry->getType() == XdmfGeometryType::XYZ()) { - printf("This geometry is XYZ\n"); + std::cout << "This geometry is XYZ" << std::endl; } else { - printf("This geometry is not XYZ\n"); + std::cout << "This geometry is not XYZ" << std::endl; } outputInformation = curvgeometry->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("Contains %d points\n", curvgeometry->getNumberPoints()); - printf("Contains the values: %s\n", curvgeometry->getValuesString().c_str()); + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << "Contains " << curvgeometry->getNumberPoints() << " points\n" << std::endl; + std::cout << "Contains the values: " << curvgeometry->getValuesString().c_str() << std::endl; - printf("Rectilinear Grid\n"); + std::cout << "Rectilinear Grid" << std::endl; shared_ptr rectgrid = gridHolder->getRectilinearGrid(0); - printf("The Rectilinear Grid's tag is: %s\n", rectgrid->getItemTag().c_str()); - printf("The Rectilinear Grid's name is: %s\n", rectgrid->getName().c_str()); - printf("The Rectilinear Grid's time is: %f\n", rectgrid->getTime()->getValue()); + std::cout << "The Rectilinear Grid's tag is: " << rectgrid->getItemTag().c_str() << std::endl; + std::cout << "The Rectilinear Grid's name is: " << rectgrid->getName().c_str() << std::endl; + std::cout << "The Rectilinear Grid's time is: " << rectgrid->getTime()->getValue() << std::endl; outputwalker = rectgrid->getItemProperties().begin(); - for (; outputwalker!=rectgrid->getItemProperties().end(); outputwalker++) + for (; outputwalker!=rectgrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - for (i=0; igetNumberMaps(); i++) + for (i=0; igetNumberMaps(); ++i) { readMap = rectgrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task <<"\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < rectgrid->getNumberSets(); i++) + for (i=0; i < rectgrid->getNumberSets(); ++i) { readSet = rectgrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node\n"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node\n"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < rectgrid->getNumberAttributes(); i++) + for (i = 0; i < rectgrid->getNumberAttributes(); ++i) { readAttribute = rectgrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Rectilinear Dimensions\n"); + std::cout << "Rectilinear Dimensions" << std::endl; shared_ptr rectdimensions = rectgrid->getDimensions(); if (!rectdimensions->isInitialized()) { rectdimensions->read(); } - printf("The dimensions' tag: %s\n", rectdimensions->getItemTag().c_str()); - printf("Contains the values: %s\n", rectdimensions->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << rectdimensions->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << rectdimensions->getValuesString().c_str() << std::endl; - printf("Rectilinear Coordinates\n"); + std::cout << "Rectilinear Coordinates" << std::endl; std::vector > rectcoordinates = rectgrid->getCoordinates(); - printf("Contains the values: \n"); - for (i=0;iisInitialized()) { rectcoordinates[i]->read(); } - printf("%s\n", rectcoordinates[i]->getValuesString().c_str()); + std::cout << rectcoordinates[i]->getValuesString().c_str() << std::endl; } - printf("Regular Grid\n"); + std::cout << "Regular Grid" << std::endl; shared_ptr reggrid = gridHolder->getRegularGrid(0); - printf("The Regular Grid's tag is: %s\n", reggrid->getItemTag().c_str()); - printf("The Regular Grid's name is: %s\n", reggrid->getName().c_str()); + std::cout << "The Regular Grid's tag is: " << reggrid->getItemTag().c_str() << std::endl; + std::cout << "The Regular Grid's name is: " << reggrid->getName().c_str() << std::endl; outputwalker = reggrid->getItemProperties().begin(); - for (;outputwalker!=reggrid->getItemProperties().end(); outputwalker++) + for (;outputwalker!=reggrid->getItemProperties().end(); ++outputwalker) { - printf("%s: %s\n", (*outputwalker).first.c_str(), (*outputwalker).second.c_str()); + std::cout << (*outputwalker).first.c_str() << ": " << (*outputwalker).second.c_str() << std::endl; } - printf("The Regular Grid's time is: %f\n", reggrid->getTime()->getValue()); - for (i=0; igetNumberMaps(); i++) + std::cout << "The Regular Grid's time is: " << reggrid->getTime()->getValue() << std::endl; + for (i=0; igetNumberMaps(); ++i) { readMap = reggrid->getMap(i); if (!readMap->isInitialized()) { readMap->read(); } - printf("Map # %d\n", i); + std::cout << "Map # " << i << std::endl; taskIDMap = readMap->getMap(); - for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); taskWalker++) + for (taskWalker = taskIDMap.begin(); taskWalker!= taskIDMap.end(); ++taskWalker) { task = (*taskWalker).first; nodeIDMap = (*taskWalker).second; - for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); nodeWalker++) + for (nodeWalker = nodeIDMap.begin(); nodeWalker != nodeIDMap.end(); ++nodeWalker) { node = (*nodeWalker).first; remoteIDset = (*nodeWalker).second; - for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end();remoteWalker++) + for (remoteWalker = remoteIDset.begin(); remoteWalker != remoteIDset.end(); ++remoteWalker) { remote = (*remoteWalker); - printf("taskID: %d\tlocalnodeID: %d\tremotenodeID: %d\n", task, node, remote); + std::cout << "taskID: " << task << "\tlocalnodeID: " << node << "\tremotenodeID: " << remote << std::endl; } } } } - for (i=0; i < reggrid->getNumberSets(); i++) + for (i=0; i < reggrid->getNumberSets(); ++i) { readSet = reggrid->getSet(i); if (!readSet->isInitialized()) { readSet->read(); } - printf("Set # %d\n", i); - printf("%s\n", readSet->getName().c_str()); + std::cout << "Set # " << i << std::endl; + std::cout << readSet->getName().c_str() << std::endl; if (readSet->getType() == XdmfSetType::Node()) { - printf("This set is a node"); + std::cout << "This set is a node" << std::endl; } else { - printf("This set is not a node"); + std::cout << "This set is not a node" << std::endl; } outputInformation = readSet->getInformation(0); - printf("Key: %s\nValue: %s\n", outputInformation->getKey().c_str(), outputInformation->getValue().c_str()); - printf("%s\n", readSet->getValuesString().c_str()); - for (j=0; j < readSet->getNumberAttributes(); j++) + std::cout << "Key: " << outputInformation->getKey().c_str() << "\nValue: " << outputInformation->getValue().c_str() << std::endl; + std::cout << readSet->getValuesString().c_str() << std::endl; + for (j=0; j < readSet->getNumberAttributes(); ++j) { readAttribute = readSet->getAttribute(j); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Set Attribute # %d\n", j); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Set Attribute # " << j << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } } - for (i = 0; i < reggrid->getNumberAttributes(); i++) + for (i = 0; i < reggrid->getNumberAttributes(); ++i) { readAttribute = reggrid->getAttribute(i); if (!readAttribute->isInitialized()) { readAttribute->read(); } - printf("Attribute # %d\n", i); - printf("%s\n", readAttribute->getName().c_str()); + std::cout << "Attribute # " << i << std::endl; + std::cout << readAttribute->getName().c_str() << std::endl; if (readAttribute->getType() == XdmfAttributeType::Scalar()) { - printf("This attribute is a scalar\n"); + std::cout << "This attribute is a scalar" << std::endl; } else { - printf("This attribute is not a scalar\n"); + std::cout << "This attribute is not a scalar" << std::endl; } if (readAttribute->getCenter() == XdmfAttributeCenter::Node()) { - printf("This attribute is a node\n"); + std::cout << "This attribute is a node" << std::endl; } else { - printf("This attribute is not a node\n"); + std::cout << "This attribute is not a node" << std::endl; } - printf("%s\n", readAttribute->getValuesString().c_str()); + std::cout << readAttribute->getValuesString().c_str() << std::endl; } - printf("Regular Brick Size\n"); + std::cout << "Regular Brick Size" << std::endl; shared_ptr regbricksize = reggrid->getBrickSize(); if (!regbricksize->isInitialized()) { regbricksize->read(); } - printf("The brick's tag: %s\n", regbricksize->getItemTag().c_str()); - printf("Contains the values: %s\n", regbricksize->getValuesString().c_str()); + std::cout << "The brick's tag: " << regbricksize->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regbricksize->getValuesString().c_str() << std::endl; - printf("Regular Number of Points\n"); + std::cout << "Regular Number of Points" << std::endl; shared_ptr regnumpoints = reggrid->getDimensions(); - printf("The dimensions' tag: %s\n", regnumpoints->getItemTag().c_str()); - printf("Contains the values: %s\n", regnumpoints->getValuesString().c_str()); + std::cout << "The dimensions' tag: " << regnumpoints->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regnumpoints->getValuesString().c_str() << std::endl; - printf("Regular Origin\n"); + std::cout << "Regular Origin" << std::endl; shared_ptr regorigin = reggrid->getOrigin(); if (!regorigin->isInitialized()) { regorigin->read(); } - printf("The origin's tag: %s\n", regorigin->getItemTag().c_str()); - printf("Contains the values: %s\n", regorigin->getValuesString().c_str()); + std::cout << "The origin's tag: " << regorigin->getItemTag().c_str() << std::endl; + std::cout << "Contains the values: " << regorigin->getValuesString().c_str() << std::endl; return 0; } diff --git a/tests/Cxx/ExampleXdmfWrite.cpp b/tests/Cxx/ExampleXdmfWrite.cpp index 58f8cac8..f400d980 100644 --- a/tests/Cxx/ExampleXdmfWrite.cpp +++ b/tests/Cxx/ExampleXdmfWrite.cpp @@ -222,28 +222,23 @@ int main(int, char **) exampleHeavyWriter->setFileSizeLimit(1); primaryDomain->accept(exampleHeavyWriter); - printf("default mode\n"); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Overwrite);//do this so that the data isn't in the hdf5 file twice. - printf("overwrite mode\n"); exampleHeavyWriter->setFileIndex(0); exampleWriter->setLightDataLimit(1); primaryDomain->accept(exampleWriter); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); - printf("append mode\n"); for (int i = 0; i <= 797; i++) {//overflow occurs at around 509 primaryDomain->accept(exampleHeavyWriter); } - /*exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Default); - printf("default mode\n"); + exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Default); primaryDomain->accept(exampleHeavyWriter); - printf("append mode\n"); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); for (int i = 0; i<500; i++) { primaryDomain->accept(exampleHeavyWriter); - }*/ + } primaryDomain->accept(exampleWriter); return 0; } diff --git a/tests/Cxx/HugeReadArray.cpp b/tests/Cxx/HugeReadArray.cpp index 56113e0c..e976fc7a 100644 --- a/tests/Cxx/HugeReadArray.cpp +++ b/tests/Cxx/HugeReadArray.cpp @@ -9,6 +9,6 @@ int main(int, char **) shared_ptr testReader = XdmfReader::New(); shared_ptr readArray = shared_dynamic_cast(testReader->read("arraydata.xmf")); readArray->read(); - printf("Array ocntains %s\n", readArray->getValuesString()); + std::cout << "Array ocntains " << readArray->getValuesString() << std::endl; return 0; } diff --git a/tests/Cxx/ReadArray.cpp b/tests/Cxx/ReadArray.cpp index 8c567b29..c12bd2e1 100644 --- a/tests/Cxx/ReadArray.cpp +++ b/tests/Cxx/ReadArray.cpp @@ -17,16 +17,16 @@ int main(int, char **) shared_ptr testReader = XdmfReader::New(); /* shared_ptr readArray = shared_dynamic_cast(testReader->read("array.xmf")); - printf("Array ocntains %s\n", readArray->getValuesString()); + std::cout << "Array ocntains " << readArray->getValuesString() << std::endl; */ shared_ptr readDomain = shared_dynamic_cast(testReader->read("array.xmf")); - printf("pulling out unstructured grid\n"); + std::cout << "pulling out unstructured grid" << std::endl; shared_ptr readGrid = readDomain->getRectilinearGrid(0); - //printf("pulling out geometry\n"); + //std::cout << "pulling out geometry" << std::endl; //shared_ptr readGeometry = readGrid->getGeometry(); - printf("pulling out dimensions\n"); + std::cout << "pulling out dimensions" << std::endl; std::vector > readDimensions = readGrid->getCoordinates(); - printf("Geometry contains %s\n", readDimensions[0]->getValuesString()); + std::cout << "Geometry contains " << readDimensions[0]->getValuesString() << std::endl; shared_ptr testWriter = XdmfWriter::New("arrayoutput.xmf"); readGrid->accept(testWriter); //readArray->accept(testWriter); diff --git a/tests/Cxx/TestXdmfGraph.cpp b/tests/Cxx/TestXdmfGraph.cpp index 637770cb..c68c22ce 100644 --- a/tests/Cxx/TestXdmfGraph.cpp +++ b/tests/Cxx/TestXdmfGraph.cpp @@ -35,11 +35,9 @@ int main(int, char **) shared_ptr writer = XdmfWriter::New("TestXdmfGraph.xmf"); graph->accept(writer); - printf("after writing\n"); shared_ptr reader = XdmfReader::New(); shared_ptr readGraph = shared_dynamic_cast(reader->read("TestXdmfGraph.xmf")); - printf("after reading\n"); assert(readGraph); assert(readGraph->getNumberNodes() == graph->getNumberNodes()); assert(readGraph->getNumberAttributes() == graph->getNumberAttributes()); diff --git a/tests/Cxx/XdmfPostFixCalc.cpp b/tests/Cxx/XdmfPostFixCalc.cpp index c698b63b..c649612b 100644 --- a/tests/Cxx/XdmfPostFixCalc.cpp +++ b/tests/Cxx/XdmfPostFixCalc.cpp @@ -211,7 +211,7 @@ double parse(std::string expression, std::map variables) //if it is grab the string between paranthesis i = i + 2; valueStart = i; - unsigned int numOpenParenthesis = 0; + int numOpenParenthesis = 0; while ((expression[i] != ')' || numOpenParenthesis) && i < expression.size()) { if (expression[i] == '(') @@ -483,7 +483,7 @@ shared_ptr parse(std::string expression, std::map calculation(shared_ptr val1, shared_ptrgetSize()/arrayRatio1; - if ((unsigned int)((amountWritten * arrayRatio1) + i) < val1->getSize()) + if (((amountWritten * arrayRatio1) + i) < (int)val1->getSize()) { amountWritten++; } - if (amountWritten > floor(val2->getSize()/arrayRatio2)) + if (amountWritten > (int)floor(val2->getSize()/arrayRatio2)) { arrayExcess1 += amountWritten - (int)floor(val2->getSize()/arrayRatio2); amountWritten = (int)floor(val2->getSize()/arrayRatio2); @@ -1010,11 +1010,11 @@ shared_ptr calculation(shared_ptr val1, shared_ptrgetSize()/arrayRatio2; - if ((unsigned int)((amountWritten * arrayRatio2) + i) < val2->getSize()) + if (((amountWritten * arrayRatio2) + i) < (int)val2->getSize()) { amountWritten++; } - if (amountWritten > floor(val1->getSize()/arrayRatio1)) + if (amountWritten > (int)floor(val1->getSize()/arrayRatio1)) { arrayExcess2 += amountWritten - (int)floor(val1->getSize()/arrayRatio1); amountWritten = (int)floor(val1->getSize()/arrayRatio1); diff --git a/tests/Python/WriteTime.py b/tests/Python/WriteTime.py index 085a0932..067567bc 100644 --- a/tests/Python/WriteTime.py +++ b/tests/Python/WriteTime.py @@ -35,7 +35,6 @@ if __name__ == "__main__": startclock = time.clock() for i in range(numTimestamps): - #print "timestamp " + str(i) timestampGrid = XdmfGridCollection.New() timestampTime = XdmfTime.New(i) timestampGrid.setTime(timestampTime) @@ -68,11 +67,15 @@ if __name__ == "__main__": #sectionGrid.accept(exampleHeavyWriter) #exampleHeavyWriter.closeFile() primaryCollection.insert(timestampGrid) + writeclock = time.clock() exampleHeavyWriter.openFile() - timestampGrid.accept(exampleHeavyWriter) #primaryDomain.accept(exampleHeavyWriter) - #primaryDomain.accept(exampleWriter) + if i % 10 == 9: + primaryDomain.accept(exampleWriter) + else: + timestampGrid.accept(exampleHeavyWriter) exampleHeavyWriter.closeFile() + print "iteration " + str(i) + " Time = " + str(time.clock() - writeclock) exampleHeavyWriter.openFile() @@ -81,3 +84,8 @@ if __name__ == "__main__": exampleHeavyWriter.closeFile() print (time.clock() - startclock) + + print XdmfSystemUtils.getRealPath("timestamptest.xmf") + + #os.remove("/usr/var/tmp/ajburns/timing.xmf") + #os.remove("/usr/var/tmp/ajburns/timing.h5") diff --git a/utils/XdmfFortran.cpp b/utils/XdmfFortran.cpp index 793ce975..8b2a86d4 100644 --- a/utils/XdmfFortran.cpp +++ b/utils/XdmfFortran.cpp @@ -377,8 +377,9 @@ XdmfFortran::addAttribute(const char * const name, return id; } +// unstructured version void -XdmfFortran::addGrid(const char * const name, const bool writeToHDF5)//unstructured version +XdmfFortran::addGrid(const char * const name, const bool writeToHDF5) { const shared_ptr grid = XdmfUnstructuredGrid::New(); grid->setName(name); @@ -837,4094 +838,3243 @@ XdmfFortran::setTopology(const int topologyType, int XdmfFortran::retrieveNumDomainGridCollections() { - return mDomain->getNumberGridCollections(); + return mDomain->getNumberGridCollections(); } int XdmfFortran::numGridCollectionGridCollections() { - if (!mGridCollections.empty()) - { - return mGridCollections.top()->getNumberGridCollections(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (!mGridCollections.empty()) { + return mGridCollections.top()->getNumberGridCollections(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveDomainTag(char * returnTag, int tagLength) { - char * tempTag = strdup(mDomain->getItemTag().c_str()); - memset(returnTag, 0, tagLength); - memcpy(returnTag, tempTag, strlen(tempTag)+1); - delete [] tempTag; + char * tempTag = strdup(mDomain->getItemTag().c_str()); + memset(returnTag, 0, tagLength); + memcpy(returnTag, tempTag, strlen(tempTag)+1); + delete [] tempTag; } int XdmfFortran::retrieveDomainNumProperties() { - return mDomain->getItemProperties().size(); + return mDomain->getItemProperties().size(); } void XdmfFortran::retrieveDomainProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (index < (int)mDomain->getItemProperties().size()) - { - std::map::iterator walker = mDomain->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mDomain->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mDomain->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } + std::string tempString = key; + memset(value, 0, valueLength); + if ((mDomain->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mDomain->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } } void XdmfFortran::removeDomainGridCollection(int index) { - if ((int)mDomain->getNumberGridCollections() > index) - { - mDomain->removeGridCollection(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if ((int)mDomain->getNumberGridCollections() > index) { + mDomain->removeGridCollection(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::openDomainGridCollection(int index, int openMaps, int openAttributes, int openInformation, int openSets) { - if ((int)mDomain->getNumberGridCollections() > index) - { - shared_ptr openedGridCollection = mDomain->getGridCollection(index); - int i; - int n; - if (openMaps == 1) - { - n = openedGridCollection->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGridCollection->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openAttributes == 1) - { - n = openedGridCollection->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGridCollection->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openInformation == 1) - { - n = openedGridCollection->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGridCollection->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGridCollection->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGridCollection->getSet(i); - mSets.push_back(openedSet); - } - mGridCollections.push(openedGridCollection); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if ((int)mDomain->getNumberGridCollections() > index) { + shared_ptr openedGridCollection = mDomain->getGridCollection(index); + int i; + int n; + if (openMaps == 1) { + n = openedGridCollection->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGridCollection->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openAttributes == 1) { + n = openedGridCollection->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGridCollection->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openInformation == 1) { + n = openedGridCollection->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGridCollection->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGridCollection->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGridCollection->getSet(i); + mSets.push_back(openedSet); + } + mGridCollections.push(openedGridCollection); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeGridCollectionGridCollection(int index) { - if (!mGridCollections.empty()) - { - if ((int)mGridCollections.top()->getNumberGridCollections() > index) - { - mGridCollections.top()->removeGridCollection(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + if ((int)mGridCollections.top()->getNumberGridCollections() > index) { + mGridCollections.top()->removeGridCollection(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::openGridCollectionGridCollection(int index, int openMaps, int openAttributes, int openInformation, int openSets) { - if (!mGridCollections.empty()) - { - if ((int)mGridCollections.top()->getNumberGridCollections() > index) - { - shared_ptr openedGridCollection = mGridCollections.top()->getGridCollection(index); - int i; - int n; - if (openMaps == 1) - { - n = openedGridCollection->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGridCollection->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openAttributes == 1) - { - n = openedGridCollection->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGridCollection->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openInformation == 1) - { - n = openedGridCollection->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGridCollection->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGridCollection->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGridCollection->getSet(i); - mSets.push_back(openedSet); - } - mGridCollections.push(openedGridCollection); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + if ((int)mGridCollections.top()->getNumberGridCollections() > index) { + shared_ptr openedGridCollection = mGridCollections.top()->getGridCollection(index); + int i; + int n; + if (openMaps == 1) { + n = openedGridCollection->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGridCollection->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openAttributes == 1) { + n = openedGridCollection->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGridCollection->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openInformation == 1) { + n = openedGridCollection->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGridCollection->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGridCollection->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGridCollection->getSet(i); + mSets.push_back(openedSet); + } + mGridCollections.push(openedGridCollection); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveGridCollectionTag(char * returnTag, int tagLength) { - if (!mGridCollections.empty()) - { - char * tempTag = strdup(mGridCollections.top()->getItemTag().c_str()); - memset(returnTag, 0, tagLength); - memcpy(returnTag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + char * tempTag = strdup(mGridCollections.top()->getItemTag().c_str()); + memset(returnTag, 0, tagLength); + memcpy(returnTag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveGridCollectionName(char * returnName, int nameLength) { - if (!mGridCollections.empty()) - { - char * tempName = strdup(mGridCollections.top()->getName().c_str()); - memset(returnName, 0, nameLength); - memcpy(returnName, tempName, strlen(tempName)+1); - delete [] tempName; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + char * tempName = strdup(mGridCollections.top()->getName().c_str()); + memset(returnName, 0, nameLength); + memcpy(returnName, tempName, strlen(tempName)+1); + delete [] tempName; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveGridCollectionNumProperties() { - if (!mGridCollections.empty()) - { - return mGridCollections.top()->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (!mGridCollections.empty()) { + return mGridCollections.top()->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveGridCollectionProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (!mGridCollections.empty()) - { - if (index < (int)mGridCollections.top()->getItemProperties().size()) - { - std::map::iterator walker = mGridCollections.top()->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mGridCollections.top()->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mGridCollections.top()->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mGridCollections.top()->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mGridCollections.top()->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: No grid collections are open."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::openDomainGrid(int gridType, int index, int openMaps, int openAttributes, int openInformation, int openSets) { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - shared_ptr openedGrid = mDomain->getCurvilinearGrid(index); - shared_ptr dataType; - mGeometry = openedGrid->getGeometry(); - mDimensions = openedGrid->getDimensions(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - shared_ptr openedGrid = mDomain->getRectilinearGrid(index); - shared_ptr dataType; - mCoordinates = openedGrid->getCoordinates(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - shared_ptr openedGrid = mDomain->getRegularGrid(index); - shared_ptr dataType; - mTime = openedGrid->getTime(); - mBrick = openedGrid->getBrickSize(); - mOrigin = openedGrid->getOrigin(); - mDimensions = openedGrid->getDimensions(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - shared_ptr openedGrid = mDomain->getUnstructuredGrid(index); - mTopology = openedGrid->getTopology(); - mGeometry = openedGrid->getGeometry(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + shared_ptr openedGrid = mDomain->getCurvilinearGrid(index); + shared_ptr dataType; + mGeometry = openedGrid->getGeometry(); + mDimensions = openedGrid->getDimensions(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + shared_ptr openedGrid = mDomain->getRectilinearGrid(index); + shared_ptr dataType; + mCoordinates = openedGrid->getCoordinates(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + shared_ptr openedGrid = mDomain->getRegularGrid(index); + shared_ptr dataType; + mTime = openedGrid->getTime(); + mBrick = openedGrid->getBrickSize(); + mOrigin = openedGrid->getOrigin(); + mDimensions = openedGrid->getDimensions(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + shared_ptr openedGrid = mDomain->getUnstructuredGrid(index); + mTopology = openedGrid->getTopology(); + mGeometry = openedGrid->getGeometry(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeDomainGrid(int gridType, int index) { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - mDomain->removeCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - mDomain->removeRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - mDomain->removeRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - mDomain->removeUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + mDomain->removeCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + mDomain->removeRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + mDomain->removeRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + mDomain->removeUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceDomainGrid(int gridType, int index, char * name) { - int i; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - if(mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); - } - catch (XdmfError e) - { - throw e; - } - } - if(mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - shared_ptr grid = mDomain->getCurvilinearGrid(index); - grid->setName(name); - - grid->setGeometry(mGeometry); - grid->setDimensions(mDimensions); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for( i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); - - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - if(mCoordinates.empty()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Coordinates before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - shared_ptr grid = mDomain->getRectilinearGrid(index); - grid->setCoordinates(mCoordinates); - mCoordinates.clear(); - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); - - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - if(mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick size before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - if(mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - if(mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - shared_ptr grid = mDomain->getRegularGrid(index); - grid->setOrigin(mOrigin); - grid->setDimensions(mDimensions); - grid->setBrickSize(mBrick); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); - - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - if(mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - if(mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set topology before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - shared_ptr grid = mDomain->getUnstructuredGrid(index); - grid->setName(name); - grid->setGeometry(mGeometry); - grid->setTopology(mTopology); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); - - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } -} - -void -XdmfFortran::retrieveDomainGridName(int gridType, int index, char * returnName, int nameLength) -{ - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - openedGrid = mDomain->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - openedGrid = mDomain->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - openedGrid = mDomain->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - openedGrid = mDomain->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - char * tempName = strdup(openedGrid->getName().c_str()); - memset(returnName, 0, nameLength); - memcpy(returnName, tempName, strlen(tempName)+1); - delete [] tempName; -} + int i; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + if(mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); + } + catch (XdmfError e) { + throw e; + } + } + if(mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } -void -XdmfFortran::retrieveDomainGridTag(int gridType, int index, char * returnTag, int tagLength) -{ - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - openedGrid = mDomain->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - openedGrid = mDomain->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - openedGrid = mDomain->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - openedGrid = mDomain->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - char * tempTag = strdup(openedGrid->getItemTag().c_str()); - memset(returnTag, 0, tagLength); - memcpy(returnTag, tempTag, strlen(tempTag)+1); - delete [] tempTag; -} + shared_ptr grid = mDomain->getCurvilinearGrid(index); + grid->setName(name); -int -XdmfFortran::retrieveDomainGridNumProperties(int gridType, int index) -{ - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - return mDomain->getCurvilinearGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - return mDomain->getRectilinearGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - return mDomain->getRegularGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - return mDomain->getUnstructuredGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } -} + grid->setGeometry(mGeometry); + grid->setDimensions(mDimensions); -void -XdmfFortran::retrieveDomainGridProperty(int gridType, int gridIndex, int index, char * key, int keyLength, char * value, int valueLength) -{ - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - openedGrid = mDomain->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - openedGrid = mDomain->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - openedGrid = mDomain->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - openedGrid = mDomain->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - if (index < (int)openedGrid->getItemProperties().size()) - { - std::map::iterator walker = openedGrid->getItemProperties().begin(); - for (int i = 0; igetNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for( i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); + + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + if(mCoordinates.empty()) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Coordinates before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + shared_ptr grid = mDomain->getRectilinearGrid(index); + grid->setCoordinates(mCoordinates); + mCoordinates.clear(); + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); + + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + if(mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick size before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + if(mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + if(mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + shared_ptr grid = mDomain->getRegularGrid(index); + grid->setOrigin(mOrigin); + grid->setDimensions(mDimensions); + grid->setBrickSize(mBrick); + + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); + + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + if(mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + if(mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set topology before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + shared_ptr grid = mDomain->getUnstructuredGrid(index); + grid->setName(name); + grid->setGeometry(mGeometry); + grid->setTopology(mTopology); + + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); + + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } +} + +void +XdmfFortran::retrieveDomainGridName(int gridType, int index, char * returnName, int nameLength) +{ + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + openedGrid = mDomain->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + openedGrid = mDomain->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + openedGrid = mDomain->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + openedGrid = mDomain->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + char * tempName = strdup(openedGrid->getName().c_str()); + memset(returnName, 0, nameLength); + memcpy(returnName, tempName, strlen(tempName)+1); + delete [] tempName; +} + +void +XdmfFortran::retrieveDomainGridTag(int gridType, int index, char * returnTag, int tagLength) +{ + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + openedGrid = mDomain->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) + { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + openedGrid = mDomain->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + openedGrid = mDomain->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + openedGrid = mDomain->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + char * tempTag = strdup(openedGrid->getItemTag().c_str()); + memset(returnTag, 0, tagLength); + memcpy(returnTag, tempTag, strlen(tempTag)+1); + delete [] tempTag; +} + +int +XdmfFortran::retrieveDomainGridNumProperties(int gridType, int index) +{ + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + return mDomain->getCurvilinearGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + return mDomain->getRectilinearGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + return mDomain->getRegularGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + return mDomain->getUnstructuredGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } +} + +void +XdmfFortran::retrieveDomainGridProperty(int gridType, int gridIndex, int index, char * key, int keyLength, char * value, int valueLength) +{ + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + openedGrid = mDomain->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + openedGrid = mDomain->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + openedGrid = mDomain->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + openedGrid = mDomain->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + if (index < (int)openedGrid->getItemProperties().size()) { + std::map::iterator walker = openedGrid->getItemProperties().begin(); + for (int i = 0; i openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mDomain->getNumberCurvilinearGrids()) - { - openedGrid = mDomain->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mDomain->getNumberRectilinearGrids()) - { - openedGrid = mDomain->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mDomain->getNumberRegularGrids()) - { - openedGrid = mDomain->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mDomain->getNumberUnstructuredGrids()) - { - openedGrid = mDomain->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - std::string tempString = key; - memset(value, 0, valueLength); - if ((openedGrid->getItemProperties().count(tempString))>0) - { - char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mDomain->getNumberCurvilinearGrids()) { + openedGrid = mDomain->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mDomain->getNumberRectilinearGrids()) { + openedGrid = mDomain->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mDomain->getNumberRegularGrids()) { + openedGrid = mDomain->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mDomain->getNumberUnstructuredGrids()) { + openedGrid = mDomain->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + std::string tempString = key; + memset(value, 0, valueLength); + if ((openedGrid->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } } void XdmfFortran::openGridCollectionGrid(int gridType, int index, int openMaps, int openAttributes, int openInformation, int openSets) { - if (!mGridCollections.empty()) - { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - shared_ptr openedGrid = mGridCollections.top()->getCurvilinearGrid(index); - shared_ptr dataType; - mGeometry = openedGrid->getGeometry(); - mDimensions = openedGrid->getDimensions(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - shared_ptr openedGrid = mGridCollections.top()->getRectilinearGrid(index); - shared_ptr dataType; - mCoordinates = openedGrid->getCoordinates(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - shared_ptr openedGrid = mGridCollections.top()->getRegularGrid(index); - shared_ptr dataType; - mTime = openedGrid->getTime(); - mBrick = openedGrid->getBrickSize(); - mOrigin = openedGrid->getOrigin(); - mDimensions = openedGrid->getDimensions(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - shared_ptr openedGrid = mGridCollections.top()->getUnstructuredGrid(index); - mTopology = openedGrid->getTopology(); - mGeometry = openedGrid->getGeometry(); - mTime = openedGrid->getTime(); - int i; - int n; - if (openAttributes == 1) - { - n = openedGrid->getNumberAttributes(); - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedGrid->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openMaps == 1) - { - n = openedGrid->getNumberMaps(); - shared_ptr openedMap; - for (i = 0; i < n; i++) - { - openedMap = openedGrid->getMap(i); - mMaps.push_back(openedMap); - mPreviousMaps.push_back(openedMap); - } - } - if (openInformation == 1) - { - n = openedGrid->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedGrid->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - if (openSets == 1) - { - n = openedGrid->getNumberSets(); - shared_ptr openedSet; - for (i = 0; i < n; i++) - { - openedSet = openedGrid->getSet(i); - mSets.push_back(openedSet); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + shared_ptr openedGrid = mGridCollections.top()->getCurvilinearGrid(index); + shared_ptr dataType; + mGeometry = openedGrid->getGeometry(); + mDimensions = openedGrid->getDimensions(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + shared_ptr openedGrid = mGridCollections.top()->getRectilinearGrid(index); + shared_ptr dataType; + mCoordinates = openedGrid->getCoordinates(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + shared_ptr openedGrid = mGridCollections.top()->getRegularGrid(index); + shared_ptr dataType; + mTime = openedGrid->getTime(); + mBrick = openedGrid->getBrickSize(); + mOrigin = openedGrid->getOrigin(); + mDimensions = openedGrid->getDimensions(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + shared_ptr openedGrid = mGridCollections.top()->getUnstructuredGrid(index); + mTopology = openedGrid->getTopology(); + mGeometry = openedGrid->getGeometry(); + mTime = openedGrid->getTime(); + int i; + int n; + if (openAttributes == 1) { + n = openedGrid->getNumberAttributes(); + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedGrid->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openMaps == 1) { + n = openedGrid->getNumberMaps(); + shared_ptr openedMap; + for (i = 0; i < n; i++) { + openedMap = openedGrid->getMap(i); + mMaps.push_back(openedMap); + mPreviousMaps.push_back(openedMap); + } + } + if (openInformation == 1) { + n = openedGrid->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedGrid->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + if (openSets == 1) { + n = openedGrid->getNumberSets(); + shared_ptr openedSet; + for (i = 0; i < n; i++) { + openedSet = openedGrid->getSet(i); + mSets.push_back(openedSet); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeGridCollectionGrid(int gridType, int index) -{ - if (!mGridCollections.empty()) - { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - mGridCollections.top()->removeCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - mGridCollections.top()->removeRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - mGridCollections.top()->removeRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - mGridCollections.top()->removeUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } +{ + if (!mGridCollections.empty()) { + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + mGridCollections.top()->removeCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + mGridCollections.top()->removeRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + mGridCollections.top()->removeRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + mGridCollections.top()->removeUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceGridCollectionGrid(int gridType, int index, char * name) { - if (!mGridCollections.empty()) - { - int i; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - if(mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); - } - catch (XdmfError e) - { - throw e; - } - } - if(mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - shared_ptr grid = mGridCollections.top()->getCurvilinearGrid(index); - grid->setName(name); - - grid->setGeometry(mGeometry); - grid->setDimensions(mDimensions); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for( i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); + if (!mGridCollections.empty()) { + int i; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + if(mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, "Must set dimensions before replacing grid."); + } + catch (XdmfError e) { + throw e; + } + } + if(mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + shared_ptr grid = mGridCollections.top()->getCurvilinearGrid(index); + grid->setName(name); + + grid->setGeometry(mGeometry); + grid->setDimensions(mDimensions); + + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for( i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - if(mCoordinates.empty()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Coordinates before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - shared_ptr grid = mGridCollections.top()->getRectilinearGrid(index); - grid->setCoordinates(mCoordinates); - mCoordinates.clear(); - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + if(mCoordinates.empty()) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Coordinates before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + shared_ptr grid = mGridCollections.top()->getRectilinearGrid(index); + grid->setCoordinates(mCoordinates); + mCoordinates.clear(); + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - if(mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick size before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - if(mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - - if(mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + if(mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick size before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + if(mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + + if(mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } - shared_ptr grid = mGridCollections.top()->getRegularGrid(index); - grid->setOrigin(mOrigin); - grid->setDimensions(mDimensions); - grid->setBrickSize(mBrick); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); + shared_ptr grid = mGridCollections.top()->getRegularGrid(index); + grid->setOrigin(mOrigin); + grid->setDimensions(mDimensions); + grid->setBrickSize(mBrick); + + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - if(mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - if(mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set topology before adding grid."); - } - catch (XdmfError e) - { - throw e; - } - } - shared_ptr grid = mGridCollections.top()->getUnstructuredGrid(index); - grid->setName(name); - grid->setGeometry(mGeometry); - grid->setTopology(mTopology); - - for (i=grid->getNumberAttributes()-1;i>=0;i--) - { - grid->removeAttribute(0); - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - grid->insert(*iter); - } - - mAttributes.clear(); - - for (i=grid->getNumberInformations()-1;i>=0;i--) - { - grid->removeInformation(0); - } - - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - grid->insert(*iter); - } - - mInformations.clear(); - - for (i=grid->getNumberSets()-1;i>=0;i--) - { - grid->removeSet(0); - } - - for(std::vector >::const_iterator iter = - mSets.begin(); - iter != mSets.end(); - ++iter) - { - grid->insert(*iter); - } - - mSets.clear(); - - for (i=grid->getNumberMaps()-1;i>=0;i--) - { - grid->removeMap(0); - } - - for(std::vector >::const_iterator iter = - mMaps.begin(); - iter != mMaps.end(); - ++iter) - { - grid->insert(*iter); - } - - mMaps.clear(); + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + if(mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + if(mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set topology before adding grid."); + } + catch (XdmfError e) { + throw e; + } + } + shared_ptr grid = mGridCollections.top()->getUnstructuredGrid(index); + grid->setName(name); + grid->setGeometry(mGeometry); + grid->setTopology(mTopology); + + for (i=grid->getNumberAttributes()-1;i>=0;i--) { + grid->removeAttribute(0); + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + grid->insert(*iter); + } + + mAttributes.clear(); + + for (i=grid->getNumberInformations()-1;i>=0;i--) { + grid->removeInformation(0); + } + + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + grid->insert(*iter); + } + + mInformations.clear(); + + for (i=grid->getNumberSets()-1;i>=0;i--) { + grid->removeSet(0); + } + + for(std::vector >::const_iterator iter = + mSets.begin(); + iter != mSets.end(); + ++iter) { + grid->insert(*iter); + } + + mSets.clear(); + + for (i=grid->getNumberMaps()-1;i>=0;i--) { + grid->removeMap(0); + } + + for(std::vector >::const_iterator iter = + mMaps.begin(); + iter != mMaps.end(); + ++iter) { + grid->insert(*iter); + } + + mMaps.clear(); - if(mTime) - { - grid->setTime(mTime); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } + if(mTime) { + grid->setTime(mTime); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveGridCollectionGridName(int gridType, int index, char * returnName, int nameLength) { - if (!mGridCollections.empty()) - { - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - openedGrid = mGridCollections.top()->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - openedGrid = mGridCollections.top()->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - openedGrid = mGridCollections.top()->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - openedGrid = mGridCollections.top()->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - char * tempName = strdup(openedGrid->getName().c_str()); - memset(returnName, 0, nameLength); - memcpy(returnName, tempName, strlen(tempName)+1); - delete [] tempName; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + openedGrid = mGridCollections.top()->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + openedGrid = mGridCollections.top()->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + openedGrid = mGridCollections.top()->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + openedGrid = mGridCollections.top()->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + char * tempName = strdup(openedGrid->getName().c_str()); + memset(returnName, 0, nameLength); + memcpy(returnName, tempName, strlen(tempName)+1); + delete [] tempName; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveGridCollectionGridTag(int gridType, int index, char * returnTag, int tagLength) { - if (!mGridCollections.empty()) - { - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - openedGrid = mGridCollections.top()->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - openedGrid = mGridCollections.top()->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - openedGrid = mGridCollections.top()->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - openedGrid = mGridCollections.top()->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - char * tempTag = strdup(openedGrid->getItemTag().c_str()); - memset(returnTag, 0, tagLength); - memcpy(returnTag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + openedGrid = mGridCollections.top()->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + openedGrid = mGridCollections.top()->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + openedGrid = mGridCollections.top()->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + openedGrid = mGridCollections.top()->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + char * tempTag = strdup(openedGrid->getItemTag().c_str()); + memset(returnTag, 0, tagLength); + memcpy(returnTag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveGridCollectionGridNumProperties(int gridType, int index) { - if (!mGridCollections.empty()) - { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - return mGridCollections.top()->getCurvilinearGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - return mGridCollections.top()->getRectilinearGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - return mGridCollections.top()->getRegularGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - return mGridCollections.top()->getUnstructuredGrid(index)->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (!mGridCollections.empty()) { + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + return mGridCollections.top()->getCurvilinearGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + return mGridCollections.top()->getRectilinearGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + return mGridCollections.top()->getRegularGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + return mGridCollections.top()->getUnstructuredGrid(index)->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveGridCollectionGridProperty(int gridType, int gridIndex, int index, - char * key, int keyLength, char * value, int valueLength) -{ - if (!mGridCollections.empty()) - { - shared_ptr openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - openedGrid = mGridCollections.top()->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - openedGrid = mGridCollections.top()->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - openedGrid = mGridCollections.top()->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - openedGrid = mGridCollections.top()->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - if (index < (int)openedGrid->getItemProperties().size()) - { - std::map::iterator walker = openedGrid->getItemProperties().begin(); - for (int i = 0; i openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + openedGrid = mGridCollections.top()->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + openedGrid = mGridCollections.top()->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + openedGrid = mGridCollections.top()->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + openedGrid = mGridCollections.top()->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + if (index < (int)openedGrid->getItemProperties().size()) { + std::map::iterator walker = openedGrid->getItemProperties().begin(); + for (int i = 0; i openedGrid; - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) - { - openedGrid = mGridCollections.top()->getCurvilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) - { - openedGrid = mGridCollections.top()->getRectilinearGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - if (index < (int)mGridCollections.top()->getNumberRegularGrids()) - { - openedGrid = mGridCollections.top()->getRegularGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) - { - openedGrid = mGridCollections.top()->getUnstructuredGrid(index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - } - std::string tempString = key; - memset(value, 0, valueLength); - if ((openedGrid->getItemProperties().count(tempString))>0) - { - char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - } + if (!mGridCollections.empty()) { + shared_ptr openedGrid; + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + if (index < (int)mGridCollections.top()->getNumberCurvilinearGrids()) { + openedGrid = mGridCollections.top()->getCurvilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + if (index < (int)mGridCollections.top()->getNumberRectilinearGrids()) { + openedGrid = mGridCollections.top()->getRectilinearGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + if (index < (int)mGridCollections.top()->getNumberRegularGrids()) { + openedGrid = mGridCollections.top()->getRegularGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + if (index < (int)mGridCollections.top()->getNumberUnstructuredGrids()) { + openedGrid = mGridCollections.top()->getUnstructuredGrid(index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + } + std::string tempString = key; + memset(value, 0, valueLength); + if ((openedGrid->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(openedGrid->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::numDomainGrids(int gridType) { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - return mDomain->getNumberCurvilinearGrids(); - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - return mDomain->getNumberRectilinearGrids(); - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - return mDomain->getNumberRegularGrids(); - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - return mDomain->getNumberUnstructuredGrids(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + return mDomain->getNumberCurvilinearGrids(); + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + return mDomain->getNumberRectilinearGrids(); + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + return mDomain->getNumberRegularGrids(); + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + return mDomain->getNumberUnstructuredGrids(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::numGridCollectionGrids(int gridType) { - if (!mGridCollections.empty()) - { - if (gridType == XDMF_GRID_TYPE_CURVILINEAR) - { - return mGridCollections.top()->getNumberCurvilinearGrids(); - } - else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) - { - return mGridCollections.top()->getNumberRectilinearGrids(); - } - else if (gridType == XDMF_GRID_TYPE_REGULAR) - { - return mGridCollections.top()->getNumberRegularGrids(); - } - else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) - { - return mGridCollections.top()->getNumberUnstructuredGrids(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: No Grid Collections have been loaded."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (!mGridCollections.empty()) { + if (gridType == XDMF_GRID_TYPE_CURVILINEAR) { + return mGridCollections.top()->getNumberCurvilinearGrids(); + } + else if (gridType == XDMF_GRID_TYPE_RECTILINEAR) { + return mGridCollections.top()->getNumberRectilinearGrids(); + } + else if (gridType == XDMF_GRID_TYPE_REGULAR) { + return mGridCollections.top()->getNumberRegularGrids(); + } + else if (gridType == XDMF_GRID_TYPE_UNSTRUCTURED) { + return mGridCollections.top()->getNumberUnstructuredGrids(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: No Grid Collections have been loaded."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::retrieveGridCollectionType() { - if (!mGridCollections.empty()) - { - shared_ptr returnType = mGridCollections.top()->getType(); - if (returnType == XdmfGridCollectionType::Spatial()) - { - return XDMF_GRID_COLLECTION_TYPE_SPATIAL; - } - else if (returnType == XdmfGridCollectionType::Temporal()) - { - return XDMF_GRID_COLLECTION_TYPE_TEMPORAL; - } - else if (returnType == XdmfGridCollectionType::NoCollectionType()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: No Grid Collection Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Grid Collection Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "There is no grid collection currently loaded."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (!mGridCollections.empty()) { + shared_ptr returnType = mGridCollections.top()->getType(); + if (returnType == XdmfGridCollectionType::Spatial()) { + return XDMF_GRID_COLLECTION_TYPE_SPATIAL; + } + else if (returnType == XdmfGridCollectionType::Temporal()) { + return XDMF_GRID_COLLECTION_TYPE_TEMPORAL; + } + else if (returnType == XdmfGridCollectionType::NoCollectionType()) { + try { + XdmfError::message(XdmfError::FATAL, + "Error: No Grid Collection Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Grid Collection Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "There is no grid collection currently loaded."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } float XdmfFortran::retrieveTime() { - return static_cast(mTime->getValue()); + return static_cast(mTime->getValue()); } void XdmfFortran::retrieveGeometryTag(char * tag, int tagLength) { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before its tag can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - char * tempTag = strdup(mGeometry->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before its tag can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + char * tempTag = strdup(mGeometry->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } } int XdmfFortran::retrieveGeometryType() { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before its type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr returnType = mGeometry->getType(); - if (returnType == XdmfGeometryType::XY()) - { - return XDMF_GEOMETRY_TYPE_XY; - } - else if (returnType == XdmfGeometryType::XYZ()) - { - return XDMF_GEOMETRY_TYPE_XYZ; - } - else if (returnType == XdmfGeometryType::NoGeometryType()) - { - try - { - XdmfError::message(XdmfError::FATAL, "Uninitialized geometry type"); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Invalid geometry type"); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before its type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr returnType = mGeometry->getType(); + if (returnType == XdmfGeometryType::XY()) { + return XDMF_GEOMETRY_TYPE_XY; + } + else if (returnType == XdmfGeometryType::XYZ()) { + return XDMF_GEOMETRY_TYPE_XYZ; + } + else if (returnType == XdmfGeometryType::NoGeometryType()) { + try { + XdmfError::message(XdmfError::FATAL, "Uninitialized geometry type"); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Invalid geometry type"); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } int XdmfFortran::retrieveGeometryValueType() { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before its value type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr dataType = mGeometry->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Geometry Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Geometry Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before its value type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr dataType = mGeometry->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Geometry Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Geometry Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } void XdmfFortran::retrieveGeometryValues(void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if(mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before its values can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (!mGeometry->isInitialized()) - { - mGeometry->read(); - } - readFromArray(mGeometry, - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } + if(mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before its values can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + if (!mGeometry->isInitialized()) { + mGeometry->read(); + } + readFromArray(mGeometry, + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } } int XdmfFortran::retrieveGeometryNumPoints() { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before the number of points it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mGeometry->getNumberPoints(); - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before the number of points it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mGeometry->getNumberPoints(); + } } int XdmfFortran::retrieveGeometrySize() { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before its size can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mGeometry->getSize(); - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before its size can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mGeometry->getSize(); + } } void XdmfFortran::clearPreviousGeometries() { - mPreviousGeometries.clear(); + mPreviousGeometries.clear(); } int XdmfFortran::retrieveGeometryNumProperties() { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before the number of properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mGeometry->getItemProperties().size(); - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before the number of properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mGeometry->getItemProperties().size(); + } } void XdmfFortran::retrieveGeometryProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (mGeometry == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set geometry before the properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (index < (int)mGeometry->getItemProperties().size()) - { - std::map::iterator walker = mGeometry->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mGeometry->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mGeometry->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } + if (mGeometry == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set geometry before the properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mGeometry->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mGeometry->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } } void XdmfFortran::retrieveTopologyTag(char * tag, int tagLength) { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before its tag can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - char * tempTag = strdup(mTopology->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before its tag can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + char * tempTag = strdup(mTopology->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } } int XdmfFortran::retrieveTopologyType() { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before its type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr returnType = mTopology->getType(); - if (returnType == XdmfTopologyType::Polyvertex()) - { - return XDMF_TOPOLOGY_TYPE_POLYVERTEX; - } - else if (returnType == XdmfTopologyType::Polyline(0)) - { - return XDMF_TOPOLOGY_TYPE_POLYLINE; - } - else if (returnType == XdmfTopologyType::Polygon(0)) - { - return XDMF_TOPOLOGY_TYPE_POLYGON; - } - else if (returnType == XdmfTopologyType::Triangle()) - { - return XDMF_TOPOLOGY_TYPE_TRIANGLE; - } - else if (returnType == XdmfTopologyType::Quadrilateral()) - { - return XDMF_TOPOLOGY_TYPE_QUADRILATERAL; - } - else if (returnType == XdmfTopologyType::Tetrahedron()) - { - return XDMF_TOPOLOGY_TYPE_TETRAHEDRON; - } - else if (returnType == XdmfTopologyType::Pyramid()) - { - return XDMF_TOPOLOGY_TYPE_PYRAMID; - } - else if (returnType == XdmfTopologyType::Wedge()) - { - return XDMF_TOPOLOGY_TYPE_WEDGE; - } - else if (returnType == XdmfTopologyType::Hexahedron()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON; - } - else if (returnType == XdmfTopologyType::Edge_3()) - { - return XDMF_TOPOLOGY_TYPE_EDGE_3; - } - else if (returnType == XdmfTopologyType::Triangle_6()) - { - return XDMF_TOPOLOGY_TYPE_TRIANGLE_6; - } - else if (returnType == XdmfTopologyType::Quadrilateral_8()) - { - return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; - } - else if (returnType == XdmfTopologyType::Quadrilateral_9()) - { - return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; - } - else if (returnType == XdmfTopologyType::Tetrahedron_10()) - { - return XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; - } - else if (returnType == XdmfTopologyType::Pyramid_13()) - { - return XDMF_TOPOLOGY_TYPE_PYRAMID_13; - } - else if (returnType == XdmfTopologyType::Wedge_15()) - { - return XDMF_TOPOLOGY_TYPE_WEDGE_15; - } - else if (returnType == XdmfTopologyType::Wedge_18()) - { - return XDMF_TOPOLOGY_TYPE_WEDGE_18; - } - else if (returnType == XdmfTopologyType::Hexahedron_20()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; - } - else if (returnType == XdmfTopologyType::Hexahedron_24()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; - } - else if (returnType == XdmfTopologyType::Hexahedron_27()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; - } - else if (returnType == XdmfTopologyType::Hexahedron_64()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; - } - else if (returnType == XdmfTopologyType::Hexahedron_125()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; - } - else if (returnType == XdmfTopologyType::Hexahedron_216()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; - } - else if (returnType == XdmfTopologyType::Hexahedron_343()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; - } - else if (returnType == XdmfTopologyType::Hexahedron_512()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; - } - else if (returnType == XdmfTopologyType::Hexahedron_729()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; - } - else if (returnType == XdmfTopologyType::Hexahedron_1000()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; - } - else if (returnType == XdmfTopologyType::Hexahedron_1331()) - { - return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; - } - else if (returnType == XdmfTopologyType::Mixed()) - { - return XDMF_TOPOLOGY_TYPE_MIXED; - } - else if (returnType == XdmfTopologyType::NoTopologyType()) - { - try - { - XdmfError::message(XdmfError::FATAL, "Uninitialized topology type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Invalid topology type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before its type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr returnType = mTopology->getType(); + if (returnType == XdmfTopologyType::Polyvertex()) { + return XDMF_TOPOLOGY_TYPE_POLYVERTEX; + } + else if (returnType == XdmfTopologyType::Polyline(0)) { + return XDMF_TOPOLOGY_TYPE_POLYLINE; + } + else if (returnType == XdmfTopologyType::Polygon(0)) { + return XDMF_TOPOLOGY_TYPE_POLYGON; + } + else if (returnType == XdmfTopologyType::Triangle()) { + return XDMF_TOPOLOGY_TYPE_TRIANGLE; + } + else if (returnType == XdmfTopologyType::Quadrilateral()) { + return XDMF_TOPOLOGY_TYPE_QUADRILATERAL; + } + else if (returnType == XdmfTopologyType::Tetrahedron()) { + return XDMF_TOPOLOGY_TYPE_TETRAHEDRON; + } + else if (returnType == XdmfTopologyType::Pyramid()) { + return XDMF_TOPOLOGY_TYPE_PYRAMID; + } + else if (returnType == XdmfTopologyType::Wedge()) { + return XDMF_TOPOLOGY_TYPE_WEDGE; + } + else if (returnType == XdmfTopologyType::Hexahedron()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON; + } + else if (returnType == XdmfTopologyType::Edge_3()) { + return XDMF_TOPOLOGY_TYPE_EDGE_3; + } + else if (returnType == XdmfTopologyType::Triangle_6()) { + return XDMF_TOPOLOGY_TYPE_TRIANGLE_6; + } + else if (returnType == XdmfTopologyType::Quadrilateral_8()) { + return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_8; + } + else if (returnType == XdmfTopologyType::Quadrilateral_9()) { + return XDMF_TOPOLOGY_TYPE_QUADRILATERAL_9; + } + else if (returnType == XdmfTopologyType::Tetrahedron_10()) { + return XDMF_TOPOLOGY_TYPE_TETRAHEDRON_10; + } + else if (returnType == XdmfTopologyType::Pyramid_13()) { + return XDMF_TOPOLOGY_TYPE_PYRAMID_13; + } + else if (returnType == XdmfTopologyType::Wedge_15()) { + return XDMF_TOPOLOGY_TYPE_WEDGE_15; + } + else if (returnType == XdmfTopologyType::Wedge_18()) { + return XDMF_TOPOLOGY_TYPE_WEDGE_18; + } + else if (returnType == XdmfTopologyType::Hexahedron_20()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_20; + } + else if (returnType == XdmfTopologyType::Hexahedron_24()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_24; + } + else if (returnType == XdmfTopologyType::Hexahedron_27()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_27; + } + else if (returnType == XdmfTopologyType::Hexahedron_64()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_64; + } + else if (returnType == XdmfTopologyType::Hexahedron_125()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_125; + } + else if (returnType == XdmfTopologyType::Hexahedron_216()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_216; + } + else if (returnType == XdmfTopologyType::Hexahedron_343()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_343; + } + else if (returnType == XdmfTopologyType::Hexahedron_512()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_512; + } + else if (returnType == XdmfTopologyType::Hexahedron_729()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_729; + } + else if (returnType == XdmfTopologyType::Hexahedron_1000()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1000; + } + else if (returnType == XdmfTopologyType::Hexahedron_1331()) { + return XDMF_TOPOLOGY_TYPE_HEXAHEDRON_1331; + } + else if (returnType == XdmfTopologyType::Mixed()) { + return XDMF_TOPOLOGY_TYPE_MIXED; + } + else if (returnType == XdmfTopologyType::NoTopologyType()) { + try { + XdmfError::message(XdmfError::FATAL, "Uninitialized topology type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Invalid topology type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } int XdmfFortran::retrieveTopologyValueType() { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before its value type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr dataType = mTopology->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Topology Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Topology Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before its value type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr dataType = mTopology->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Topology Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Topology Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } void XdmfFortran::retrieveTopologyValues(void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if(mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set topology before its values can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (!mTopology->isInitialized()) - { - mTopology->read(); - } - readFromArray(mTopology, - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } + if(mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set topology before its values can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + if (!mTopology->isInitialized()) { + mTopology->read(); + } + readFromArray(mTopology, + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } } int XdmfFortran::retrieveTopologyNumElements() { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before the number of Elements it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mTopology->getNumberElements(); - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before the number of Elements it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mTopology->getNumberElements(); + } } int XdmfFortran::retrieveTopologySize() { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before its size can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mTopology->getSize(); - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before its size can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mTopology->getSize(); + } } void XdmfFortran::clearPreviousTopologies() { - mPreviousTopologies.clear(); + mPreviousTopologies.clear(); } int XdmfFortran::retrieveTopologyNumProperties() { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before the number of properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mTopology->getItemProperties().size(); - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before the number of properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mTopology->getItemProperties().size(); + } } void XdmfFortran::retrieveTopologyProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (mTopology == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Topology before the properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (index < (int)mTopology->getItemProperties().size()) - { - std::map::iterator walker = mTopology->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mTopology->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mTopology->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } + if (mTopology == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Topology before the properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mTopology->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mTopology->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } } int @@ -4943,286 +4093,232 @@ XdmfFortran::setDimensions(int numValues, int arrayType, void * pointValues) void XdmfFortran::openPreviousDimensions(int index) { - if ((int)mPreviousDimensions.size()>index) - { - mDimensions = mPreviousDimensions[index]; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if ((int)mPreviousDimensions.size()>index) { + mDimensions = mPreviousDimensions[index]; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousDimensions() { - mPreviousDimensions.clear(); + mPreviousDimensions.clear(); } void XdmfFortran::retrieveDimensionsTag(char * tag, int tagLength) { - if (mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before its tag can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - char * tempTag = strdup(mDimensions->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } + if (mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before its tag can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + char * tempTag = strdup(mDimensions->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } } int XdmfFortran::retrieveDimensionsValueType() { - if (mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before its value type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr dataType = mDimensions->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Dimension Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Dimension Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before its value type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr dataType = mDimensions->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Dimension Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Dimension Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } void XdmfFortran::retrieveDimensionsValues(void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if(mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before its values can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (!mDimensions->isInitialized()) - { - mDimensions->read(); - } - readFromArray(mDimensions, - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } + if(mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before its values can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + if (!mDimensions->isInitialized()) { + mDimensions->read(); + } + readFromArray(mDimensions, + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } } int XdmfFortran::retrieveDimensionsSize() { - if (mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Dimensions before its size can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mDimensions->getSize(); - } + if (mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Dimensions before its size can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mDimensions->getSize(); + } } int XdmfFortran::retrieveDimensionsNumProperties() { - if (mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before the number of properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mDimensions->getItemProperties().size(); - } + if (mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before the number of properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mDimensions->getItemProperties().size(); + } } void XdmfFortran::retrieveDimensionsProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (mDimensions == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set dimensions before the properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (index < (int)mDimensions->getItemProperties().size()) - { - std::map::iterator walker = mDimensions->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mDimensions->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mDimensions->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } + if (mDimensions == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set dimensions before the properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mDimensions->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mDimensions->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } } int @@ -5241,286 +4337,232 @@ XdmfFortran::setOrigin(int numValues, int arrayType, void * pointValues) void XdmfFortran::setPreviousOrigin(int index) { - if (index < (int)mPreviousOrigins.size()) - { - mOrigin = mPreviousOrigins[index]; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of bounds."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mPreviousOrigins.size()) { + mOrigin = mPreviousOrigins[index]; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of bounds."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousOrigins() { - mPreviousOrigins.clear(); + mPreviousOrigins.clear(); } void XdmfFortran::retrieveOriginTag(char * tag, int tagLength) { - if (mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before its tag can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - char * tempTag = strdup(mOrigin->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } + if (mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before its tag can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + char * tempTag = strdup(mOrigin->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } } int XdmfFortran::retrieveOriginValueType() { - if (mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before its value type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr dataType = mOrigin->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Origin Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Origin Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before its value type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr dataType = mOrigin->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Origin Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Origin Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } void XdmfFortran::retrieveOriginValues(void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if(mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before its values can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (!mOrigin->isInitialized()) - { - mOrigin->read(); - } - readFromArray(mOrigin, - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } + if(mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before its values can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + if (!mOrigin->isInitialized()) { + mOrigin->read(); + } + readFromArray(mOrigin, + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } } int XdmfFortran::retrieveOriginSize() { - if (mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before its size can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mOrigin->getSize(); - } + if (mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before its size can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mOrigin->getSize(); + } } int XdmfFortran::retrieveOriginNumProperties() { - if (mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set origin before the number of properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mOrigin->getItemProperties().size(); - } + if (mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before the number of properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mOrigin->getItemProperties().size(); + } } void XdmfFortran::retrieveOriginProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (mOrigin == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Origin before the properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (index < (int)mOrigin->getItemProperties().size()) - { - std::map::iterator walker = mOrigin->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mOrigin->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mOrigin->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } + if (mOrigin == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set origin before the properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mOrigin->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mOrigin->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } } int @@ -5539,2363 +4581,1949 @@ XdmfFortran::setBrick(int numValues, int arrayType, void * pointValues) void XdmfFortran::setPreviousBrick(int index) { - if (index < (int)mPreviousBricks.size()) - { - mBrick = mPreviousBricks[index]; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of bounds."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mPreviousBricks.size()) { + mBrick = mPreviousBricks[index]; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of bounds."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousBricks() { - mPreviousBricks.clear(); + mPreviousBricks.clear(); } void XdmfFortran::retrieveBrickTag(char * tag, int tagLength) { - if (mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set Brick before its tag can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - char * tempTag = strdup(mBrick->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } + if (mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set Brick before its tag can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + char * tempTag = strdup(mBrick->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } } int XdmfFortran::retrieveBrickValueType() { - if (mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick before its value type can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - shared_ptr dataType = mBrick->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Brick Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Brick Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } + if (mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick before its value type can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + shared_ptr dataType = mBrick->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Brick Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Brick Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } } void XdmfFortran::retrieveBrickValues(void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if(mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick before its values can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (!mBrick->isInitialized()) - { - mBrick->read(); - } - readFromArray(mBrick, - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } + if(mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick before its values can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + if (!mBrick->isInitialized()) { + mBrick->read(); + } + readFromArray(mBrick, + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } } int XdmfFortran::retrieveBrickSize() { - if (mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick before its size can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mBrick->getSize(); - } + if (mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick before its size can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mBrick->getSize(); + } } int XdmfFortran::retrieveBrickNumProperties() { - if (mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick before the number of properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - return mBrick->getItemProperties().size(); - } + if (mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick before the number of properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + return mBrick->getItemProperties().size(); + } } void XdmfFortran::retrieveBrickProperty(int index, char * key, int keyLength, char * value, int valueLength) { - if (mBrick == NULL) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Must set brick before the properties it contains can be retrieved."); - } - catch (XdmfError e) - { - throw e; - } - } - else - { - if (index < (int)mBrick->getItemProperties().size()) - { - std::map::iterator walker = mBrick->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mBrick->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mBrick->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } + if (mBrick == NULL) { + try { + XdmfError::message(XdmfError::FATAL, + "Must set brick before the properties it contains can be retrieved."); + } + catch (XdmfError e) { + throw e; + } + } + else { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mBrick->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mBrick->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } } void XdmfFortran::addMap(char * name) { - shared_ptr addedMap = XdmfMap::New(); - addedMap->setName(name); - mMaps.push_back(addedMap); + shared_ptr addedMap = XdmfMap::New(); + addedMap->setName(name); + mMaps.push_back(addedMap); } int XdmfFortran::retrieveNumMaps() { - return mMaps.size(); + return mMaps.size(); } void XdmfFortran::clearMaps() { - mMaps.clear(); + mMaps.clear(); } void XdmfFortran::retrieveMapTag(int index, char * tag, int tagLength) { - if (index < (int)mMaps.size()) - { - char * tempTag = strdup(mMaps[index]->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mMaps.size()) { + char * tempTag = strdup(mMaps[index]->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::addRemoteNodeID(int index, int localNodeID, int remoteTaskID, int remoteLocalNodeID) { - mMaps[index]->insert(remoteTaskID, localNodeID, remoteLocalNodeID); + mMaps[index]->insert(remoteTaskID, localNodeID, remoteLocalNodeID); } void XdmfFortran::retrieveRemoteNodeIDs(int index, int localNodeID, int remoteTaskID, int * remoteNodeIDs) { - if ((int)mMaps.size()>index) - { - if (mMaps[index]->getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) - { - std::set returnSet = mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID]; - std::set::iterator walker; - int i = 0; - for (walker = returnSet.begin(); walker != returnSet.end();walker++) - { - remoteNodeIDs[i] = *walker; - i++; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "The map does not contain a remote ID for the requested node."); - } - catch (XdmfError e) - { - throw e; - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of Range."); - } - catch (XdmfError e) - { - throw e; - } - } + if ((int)mMaps.size()>index) { + if (mMaps[index]->getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) { + std::set returnSet = mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID]; + std::set::iterator walker; + int i = 0; + for (walker = returnSet.begin(); walker != returnSet.end();walker++) { + remoteNodeIDs[i] = *walker; + i++; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "The map does not contain a remote ID for the requested node."); + } + catch (XdmfError e) { + throw e; + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of Range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveNumRemoteNodeIDs(int index, int localNodeID, int remoteTaskID) { - if ((int)mMaps.size()getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) - { - return mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID].size(); - } - else - { - return 0; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of Range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if ((int)mMaps.size()getRemoteNodeIds(remoteTaskID).count(localNodeID)>0) { + return mMaps[index]->getRemoteNodeIds(remoteTaskID)[localNodeID].size(); + } + else { + return 0; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of Range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::storeMap(int index) { - if (index < (int)mMaps.size()) - { - int id = mPreviousMaps.size(); - mPreviousMaps.push_back(mMaps[index]); - return id; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of Range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mMaps.size()) { + int id = mPreviousMaps.size(); + mPreviousMaps.push_back(mMaps[index]); + return id; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of Range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::addPreviousMap(int index) { - if (index < (int)mPreviousMaps.size()) - { - mMaps.push_back(mPreviousMaps[index]); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mPreviousMaps.size()) { + mMaps.push_back(mPreviousMaps[index]); + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousMaps() { - mPreviousMaps.clear(); + mPreviousMaps.clear(); } void XdmfFortran::removeMap(int index) -{ - if (index < (int)mMaps.size()) - { - mMaps.erase(mMaps.begin()+index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } +{ + if (index < (int)mMaps.size()) { + mMaps.erase(mMaps.begin()+index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveMapNumProperties(int index) { - if (index < (int)mMaps.size()) - { - return mMaps[index]->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mMaps.size()) { + return mMaps[index]->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveMapProperty(int mapIndex, int index, char * key, int keyLength, char * value, int valueLength) { - if (mapIndex < (int)mMaps.size()) - { - if (index < (int)mMaps[index]->getItemProperties().size()) - { - std::map::iterator walker = mMaps[index]->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mMaps[index]->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mMaps[index]->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mMaps.size()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mMaps[index]->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mMaps[index]->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveNumAttributes() { - return mAttributes.size(); + return mAttributes.size(); } void XdmfFortran::clearAttributes() { - mAttributes.clear(); + mAttributes.clear(); } void XdmfFortran::retrieveAttributeTag(int index, char * tag, int tagLength) { - if (index < (int)mAttributes.size()) - { - char * tempTag = strdup(mAttributes[index]->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + char * tempTag = strdup(mAttributes[index]->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveAttributeName(int index, char * name, int nameLength) { - if (index < (int)mAttributes.size()) - { - char * tempName = strdup(mAttributes[index]->getName().c_str()); - memset(name, 0, nameLength); - memcpy(name, tempName, strlen(tempName)+1); - delete [] tempName; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + char * tempName = strdup(mAttributes[index]->getName().c_str()); + memset(name, 0, nameLength); + memcpy(name, tempName, strlen(tempName)+1); + delete [] tempName; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveAttributeValueType(int index) { - if (index < (int)mAttributes.size()) - { - shared_ptr dataType = mAttributes[index]->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Attribute Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Attribute Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mAttributes.size()) { + shared_ptr dataType = mAttributes[index]->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Attribute Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Attribute Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveAttributeValues(int index, void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if (index < (int)mAttributes.size()) - { - if (!mAttributes[index]->isInitialized()) - { - mAttributes[index]->read(); - } - readFromArray(mAttributes[index], - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + if (!mAttributes[index]->isInitialized()) { + mAttributes[index]->read(); + } + readFromArray(mAttributes[index], + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeAttribute(int index) { - if (index < (int)mAttributes.size()) - { - mAttributes.erase(mAttributes.begin()+index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + mAttributes.erase(mAttributes.begin()+index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceAttribute(int index, char * name, int attributeCenter, int attributeType, int numValues, int arrayType, void * values) { - if (index < (int)mAttributes.size()) - { - shared_ptr currAttribute = XdmfAttribute::New(); - currAttribute->setName(name); - switch(attributeCenter) - { - case XDMF_ATTRIBUTE_CENTER_GRID: - currAttribute->setCenter(XdmfAttributeCenter::Grid()); - break; - case XDMF_ATTRIBUTE_CENTER_CELL: - currAttribute->setCenter(XdmfAttributeCenter::Cell()); - break; - case XDMF_ATTRIBUTE_CENTER_FACE: - currAttribute->setCenter(XdmfAttributeCenter::Face()); - break; - case XDMF_ATTRIBUTE_CENTER_EDGE: - currAttribute->setCenter(XdmfAttributeCenter::Edge()); - break; - case XDMF_ATTRIBUTE_CENTER_NODE: - currAttribute->setCenter(XdmfAttributeCenter::Node()); - break; - default: - try - { - XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); - } - catch (XdmfError e) - { - throw e; - } - } - - switch(attributeType) - { - case XDMF_ATTRIBUTE_TYPE_SCALAR: - currAttribute->setType(XdmfAttributeType::Scalar()); - break; - case XDMF_ATTRIBUTE_TYPE_VECTOR: - currAttribute->setType(XdmfAttributeType::Vector()); - break; - case XDMF_ATTRIBUTE_TYPE_TENSOR: - currAttribute->setType(XdmfAttributeType::Tensor()); - break; - case XDMF_ATTRIBUTE_TYPE_MATRIX: - currAttribute->setType(XdmfAttributeType::Matrix()); - break; - case XDMF_ATTRIBUTE_TYPE_TENSOR6: - currAttribute->setType(XdmfAttributeType::Tensor6()); - break; - case XDMF_ATTRIBUTE_TYPE_GLOBALID: - currAttribute->setType(XdmfAttributeType::GlobalId()); - break; - default: - try - { - XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); - } - catch (XdmfError e) - { - throw e; - } - } - - writeToArray(currAttribute, numValues, arrayType, values); - mAttributes[index] = currAttribute; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + shared_ptr currAttribute = XdmfAttribute::New(); + currAttribute->setName(name); + switch(attributeCenter) { + case XDMF_ATTRIBUTE_CENTER_GRID: + currAttribute->setCenter(XdmfAttributeCenter::Grid()); + break; + case XDMF_ATTRIBUTE_CENTER_CELL: + currAttribute->setCenter(XdmfAttributeCenter::Cell()); + break; + case XDMF_ATTRIBUTE_CENTER_FACE: + currAttribute->setCenter(XdmfAttributeCenter::Face()); + break; + case XDMF_ATTRIBUTE_CENTER_EDGE: + currAttribute->setCenter(XdmfAttributeCenter::Edge()); + break; + case XDMF_ATTRIBUTE_CENTER_NODE: + currAttribute->setCenter(XdmfAttributeCenter::Node()); + break; + default: + try { + XdmfError::message(XdmfError::FATAL, "Invalid attribute center"); + } + catch (XdmfError e) { + throw e; + } + } + + switch(attributeType) { + case XDMF_ATTRIBUTE_TYPE_SCALAR: + currAttribute->setType(XdmfAttributeType::Scalar()); + break; + case XDMF_ATTRIBUTE_TYPE_VECTOR: + currAttribute->setType(XdmfAttributeType::Vector()); + break; + case XDMF_ATTRIBUTE_TYPE_TENSOR: + currAttribute->setType(XdmfAttributeType::Tensor()); + break; + case XDMF_ATTRIBUTE_TYPE_MATRIX: + currAttribute->setType(XdmfAttributeType::Matrix()); + break; + case XDMF_ATTRIBUTE_TYPE_TENSOR6: + currAttribute->setType(XdmfAttributeType::Tensor6()); + break; + case XDMF_ATTRIBUTE_TYPE_GLOBALID: + currAttribute->setType(XdmfAttributeType::GlobalId()); + break; + default: + try { + XdmfError::message(XdmfError::FATAL, "Invalid attribute type"); + } + catch (XdmfError e) { + throw e; + } + } + + writeToArray(currAttribute, numValues, arrayType, values); + mAttributes[index] = currAttribute; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::openAttribute(int index) { - if (index < (int)mAttributes.size()) - { - int i; - shared_ptr openedAttribute = mAttributes[index]; - int n = openedAttribute->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedAttribute->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + int i; + shared_ptr openedAttribute = mAttributes[index]; + int n = openedAttribute->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedAttribute->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveAttributeSize(int index) { - if (index < (int)mAttributes.size()) - { - return mAttributes[index]->getSize(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mAttributes.size()) { + return mAttributes[index]->getSize(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::retrieveAttributeType(int index) { - if (index < (int)mAttributes.size()) - { - shared_ptr returnType = mAttributes[index]->getType(); - if (returnType == XdmfAttributeType::Scalar()) - { - return XDMF_ATTRIBUTE_TYPE_SCALAR; - } - else if (returnType == XdmfAttributeType::Vector()) - { - return XDMF_ATTRIBUTE_TYPE_VECTOR; - } - else if (returnType == XdmfAttributeType::Tensor()) - { - return XDMF_ATTRIBUTE_TYPE_TENSOR; - } - else if (returnType == XdmfAttributeType::Matrix()) - { - return XDMF_ATTRIBUTE_TYPE_MATRIX; - } - else if (returnType == XdmfAttributeType::Tensor6()) - { - return XDMF_ATTRIBUTE_TYPE_TENSOR6; - } - else if (returnType == XdmfAttributeType::GlobalId()) - { - return XDMF_ATTRIBUTE_TYPE_GLOBALID; - } - else - { - return XDMF_ATTRIBUTE_TYPE_NOTYPE; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mAttributes.size()) { + shared_ptr returnType = mAttributes[index]->getType(); + if (returnType == XdmfAttributeType::Scalar()) { + return XDMF_ATTRIBUTE_TYPE_SCALAR; + } + else if (returnType == XdmfAttributeType::Vector()) { + return XDMF_ATTRIBUTE_TYPE_VECTOR; + } + else if (returnType == XdmfAttributeType::Tensor()) { + return XDMF_ATTRIBUTE_TYPE_TENSOR; + } + else if (returnType == XdmfAttributeType::Matrix()) { + return XDMF_ATTRIBUTE_TYPE_MATRIX; + } + else if (returnType == XdmfAttributeType::Tensor6()) { + return XDMF_ATTRIBUTE_TYPE_TENSOR6; + } + else if (returnType == XdmfAttributeType::GlobalId()) { + return XDMF_ATTRIBUTE_TYPE_GLOBALID; + } + else { + return XDMF_ATTRIBUTE_TYPE_NOTYPE; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::retrieveAttributeCenter(int index) { - if (index < (int)mAttributes.size()) - { - shared_ptr returnCenter = mAttributes[index]->getCenter(); - if (returnCenter == XdmfAttributeCenter::Grid()) - { - return XDMF_ATTRIBUTE_CENTER_GRID; - } - else if (returnCenter == XdmfAttributeCenter::Cell()) - { - return XDMF_ATTRIBUTE_CENTER_CELL; - } - else if (returnCenter == XdmfAttributeCenter::Face()) - { - return XDMF_ATTRIBUTE_CENTER_FACE; - } - else if (returnCenter == XdmfAttributeCenter::Edge()) - { - return XDMF_ATTRIBUTE_CENTER_EDGE; - } - else if (returnCenter == XdmfAttributeCenter::Node()) - { - return XDMF_ATTRIBUTE_CENTER_NODE; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid Attribute Center."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mAttributes.size()) { + shared_ptr returnCenter = mAttributes[index]->getCenter(); + if (returnCenter == XdmfAttributeCenter::Grid()) { + return XDMF_ATTRIBUTE_CENTER_GRID; + } + else if (returnCenter == XdmfAttributeCenter::Cell()) { + return XDMF_ATTRIBUTE_CENTER_CELL; + } + else if (returnCenter == XdmfAttributeCenter::Face()) { + return XDMF_ATTRIBUTE_CENTER_FACE; + } + else if (returnCenter == XdmfAttributeCenter::Edge()) { + return XDMF_ATTRIBUTE_CENTER_EDGE; + } + else if (returnCenter == XdmfAttributeCenter::Node()) { + return XDMF_ATTRIBUTE_CENTER_NODE; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid Attribute Center."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::clearPreviousAttributes() { - mPreviousAttributes.clear(); + mPreviousAttributes.clear(); } int XdmfFortran::retrieveAttributeNumProperties(int index) { - if (index < (int)mAttributes.size()) - { - return mAttributes[index]->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mAttributes.size()) { + return mAttributes[index]->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveAttributeProperty(int attributeIndex, int index, char * key, int keyLength, char * value, int valueLength) { - if (attributeIndex < (int)mAttributes.size()) - { - if (index < (int)mAttributes[attributeIndex]->getItemProperties().size()) - { - std::map::iterator walker = mAttributes[attributeIndex]->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mAttributes[attributeIndex]->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mAttributes[index]->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mAttributes.size()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mAttributes[index]->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mAttributes[index]->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::addCoordinate(char * name, int numValues, int arrayType, void * values) { - shared_ptr currArray = XdmfArray::New(); - currArray->setName(name); + shared_ptr currArray = XdmfArray::New(); + currArray->setName(name); - writeToArray(currArray, numValues, arrayType, values); + writeToArray(currArray, numValues, arrayType, values); - mCoordinates.push_back(currArray); + mCoordinates.push_back(currArray); - const int id = mPreviousCoordinates.size(); - mPreviousCoordinates.push_back(currArray); - return id; + const int id = mPreviousCoordinates.size(); + mPreviousCoordinates.push_back(currArray); + return id; } void XdmfFortran::addPreviousCoordinate(int index) { - if (index < (int)mPreviousCoordinates.size()) - { - mCoordinates.push_back(mPreviousCoordinates[index]); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mPreviousCoordinates.size()) { + mCoordinates.push_back(mPreviousCoordinates[index]); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousCoordinates() { - mPreviousCoordinates.clear(); + mPreviousCoordinates.clear(); } int XdmfFortran::retrieveNumCoordinates() { - return mCoordinates.size(); + return mCoordinates.size(); } void XdmfFortran::retrieveCoordinateTag(int index, char * tag, int tagLength) { - if (index < (int)mCoordinates.size()) - { - char * tempTag = strdup(mCoordinates[index]->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + char * tempTag = strdup(mCoordinates[index]->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveCoordinateName(int index, char * name, int nameLength) { - if (index < (int)mCoordinates.size()) - { - char * tempName = strdup(mCoordinates[index]->getName().c_str()); - memset(name, 0, nameLength); - memcpy(name, tempName, strlen(tempName)+1); - delete [] tempName; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + char * tempName = strdup(mCoordinates[index]->getName().c_str()); + memset(name, 0, nameLength); + memcpy(name, tempName, strlen(tempName)+1); + delete [] tempName; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveCoordinateValueType(int index) { - if (index < (int)mCoordinates.size()) - { - shared_ptr dataType = mCoordinates[index]->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Coordinate Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Coordinate Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mCoordinates.size()) { + shared_ptr dataType = mCoordinates[index]->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Coordinate Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Coordinate Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveCoordinateValues(int index, void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if (index < (int)mCoordinates.size()) - { - if (!mCoordinates[index]->isInitialized()) - { - mCoordinates[index]->read(); - } - readFromArray(mCoordinates[index], - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + if (!mCoordinates[index]->isInitialized()) { + mCoordinates[index]->read(); + } + readFromArray(mCoordinates[index], + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeCoordinate(int index) { - if (index < (int)mCoordinates.size()) - { - mCoordinates.erase(mCoordinates.begin()+index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + mCoordinates.erase(mCoordinates.begin()+index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceCoordinate(int index, char * name, int numValues, int arrayType, void * values) { - if (index < (int)mCoordinates.size()) - { - shared_ptr currArray = XdmfArray::New(); - currArray->setName(name); - writeToArray(currArray, numValues, arrayType, values); - mCoordinates[index] = currArray; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + shared_ptr currArray = XdmfArray::New(); + currArray->setName(name); + writeToArray(currArray, numValues, arrayType, values); + mCoordinates[index] = currArray; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveCoordinateSize(int index) { - if (index < (int)mCoordinates.size()) - { - return mCoordinates[index]->getSize(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mCoordinates.size()) { + return mCoordinates[index]->getSize(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::clearCoordinates() { - mCoordinates.clear(); + mCoordinates.clear(); } int XdmfFortran::retrieveCoordinateNumProperties(int index) { - if (index < (int)mCoordinates.size()) - { - return mCoordinates[index]->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mCoordinates.size()) { + return mCoordinates[index]->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveCoordinateProperty(int coordinateIndex, int index, char * key, int keyLength, char * value, int valueLength) { - if (coordinateIndex < (int)mCoordinates.size()) - { - if (index < (int)mCoordinates[coordinateIndex]->getItemProperties().size()) - { - std::map::iterator walker = mCoordinates[coordinateIndex]->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mCoordinates[coordinateIndex]->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mCoordinates[index]->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mCoordinates.size()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mCoordinates[index]->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mCoordinates[index]->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::addSet(char * name, int newSetType, void * values, int numValues, int arrayType) { - const shared_ptr newSet = XdmfSet::New(); - newSet->setName(name); - - switch (newSetType) - { - case XDMF_SET_TYPE_NODE: - newSet->setType(XdmfSetType::Node()); - break; - case XDMF_SET_TYPE_CELL: - newSet->setType(XdmfSetType::Cell()); - break; - case XDMF_SET_TYPE_FACE: - newSet->setType(XdmfSetType::Face()); - break; - case XDMF_SET_TYPE_EDGE: - newSet->setType(XdmfSetType::Edge()); - break; - default: - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid set type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - newSet->insert(*iter); - } - mAttributes.clear(); - - if (!mInformations.empty()) - { - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - newSet->insert(*iter); - } - mInformations.clear(); - } - - writeToArray(newSet, numValues, arrayType, values); - - mSets.push_back(newSet); - int id = mPreviousSets.size(); - mPreviousSets.push_back(newSet); - return id; + const shared_ptr newSet = XdmfSet::New(); + newSet->setName(name); + + switch (newSetType) { + case XDMF_SET_TYPE_NODE: + newSet->setType(XdmfSetType::Node()); + break; + case XDMF_SET_TYPE_CELL: + newSet->setType(XdmfSetType::Cell()); + break; + case XDMF_SET_TYPE_FACE: + newSet->setType(XdmfSetType::Face()); + break; + case XDMF_SET_TYPE_EDGE: + newSet->setType(XdmfSetType::Edge()); + break; + default: + try { + XdmfError::message(XdmfError::FATAL, + "Invalid set type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + newSet->insert(*iter); + } + mAttributes.clear(); + + if (!mInformations.empty()) { + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + newSet->insert(*iter); + } + mInformations.clear(); + } + + writeToArray(newSet, numValues, arrayType, values); + + mSets.push_back(newSet); + int id = mPreviousSets.size(); + mPreviousSets.push_back(newSet); + return id; } void XdmfFortran::clearSets() { - mSets.clear(); + mSets.clear(); } void XdmfFortran::addPreviousSet(int index) { - if (index < (int)mPreviousSets.size()) - { - mSets.push_back(mPreviousSets[index]); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mPreviousSets.size()) { + mSets.push_back(mPreviousSets[index]); + } + else + { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousSets() { - mPreviousSets.clear(); + mPreviousSets.clear(); } void XdmfFortran::retrieveSetTag(int index, char * tag, int tagLength) { - if (index < (int)mSets.size()) - { - char * tempTag = strdup(mSets[index]->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + char * tempTag = strdup(mSets[index]->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveSetName(int index, char * name, int nameLength) { - if (index < (int)mSets.size()) - { - char * tempName = strdup(mSets[index]->getName().c_str()); - memset(name, 0, nameLength); - memcpy(name, tempName, strlen(tempName)+1); - delete [] tempName; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + char * tempName = strdup(mSets[index]->getName().c_str()); + memset(name, 0, nameLength); + memcpy(name, tempName, strlen(tempName)+1); + delete [] tempName; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveNumSets() { - return mSets.size(); + return mSets.size(); } int XdmfFortran::retrieveSetSize(int index) { - if (index < (int)mSets.size()) - { - return mSets[index]->getSize(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mSets.size()) { + return mSets[index]->getSize(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } int XdmfFortran::retrieveSetValueType(int index) { - if (index < (int)mSets.size()) - { - shared_ptr dataType = mSets[index]->getArrayType(); - if (dataType == XdmfArrayType::Int8()) - { - return XDMF_ARRAY_TYPE_INT8; - } - else if (dataType == XdmfArrayType::Int16()) - { - return XDMF_ARRAY_TYPE_INT16; - } - else if (dataType == XdmfArrayType::Int32()) - { - return XDMF_ARRAY_TYPE_INT32; - } - else if (dataType == XdmfArrayType::Int64()) - { - return XDMF_ARRAY_TYPE_INT64; - } - else if (dataType == XdmfArrayType::UInt8()) - { - return XDMF_ARRAY_TYPE_UINT8; - } - else if (dataType == XdmfArrayType::UInt16()) - { - return XDMF_ARRAY_TYPE_UINT16; - } - else if (dataType == XdmfArrayType::UInt32()) - { - return XDMF_ARRAY_TYPE_UINT32; - } - else if (dataType == XdmfArrayType::Float32()) - { - return XDMF_ARRAY_TYPE_FLOAT32; - } - else if (dataType == XdmfArrayType::Float64()) - { - return XDMF_ARRAY_TYPE_FLOAT64; - } - else if (dataType == XdmfArrayType::Uninitialized()) - { - try - { - XdmfError::message(XdmfError::FATAL, - "Uninitialized Set Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid Set Data Type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mSets.size()) { + shared_ptr dataType = mSets[index]->getArrayType(); + if (dataType == XdmfArrayType::Int8()) { + return XDMF_ARRAY_TYPE_INT8; + } + else if (dataType == XdmfArrayType::Int16()) { + return XDMF_ARRAY_TYPE_INT16; + } + else if (dataType == XdmfArrayType::Int32()) { + return XDMF_ARRAY_TYPE_INT32; + } + else if (dataType == XdmfArrayType::Int64()) { + return XDMF_ARRAY_TYPE_INT64; + } + else if (dataType == XdmfArrayType::UInt8()) { + return XDMF_ARRAY_TYPE_UINT8; + } + else if (dataType == XdmfArrayType::UInt16()) { + return XDMF_ARRAY_TYPE_UINT16; + } + else if (dataType == XdmfArrayType::UInt32()) { + return XDMF_ARRAY_TYPE_UINT32; + } + else if (dataType == XdmfArrayType::Float32()) { + return XDMF_ARRAY_TYPE_FLOAT32; + } + else if (dataType == XdmfArrayType::Float64()) { + return XDMF_ARRAY_TYPE_FLOAT64; + } + else if (dataType == XdmfArrayType::Uninitialized()) { + try { + XdmfError::message(XdmfError::FATAL, + "Uninitialized Set Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, + "Invalid Set Data Type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveSetValues(int index, void * values, int dataType, int numberRead, int startIndex, int arrayStride, int valueStride) { - if (index < (int)mSets.size()) - { - if (!mSets[index]->isInitialized()) - { - mSets[index]->read(); - } - readFromArray(mSets[index], - dataType, - values, - numberRead, - startIndex, - arrayStride, - valueStride); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + if (!mSets[index]->isInitialized()) { + mSets[index]->read(); + } + readFromArray(mSets[index], + dataType, + values, + numberRead, + startIndex, + arrayStride, + valueStride); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveSetType(int index) { - if (index < (int)mSets.size()) - { - shared_ptr returnType = mSets[index]->getType(); - if (returnType == XdmfSetType::Node()) - { - return XDMF_SET_TYPE_NODE; - } - else if (returnType == XdmfSetType::Cell()) - { - return XDMF_SET_TYPE_CELL; - } - else if (returnType == XdmfSetType::Face()) - { - return XDMF_SET_TYPE_FACE; - } - else if (returnType == XdmfSetType::Edge()) - { - return XDMF_SET_TYPE_EDGE; - } - else if (returnType == XdmfSetType::NoSetType()) - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Uninitialized set type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Invalid set type."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mSets.size()) { + shared_ptr returnType = mSets[index]->getType(); + if (returnType == XdmfSetType::Node()) { + return XDMF_SET_TYPE_NODE; + } + else if (returnType == XdmfSetType::Cell()) { + return XDMF_SET_TYPE_CELL; + } + else if (returnType == XdmfSetType::Face()) { + return XDMF_SET_TYPE_FACE; + } + else if (returnType == XdmfSetType::Edge()) { + return XDMF_SET_TYPE_EDGE; + } + else if (returnType == XdmfSetType::NoSetType()) { + try { + XdmfError::message(XdmfError::FATAL, "Error: Uninitialized set type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Invalid set type."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::openSet(int index, int openAttribute, int openInformation) { - if (index < (int)mSets.size()) - { - shared_ptr openedSet = mSets[index]; - int i; - int n; - n = openedSet->getNumberAttributes(); - if (openAttribute == 1) - { - shared_ptr openedAttribute; - for (i = 0; i < n; i++) - { - openedAttribute = openedSet->getAttribute(i); - mAttributes.push_back(openedAttribute); - mPreviousAttributes.push_back(openedAttribute); - } - } - if (openInformation == 1) - { - n = openedSet->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = openedSet->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + shared_ptr openedSet = mSets[index]; + int i; + int n; + n = openedSet->getNumberAttributes(); + if (openAttribute == 1) { + shared_ptr openedAttribute; + for (i = 0; i < n; i++) { + openedAttribute = openedSet->getAttribute(i); + mAttributes.push_back(openedAttribute); + mPreviousAttributes.push_back(openedAttribute); + } + } + if (openInformation == 1) { + n = openedSet->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = openedSet->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeSet(int index) { - if (index < (int)mSets.size()) - { - mSets.erase(mSets.begin()+index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + mSets.erase(mSets.begin()+index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceSet(int index, char * name, int newSetType, void * values, int numValues, int arrayType) { - const shared_ptr newSet = XdmfSet::New(); - newSet->setName(name); - - switch (newSetType) - { - case XDMF_SET_TYPE_NODE: - newSet->setType(XdmfSetType::Node()); - break; - case XDMF_SET_TYPE_CELL: - newSet->setType(XdmfSetType::Cell()); - break; - case XDMF_SET_TYPE_FACE: - newSet->setType(XdmfSetType::Face()); - break; - case XDMF_SET_TYPE_EDGE: - newSet->setType(XdmfSetType::Edge()); - break; - default: - try - { - XdmfError::message(XdmfError::FATAL, - "Invalid set type."); - } - catch (XdmfError e) - { - throw e; - } - } - - for(std::vector >::const_iterator iter = - mAttributes.begin(); - iter != mAttributes.end(); - ++iter) - { - newSet->insert(*iter); - } - mAttributes.clear(); - - if (!mInformations.empty()) - { - for(std::vector >::const_iterator iter = - mInformations.begin(); - iter != mInformations.end(); - ++iter) - { - newSet->insert(*iter); - } - mInformations.clear(); - } - - writeToArray(newSet, numValues, arrayType, values); - - mSets[index] = newSet; + const shared_ptr newSet = XdmfSet::New(); + newSet->setName(name); + + switch (newSetType) { + case XDMF_SET_TYPE_NODE: + newSet->setType(XdmfSetType::Node()); + break; + case XDMF_SET_TYPE_CELL: + newSet->setType(XdmfSetType::Cell()); + break; + case XDMF_SET_TYPE_FACE: + newSet->setType(XdmfSetType::Face()); + break; + case XDMF_SET_TYPE_EDGE: + newSet->setType(XdmfSetType::Edge()); + break; + default: + try { + XdmfError::message(XdmfError::FATAL, + "Invalid set type."); + } + catch (XdmfError e) { + throw e; + } + } + + for(std::vector >::const_iterator iter = + mAttributes.begin(); + iter != mAttributes.end(); + ++iter) { + newSet->insert(*iter); + } + mAttributes.clear(); + + if (!mInformations.empty()) { + for(std::vector >::const_iterator iter = + mInformations.begin(); + iter != mInformations.end(); + ++iter) { + newSet->insert(*iter); + } + mInformations.clear(); + } + + writeToArray(newSet, numValues, arrayType, values); + + mSets[index] = newSet; } int XdmfFortran::retrieveSetNumProperties(int index) { - if (index < (int)mSets.size()) - { - return mSets[index]->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mSets.size()) { + return mSets[index]->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveSetProperty(int setIndex, int index, char * key, int keyLength, char * value, int valueLength) { - if (setIndex < (int)mSets.size()) - { - if (index < (int)mSets[setIndex]->getItemProperties().size()) - { - std::map::iterator walker = mSets[setIndex]->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mSets[setIndex]->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mSets[index]->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mSets.size()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mSets[index]->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mSets[index]->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } int XdmfFortran::retrieveNumInformation() { - return mInformations.size(); + return mInformations.size(); } void XdmfFortran::clearInformations() { - mInformations.clear(); + mInformations.clear(); } void XdmfFortran::retrieveInformationTag(int index, char * tag, int tagLength) { - if (index < (int)mInformations.size()) - { - char * tempTag = strdup(mInformations[index]->getItemTag().c_str()); - memset(tag, 0, tagLength); - memcpy(tag, tempTag, strlen(tempTag)+1); - delete [] tempTag; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + char * tempTag = strdup(mInformations[index]->getItemTag().c_str()); + memset(tag, 0, tagLength); + memcpy(tag, tempTag, strlen(tempTag)+1); + delete [] tempTag; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveInformation(int index, char * key, int keyLength, char * value, int valueLength) { - if (index < (int)mInformations.size()) - { - char * tempKey = strdup(mInformations[index]->getKey().c_str()); - char * tempValue = strdup(mInformations[index]->getValue().c_str()); - memset(key, 0, keyLength); - memset(value, 0, valueLength); - memcpy(key, tempKey, strlen(tempKey)+1); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempKey; - delete [] tempValue; - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + char * tempKey = strdup(mInformations[index]->getKey().c_str()); + char * tempValue = strdup(mInformations[index]->getValue().c_str()); + memset(key, 0, keyLength); + memset(value, 0, valueLength); + memcpy(key, tempKey, strlen(tempKey)+1); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempKey; + delete [] tempValue; + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceInformation(int index, char * key, char * value) { - if (index < (int)mInformations.size()) - { - mInformations[index]->setKey(key); - mInformations[index]->setValue(value); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + mInformations[index]->setKey(key); + mInformations[index]->setValue(value); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeInformation(int index) { - if (index < (int)mInformations.size()) - { - mInformations.erase(mInformations.begin()+index); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + mInformations.erase(mInformations.begin()+index); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::openInformation(int index) { - if (index < (int)mInformations.size()) - { - shared_ptr sourceInformation = mInformations[index]; - int i; - int n = sourceInformation->getNumberInformations(); - shared_ptr openedInformation; - for (i = 0; i < n; i++) - { - openedInformation = sourceInformation->getInformation(i); - mInformations.push_back(openedInformation); - mPreviousInformations.push_back(openedInformation); - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + shared_ptr sourceInformation = mInformations[index]; + int i; + int n = sourceInformation->getNumberInformations(); + shared_ptr openedInformation; + for (i = 0; i < n; i++) { + openedInformation = sourceInformation->getInformation(i); + mInformations.push_back(openedInformation); + mPreviousInformations.push_back(openedInformation); + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::retrieveInformationByKey(char * key, char * value, int valueLength) { - unsigned int i; - int found = 0; - std::string searchString(key); - char * tempValue; - for (i=0;igetKey()) - { - found = 1; - tempValue = strdup(mInformations[i]->getValue().c_str()); - memset(value, 0, valueLength); - memcpy(value, tempValue, strlen(tempValue)+1); - i = mInformations.size(); - delete [] tempValue; - } - } - if (found == 0) - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); - } - catch (XdmfError e) - { - throw e; - } - } + unsigned int i; + int found = 0; + std::string searchString(key); + char * tempValue; + for (i=0;igetKey()) { + found = 1; + tempValue = strdup(mInformations[i]->getValue().c_str()); + memset(value, 0, valueLength); + memcpy(value, tempValue, strlen(tempValue)+1); + i = mInformations.size(); + delete [] tempValue; + } + } + if (found == 0) { + try { + XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::replaceInformationByKey(char * key, char * value) { - unsigned int i; - int found = 0; - std::string searchString(key); - for (i=0;igetKey()) - { - mInformations[i]->setValue(value); - i = mInformations.size(); - found = 1; - } - } - if (found == 0) - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); - } - catch (XdmfError e) - { - throw e; - } - } + unsigned int i; + int found = 0; + std::string searchString(key); + for (i=0;igetKey()) { + mInformations[i]->setValue(value); + i = mInformations.size(); + found = 1; + } + } + if (found == 0) { + try { + XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::removeInformationByKey(char * key) { - unsigned int i; - int found = 0; - std::string searchString(key); - for (i=0;igetKey()) - { - mInformations.erase(mInformations.begin()+i); - i = mInformations.size(); - found = 1; - } - } - if (found == 0) - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); - } - catch (XdmfError e) - { - throw e; - } - } + unsigned int i; + int found = 0; + std::string searchString(key); + for (i=0;igetKey()) { + mInformations.erase(mInformations.begin()+i); + i = mInformations.size(); + found = 1; + } + } + if (found == 0) { + try { + XdmfError::message(XdmfError::FATAL, "Error: Item with specifed key does not exist."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPreviousInformation() { - mPreviousInformations.clear(); + mPreviousInformations.clear(); } int XdmfFortran::retrieveInformationNumProperties(int index) { - if (index < (int)mInformations.size()) - { - return mInformations[index]->getItemProperties().size(); - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - return -1; - } + if (index < (int)mInformations.size()) { + return mInformations[index]->getItemProperties().size(); + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + return -1; + } } void XdmfFortran::retrieveInformationProperty(int informationIndex, int index, char * key, int keyLength, char * value, int valueLength) { - if (informationIndex < (int)mInformations.size()) - { - if (index < (int)mInformations[informationIndex]->getItemProperties().size()) - { - std::map::iterator walker = mInformations[informationIndex]->getItemProperties().begin(); - for (int i = 0; igetItemProperties().size()) { + std::map::iterator walker = mInformations[informationIndex]->getItemProperties().begin(); + for (int i = 0; igetItemProperties().count(tempString))>0) - { - char * tempValue = strdup(mInformations[index]->getItemProperties()[tempString].c_str()); - memcpy(value, tempValue, strlen(tempValue)+1); - delete [] tempValue; - } - } - else - { - try - { - XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); - } - catch (XdmfError e) - { - throw e; - } - } + if (index < (int)mInformations.size()) { + std::string tempString = key; + memset(value, 0, valueLength); + if ((mInformations[index]->getItemProperties().count(tempString))>0) { + char * tempValue = strdup(mInformations[index]->getItemProperties()[tempString].c_str()); + memcpy(value, tempValue, strlen(tempValue)+1); + delete [] tempValue; + } + } + else { + try { + XdmfError::message(XdmfError::FATAL, "Error: Index out of range."); + } + catch (XdmfError e) { + throw e; + } + } } void XdmfFortran::clearPrevious() { - mPreviousTopologies.clear(); - mPreviousGeometries.clear(); - mPreviousAttributes.clear(); - mPreviousMaps.clear(); - mPreviousSets.clear(); - mPreviousDimensions.clear(); - mPreviousOrigins.clear(); - mPreviousBricks.clear(); - mPreviousCoordinates.clear(); + mPreviousTopologies.clear(); + mPreviousGeometries.clear(); + mPreviousAttributes.clear(); + mPreviousMaps.clear(); + mPreviousSets.clear(); + mPreviousDimensions.clear(); + mPreviousOrigins.clear(); + mPreviousBricks.clear(); + mPreviousCoordinates.clear(); } @@ -7929,9 +6557,7 @@ XdmfFortran::write(const char * const xmlFilePath, const int datalimit, const bo writer->getHeavyDataWriter()->setReleaseData(release); shared_dynamic_cast(writer->getHeavyDataWriter())->setFileSizeLimit(mMaxFileSize); shared_dynamic_cast(writer->getHeavyDataWriter())->setAllowSetSplitting(mAllowSetSplitting); - shared_dynamic_cast(writer->getHeavyDataWriter())->openFile(); mDomain->accept(writer); - shared_dynamic_cast(writer->getHeavyDataWriter())->closeFile(); } void @@ -7989,6 +6615,24 @@ XdmfFortran::setTopologyPolyline(const unsigned int nodesPerElement, return id; } +int +XdmfFortran::setTopologyPolygon(const unsigned int nodesPerElement, + const unsigned int numValues, + const int arrayType, + const void * const connectivityValues) +{ + mTopology = XdmfTopology::New(); + mTopology->setType(XdmfTopologyType::Polygon(nodesPerElement)); + // insert connectivity values into array + writeToArray(mTopology, + numValues, + arrayType, + connectivityValues); + const int id = mPreviousTopologies.size(); + mPreviousTopologies.push_back(mTopology); + return id; +} + // // C++ will mangle the name based on the argument list. This tells the // compiler not to mangle the name so we can call it from 'C' (but @@ -8319,7 +6963,7 @@ extern "C" void XdmfRetrieveDomainGridProperty(long * pointer, int * gridType, int * gridIndex, int * index, - char * key, int * keyLength, char * value, int * valueLength) + char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDomainGridProperty(*gridType, *gridIndex, *index, key, *keyLength, value, *valueLength); @@ -8377,7 +7021,7 @@ extern "C" void XdmfRetrieveGridCollectionGridProperty(long * pointer, int * gridType, int * gridIndex, int * index, - char * key, int * keyLength, char * value, int * valueLength) + char * key, int * keyLength, char * value, int * valueLength) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGridCollectionGridProperty(*gridType, *gridIndex, *index, key, *keyLength, value, *valueLength); @@ -8413,7 +7057,7 @@ extern "C" void XdmfRetrieveTopologyValues(long * pointer, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveTopologyValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -8454,7 +7098,7 @@ extern "C" xdmfFortran->clearPreviousTopologies(); } - void + void XdmfRetrieveTopologyNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8484,7 +7128,7 @@ extern "C" void XdmfRetrieveGeometryValues(long * pointer, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveGeometryValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -8525,7 +7169,7 @@ extern "C" xdmfFortran->clearPreviousGeometries(); } - void + void XdmfRetrieveGeometryNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8558,7 +7202,7 @@ extern "C" XdmfOpenPreviousDimensions(long * pointer, int * index) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); - xdmfFortran->openPreviousDimensions(*index); + xdmfFortran->openPreviousDimensions(*index); } void @@ -8577,7 +7221,7 @@ extern "C" void XdmfRetrieveDimensionsValues(long * pointer, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveDimensionsValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -8597,7 +7241,7 @@ extern "C" *total = xdmfFortran->retrieveDimensionsSize(); } - void + void XdmfRetrieveDimensionsNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8648,7 +7292,7 @@ extern "C" void XdmfRetrieveOriginValues(long * pointer, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveOriginValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -8668,7 +7312,7 @@ extern "C" *total = xdmfFortran->retrieveOriginSize(); } - void + void XdmfRetrieveOriginNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8720,7 +7364,7 @@ extern "C" void XdmfRetrieveBrickValues(long * pointer, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveBrickValues(values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -8740,7 +7384,7 @@ extern "C" *total = xdmfFortran->retrieveBrickSize(); } - void + void XdmfRetrieveBrickNumProperties(long * pointer, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8838,7 +7482,7 @@ extern "C" xdmfFortran->clearPreviousMaps(); } - void + void XdmfRetrieveMapNumProperties(long * pointer, int * index, int * total) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); @@ -8875,7 +7519,7 @@ extern "C" void XdmfReplaceAttribute(long * pointer, int * index, char * name, int * attributeCenter, - int * attributeType, int * numValues, int * arrayType, void * values) + int * attributeType, int * numValues, int * arrayType, void * values) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->replaceAttribute(*index, name, *attributeCenter, *attributeType, *numValues, *arrayType, values); @@ -8911,7 +7555,7 @@ extern "C" void XdmfRetrieveAttributeValues(long * pointer, int * index, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveAttributeValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -9031,7 +7675,7 @@ extern "C" void XdmfRetrieveCoordinateValues(long * pointer, int * index, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveCoordinateValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); @@ -9151,7 +7795,7 @@ extern "C" void XdmfRetrieveSetValues(long * pointer, int * index, void * values, int * dataType, - int * numberRead, int * startIndex, int * arrayStride, int * valueStride) + int * numberRead, int * startIndex, int * arrayStride, int * valueStride) { XdmfFortran * xdmfFortran = reinterpret_cast(*pointer); xdmfFortran->retrieveSetValues(*index, values, *dataType, *numberRead, *startIndex, *arrayStride, *valueStride); diff --git a/utils/XdmfFortran.hpp b/utils/XdmfFortran.hpp index b90cde5a..0f8c40d7 100644 --- a/utils/XdmfFortran.hpp +++ b/utils/XdmfFortran.hpp @@ -173,6 +173,7 @@ class XdmfHeavyDataWriter; #define XdmfInitHDF5 xdmfinithdf5_ #define XdmfSetTopologyPolyline xdmfsettopologypolyline_ +#define XdmfSetTopologyPolygon xdmfsettopologypolygon_ #define XdmfRetrieveNumDomainGridCollections xdmfretrievenumdomaingridcollections_ @@ -541,10 +542,6 @@ public: const void * const connectivityValues, const int numNodes); - - - - /** * Returns the number of grid collections currently * contained in the domain @@ -2285,6 +2282,21 @@ public: const int arrayType, const void * const connectivityValues); + /** + * Set the topology (connectivity data) for a polygon that will be + * added to the next grid. + * + * @param nodesPerElement number of nodes in the polygon. + * @param numValues number of connectivity values to copy. + * @param arrayType type of connectivity values. + * @param connectivityValues array of connectivity values. + * + * @return int providing id to fortran if reusing. + */ + int setTopologyPolygon(const unsigned int nodesPerElement, + const unsigned int numValues, + const int arrayType, + const void * const connectivityValues); private: -- GitLab