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

merging in from main branch

parents d8606853 6748b239
...@@ -85,7 +85,8 @@ public: ...@@ -85,7 +85,8 @@ public:
mArray->mArray); mArray->mArray);
} }
private: private:
XdmfArray * const mArray; XdmfArray * const mArray;
}; };
...@@ -390,10 +391,10 @@ public: ...@@ -390,10 +391,10 @@ public:
void void
operator()(const shared_ptr<std::vector<T> > & array) const operator()(const shared_ptr<std::vector<T> > & array) const
{ {
unsigned int size = mStartIndex + mNumValues; unsigned int size =
if(mArrayStride > 1) { mStartIndex + (mNumValues) * mArrayStride + 1;
size = mStartIndex + (mNumValues - 1) * mArrayStride + 1;
}
if(array->size() < size) { if(array->size() < size) {
array->resize(size); array->resize(size);
mDimensions.clear(); mDimensions.clear();
...@@ -463,6 +464,34 @@ private: ...@@ -463,6 +464,34 @@ private:
XdmfArray * const mArray; 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> { class XdmfArray::Reserve : public boost::static_visitor<void> {
public: public:
...@@ -517,7 +546,7 @@ public: ...@@ -517,7 +546,7 @@ public:
for (int i = 0; i < mArray->mHeavyDataControllers.size(); i++) { for (int i = 0; i < mArray->mHeavyDataControllers.size(); i++) {
total += mArray->mHeavyDataControllers[i]->getSize(); total += mArray->mHeavyDataControllers[i]->getSize();
} }
return total;//modify this to compile all controllers return total;
} }
return 0; return 0;
} }
...@@ -1452,7 +1481,7 @@ XdmfArray::insert(const unsigned int startIndex, ...@@ -1452,7 +1481,7 @@ XdmfArray::insert(const unsigned int startIndex,
} }
//TODO
void void
XdmfArray::insert(const std::vector<unsigned int> startIndex, XdmfArray::insert(const std::vector<unsigned int> startIndex,
const shared_ptr<const XdmfArray> values, const shared_ptr<const XdmfArray> values,
...@@ -1591,13 +1620,8 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex, ...@@ -1591,13 +1620,8 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex,
bool bool
XdmfArray::isInitialized() const XdmfArray::isInitialized() const
{ {
try { return boost::apply_visitor(IsInitialized(),
boost::get<boost::blank>(mArray); mArray);
return false;
}
catch(const boost::bad_get & exception) {
}
return true;
} }
void void
......
...@@ -263,10 +263,8 @@ public: ...@@ -263,10 +263,8 @@ public:
void void
operator()(shared_ptr<std::vector<std::string> > & array) const operator()(shared_ptr<std::vector<std::string> > & array) const
{ {
unsigned int size = mStartIndex + mNumValues; const unsigned int size =
if(mArrayStride > 1) { mStartIndex + (mNumValues - 1) * mArrayStride + 1;
size = mStartIndex + mNumValues * mArrayStride - 1;
}
if(array->size() < size) { if(array->size() < size) {
array->resize(size); array->resize(size);
mDimensions.clear(); mDimensions.clear();
...@@ -282,10 +280,8 @@ public: ...@@ -282,10 +280,8 @@ public:
void void
operator()(shared_ptr<std::vector<U> > & array) const operator()(shared_ptr<std::vector<U> > & array) const
{ {
unsigned int size = mStartIndex + mNumValues; const unsigned int size =
if(mArrayStride > 1) { mStartIndex + (mNumValues - 1) * mArrayStride + 1;
size = mStartIndex + mNumValues * mArrayStride - 1;
}
if(array->size() < size) { if(array->size() < size) {
array->resize(size); array->resize(size);
mDimensions.clear(); mDimensions.clear();
...@@ -348,10 +344,8 @@ public: ...@@ -348,10 +344,8 @@ public:
void void
operator()(shared_ptr<std::vector<std::string> > & array) const operator()(shared_ptr<std::vector<std::string> > & array) const
{ {
unsigned int size = mStartIndex + mNumValues; const unsigned int size =
if(mArrayStride > 1) { mStartIndex + (mNumValues - 1) * mArrayStride + 1;
size = mStartIndex + mNumValues * mArrayStride - 1;
}
if(array->size() < size) { if(array->size() < size) {
array->resize(size); array->resize(size);
mDimensions.clear(); mDimensions.clear();
...@@ -366,10 +360,8 @@ public: ...@@ -366,10 +360,8 @@ public:
void void
operator()(shared_ptr<std::vector<U> > & array) const operator()(shared_ptr<std::vector<U> > & array) const
{ {
unsigned int size = mStartIndex + mNumValues; const unsigned int size =
if(mArrayStride > 1) { mStartIndex + (mNumValues - 1) * mArrayStride + 1;
size = mStartIndex + mNumValues * mArrayStride - 1;
}
if(array->size() < size) { if(array->size() < size) {
array->resize(size); array->resize(size);
mDimensions.clear(); mDimensions.clear();
......
...@@ -236,6 +236,12 @@ XdmfWriter::setDocumentTitle(std::string title) ...@@ -236,6 +236,12 @@ XdmfWriter::setDocumentTitle(std::string title)
mImpl->mDocumentTitle = title; mImpl->mDocumentTitle = title;
} }
void
XdmfWriter::setHeavyDataWriter(shared_ptr<XdmfHeavyDataWriter> heavyDataWriter)
{
mImpl->mHeavyDataWriter = heavyDataWriter;
}
void void
XdmfWriter::setLightDataLimit(const unsigned int numValues) XdmfWriter::setLightDataLimit(const unsigned int numValues)
{ {
......
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include <iostream>
int main(int, char **) 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> insertArray1 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray2 = XdmfArray::New(); shared_ptr<XdmfArray> insertArray2 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray3 = XdmfArray::New(); shared_ptr<XdmfArray> insertArray3 = XdmfArray::New();
shared_ptr<XdmfArray> insertArray4 = XdmfArray::New(); shared_ptr<XdmfArray> insertArray4 = XdmfArray::New();
for (int i = 0; i< 10; i++) insertArray1->resize<int>(10, 1);
{ insertArray2->resize<int>(10, 2);
insertArray1->pushBack(1); insertArray3->resize<int>(10, 3);
} insertArray4->resize<int>(10, 4);
for (int i = 0; i< 10; i++) array1->insert(0, insertArray1, 0, 10, 4, 1);
{ array1->insert(1, insertArray2, 0, 10, 4, 1);
insertArray2->pushBack(2); array1->insert(2, insertArray3, 0, 10, 4, 1);
} array1->insert(3, insertArray4, 0, 10, 4, 1);
for (int i = 0; i< 10; i++) 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 "
insertArray3->pushBack(3); "3 4 1 2 3 4") == 0);
}
// Insert from vector
for (int i = 0; i< 10; i++) std::vector<int> insertArray5(10, 1);
{ std::vector<int> insertArray6(10, 2);
insertArray4->pushBack(4); std::vector<int> insertArray7(10, 3);
} std::vector<int> insertArray8(10, 4);
resultArray->insert(0, insertArray1, 0, 10, 4, 1); shared_ptr<XdmfArray> array2 = XdmfArray::New();
resultArray->insert(1, insertArray2, 0, 10, 4, 1);
resultArray->insert(2, insertArray3, 0, 10, 4, 1); array2->insert(0, &(insertArray5[0]), 10, 4, 1);
resultArray->insert(3, insertArray4, 0, 10, 4, 1); array2->insert(1, &(insertArray6[0]), 10, 4, 1);
array2->insert(2, &(insertArray7[0]), 10, 4, 1);
printf("result array contains:\n%s\n", resultArray->getValuesString()); array2->insert(3, &(insertArray8[0]), 10, 4, 1);
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(array2->getValuesString().compare("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 "
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); "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; return 0;
} }
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "XdmfGridCollectionType.hpp" #include "XdmfGridCollectionType.hpp"
#include "XdmfInformation.hpp" #include "XdmfInformation.hpp"
#include "XdmfReader.hpp" #include "XdmfReader.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfTime.hpp" #include "XdmfTime.hpp"
#include "XdmfTopology.hpp" #include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp" #include "XdmfTopologyType.hpp"
...@@ -723,12 +724,6 @@ XdmfFortran::setTopology(const int topologyType, ...@@ -723,12 +724,6 @@ XdmfFortran::setTopology(const int topologyType,
return id; return id;
} }
int int
XdmfFortran::retrieveNumDomainGridCollections() XdmfFortran::retrieveNumDomainGridCollections()
{ {
...@@ -1377,7 +1372,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name) ...@@ -1377,7 +1372,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name)
shared_ptr<XdmfCurvilinearGrid> grid = mDomain->getCurvilinearGrid(index); shared_ptr<XdmfCurvilinearGrid> grid = mDomain->getCurvilinearGrid(index);
grid->setName(name); grid->setName(name);
grid->setGeometry(mGeometry); grid->setGeometry(mGeometry);
grid->setDimensions(mDimensions); grid->setDimensions(mDimensions);
...@@ -1385,7 +1379,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name) ...@@ -1385,7 +1379,6 @@ XdmfFortran::replaceDomainGrid(int gridType, int index, char * name)
{ {
grid->removeAttribute(0); grid->removeAttribute(0);
} }
for(std::vector<shared_ptr<XdmfAttribute> >::const_iterator iter = for(std::vector<shared_ptr<XdmfAttribute> >::const_iterator iter =
mAttributes.begin(); mAttributes.begin();
iter != mAttributes.end(); iter != mAttributes.end();
......
...@@ -44,6 +44,7 @@ class XdmfHeavyDataWriter; ...@@ -44,6 +44,7 @@ class XdmfHeavyDataWriter;
//Includes //Includes
#include <stack> #include <stack>
#include <map>
#include <vector> #include <vector>
#include "XdmfUtils.hpp" #include "XdmfUtils.hpp"
#include "XdmfSharedPtr.hpp" #include "XdmfSharedPtr.hpp"
...@@ -532,6 +533,8 @@ public: ...@@ -532,6 +533,8 @@ public:
* @param numValues number of connectivity values to copy. * @param numValues number of connectivity values to copy.
* @param arrayType type of connectivity values. * @param arrayType type of connectivity values.
* @param connectivityValues array 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. * @return int providing id to fortran if reusing.
*/ */
...@@ -539,11 +542,15 @@ public: ...@@ -539,11 +542,15 @@ public:
const unsigned int numValues, const unsigned int numValues,
const int arrayType, const int arrayType,
const void * const connectivityValues, const void * const connectivityValues,
<<<<<<< HEAD
const int numNodes); const int numNodes);
=======
const int polyNodesPerElement = 0);
>>>>>>> 6748b23947ebc47742c96d7e3a56242511c67d73
/** /**
* Returns the number of grid collections currently * Returns the number of grid collections currently
......
...@@ -134,11 +134,28 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition, ...@@ -134,11 +134,28 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
XdmfError::message(XdmfError::FATAL, XdmfError::message(XdmfError::FATAL,
"Current graph's row pointer or column index is null " "Current graph's row pointer or column index is null "
"in XdmfPartitioner::partition"); "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> rowPointer = graphToPartition->getRowPointer();
shared_ptr<XdmfArray> columnIndex = graphToPartition->getColumnIndex(); shared_ptr<XdmfArray> columnIndex = graphToPartition->getColumnIndex();
idx_t numberVertices = graphToPartition->getNumberNodes();
idx_t numberConstraints = 1; idx_t numberConstraints = 1;
bool releaseRowPointer = false; bool releaseRowPointer = false;
...@@ -239,16 +256,9 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition, ...@@ -239,16 +256,9 @@ XdmfPartitioner::partition(const shared_ptr<XdmfGraph> graphToPartition,
delete [] xadj; delete [] xadj;
delete [] adjncy; 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, attribute->insert(0,
part, part,
numberVertices); numberVertices);
graphToPartition->insert(attribute);
delete [] part; 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