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

merging in from main branch

parents d8606853 6748b239
......@@ -85,7 +85,8 @@ public:
mArray->mArray);
}
private:
private:
XdmfArray * const mArray;
};
......@@ -390,10 +391,10 @@ public:
void
operator()(const shared_ptr<std::vector<T> > & array) const
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + (mNumValues - 1) * mArrayStride + 1;
}
unsigned int size =
mStartIndex + (mNumValues) * mArrayStride + 1;
if(array->size() < size) {
array->resize(size);
mDimensions.clear();
......@@ -463,6 +464,34 @@ private:
XdmfArray * const mArray;
};
class XdmfArray::IsInitialized : public boost::static_visitor<bool> {
public:
IsInitialized()
{
}
bool
operator()(const boost::blank &) const
{
return false;
}
template<typename T>
bool
operator()(const shared_ptr<std::vector<T> > &) const
{
return true;
}
template<typename T>
bool
operator()(const T &) const
{
return true;
}
};
class XdmfArray::Reserve : public boost::static_visitor<void> {
public:
......@@ -517,7 +546,7 @@ public:
for (int i = 0; i < mArray->mHeavyDataControllers.size(); i++) {
total += mArray->mHeavyDataControllers[i]->getSize();
}
return total;//modify this to compile all controllers
return total;
}
return 0;
}
......@@ -1452,7 +1481,7 @@ XdmfArray::insert(const unsigned int startIndex,
}
//TODO
void
XdmfArray::insert(const std::vector<unsigned int> startIndex,
const shared_ptr<const XdmfArray> values,
......@@ -1591,13 +1620,8 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex,
bool
XdmfArray::isInitialized() const
{
try {
boost::get<boost::blank>(mArray);
return false;
}
catch(const boost::bad_get & exception) {
}
return true;
return boost::apply_visitor(IsInitialized(),
mArray);
}
void
......
......@@ -263,10 +263,8 @@ public:
void
operator()(shared_ptr<std::vector<std::string> > & array) const
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + mNumValues * mArrayStride - 1;
}
const unsigned int size =
mStartIndex + (mNumValues - 1) * mArrayStride + 1;
if(array->size() < size) {
array->resize(size);
mDimensions.clear();
......@@ -282,10 +280,8 @@ public:
void
operator()(shared_ptr<std::vector<U> > & array) const
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + mNumValues * mArrayStride - 1;
}
const unsigned int size =
mStartIndex + (mNumValues - 1) * mArrayStride + 1;
if(array->size() < size) {
array->resize(size);
mDimensions.clear();
......@@ -348,10 +344,8 @@ public:
void
operator()(shared_ptr<std::vector<std::string> > & array) const
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + mNumValues * mArrayStride - 1;
}
const unsigned int size =
mStartIndex + (mNumValues - 1) * mArrayStride + 1;
if(array->size() < size) {
array->resize(size);
mDimensions.clear();
......@@ -366,10 +360,8 @@ public:
void
operator()(shared_ptr<std::vector<U> > & array) const
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + mNumValues * mArrayStride - 1;
}
const unsigned int size =
mStartIndex + (mNumValues - 1) * mArrayStride + 1;
if(array->size() < size) {
array->resize(size);
mDimensions.clear();
......
......@@ -236,6 +236,12 @@ XdmfWriter::setDocumentTitle(std::string title)
mImpl->mDocumentTitle = title;
}
void
XdmfWriter::setHeavyDataWriter(shared_ptr<XdmfHeavyDataWriter> heavyDataWriter)
{
mImpl->mHeavyDataWriter = heavyDataWriter;
}
void
XdmfWriter::setLightDataLimit(const unsigned int numValues)
{
......
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include <iostream>
int main(int, char **)
{
shared_ptr<XdmfArray> resultArray = XdmfArray::New();
// Insert from another array
shared_ptr<XdmfArray> array1 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray1 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray2 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray3 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray4 = XdmfArray::New();
for (int i = 0; i< 10; i++)
{
insertArray1->pushBack(1);
}
for (int i = 0; i< 10; i++)
{
insertArray2->pushBack(2);
}
for (int i = 0; i< 10; i++)
{
insertArray3->pushBack(3);
}
for (int i = 0; i< 10; i++)
{
insertArray4->pushBack(4);
}
resultArray->insert(0, insertArray1, 0, 10, 4, 1);
resultArray->insert(1, insertArray2, 0, 10, 4, 1);
resultArray->insert(2, insertArray3, 0, 10, 4, 1);
resultArray->insert(3, insertArray4, 0, 10, 4, 1);
printf("result array contains:\n%s\n", resultArray->getValuesString());
printf("result should be:\n%s\n", "1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4");
assert(resultArray->getValuesString().compare("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4") == 0);
insertArray1->resize<int>(10, 1);
insertArray2->resize<int>(10, 2);
insertArray3->resize<int>(10, 3);
insertArray4->resize<int>(10, 4);
array1->insert(0, insertArray1, 0, 10, 4, 1);
array1->insert(1, insertArray2, 0, 10, 4, 1);
array1->insert(2, insertArray3, 0, 10, 4, 1);
array1->insert(3, insertArray4, 0, 10, 4, 1);
assert(array1->getValuesString().compare("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 "
"2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 "
"3 4 1 2 3 4") == 0);
// Insert from vector
std::vector<int> insertArray5(10, 1);
std::vector<int> insertArray6(10, 2);
std::vector<int> insertArray7(10, 3);
std::vector<int> insertArray8(10, 4);
shared_ptr<XdmfArray> array2 = XdmfArray::New();
array2->insert(0, &(insertArray5[0]), 10, 4, 1);
array2->insert(1, &(insertArray6[0]), 10, 4, 1);
array2->insert(2, &(insertArray7[0]), 10, 4, 1);
array2->insert(3, &(insertArray8[0]), 10, 4, 1);
assert(array2->getValuesString().compare("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 "
"2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 "
"3 4 1 2 3 4") == 0);
// Insert from vector string
std::vector<std::string> insertArray9(10, "1");
std::vector<std::string> insertArray10(10, "2");
std::vector<std::string> insertArray11(10, "3");
std::vector<std::string> insertArray12(10, "4");
shared_ptr<XdmfArray> array3 = XdmfArray::New();
array3->insert(0, &(insertArray9[0]), 10, 4, 1);
array3->insert(1, &(insertArray10[0]), 10, 4, 1);
array3->insert(2, &(insertArray11[0]), 10, 4, 1);
array3->insert(3, &(insertArray12[0]), 10, 4, 1);
assert(array3->getValuesString().compare("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 "
"2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 "
"3 4 1 2 3 4") == 0);
return 0;
}
......@@ -40,6 +40,7 @@
#include "XdmfGridCollectionType.hpp"
#include "XdmfInformation.hpp"
#include "XdmfReader.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfTime.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
......@@ -723,12 +724,6 @@ XdmfFortran::setTopology(const int topologyType,
return id;
}
int
XdmfFortran::retrieveNumDomainGridCollections()
{
......@@ -1377,7 +1372,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name)
shared_ptr<XdmfCurvilinearGrid> grid = mDomain->getCurvilinearGrid(index);
grid->setName(name);
grid->setGeometry(mGeometry);
grid->setDimensions(mDimensions);
......@@ -1385,7 +1379,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name)
{
grid->removeAttribute(0);
}
for(std::vector<shared_ptr<XdmfAttribute> >::const_iterator iter =
mAttributes.begin();
iter != mAttributes.end();
......
......@@ -44,6 +44,7 @@ class XdmfHeavyDataWriter;
//Includes
#include <stack>
#include <map>
#include <vector>
#include "XdmfUtils.hpp"
#include "XdmfSharedPtr.hpp"
......@@ -532,6 +533,8 @@ public:
* @param numValues number of connectivity values to copy.
* @param arrayType type of connectivity values.
* @param connectivityValues array of connectivity values.
* @param polyNodesPerElement for polyline and polyvertex types the
* number of nodes per element.
*
* @return int providing id to fortran if reusing.
*/
......@@ -539,11 +542,15 @@ public:
const unsigned int numValues,
const int arrayType,
const void * const connectivityValues,
<<<<<<< HEAD
const int numNodes);
=======
const int polyNodesPerElement = 0);
>>>>>>> 6748b23947ebc47742c96d7e3a56242511c67d73
/**
* Returns the number of grid collections currently
......
......@@ -134,11 +134,28 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
XdmfError::message(XdmfError::FATAL,
"Current graph's row pointer or column index is null "
"in XdmfPartitioner::partition");
graphToPartition->removeAttribute("Partition");
shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
attribute->setName("Partition");
attribute->setCenter(XdmfAttributeCenter::Node());
attribute->setType(XdmfAttributeType::Scalar());
graphToPartition->insert(attribute);
idx_t numberVertices = graphToPartition->getNumberNodes();
// Handle case where we partition onto 1 processor. Metis for some reason
// handles this incorrectly (indices are 1 instead of zero even though
// correct numbering option is supplied to metis)
if(numberOfPartitions == 1) {
attribute->resize<idx_t>(numberVertices, 0);
return;
}
shared_ptr<XdmfArray> rowPointer = graphToPartition->getRowPointer();
shared_ptr<XdmfArray> columnIndex = graphToPartition->getColumnIndex();
idx_t numberVertices = graphToPartition->getNumberNodes();
idx_t numberConstraints = 1;
bool releaseRowPointer = false;
......@@ -239,16 +256,9 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
delete [] xadj;
delete [] adjncy;
graphToPartition->removeAttribute("Partition");
shared_ptr<XdmfAttribute> attribute = XdmfAttribute::New();
attribute->setName("Partition");
attribute->setCenter(XdmfAttributeCenter::Node());
attribute->setType(XdmfAttributeType::Scalar());
attribute->insert(0,
part,
numberVertices);
graphToPartition->insert(attribute);
delete [] part;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment