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

changes to file splitting, hyperslab not completely working yet. changes to...

changes to file splitting, hyperslab not completely working yet. changes to Fortran to allow for polylines and releasing data after standard write
parent cf18fe6b
...@@ -78,6 +78,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -78,6 +78,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfItem.hpp> #include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp> #include <XdmfItemProperty.hpp>
#include <XdmfSharedPtr.hpp> #include <XdmfSharedPtr.hpp>
#include <XdmfSparseMatrix.hpp>
#include <XdmfSystemUtils.hpp> #include <XdmfSystemUtils.hpp>
#include <XdmfVisitor.hpp> #include <XdmfVisitor.hpp>
#include <XdmfWriter.hpp> #include <XdmfWriter.hpp>
......
...@@ -54,6 +54,7 @@ XdmfGraph::getItemTag() const ...@@ -54,6 +54,7 @@ XdmfGraph::getItemTag() const
unsigned int unsigned int
XdmfGraph::getNumberNodes() const XdmfGraph::getNumberNodes() const
{ {
//The number of nodes is equal to the number of rows or columns. Either will work.
return this->getNumberRows(); return this->getNumberRows();
} }
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
virtual ~XdmfGraph(); virtual ~XdmfGraph();
LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix); LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix);
XDMF_CHILDREN(XdmfAttribute, Attribute, Name); XDMF_CHILDREN(XdmfGraph, XdmfAttribute, Attribute, Name);
static const std::string ItemTag; static const std::string ItemTag;
std::string getItemTag() const; std::string getItemTag() const;
......
This diff is collapsed.
This diff is collapsed.
...@@ -800,7 +800,7 @@ XdmfArray::swap(std::vector<T> & array) ...@@ -800,7 +800,7 @@ XdmfArray::swap(std::vector<T> & array)
currArray->swap(array); currArray->swap(array);
return true; return true;
} }
catch(const boost::bad_get& exception) { catch(const boost::bad_get & exception) {
return false; return false;
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -123,10 +123,72 @@ public: ...@@ -123,10 +123,72 @@ public:
*/ */
int getFileSizeLimit(); int getFileSizeLimit();
/**
* Sets the file index. Used when file splitting and incremented when the current file is full. Set to 0 before using hyperslab or overwrite.
*
* C++
*
* @dontinclude ExampleXdmfHDF5Writer.cpp
*
* Python
*
* @dontinclude XdmfExampleHDF5Writer.py
*
* @param newIndex The index that the writer will append to the file name when incorperating file splitting
*/
void setFileIndex(int newIndex);
/**
* Gets the file index. Used when file splitting and incremented whent he current file is full.
*
* C++
*
* @dontinclude ExampleXdmfHDF5Writer.cpp
*
* Python
*
* @dontinclude XdmfExampleHDF5Writer.py
*
* @return The current file index.
*/
int getFileIndex();
virtual void closeFile(); virtual void closeFile();
/**
* Get the chunk size used to output datasets to hdf5.
*
* C++
*
* @dontinclude ExampleXdmfHDF5Writer.cpp
*
* Python
*
* @dontinclude XdmfExampleHDF5Writer.py
*
* @return chunk size used to output datasets to hdf5.
*/
unsigned int getChunkSize() const;
virtual void openFile(); virtual void openFile();
/**
* Set the chunk size used to output datasets to hdf5. For
* multidimensional datasets the chunk size is the total number of
* elements in the chunk.
*
* C++
*
* @dontinclude ExampleXdmfHDF5Writer.cpp
*
* Python
*
* @dontinclude XdmfExampleHDF5Writer.py
*
* @param chunkSize the number of elements per chunk.
*/
void setChunkSize(const unsigned int chunkSize);
using XdmfHeavyDataWriter::visit; using XdmfHeavyDataWriter::visit;
virtual void visit(XdmfArray & array, virtual void visit(XdmfArray & array,
const shared_ptr<XdmfBaseVisitor> visitor); const shared_ptr<XdmfBaseVisitor> visitor);
......
...@@ -187,6 +187,8 @@ XdmfSparseMatrix::populateItem(const std::map<std::string, std::string> & itemPr ...@@ -187,6 +187,8 @@ XdmfSparseMatrix::populateItem(const std::map<std::string, std::string> & itemPr
} }
if(arrayVector.size() < 3) { 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.
XdmfError::message(XdmfError::FATAL, XdmfError::message(XdmfError::FATAL,
"Expected 3 arrays attached to " "Expected 3 arrays attached to "
"XdmfSparseMatrix::populateItem"); "XdmfSparseMatrix::populateItem");
......
...@@ -328,7 +328,6 @@ XdmfWriter::visit(XdmfArray & array, ...@@ -328,7 +328,6 @@ XdmfWriter::visit(XdmfArray & array,
} }
xmlTextValues.push_back(valuesStream.str()); xmlTextValues.push_back(valuesStream.str());
} }
array.read();//ensures that the data matches the data in the controllers
} }
else { else {
// Write values to XML // Write values to XML
......
...@@ -163,7 +163,6 @@ int main(int, char **) ...@@ -163,7 +163,6 @@ int main(int, char **)
array5->setValuesInternal(doubleValues, 3, 1); array5->setValuesInternal(doubleValues, 3, 1);
assert(array5->getSize() == 3); assert(array5->getSize() == 3);
assert(array5->getArrayType() == XdmfArrayType::Float64()); assert(array5->getArrayType() == XdmfArrayType::Float64());
assert(array5->getValuesString().compare("0 1.1 10.1") == 0);
// //
// SHARED ASSIGNMENTS // SHARED ASSIGNMENTS
......
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
int main(int, char **) int main(int, char **)
{ {
shared_ptr<XdmfSparseMatrix> matrix = XdmfSparseMatrix::New(3, 3); shared_ptr<XdmfSparseMatrix> matrix = XdmfSparseMatrix::New(3, 3);
matrix->setName("foo"); matrix->setName("foo");
shared_ptr<XdmfArray> rowPointer = matrix->getRowPointer(); shared_ptr<XdmfArray> rowPointer = matrix->getRowPointer();
shared_ptr<XdmfArray> columnIndex = matrix->getColumnIndex(); shared_ptr<XdmfArray> columnIndex = matrix->getColumnIndex();
shared_ptr<XdmfArray> values = matrix->getValues(); shared_ptr<XdmfArray> values = matrix->getValues();
rowPointer->insert<unsigned int>(0, 0);
rowPointer->insert<unsigned int>(1, 0); rowPointer->insert<unsigned int>(0, 1);
rowPointer->insert<unsigned int>(1, 1);
rowPointer->insert<unsigned int>(2, 2); rowPointer->insert<unsigned int>(2, 2);
rowPointer->insert<unsigned int>(3, 3); rowPointer->insert<unsigned int>(3, 3);
columnIndex->pushBack<unsigned int>(1); columnIndex->pushBack<unsigned int>(1);
......
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include <vector>
#include <map>
shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values);
shared_ptr<XdmfArray> prepend(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2);
int main(int, char **) int main(int, char **)
{ {
...@@ -10,13 +16,13 @@ int main(int, char **) ...@@ -10,13 +16,13 @@ int main(int, char **)
int newSize = 10; int newSize = 10;
exampleArray->reserve(newSize); exampleArray->reserve(newSize);
shared_ptr<std::vector<int> > exampleVector = exampleArray->initialize(newSize); shared_ptr<std::vector<int> > exampleVector = exampleArray->initialize<int>(newSize);
exampleArray->initialize(XdmfArrayType::Int32(), newSize); exampleArray->initialize(XdmfArrayType::Int32(), newSize);
std::vector<unsigned int> newSizeVector; std::vector<unsigned int> newSizeVector;
newSizeVector.push_back(4); newSizeVector.push_back(4);
newSizeVector.push_back(5); newSizeVector.push_back(5);
shared_ptr<std::vector<int> > exampleVector = exampleArray->initialize(newSizeVector); shared_ptr<std::vector<int> > exampleVectorFromVector = exampleArray->initialize<int>(newSizeVector);
exampleArray->initialize(XdmfArrayType::Int32(), newSize); exampleArray->initialize(XdmfArrayType::Int32(), newSize);
if (exampleArray->isInitialized()) if (exampleArray->isInitialized())
...@@ -33,9 +39,9 @@ int main(int, char **) ...@@ -33,9 +39,9 @@ int main(int, char **)
shared_ptr<XdmfArray> tempArray = XdmfArray::New(); shared_ptr<XdmfArray> tempArray = XdmfArray::New();
exampleArray->insert(0, initArray, 10, 1, 1); exampleArray->insert(0, initArray, 10, 1, 1);
//exampleArray now contains {0,1,2,3,4,5,6,7,8,9} //exampleArray now contains {0,1,2,3,4,5,6,7,8,9}
exampleArray->insert(0, initArray, 0, 5, 2, 1); exampleArray->insert(0, initArray, 5, 2, 1);
//exampleArray now contains {0,1,1,3,2,5,3,7,4,9} //exampleArray now contains {0,1,1,3,2,5,3,7,4,9}
examleArray->insert(0, initArray, 0, 5, 1, 2); exampleArray->insert(0, initArray, 5, 1, 2);
//exampleArray now contains {0,2,4,6,8,5,3,7,4,9} //exampleArray now contains {0,2,4,6,8,5,3,7,4,9}
tempArray->insert(0, exampleArray, 0, 10, 1, 1); tempArray->insert(0, exampleArray, 0, 10, 1, 1);
//tempArray now contains {0,1,2,3,4,5,6,7,8,9} //tempArray now contains {0,1,2,3,4,5,6,7,8,9}
...@@ -49,7 +55,7 @@ int main(int, char **) ...@@ -49,7 +55,7 @@ int main(int, char **)
exampleArray->pushBack(newValue); exampleArray->pushBack(newValue);
exampleArray->insert(newIndex, newValue);//the value of 3.5 is inserted at index 0 exampleArray->insert(newIndex, newValue);//the value of 3.5 is inserted at index 0
exampleArray->setValuesInternal(&initArray, 10, 1); exampleArray->setValuesInternal(initArray, 10, 1);
std::vector<int> initVector; std::vector<int> initVector;
initVector.push_back(1); initVector.push_back(1);
...@@ -59,7 +65,7 @@ int main(int, char **) ...@@ -59,7 +65,7 @@ int main(int, char **)
initVector.push_back(5); initVector.push_back(5);
exampleArray->setValuesInternal(initVector, 1); exampleArray->setValuesInternal(initVector, 1);
shared_ptr<std::vector> storeVector(&initVector); shared_ptr<std::vector<int> > storeVector(&initVector);
exampleArray->setValuesInternal(storeVector); exampleArray->setValuesInternal(storeVector);
//The vector contains {1,2,3,4,5} and the XdmfArray contains {0,1,2,3,4,5,6,7,8,9} //The vector contains {1,2,3,4,5} and the XdmfArray contains {0,1,2,3,4,5,6,7,8,9}
...@@ -84,18 +90,18 @@ int main(int, char **) ...@@ -84,18 +90,18 @@ int main(int, char **)
exampleArray->getValues(0, readArray, 5, 2, 1); exampleArray->getValues(0, readArray, 5, 2, 1);
//readArray now contains {0, 2, 4, 6, 8, 15, 3, 17, 4, 19} //readArray now contains {0, 2, 4, 6, 8, 15, 3, 17, 4, 19}
newSize = 20 newSize = 20;
int baseValue = 1 int baseValue = 1;
exampleArray->resize(newSize, baseValue) exampleArray->resize(newSize, baseValue);
//exampleArray now contains {0,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1} //exampleArray now contains {0,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1}
newSize = 5; newSize = 5;
exampleArray->resize(newSize, baseValue) exampleArray->resize(newSize, baseValue);
//exampleArray now contains {0,1,2,3,4} //exampleArray now contains {0,1,2,3,4}
exampleArray->resize(newSizeVector, baseValue) exampleArray->resize(newSizeVector, baseValue);
//exampleArray now contains {0,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1} //exampleArray now contains {0,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1}
newSizeVector[0] = 1; newSizeVector[0] = 1;
exampleArray->resize(newSizeVector, baseValue) exampleArray->resize(newSizeVector, baseValue);
//exampleArray now contains {0,1,2,3,4} //exampleArray now contains {0,1,2,3,4}
...@@ -113,18 +119,18 @@ int main(int, char **) ...@@ -113,18 +119,18 @@ int main(int, char **)
unsigned int exampleSize = exampleArray->getSize(); unsigned int exampleSize = exampleArray->getSize();
shared_ptr<XdmfHeavyDataController> exampleController = exampleArray->getHeavyDataController(); shared_ptr<XdmfHeavyDataController> exampleController = exampleArray->getHeavyDataController();
newArray = XdmfArray.New() shared_ptr<XdmfArray> newArray = XdmfArray::New();
newArray.setHeaveyDataController(exampleController) newArray->setHeavyDataController(exampleController);
shared_ptr<const XdmfHeavyDataController> exampleControllerConst = exampleArray->getHeavyDataController(); shared_ptr<const XdmfHeavyDataController> exampleControllerConst = exampleArray->getHeavyDataController();
//if exampleArray contains [0, 1, 2, 3, 4, 5, 6, 7] //if exampleArray contains [0, 1, 2, 3, 4, 5, 6, 7]
int exampleValue = exampleArray->getValue(4); int exampleValue = exampleArray->getValue<int>(4);
//exampleValue now has the value of what was stored at index 4, which in this case is 4 //exampleValue now has the value of what was stored at index 4, which in this case is 4
std::string exampleValueString = exampleArray->getValuesString(); std::string exampleValueString = exampleArray->getValuesString();
//assuming that exampleArray is filled with ints //assuming that exampleArray is filled with ints
shared_ptr<std::vector<int> > exampleInternalVector = exampleArray->getValuesInternal(); shared_ptr<std::vector<int> > exampleInternalVector = exampleArray->getValuesInternal<int>();
void * exampleInternalPointer = exampleArray->getValuesInternal(); void * exampleInternalPointer = exampleArray->getValuesInternal();
const void * exampleInternalPointerConst = exampleArray->getValuesInternal(); const void * exampleInternalPointerConst = exampleArray->getValuesInternal();
...@@ -136,5 +142,83 @@ int main(int, char **) ...@@ -136,5 +142,83 @@ int main(int, char **)
exampleArray->release(); exampleArray->release();
std::string exampleOperations = XdmfArray::getSupportedOperations();
std::vector<std::string> exampleFunctions = XdmfArray::getSupportedFunctions();
std::string exampleVariableChars = XdmfArray::getValidVariableChars();
std::string exampleDigitChars = XdmfArray::getValidDigitChars();
int examplePriority = XdmfArray::getOperationPriority('|');
shared_ptr<XdmfArray> valueArray1 = XdmfArray::New();
valueArray1->pushBack(1);
valueArray1->pushBack(2);
valueArray1->pushBack(3);
valueArray1->pushBack(4);
shared_ptr<XdmfArray> valueArray2 = XdmfArray::New();
valueArray2->pushBack(9);
valueArray2->pushBack(8);
valueArray2->pushBack(7);
valueArray2->pushBack(6);
std::vector<shared_ptr<XdmfArray> > valueVector;
valueVector.push_back(valueArray1);
valueVector.push_back(valueArray2);
shared_ptr<XdmfArray> answerArray;
answerArray = XdmfArray::sum(valueVector);
answerArray = XdmfArray::ave(valueVector);
answerArray = XdmfArray::chunk(valueArray1, valueArray2);
answerArray = XdmfArray::interlace(valueArray1, valueArray2);
int exampleNumOperations = XdmfArray::addOperation('@', (shared_ptr<XdmfArray>(*)(shared_ptr<XdmfArray>, shared_ptr<XdmfArray>))prepend, 2);
answerArray = XdmfArray::evaluateOperation(valueArray1, valueArray2, '@');
int exampleNumFunctions = XdmfArray::addFunction("MAX", (shared_ptr<XdmfArray>(*)(std::vector<shared_ptr<XdmfArray> >))maximum);
answerArray = XdmfArray::evaluateFunction(valueVector, "MAX");
std::map<std::string, shared_ptr<XdmfArray> > valueMap;
valueMap["A"] = valueArray1;
valueMap["B"] = valueArray2;
std::string parsedExpression = "MAX(A,B)@(A#B)";
answerArray = XdmfArray::evaluateExpression(parsedExpression, valueMap);
return 0; return 0;
} }
shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values)
{
if (values[0]->getArrayType() == XdmfArrayType::String())
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->pushBack(values[0]->getValue<std::string>(0));
return returnArray;
}
else
{
double maxVal = values[0]->getValue<double>(0);
for (int i = 0; i < values.size(); i++)
{
for (int j = 0; j < values[i]->getSize(); j++)
{
if (maxVal < values[i]->getValue<double>(j))
{
maxVal = values[i]->getValue<double>(j);
}
}
}
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->pushBack(maxVal);
return returnArray;
}
}
shared_ptr<XdmfArray> prepend(shared_ptr<XdmfArray> val1, shared_ptr<XdmfArray> val2)
{
//joins into new array and returns it
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->insert(0, val2, 0, val2->getSize(), 1, 1);
returnArray->insert(val2->getSize(), val1, 0, val1->getSize(), 1, 1);
return returnArray;
}
from Xdmf import * from Xdmf import *
from numpy import * from numpy import *
def maximum(values):
values = ArrayVector(values)#need to cast to the right data type
if values[0].getArrayType() == XdmfArrayType.String():
returnArray = XdmfArray.New()
returnArray.pushBackAsString(values[0].getValueAsString(0))
return returnArray;
else:
maxVal = values[0].getValueAsFloat64(0)
for i in range (0, values.size()):
for j in range (0, values[i].getSize()):
if maxVal < values[i].getValueAsFloat64(j):
maxVal = values[i].getValueAsFloat64(j)
returnArray = XdmfArray.New()
returnArray.pushBackAsFloat64(maxVal)
return returnArray
def prepend(val1, val2):
val1 = XdmfArray.XdmfArrayPtr(val1)#need to cast to the right data type
val2 = XdmfArray.XdmfArrayPtr(val2)#had to write a custom casting method to integrate it properly
returnArray = XdmfArray.New()
returnArray.insert(0, val2, 0, val2.getSize())
returnArray.insert(val2.getSize(), val1, 0, val1.getSize())
return returnArray
if __name__ == "__main__": if __name__ == "__main__":
exampleArray = XdmfArray.New() exampleArray = XdmfArray.New()
...@@ -130,3 +154,46 @@ if __name__ == "__main__": ...@@ -130,3 +154,46 @@ if __name__ == "__main__":
newArray.setHeavyDataController(exampleController) newArray.setHeavyDataController(exampleController)
exampleArray.release() exampleArray.release()
exampleOperations = XdmfArray.getSupportedOperations()
exampleFunctions = XdmfArray.getSupportedFunctions()
exampleVariableChars = XdmfArray.getValidVariableChars()
exampleDigitChars = XdmfArray.getValidDigitChars()
examplePriority = XdmfArray.getOperationPriority('|')
valueArray1 = XdmfArray.New()
valueArray1.pushBackAsInt32(1)
valueArray1.pushBackAsInt32(2)
valueArray1.pushBackAsInt32(3)
valueArray1.pushBackAsInt32(4)
valueArray2 = XdmfArray.New()
valueArray2.pushBackAsInt32(9)
valueArray2.pushBackAsInt32(8)
valueArray2.pushBackAsInt32(7)
valueArray2.pushBackAsInt32(6)
valueVector = ArrayVector()
valueVector.push_back(valueArray1)
valueVector.push_back(valueArray2)
answerArray = XdmfArray.sum(valueVector)
answerArray = XdmfArray.ave(valueVector)
answerArray = XdmfArray.chunk(valueArray1, valueArray2)
answerArray = XdmfArray.interlace(valueArray1, valueArray2)
exampleNumOperations = XdmfArray.addOperation('@', prepend, 2)
answerArray = XdmfArray.evaluateOperation(valueArray1, valueArray2, '@')
exampleNumFunctions = XdmfArray.addFunction("MAX", maximum)
answerArray = XdmfArray.evaluateFunction(valueVector, "MAX")
valueMap = ArrayMap()
valueMap["A"] = valueArray1
valueMap["B"] = valueArray2
parsedExpression = "MAX(A,B)@(A#B)"
answerArray = XdmfArray.evaluateExpression(parsedExpression, valueMap)
...@@ -222,21 +222,28 @@ int main(int, char **) ...@@ -222,21 +222,28 @@ int main(int, char **)
exampleHeavyWriter->setFileSizeLimit(1); exampleHeavyWriter->setFileSizeLimit(1);
primaryDomain->accept(exampleHeavyWriter); primaryDomain->accept(exampleHeavyWriter);
printf("default mode\n");
exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Overwrite);//do this so that the data isn't in the hdf5 file twice. 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); primaryDomain->accept(exampleWriter);
exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append);
for (int i = 0; i <= 408; i++) printf("append mode\n");
for (int i = 0; i <= 797; i++)
{//overflow occurs at around 509 {//overflow occurs at around 509
primaryDomain->accept(exampleHeavyWriter); primaryDomain->accept(exampleHeavyWriter);
} }
exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Default); /*exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Default);
printf("default mode\n");
primaryDomain->accept(exampleHeavyWriter); primaryDomain->accept(exampleHeavyWriter);
printf("append mode\n");
exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append); exampleHeavyWriter->setMode(XdmfHeavyDataWriter::Append);
for (int i = 0; i<5; i++) for (int i = 0; i<500; i++)
{ {
primaryDomain->accept(exampleHeavyWriter); primaryDomain->accept(exampleHeavyWriter);
} }*/
primaryDomain->accept(exampleWriter); primaryDomain->accept(exampleWriter);
return 0; return 0;
} }
#include <iostream>
#include <stdlib.h>
#include <XdmfArray.hpp>
#include <XdmfReader.hpp>
int main(int, char **)
{
shared_ptr<XdmfReader> testReader = XdmfReader::New();
shared_ptr<XdmfArray> readArray = shared_dynamic_cast<XdmfArray>(testReader->read("arraydata.xmf"));
readArray->read();
printf("Array ocntains %s\n", readArray->getValuesString());
return 0;
}
#include <iostream>
#include <stdlib.h>
#include <XdmfArray.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfWriter.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHDF5Controller.hpp>
int main(int, char **)
{
shared_ptr<XdmfArray> writtenArray = XdmfArray::New();
for (int i = 0; i < 600000; i++)
{
writtenArray->pushBack(i);
}
std::vector<unsigned int> starts;
std::vector<unsigned int> strides;
std::vector<unsigned int> dimensions;
std::vector<unsigned int> dataspaces;
starts.push_back(0);
strides.push_back(6);
dimensions.push_back(100000);
dataspaces.push_back(600000);
shared_ptr<XdmfHDF5Controller> arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
starts[0] = 1;
arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
starts[0] = 2;
arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
starts[0] = 3;
arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
starts[0] = 4;
arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
starts[0] = 5;
arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
writtenArray->insert(arrayController);
shared_ptr<XdmfHDF5Writer> arrayHeavyWriter = XdmfHDF5Writer::New("arraydata.h5");
arrayHeavyWriter->setFileSizeLimit(1);
arrayHeavyWriter->setMode(XdmfHDF5Writer::Hyperslab);
shared_ptr<XdmfWriter> arrayWriter = XdmfWriter::New("arraydata.xmf", arrayHeavyWriter);
arrayWriter->setLightDataLimit(5);
writtenArray->accept(arrayWriter);
printf("%s\n\n", writtenArray->getValuesString());
writtenArray->release();
printf("after release\narray contains: %s\n", writtenArray->getValuesString());
writtenArray->read();
printf("%s\n\n", writtenArray->getValuesString());
return 0;
}
#include <iostream>
#include <stdlib.h>
#include <XdmfArray.hpp>
#include <XdmfDomain.hpp>
#include <XdmfUnstructuredGrid.hpp>
#include <XdmfRectilinearGrid.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfReader.hpp>
#include <XdmfWriter.hpp>
shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values);
int main(int, char **)
{
XdmfArray::addFunction("MAX", maximum);
shared_ptr<XdmfReader> testReader = XdmfReader::New();
/*
shared_ptr<XdmfArray> readArray = shared_dynamic_cast<XdmfArray>(testReader->read("array.xmf"));
printf("Array ocntains %s\n", readArray->getValuesString());
*/
shared_ptr<XdmfDomain> readDomain = shared_dynamic_cast<XdmfDomain>(testReader->read("array.xmf"));
printf("pulling out unstructured grid\n");
shared_ptr<XdmfRectilinearGrid> readGrid = readDomain->getRectilinearGrid(0);
//printf("pulling out geometry\n");
//shared_ptr<XdmfGeometry> readGeometry = readGrid->getGeometry();
printf("pulling out dimensions\n");
std::vector<shared_ptr<XdmfArray> > readDimensions = readGrid->getCoordinates();
printf("Geometry contains %s\n", readDimensions[0]->getValuesString());
shared_ptr<XdmfWriter> testWriter = XdmfWriter::New("arrayoutput.xmf");
readGrid->accept(testWriter);
//readArray->accept(testWriter);
return 0;
}
shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values)
{
if (values[0]->getArrayType() == XdmfArrayType::String())
{
shared_ptr<XdmfArray> returnArray = XdmfArray::New();
returnArray->pushBack(values[0]->getValue<std::string>(0));
return returnArray;
}
else
{
double maxVal = values[0]->getValue<double>(0);
for (int i = 0; i < values.size(); i++)
{
for (int j = 0; j < values[i]->getSize(); j++)
{
if (maxVal < values[i]->getValue<double>(j))
{
maxVal = values[i]->getValue<double>(j);
}
}
<