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

Revert "changes to array to allow for functions"

This reverts commit df13c70f.
parent df13c70f
This diff is collapsed.
......@@ -161,308 +161,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.
* None of the XdmfArrays provided are modified during the evaluation process.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline maximum
* @skipline main
* @skipline addOperation
* @skipline addFunction
* @skipline valueMap
* @until }
* @skipline maximum
* @until else
* @skipline {
* @until returnArray;
* @skipline }
* @until }
* @skipline prepend
* @until }
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline maximum
* @until else
* @skipline maxVal
* @until pushBackAsFloat
* @skipline return
* @skipline prepend
* @until val2.getSize
* @skipline return
* @skipline __main__
* @skipline addOperation
* @skipline addFunction
* @skipline valueMap
* @until evaluateExpression
*
* @param expression a string containing the expresion to be evaluated
* @param variables a map of strings to their XdmfArray equivalent
* @return a shared pointer to the XdmfArray resulting from the expression
*/
static shared_ptr<XdmfArray> evaluateExpression(std::string expression, std::map<std::string, shared_ptr<XdmfArray> > variables);
/**
* Evaluates the operation specified using the two shared pointers to XdmfArrays provided.
* A list of valid operations is retrievable from the getSupportedOperations static method.
* None of the XdmfArrays provided are modified during the evaluation process.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline prepend
* @skipline main
* @skipline answerArray
* @skipline addOperation
* @until evaluateOperation
* @skipline return
* @until }
* @skipline prepend
* @until }
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline prepend
* @until val2.getSize
* @skipline return
* @skipline __main__
* @skipline addOperation
* @until evaluateOperation
*
* @param val1 the first array being evaluated
* @param val2 the second array being evaluated
* @param operation a character specifying the operation performed
* @return a shared pointer to the Xdmf Array that results from the calculation
*/
static shared_ptr<XdmfArray> evaluateOperation(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> 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<XdmfArray>(*functionref)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>), 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<XdmfArray> chunk(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>);
/**
* 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<XdmfArray> interlace(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>);
/**
* Evaluates the function specified using the vector of XdmfArrays provided.
* None of the XdmfArrays provided are modified during the evaluation process.
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline maximum
* @skipline main
* @skipline addFunction
* @until evaluateFunction
* @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
* @until evaluateFunction
*
* @param valueVector a vector containing the arrays to be used
* @param functionName the string associated with the function being called
* @return the result of the function being called, a scalar will be returned as an XdmfArray with one value
*/
static shared_ptr<XdmfArray> evaluateFunction(std::vector<shared_ptr<XdmfArray> > 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<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >));
/**
* 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<XdmfArray> sum(std::vector<shared_ptr<XdmfArray> > 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<XdmfArray> ave(std::vector<shared_ptr<XdmfArray> > values);
/**
* Get the data type of this array.
*
......@@ -573,37 +271,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.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline getOperationPriority
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline getOperationPriority
*
* @param operation the character associated with the operation to be checked
* @return the priority of the operation
*/
static int getOperationPriority(char operation);
/**
* Get the number of values stored in this array.
*
......@@ -625,94 +292,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.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline getSupportedOperations
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline getSupportedOperations
*
* @return a string containing the characters for all supported operations
*/
static const std::string getSupportedOperations();
/**
* Gets a string that contains all the characters of the supported operations.
* Parenthesis are included for grouping purposes in expressions.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline getSupportedFunctions
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline getSupportedFunctions
*
* @return a vector containing the strings associated with all valid functions
*/
static const std::vector<std::string> getSupportedFunctions();
/**
* Gets a string that contains all strings that are viable for use when mapping
* to shared pointers of XdmfArrays for the evaluateExpression function.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline getValidVariableChars
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline getValidVariableChars
*
* @return a string containing all valid variable characters
*/
static const std::string getValidVariableChars();
/**
* 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.
*
* Example of Use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline getValidDigitChars
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline getValidDigitChars
*
* @return a string containing all valid variable characters
*/
static const std::string getValidDigitChars();
/**
* Get a copy of a single value stored in this array.
*
......@@ -734,6 +313,7 @@ public:
* @skipline 7]
* @until Variations
*
* @param index the index in the array to copy.
* @return the requested value.
*/
template <typename T>
......@@ -1052,7 +632,7 @@ public:
template<typename T>
void insert(const unsigned int startIndex,
const T * const valuesPointer,
const unsigned int numValues = 1,
const unsigned int numValues,
const unsigned int arrayStride = 1,
const unsigned int valuesStride = 1);
......@@ -1100,6 +680,14 @@ public:
template <typename T>
void pushBack(const T & value);
/**
* Get the first heavy data controller attached to this array.
*
......@@ -1164,6 +752,12 @@ public:
void
setHeavyDataController(shared_ptr<XdmfHeavyDataController> newController);
/**
* Read data from disk into memory.
*
......@@ -1515,6 +1109,7 @@ private:
template <typename T> class Insert;
class InsertArray;
class InternalizeArrayPointer;
class IsInitialized;
struct NullDeleter;
template <typename T> class PushBack;
class Reserve;
......@@ -1551,21 +1146,13 @@ private:
boost::shared_array<const double>,
boost::shared_array<const unsigned char>,
boost::shared_array<const unsigned short>,
boost::shared_array<const unsigned int> > ArrayVariant;
boost::shared_array<const unsigned int> > ArrayVariant;
ArrayVariant mArray;
unsigned int mArrayPointerNumValues;
std::vector<unsigned int> mDimensions;
std::string mName;
unsigned int mTmpReserveSize;
static std::string mSupportedOperations;
static const std::string mValidVariableChars;
static const std::string mValidDigitChars;
static int mOperationPriority[];
static std::map<std::string, shared_ptr<XdmfArray>(*)(std::vector<shared_ptr<XdmfArray> >)> arrayFunctions;
static std::map<char, shared_ptr<XdmfArray>(*)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>)> operations;
};
#include "XdmfArray.tpp"
......
This diff is collapsed.
......@@ -24,14 +24,11 @@
#include <libxml/uri.h>
#include <libxml/xpointer.h>
#include <libxml/xmlreader.h>
#include "boost/tokenizer.hpp"
#include <map>
#include <sstream>
#include <cstring>
#include <utility>
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfCoreItemFactory.hpp"
#include "XdmfCoreReader.hpp"
#include "XdmfError.hpp"
......@@ -171,317 +168,6 @@ public:
}
}
else if (xmlStrcmp(currNode->name, (xmlChar*)"Function") == 0) {
//function handling goes here
xmlNodePtr childNode = currNode->children;
std::string arraySubType = "";
//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
}
}
std::string expressionToParse = "";
while (childNode != NULL) {
if (xmlStrcmp(childNode->name, (xmlChar*)"Expression") == 0){
//store expression
xmlAttrPtr childAttribute = childNode->properties;
while (childAttribute != NULL) {
if(xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) {
expressionToParse = (char*)childAttribute->children->content;
break;
}
childAttribute = childAttribute->next;
}
break;
}
childNode = childNode->next;
}
if (expressionToParse.compare("") == 0) {
XdmfError::message(XdmfError::FATAL,
"Error: No Expression in Function");
}
//two seperate loops to allow for different orders and multiple variable sets
childNode = currNode->children;
std::map<std::string, shared_ptr<XdmfArray> > variableCollection;
while (childNode != NULL) {
if (xmlStrcmp(childNode->name, (xmlChar*)"Variable") == 0) {
//store child variables
xmlNodePtr childVariable = childNode->children;
while (childVariable != NULL) {
if (xmlStrcmp(childVariable->name, (xmlChar*)"DataItem") == 0) {
xmlAttrPtr childAttribute = childVariable->properties;
std::string childKey = "";
shared_ptr<XdmfArray> childArray = XdmfArray::New();
std::string dataString = "";
shared_ptr<const XdmfArrayType> dataType;
xmlChar * childXPointer = NULL;
xmlChar * childhref = NULL;
std::string childhdf5 = "";
std::map<std::string, std::string> typeMap;
while (childAttribute != NULL) {
//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)
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Precision") == 0) {
typeMap["Precision"] = (char*)childAttribute->children->content;
}
//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
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) {
dataString = (char*)childAttribute->children->content;
}
//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
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"href") == 0) {
childhref = childAttribute->children->content;
}
//path to hdf5 data sets and the dimensions of those sets
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"hdf5") == 0) {
childhdf5 = (char*)childAttribute->children->content;
}
childAttribute = childAttribute->next;
}
if (typeMap["DataType"].compare("Float") == 0) {
if (typeMap["Precision"].compare("8") == 0) {
dataType = XdmfArrayType::Float64();
}
else {
dataType = XdmfArrayType::Float32();
}
}
else if (typeMap["DataType"].compare("Int") == 0) {
if (typeMap["Precision"].compare("8") == 0) {
dataType = XdmfArrayType::Int64();
}
else {
dataType = XdmfArrayType::Int32();
}
}
else if (typeMap["DataType"].compare("String") == 0) {
dataType = XdmfArrayType::String();
}
else if (typeMap["DataType"].compare("Char") == 0) {
dataType = XdmfArrayType::Int8();
}
else if (typeMap["DataType"].compare("Short") == 0) {
dataType = XdmfArrayType::Int16();
}
else if (typeMap["DataType"].compare("UChar") == 0) {
dataType = XdmfArrayType::UInt8();
}
else if (typeMap["DataType"].compare("UShort") == 0) {
dataType = XdmfArrayType::UInt16();
}
else if (typeMap["DataType"].compare("UInt") == 0) {
dataType = XdmfArrayType::UInt32();
}
else {
dataType = XdmfArrayType::Uninitialized();
}