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

Finished converting documentation to tag-based version; adjusted line length where possible

parent a5f74bf5
...@@ -66,6 +66,17 @@ ...@@ -66,6 +66,17 @@
* shared pointers can be created. These pointers are freed * shared pointers can be created. These pointers are freed
* automatically by the shared pointer reference counting mechanism. * automatically by the shared pointer reference counting mechanism.
* *
*
* Structure:
*
* Xdmf2 is structured in a tree format with an XdmfDomain serving
* as the base. The Domain contains multiple grid collections or
* grids; each with their own geometries, topologies, attributes,
* and/or sets. With the inclusion of shared pointers in Xdmf2
* a topology could be shared across multiple grids or a grid
* could be included in multiple grid collections and/or the domain.
*
*
* C++ Examples: * C++ Examples:
* *
* \subpage cppwrite "C++ Example of Xdmf Creation" * \subpage cppwrite "C++ Example of Xdmf Creation"
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* *
* @return constructed XdmfAttribute. * @return constructed XdmfAttribute.
*/ */
static shared_ptr<XdmfAttribute> New(); static shared_ptr<XdmfAttribute> New();
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
* @skipline #//getCenter * @skipline #//getCenter
* @until #//getCenter * @until #//getCenter
* *
* @return XdmfAttributeCenter of the attribute. * @return XdmfAttributeCenter of the attribute.
*/ */
shared_ptr<const XdmfAttributeCenter> getCenter() const; shared_ptr<const XdmfAttributeCenter> getCenter() const;
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
* @skipline #//getName * @skipline #//getName
* @until #//getName * @until #//getName
* *
* @return a string containing the name of the attribute. * @return a string containing the name of the attribute.
*/ */
std::string getName() const; std::string getName() const;
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
* @skipline #//getType * @skipline #//getType
* @until #//getType * @until #//getType
* *
* @return XdmfAttributeType of the attribute. * @return XdmfAttributeType of the attribute.
*/ */
shared_ptr<const XdmfAttributeType> getType() const; shared_ptr<const XdmfAttributeType> getType() const;
...@@ -183,7 +183,7 @@ public: ...@@ -183,7 +183,7 @@ public:
* @skipline #//setCenter * @skipline #//setCenter
* @until #//setCenter * @until #//setCenter
* *
* @param center the XdmfAttributeCenter to set. * @param center the XdmfAttributeCenter to set.
*/ */
void setCenter(const shared_ptr<const XdmfAttributeCenter> center); void setCenter(const shared_ptr<const XdmfAttributeCenter> center);
...@@ -208,7 +208,7 @@ public: ...@@ -208,7 +208,7 @@ public:
* @skipline #//setName * @skipline #//setName
* @until #//setName * @until #//setName
* *
* @param name a string containing the name to set. * @param name a string containing the name to set.
*/ */
void setName(const std::string & name); void setName(const std::string & name);
...@@ -233,7 +233,7 @@ public: ...@@ -233,7 +233,7 @@ public:
* @skipline #//setType * @skipline #//setType
* @until #//setType * @until #//setType
* *
* @param type XdmfAttributeType to set. * @param type XdmfAttributeType to set.
*/ */
void setType(const shared_ptr<const XdmfAttributeType> type); void setType(const shared_ptr<const XdmfAttributeType> type);
......
...@@ -182,7 +182,13 @@ public: ...@@ -182,7 +182,13 @@ public:
private: private:
XdmfTopologyTypeCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) : XdmfTopologyTypeCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
XdmfTopologyType(0, 0, std::vector<shared_ptr<const XdmfTopologyType> >(), 0, "foo", XdmfTopologyType::Structured, 0x1110), XdmfTopologyType(0,
0,
std::vector<shared_ptr<const XdmfTopologyType> >(),
0,
"foo",
XdmfTopologyType::Structured,
0x1110),
mCurvilinearGrid(curvilinearGrid) mCurvilinearGrid(curvilinearGrid)
{ {
} }
......
...@@ -65,10 +65,10 @@ public: ...@@ -65,10 +65,10 @@ public:
* @skipline #//constructor2 * @skipline #//constructor2
* @until #//constructor2 * @until #//constructor2
* *
* @param xNumPoints the number of points in the x direction. * @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction. * @param yNumPoints the number of points in the y direction.
* *
* @return constructed curvilinear grid. * @return constructed curvilinear grid.
*/ */
static shared_ptr<XdmfCurvilinearGrid> static shared_ptr<XdmfCurvilinearGrid>
New(const unsigned int xNumPoints, New(const unsigned int xNumPoints,
...@@ -93,11 +93,11 @@ public: ...@@ -93,11 +93,11 @@ public:
* @skipline #//constructor3 * @skipline #//constructor3
* @until #//constructor3 * @until #//constructor3
* *
* @param xNumPoints the number of points in the x direction. * @param xNumPoints the number of points in the x direction.
* @param yNumPoints the number of points in the y direction. * @param yNumPoints the number of points in the y direction.
* @param zNumPoints the number of points in the z direction. * @param zNumPoints the number of points in the z direction.
* *
* @return constructed curvilinear grid. * @return constructed curvilinear grid.
*/ */
static shared_ptr<XdmfCurvilinearGrid> static shared_ptr<XdmfCurvilinearGrid>
New(const unsigned int xNumPoints, New(const unsigned int xNumPoints,
...@@ -123,9 +123,9 @@ public: ...@@ -123,9 +123,9 @@ public:
* @skipline #//constructorvector * @skipline #//constructorvector
* @until #//constructorvector * @until #//constructorvector
* *
* @param numPoints the number of points in each direction. * @param numPoints the number of points in each direction.
* *
* @return constructed curvilinear grid. * @return constructed curvilinear grid.
*/ */
static shared_ptr<XdmfCurvilinearGrid> static shared_ptr<XdmfCurvilinearGrid>
New(const shared_ptr<XdmfArray> numPoints); New(const shared_ptr<XdmfArray> numPoints);
...@@ -163,7 +163,7 @@ public: ...@@ -163,7 +163,7 @@ public:
* @skipline #//getDimensions * @skipline #//getDimensions
* @until #//getDimensions * @until #//getDimensions
* *
* @return XdmfArray containing dimensions of this grid. * @return XdmfArray containing dimensions of this grid.
*/ */
shared_ptr<XdmfArray> getDimensions(); shared_ptr<XdmfArray> getDimensions();
...@@ -185,7 +185,7 @@ public: ...@@ -185,7 +185,7 @@ public:
* *
* Python: Python doesn't have a constant version * Python: Python doesn't have a constant version
* *
* @return XdmfArray containing the dimensions of this grid. * @return XdmfArray containing the dimensions of this grid.
*/ */
shared_ptr<const XdmfArray> getDimensions() const; shared_ptr<const XdmfArray> getDimensions() const;
...@@ -216,7 +216,7 @@ public: ...@@ -216,7 +216,7 @@ public:
* @skipline #//getGeometry * @skipline #//getGeometry
* @until #//getGeometry * @until #//getGeometry
* *
* @return the geometry associated with this grid. * @return the geometry associated with this grid.
*/ */
shared_ptr<XdmfGeometry> getGeometry(); shared_ptr<XdmfGeometry> getGeometry();
...@@ -244,7 +244,7 @@ public: ...@@ -244,7 +244,7 @@ public:
* @skipline #//setDimensions * @skipline #//setDimensions
* @until #//setDimensions * @until #//setDimensions
* *
* @param dimensions the dimension of the grid. * @param dimensions the dimension of the grid.
*/ */
void setDimensions(const shared_ptr<XdmfArray> dimensions); void setDimensions(const shared_ptr<XdmfArray> dimensions);
...@@ -271,7 +271,7 @@ public: ...@@ -271,7 +271,7 @@ public:
* @skipline #//setGeometry * @skipline #//setGeometry
* @until #//setGeometry * @until #//setGeometry
* *
* @param geometry an XdmfGeometry to associate with this grid. * @param geometry an XdmfGeometry to associate with this grid.
*/ */
void setGeometry(const shared_ptr<XdmfGeometry> geometry); void setGeometry(const shared_ptr<XdmfGeometry> geometry);
......
...@@ -37,7 +37,11 @@ const std::string XdmfFunction::mValidDigitChars = "-1234567890."; ...@@ -37,7 +37,11 @@ const std::string XdmfFunction::mValidDigitChars = "-1234567890.";
// List the priorities for the operations, based on the order of operations // List the priorities for the operations, based on the order of operations
// The index of the corresponding operation in validOperationChars // The index of the corresponding operation in validOperationChars
// is the same as the index of its priority in this array // is the same as the index of its priority in this array
std::map<char, int> XdmfFunction::mOperationPriority = boost::assign::map_list_of ('|', 2) ('#', 1) ('(', 0) (')', 0); std::map<char, int> XdmfFunction::mOperationPriority =
boost::assign::map_list_of ('|', 2)
('#', 1)
('(', 0)
(')', 0);
// The higher the value, the earlier the operation is // The higher the value, the earlier the operation is
// evaluated in the order of operations // evaluated in the order of operations
// With the exception of parenthesis which are evaluated // With the exception of parenthesis which are evaluated
...@@ -75,7 +79,7 @@ const std::string XdmfFunction::ItemTag = "Function"; ...@@ -75,7 +79,7 @@ const std::string XdmfFunction::ItemTag = "Function";
int int
XdmfFunction::addFunction(std::string name, XdmfFunction::addFunction(std::string name,
shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >)) shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >))
{ {
// Check to ensure that the name has valid characters // Check to ensure that the name has valid characters
for (unsigned int i = 0; i < name.size(); ++i) { for (unsigned int i = 0; i < name.size(); ++i) {
...@@ -127,8 +131,11 @@ XdmfFunction::chunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2) ...@@ -127,8 +131,11 @@ XdmfFunction::chunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
// Join chunk (add the new array to the end of the first one) // Join chunk (add the new array to the end of the first one)
// Joins into new array and returns it // Joins into new array and returns it
shared_ptr<XdmfArray> returnArray = XdmfArray::New(); shared_ptr<XdmfArray> returnArray = XdmfArray::New();
// Determining what type to class it as in order to not lose data, and to still have the smallest data type of the two // Determining what type to class it as in order to not lose data
shared_ptr<const XdmfArrayType> resultType = XdmfArrayType::comparePrecision(val1->getArrayType(), val2->getArrayType()); // and to still have the smallest data type of the two
shared_ptr<const XdmfArrayType> resultType =
XdmfArrayType::comparePrecision(val1->getArrayType(),
val2->getArrayType());
if (resultType == XdmfArrayType::Int8()) { if (resultType == XdmfArrayType::Int8()) {
char sampleValue = 0; char sampleValue = 0;
...@@ -233,7 +240,8 @@ XdmfFunction::evaluateExpression(std::string expression, ...@@ -233,7 +240,8 @@ XdmfFunction::evaluateExpression(std::string expression,
} }
} }
else { else {
std::string currentFunction = expression.substr(valueStart, i + 1 - valueStart); std::string currentFunction =
expression.substr(valueStart, i + 1 - valueStart);
// Check if next character is an open parenthesis // Check if next character is an open parenthesis
if (i+1 >= expression.size()) { if (i+1 >= expression.size()) {
if (expression[i+1] != '(') { if (expression[i+1] != '(') {
...@@ -278,7 +286,9 @@ XdmfFunction::evaluateExpression(std::string expression, ...@@ -278,7 +286,9 @@ XdmfFunction::evaluateExpression(std::string expression,
parameterVector.push_back(evaluateExpression(functionParameters, variables)); parameterVector.push_back(evaluateExpression(functionParameters, variables));
} }
else { else {
parameterVector.push_back(evaluateExpression(functionParameters.substr(0, parameterSplit), variables)); parameterVector.push_back(
evaluateExpression(functionParameters.substr(0, parameterSplit),
variables));
functionParameters = functionParameters.substr(parameterSplit+1); functionParameters = functionParameters.substr(parameterSplit+1);
} }
} }
...@@ -573,8 +583,10 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2) ...@@ -573,8 +583,10 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
// Builds a new array // Builds a new array
shared_ptr<XdmfArray> returnArray = XdmfArray::New(); shared_ptr<XdmfArray> returnArray = XdmfArray::New();
// Resize to the combined size of both arrays // 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 // Determining what type to class it as in order to not lose data
shared_ptr<const XdmfArrayType> resultType = XdmfArrayType::comparePrecision(val1->getArrayType(), val2->getArrayType()); // and to still have the smallest data type of the two
shared_ptr<const XdmfArrayType> resultType =
XdmfArrayType::comparePrecision(val1->getArrayType(), val2->getArrayType());
if (resultType == XdmfArrayType::Int8()) { if (resultType == XdmfArrayType::Int8()) {
char sampleValue = 0; char sampleValue = 0;
...@@ -635,7 +647,8 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2) ...@@ -635,7 +647,8 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
int arrayExcess1 = 0; int arrayExcess1 = 0;
int arrayExcess2 = 0; int arrayExcess2 = 0;
for (int i = 0; i < stride; ++i) { for (int i = 0; i < stride; ++i) {
// Add the values of each array, using strides to interlace and starting index to offset // 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 // first array gets the first value of the new array
if (i<arrayRatio1) { if (i<arrayRatio1) {
int amountWritten = val1->getSize()/arrayRatio1; int amountWritten = val1->getSize()/arrayRatio1;
...@@ -662,10 +675,20 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2) ...@@ -662,10 +675,20 @@ XdmfFunction::interlace(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
} }
} }
if (arrayExcess1 > 0) { if (arrayExcess1 > 0) {
returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess1, val1, 0, arrayExcess1, 1, 1); returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess1,
val1,
0,
arrayExcess1,
1,
1);
} }
else if (arrayExcess2 > 0) { else if (arrayExcess2 > 0) {
returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess2, val2, 0, arrayExcess2, 1, 1); returnArray->insert(val1->getSize()+val2->getSize()-arrayExcess2,
val2,
0,
arrayExcess2,
1,
1);
} }
// After all inserts are done, add the excess values to the end of the array // After all inserts are done, add the excess values to the end of the array
return returnArray; return returnArray;
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
/** /**
* @brief * @brief Manipulates arrays based on expressions.
* *
* * The function class provides a way to manipulate XdmfArrays via predefined functions.
*/ */
class XDMF_EXPORT XdmfFunction : public XdmfItem { class XDMF_EXPORT XdmfFunction : public XdmfItem {
...@@ -80,11 +80,13 @@ public: ...@@ -80,11 +80,13 @@ public:
* @skipline #//addOperation * @skipline #//addOperation
* @until #//addOperation * @until #//addOperation
* *
* @param newoperator the character to be associated with the provided binary operation * @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 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 * @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); static int addOperation(char newoperator,
shared_ptr<XdmfArray>(*functionref)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>),
int priority);
/* /*
* adds a specified function to the list of functions used while evaluating strings * adds a specified function to the list of functions used while evaluating strings
...@@ -113,11 +115,12 @@ public: ...@@ -113,11 +115,12 @@ public:
* @skipline #//addFunction * @skipline #//addFunction
* @until #//addFunction * @until #//addFunction
* *
* @param name A string to be associated with the provided function during string evaluation * @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 * @param functionref A pointer to the function to be associated with the given string
* @return The total number of functions currently associated * @return The total number of functions currently associated
*/ */
static int addFunction(std::string name, shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >)); static int addFunction(std::string name,
shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >));
/** /**
* Averages the values contained in all the provided arrays. * Averages the values contained in all the provided arrays.
...@@ -138,8 +141,8 @@ public: ...@@ -138,8 +141,8 @@ public:
* @skipline #//average * @skipline #//average
* @until #//average * @until #//average
* *
* @param values a vector containing the arrays to be used * @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 * @return an XdmfArray containing one value which is the average of all values contained within the provided arrays
*/ */
static shared_ptr<XdmfArray> average(std::vector<shared_ptr<XdmfArray> > values); static shared_ptr<XdmfArray> average(std::vector<shared_ptr<XdmfArray> > values);
...@@ -164,11 +167,12 @@ public: ...@@ -164,11 +167,12 @@ public:
* @skipline #//chunk * @skipline #//chunk
* @until #//chunk * @until #//chunk
* *
* @param val1 the first array being evaluated * @param val1 the first array being evaluated
* @param val2 the second array being evaluated * @param val2 the second array being evaluated
* @return the arrays joined end to end * @return the arrays joined end to end
*/ */
static shared_ptr<XdmfArray> chunk(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2); static shared_ptr<XdmfArray> chunk(shared_ptr<XdmfArray> val1,
shared_ptr<XdmfArray> val2);
/** /**
* Evaluates an expression based on the list of variables provided. * Evaluates an expression based on the list of variables provided.
...@@ -219,11 +223,12 @@ public: ...@@ -219,11 +223,12 @@ public:
* @skipline #//evaluateExpression * @skipline #//evaluateExpression
* @until #//evaluateExpression * @until #//evaluateExpression
* *
* @param expression a string containing the expresion to be evaluated * @param expression a string containing the expresion to be evaluated
* @param variables a map of strings to their XdmfArray equivalent * @param variables a map of strings to their XdmfArray equivalent
* @return a shared pointer to the XdmfArray resulting from the expression * @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); 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. * Evaluates the operation specified using the two shared pointers to XdmfArrays provided.
...@@ -264,12 +269,14 @@ public: ...@@ -264,12 +269,14 @@ public:
* @skipline #//evaluateOperation * @skipline #//evaluateOperation
* @until #//evaluateOperation * @until #//evaluateOperation
* *
* @param val1 the first array being evaluated * @param val1 the first array being evaluated
* @param val2 the second array being evaluated * @param val2 the second array being evaluated
* @param operation a character specifying the operation performed * @param operation a character specifying the operation performed
* @return a shared pointer to the Xdmf Array that results from the calculation * @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); static shared_ptr<XdmfArray> evaluateOperation(shared_ptr<XdmfArray> val1,
shared_ptr<XdmfArray> val2,
char operation);
/** /**
* Evaluates the function specified using the vector of XdmfArrays provided. * Evaluates the function specified using the vector of XdmfArrays provided.
...@@ -307,11 +314,12 @@ public: ...@@ -307,11 +314,12 @@ public:
* @skipline #//evaluateFunction * @skipline #//evaluateFunction
* @until #//evaluateFunction * @until #//evaluateFunction
* *
* @param valueVector a vector containing the arrays to be used * @param valueVector a vector containing the arrays to be used
* @param functionName the string associated with the function being called * @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 * @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); static shared_ptr<XdmfArray> evaluateFunction(std::vector<shared_ptr<XdmfArray> > valueVector,
std::string functionName);
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
...@@ -335,8 +343,8 @@ public: ...@@ -335,8 +343,8 @@ public:
* @skipline #//getOperationPriority * @skipline #//getOperationPriority
* @until #//getOperationPriority * @until #//getOperationPriority
* *
* @param operation the character associated with the operation to be checked * @param operation the character associated with the operation to be checked
* @return the priority of the operation * @return the priority of the operation
*/ */
static int getOperationPriority(char operation); static int getOperationPriority(char operation);
...@@ -358,7 +366,7 @@ public: ...@@ -358,7 +366,7 @@ public:
* @skipline #//getSupportedOperations * @skipline #//getSupportedOperations
* @until #//getSupportedOperations * @until #//getSupportedOperations
* *
* @return a string containing the characters for all supported operations * @return a string containing the characters for all supported operations
*/ */
static const std::string getSupportedOperations(); static const std::string getSupportedOperations();
...@@ -380,7 +388,7 @@ public: ...@@ -380,7 +388,7 @@ public:
* @skipline #//getSupportedFunctions * @skipline #//getSupportedFunctions
* @until #//getSupportedFunctions * @until #//getSupportedFunctions
* *
* @return a vector containing the strings associated with all valid functions * @return a vector containing the strings associated with all valid functions
*/ */
static const std::vector<std::string> getSupportedFunctions(); static const std::vector<std::string> getSupportedFunctions();
...@@ -402,7 +410,7 @@ public: ...@@ -402,7 +410,7 @@ public:
* @skipline #//getValidDigitChars * @skipline #//getValidDigitChars
* @until #//getValidDigitChars