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

XdmfFunction read legacy files, small fortran changes

parent 6a2647c0
......@@ -107,6 +107,10 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
......
......@@ -24,6 +24,7 @@
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
#include "XdmfError.hpp"
#include "XdmfFunction.hpp"
shared_ptr<XdmfGeometry> XdmfGeometry::New()
{
......@@ -78,15 +79,91 @@ XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProper
const XdmfCoreReader * const reader)
{
XdmfItem::populateItem(itemProperties, childItems, reader);
mType = XdmfGeometryType::New(itemProperties);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->swap(array);
break;
std::map<std::string, std::string>::const_iterator type =
itemProperties.find("Type");
if(type == itemProperties.end()) {
type = itemProperties.find("GeometryType");
}
if (type != itemProperties.end()) {
if(type->second.compare("X_Y_Z") == 0) {
mType = XdmfGeometryType::XYZ();
// Building Function equivalent
std::vector<std::string> dimensionIDVector;
dimensionIDVector.push_back("X");
dimensionIDVector.push_back("Y");
dimensionIDVector.push_back("Z");
std::map<std::string, shared_ptr<XdmfArray> > dimensionMap;
unsigned int dimensionIDIndex = 0;
// Find X, Y, and Z Arrays
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end() && dimensionIDIndex < dimensionIDVector.size();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
dimensionMap[dimensionIDVector[dimensionIDIndex]] = array;
dimensionIDIndex++;
}
}
shared_ptr<XdmfFunction> geoFunction = XdmfFunction::New("X#Y#Z", dimensionMap);
this->setReference(geoFunction);
this->setReadMode(XdmfArray::Reference);
}
else if(type->second.compare("X_Y") == 0) {
mType = XdmfGeometryType::XY();
// Building Function equivalent
std::vector<std::string> dimensionIDVector;
dimensionIDVector.push_back("X");
dimensionIDVector.push_back("Y");
std::map<std::string, shared_ptr<XdmfArray> > dimensionMap;
unsigned int dimensionIDIndex = 0;
// Find X, Y, and Z Arrays
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end() && dimensionIDIndex < dimensionIDVector.size();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
dimensionMap[dimensionIDVector[dimensionIDIndex]] = array;
dimensionIDIndex++;
}
}
shared_ptr<XdmfFunction> geoFunction = XdmfFunction::New("X#Y", dimensionMap);
this->setReference(geoFunction);
this->setReadMode(XdmfArray::Reference);
}
else {
mType = XdmfGeometryType::New(itemProperties);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
}
}
else {
XdmfError::message(XdmfError::FATAL,
"Neither 'Type' nor 'GeometryType' in itemProperties "
"in XdmfGeometry::populateItem");
}
}
......
......@@ -99,7 +99,12 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
else if(shared_ptr<XdmfArray> array =
shared_dynamic_cast<XdmfArray>(*iter)) {
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
// TODO: If multiple dataitems.
break;
}
}
}
......
......@@ -24,6 +24,7 @@
#include <sstream>
#include <utility>
#include "XdmfError.hpp"
#include "XdmfFunction.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
......@@ -127,8 +128,29 @@ XdmfTopology::populateItem(const std::map<std::string, std::string> & itemProper
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
std::map<std::string, std::string>::const_iterator type =
itemProperties.find("Offset");
if (type != itemProperties.end()) {
// Convert to double
double offset = atof(type->second.c_str());
std::stringstream expressionStream;
expressionStream << offset << "+X";
std::map<std::string, shared_ptr<XdmfArray> > offsetMap;
shared_ptr<XdmfArray> offsetBase = XdmfArray::New();
this->swap(offsetBase);
offsetMap["X"] = offsetBase;
shared_ptr<XdmfFunction> offsetFunction = XdmfFunction::New(expressionStream.str(), offsetMap);
this->setReference(offsetFunction);
this->setReadMode(XdmfArray::Reference);
}
}
void
......
......@@ -31,6 +31,7 @@
#include "XdmfArrayType.hpp"
#include "XdmfArrayReference.hpp"
#include "XdmfBinaryController.hpp"
#include "XdmfFunction.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfHeavyDataController.hpp"
#include "XdmfVisitor.hpp"
......@@ -1013,186 +1014,241 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
// This inserts any XdmfInformation in childItems into the object.
XdmfItem::populateItem(itemProperties, childItems, reader);
const shared_ptr<const XdmfArrayType> arrayType =
XdmfArrayType::New(itemProperties);
bool filled = false;
std::map<std::string, std::string>::const_iterator content =
itemProperties.find("Content");
if(content == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Content' not found in itemProperties in "
"XdmfArray::populateItem");
}
unsigned int contentIndex;
// Check for Function
std::map<std::string, std::string>::const_iterator itemType =
itemProperties.find("ItemType");
const std::string & contentVal = content->second;
if (itemType != itemProperties.end()) {
if (itemType->second.compare("Function") == 0) {
std::map<std::string, std::string>::const_iterator expressionLocation =
itemProperties.find("Function");
if (expressionLocation == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Function' not found in itemProperties for Function"
" ItemType in XdmfArray::populateItem");
}
std::string expression = expressionLocation->second;
// Convert from old format to new Variable format
// $X -> ValX
size_t loc = expression.find("$");
while (loc != std::string::npos) {
expression.replace(loc, 1, "Val");
loc = expression.find("$", loc);
}
// Create Variable list
std::map<std::string, shared_ptr<XdmfArray> > variableMap;
unsigned int variableIndex = 0;
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
childItems.begin();
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
std::stringstream variableKey;
variableKey << "Val" << variableIndex;
variableMap[variableKey.str()] = array;
variableIndex++;
}
}
std::vector<std::string> contentVals;
shared_ptr<XdmfFunction> function = XdmfFunction::New(expression, variableMap);
// Split the content based on "|" characters
size_t barSplit = 0;
std::string splitString(contentVal);
std::string subcontent;
while (barSplit != std::string::npos) {
barSplit = 0;
barSplit = splitString.find_first_of("|", barSplit);
if (barSplit == std::string::npos) {
subcontent = splitString;
}
else {
subcontent = splitString.substr(0, barSplit);
splitString = splitString.substr(barSplit+1);
barSplit++;
this->setReference(function);
this->setReadMode(XdmfArray::Reference);
filled = true;
}
contentVals.push_back(subcontent);
}
std::map<std::string, std::string>::const_iterator dimensions =
itemProperties.find("Dimensions");
if(dimensions == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Dimensions' not found in itemProperties in "
"XdmfArray::populateItem");
}
boost::tokenizer<> tokens(dimensions->second);
for(boost::tokenizer<>::const_iterator iter = tokens.begin();
iter != tokens.end();
++iter) {
mDimensions.push_back(atoi((*iter).c_str()));
}
if (!filled) {
std::map<std::string, std::string>::const_iterator format =
itemProperties.find("Format");
if(format == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Format' not found in itemProperties in "
"XdmfArray::populateItem");
}
const std::string & formatVal = format->second;
if(formatVal.compare("HDF") == 0) {
contentIndex = 0;
int contentStep = 2;
while (contentIndex < contentVals.size()) {
size_t colonLocation = contentVals[contentIndex].find(":");
if(colonLocation == std::string::npos) {
XdmfError::message(XdmfError::FATAL,
"':' not found in content in "
"XdmfArray::populateItem -- double check an HDF5 "
"data set is specified for the file");
}
const shared_ptr<const XdmfArrayType> arrayType =
XdmfArrayType::New(itemProperties);
std::string hdf5Path =
contentVals[contentIndex].substr(0, colonLocation);
std::string dataSetPath =
contentVals[contentIndex].substr(colonLocation+1);
hdf5Path = getFullHeavyDataPath(hdf5Path,
itemProperties);
// Parse dimensions from the content
std::vector<unsigned int> contentDims;
if (contentVals.size() > contentIndex+1) {
// 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
std::map<std::string, std::string>::const_iterator content =
itemProperties.find("Content");
if(content == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Content' not found in itemProperties in "
"XdmfArray::populateItem");
}
unsigned int contentIndex;
const std::string & contentVal = content->second;
std::vector<std::string> contentVals;
// Split the content based on "|" characters
size_t barSplit = 0;
std::string splitString(contentVal);
std::string subcontent;
while (barSplit != std::string::npos) {
barSplit = 0;
barSplit = splitString.find_first_of("|", barSplit);
if (barSplit == std::string::npos) {
subcontent = splitString;
}
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;
subcontent = splitString.substr(0, barSplit);
splitString = splitString.substr(barSplit+1);
barSplit++;
}
contentVals.push_back(subcontent);
}
mHeavyDataControllers.push_back(
XdmfHDF5Controller::New(hdf5Path,
dataSetPath,
arrayType,
std::vector<unsigned int>(contentDims.size(),
0),
std::vector<unsigned int>(contentDims.size(),
1),
contentDims,
contentDims)
);
contentIndex += contentStep;
std::map<std::string, std::string>::const_iterator dimensions =
itemProperties.find("Dimensions");
if(dimensions == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Dimensions' not found in itemProperties in "
"XdmfArray::populateItem");
}
}
else if(formatVal.compare("XML") == 0) {
this->initialize(arrayType,
mDimensions);
unsigned int index = 0;
boost::char_separator<char> sep(" \t\n");
boost::tokenizer<boost::char_separator<char> > tokens(contentVals[0], sep);
if(arrayType == XdmfArrayType::String()) {
for(boost::tokenizer<boost::char_separator<char> >::const_iterator
iter = tokens.begin();
iter != tokens.end();
++iter, ++index) {
this->insert(index, *iter);
}
boost::tokenizer<> tokens(dimensions->second);
for(boost::tokenizer<>::const_iterator iter = tokens.begin();
iter != tokens.end();
++iter) {
mDimensions.push_back(atoi((*iter).c_str()));
}
else {
for(boost::tokenizer<boost::char_separator<char> >::const_iterator
iter = tokens.begin();
iter != tokens.end();
++iter, ++index) {
this->insert(index, atof((*iter).c_str()));
}
std::map<std::string, std::string>::const_iterator format =
itemProperties.find("Format");
if(format == itemProperties.end()) {
XdmfError::message(XdmfError::FATAL,
"'Format' not found in itemProperties in "
"XdmfArray::populateItem");
}
}
else if(formatVal.compare("Binary") == 0) {
const std::string & formatVal = format->second;
if(formatVal.compare("HDF") == 0) {
contentIndex = 0;
int contentStep = 2;
while (contentIndex < contentVals.size()) {
size_t colonLocation = contentVals[contentIndex].find(":");
if(colonLocation == std::string::npos) {
XdmfError::message(XdmfError::FATAL,
"':' not found in content in "
"XdmfArray::populateItem -- double check an HDF5 "
"data set is specified for the file");
}
XdmfBinaryController::Endian endian = XdmfBinaryController::NATIVE;
std::map<std::string, std::string>::const_iterator endianIter =
itemProperties.find("Endian");
if(endianIter != itemProperties.end()) {
if(endianIter->second.compare("Big") == 0) {
endian = XdmfBinaryController::BIG;
}
else if(endianIter->second.compare("Little") == 0) {
endian = XdmfBinaryController::LITTLE;
std::string hdf5Path =
contentVals[contentIndex].substr(0, colonLocation);
std::string dataSetPath =
contentVals[contentIndex].substr(colonLocation+1);
hdf5Path = getFullHeavyDataPath(hdf5Path,
itemProperties);
// Parse dimensions from the content
std::vector<unsigned int> contentDims;
if (contentVals.size() > contentIndex+1) {
// 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
}
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;
}
mHeavyDataControllers.push_back(
XdmfHDF5Controller::New(hdf5Path,
dataSetPath,
arrayType,
std::vector<unsigned int>(contentDims.size(),
0),
std::vector<unsigned int>(contentDims.size(),
1),
contentDims,
contentDims)
);
contentIndex += contentStep;
}
else if(endianIter->second.compare("Native") == 0) {
endian = XdmfBinaryController::NATIVE;
}
else if(formatVal.compare("XML") == 0) {
this->initialize(arrayType,
mDimensions);
unsigned int index = 0;
boost::char_separator<char> sep(" \t\n");
boost::tokenizer<boost::char_separator<char> > tokens(contentVals[0], sep);
if(arrayType == XdmfArrayType::String()) {
for(boost::tokenizer<boost::char_separator<char> >::const_iterator
iter = tokens.begin();
iter != tokens.end();
++iter, ++index) {
this->insert(index, *iter);
}
}
else {
XdmfError(XdmfError::FATAL,
"Invalid endianness type: " + endianIter->second);
for(boost::tokenizer<boost::char_separator<char> >::const_iterator
iter = tokens.begin();
iter != tokens.end();
++iter, ++index) {
this->insert(index, atof((*iter).c_str()));
}
}
}
else if(formatVal.compare("Binary") == 0) {
XdmfBinaryController::Endian endian = XdmfBinaryController::NATIVE;
std::map<std::string, std::string>::const_iterator endianIter =
itemProperties.find("Endian");
if(endianIter != itemProperties.end()) {
if(endianIter->second.compare("Big") == 0) {
endian = XdmfBinaryController::BIG;
}
else if(endianIter->second.compare("Little") == 0) {
endian = XdmfBinaryController::LITTLE;
}
else if(endianIter->second.compare("Native") == 0) {
endian = XdmfBinaryController::NATIVE;
}
else {
XdmfError(XdmfError::FATAL,
"Invalid endianness type: " + endianIter->second);
}
}
unsigned int seek = 0;
std::map<std::string, std::string>::const_iterator seekIter =
itemProperties.find("Seek");
if(seekIter != itemProperties.end()) {
seek = std::atoi(seekIter->second.c_str());
}
unsigned int seek = 0;
std::map<std::string, std::string>::const_iterator seekIter =
itemProperties.find("Seek");
if(seekIter != itemProperties.end()) {
seek = std::atoi(seekIter->second.c_str());
}
const std::string binaryPath = getFullHeavyDataPath(contentVals[0],
itemProperties);
const std::string binaryPath = getFullHeavyDataPath(contentVals[0],
itemProperties);
mHeavyDataControllers.push_back(XdmfBinaryController::New(binaryPath,
arrayType,
endian,
seek,
mDimensions));
}
else {
XdmfError::message(XdmfError::FATAL,
"Neither 'HDF' nor 'XML' specified as 'Format' "
"in XdmfArray::populateItem");
}
mHeavyDataControllers.push_back(XdmfBinaryController::New(binaryPath,
arrayType,
endian,
seek,
mDimensions));
}
else {
XdmfError::message(XdmfError::FATAL,
"Neither 'HDF' nor 'XML' specified as 'Format' "
"in XdmfArray::populateItem");
}
std::map<std::string, std::string>::const_iterator name =
......
......@@ -26,7 +26,7 @@
#include "XdmfArrayType.hpp"
#include "XdmfFunction.hpp"
#include <stack>
#include <math.h>
#include <cmath>
#include <boost/assign.hpp>
#include "XdmfError.hpp"
......@@ -84,7 +84,7 @@ class XdmfOperationInternalImpl : public XdmfFunction::XdmfOperationInternal {
shared_ptr<XdmfArray> (*mInternalOperation)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>);
};
std::string XdmfFunction::mSupportedOperations = "|#()";
std::string XdmfFunction::mSupportedOperations = "-+/*|#()";
const std::string XdmfFunction::mValidVariableChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_:.";
const std::string XdmfFunction::mValidDigitChars = "1234567890.";
......@@ -92,7 +92,11 @@ const std::string XdmfFunction::mValidDigitChars = "1234567890.";
// The index of the corresponding operation in validOperationChars
// is the same as the index of its priority in this array
std::map<char, int> XdmfFunction::mOperationPriority =
boost::assign::map_list_of ('|', 2)
boost::assign::map_list_of ('-', 4)
('+', 4)
('/', 3)
('*', 3)
('|', 2)
('#', 1)
('(', 0)
(')', 0);
......@@ -106,14 +110,42 @@ std::map<char, int> XdmfFunction::mOperationPriority =
std::map<std::string, shared_ptr<XdmfFunction::XdmfFunctionInternal> >
XdmfFunction::arrayFunctions =
boost::assign::map_list_of
("ABS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs))
("ABS_TOKEN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs))
("ARCCOS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arccos))
("ARCSIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arcsin))
("ARCTAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arctan))
("AVE", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::average))
("COS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::cos))
("EXP", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::exponent))
("JOIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::join))
("LOG", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::log))
("SIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sin))
("SQRT", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sqrt))
("SUM", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sum))
("AVE", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::average));
("TAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::tan));
std::map<char, shared_ptr<XdmfFunction::XdmfOperationInternal> >
XdmfFunction::operations =
boost::assign::map_list_of
('-', XdmfOperationInternalImpl::New(XdmfFunction::subtraction))
('+', XdmfOperationInternalImpl::New(XdmfFunction::addition))
('*', XdmfOperationInternalImpl::New(XdmfFunction::multiplication))
('/', XdmfOperationInternalImpl::New(XdmfFunction::division))
('|', XdmfOperationInternalImpl::New(XdmfFunction::chunk))
('#', XdmfOperationInternalImpl::New(XdmfFunction::interlace));
......@@ -150,6 +182,21 @@ XdmfFunction::~XdmfFunction()
const std::string XdmfFunction::ItemTag = "Function";
shared_ptr<XdmfArray>
XdmfFunction::abs(std::vector<shared_ptr<XdmfArray> > values)
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
// Only working with the first array provided
if (values.size() < 1) {
XdmfError::message(XdmfError::FATAL,
"Error: No Array Passed to Function abs");
}
for (unsigned int i = 0; i < values[0]->getSize(); ++i) {
returnArray->pushBack(std::abs(values[0]->getValue<double>(i)));
}
return returnArray;
}
int
XdmfFunction::addFunction(std::string name,
shared_ptr<XdmfArray>(*functionref)(std::vector<shared_ptr<XdmfArray> >))
......@@ -232,6 +279,73 @@ XdmfFunction::addOperation(char newoperator,
return operations.size();
}
shared_ptr<XdmfArray>
XdmfFunction::addition(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
for (unsigned int i = 0; i < val1->getSize() || i < val2->getSize(); ++i) {
if (val1->getSize() == val2->getSize()) {
returnArray->pushBack(val1->getValue<double>(i) + val2->getValue<double>(i));
}
else if (val1->getSize() == 1) {
returnArray->pushBack(val1->getValue<double>(0) + val2->getValue<double>(i));
}
else if (val2->getSize() == 1) {
returnArray->pushBack(val1->getValue<double>(i) + val2->getValue<double>(0));
}
else {
XdmfError::message(XdmfError::FATAL,
"Error: Array Size Mismatch in Function addition");
}
}
return returnArray;
}
shared_ptr<XdmfArray>
XdmfFunction::arcsin(std::vector<shared_ptr<XdmfArray> > values)
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
// Only working with the first array provided
if (values.size() < 1) {
XdmfError::message(XdmfError::FATAL,
"Error: No Array Passed to Function arcsin");