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

changes to fortran for polylines and file splitting works for single dimensional arrays

parent b8e830bf
......@@ -392,7 +392,7 @@ public:
{
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1) {
size = mStartIndex + mNumValues * mArrayStride - 1;
size = mStartIndex + mNumValues * mArrayStride - (mStartIndex%mArrayStride);
}
if(array->size() < size) {
array->resize(size);
......@@ -1757,12 +1757,21 @@ void
XdmfArray::read()
{
if(mHeavyDataControllers.size() > 0) {
mHeavyDataControllers[0]->read(this);
for (int i = 1; i < mHeavyDataControllers.size(); i++)
this->release();
for (int i = 0; i < mHeavyDataControllers.size(); i++)
{
shared_ptr<XdmfArray> tempArray = XdmfArray::New();
mHeavyDataControllers[i]->read(tempArray.get());
this->insert(this->getSize(), tempArray, 0, tempArray->getSize());
unsigned int startsTotal = 0;
unsigned int strideTotal = 1;
unsigned int dimTotal = 1;
for (int j = 0; j < mHeavyDataControllers[i]->getDimensions().size(); j++) {
strideTotal *= mHeavyDataControllers[i]->getStride()[j];
startsTotal += dimTotal * mHeavyDataControllers[i]->getStart()[j];
dimTotal *= mHeavyDataControllers[i]->getDimensions()[j];
}
this->insert(mHeavyDataControllers[i]->getArrayOffset() + startsTotal, tempArray, 0, dimTotal, strideTotal, 1);
}
}
}
......
This diff is collapsed.
......@@ -47,9 +47,16 @@ int main(int, char **)
writtenArray->accept(arrayWriter);
writtenArray->release();
printf("after release\narray contains: %s\n", writtenArray->getValuesString());
writtenArray->read();
printf("%s\n\n", writtenArray->getValuesString());
//printf("%s\n", writtenArray->getValuesString());
printf("array size = %d\n", writtenArray->getSize());
for (int i = 0; i < writtenArray->getSize(); i++)
{
if (i != writtenArray->getValue<int>(i))
{
printf("%d doesn't match %d\n", i, writtenArray->getValue<int>(i));
}
}
return 0;
}
......@@ -5890,6 +5890,7 @@ XdmfFortran::write(const char * const xmlFilePath, const int datalimit, const bo
shared_ptr<XdmfWriter> writer = XdmfWriter::New(xmlFilePath);
writer->setLightDataLimit(datalimit);
writer->getHeavyDataWriter()->setReleaseData(release);
shared_dynamic_cast<XdmfHDF5Writer>(writer->getHeavyDataWriter())->setFileSizeLimit(1);
mDomain->accept(writer);
}
......@@ -5908,6 +5909,26 @@ XdmfFortran::read(const char * const xmlFilePath)
mDomain = shared_dynamic_cast<XdmfDomain>(reader->read( xmlFilePath ));
}
//temporary fix, hopefully
int
XdmfFortran::setTopologyPolyline(const unsigned int nodesPerElement,
const unsigned int numValues,
const int arrayType,
const void * const connectivityValues)
{
mTopology = XdmfTopology::New();
mTopology->setType(XdmfTopologyType::Polyline(nodesPerElement));
// insert connectivity values into array
writeToArray(mTopology,
numValues,
arrayType,
connectivityValues);
const int id = mPreviousTopologies.size();
mPreviousTopologies.push_back(mTopology);
return id;
}
//
// C++ will mangle the name based on the argument list. This tells the
// compiler not to mangle the name so we can call it from 'C' (but
......@@ -6042,15 +6063,14 @@ extern "C"
int * topologyType,
int * numValues,
int * arrayType,
void * connectivityValues,
int * numVals)
void * connectivityValues)
{
XdmfFortran * xdmfFortran = reinterpret_cast<XdmfFortran *>(*pointer);
return xdmfFortran->setTopology(*topologyType,
*numValues,
*arrayType,
connectivityValues,
*numVals);
0);
}
......@@ -7229,5 +7249,19 @@ extern "C"
xdmfFortran->read( xmlFilePath );
}
}
int
XdmfSetTopologyPolyline(long * pointer,
int * nodesPerElement,
int * numValues,
int * arrayType,
void * connectivityValues)
{
XdmfFortran * xdmfFortran = reinterpret_cast<XdmfFortran *>(*pointer);
return xdmfFortran->setTopologyPolyline(*nodesPerElement,
*numValues,
*arrayType,
connectivityValues);
}
}
......@@ -164,6 +164,8 @@ class XdmfUnstructuredGrid;
#define XdmfWriteHDF5 xdmfwritehdf5_
#define XdmfSetTopologyPolyline xdmfsettopologypolyline_
#define XdmfRetrieveNumDomainGridCollections xdmfretrievenumdomaingridcollections_
#define XdmfRetrieveNumGridCollectionGridCollections xdmfretrievenumgridcollectiongridcollections_
......@@ -2196,6 +2198,23 @@ public:
void read(const char * const xmlFilePath);
/**
* Set the topology (connectivity data) for a polyline that will be
* added to the next grid.
*
* @param nodesPerElement number of nodes in the polyline.
* @param numValues number of connectivity values to copy.
* @param arrayType type of connectivity values.
* @param connectivityValues array of connectivity values.
*
* @return int providing id to fortran if reusing.
*/
int setTopologyPolyline(const unsigned int nodesPerElement,
const unsigned int numValues,
const int arrayType,
const void * const connectivityValues);
private:
shared_ptr<XdmfDomain> mDomain;
......
......@@ -165,7 +165,7 @@ PROGRAM XdmfFortranExample
CALL XDMFADDGRID(obj, 'Identical'//CHAR(0), XDMF_GRID_TYPE_UNSTRUCTURED)
CALL XDMFCLOSEGRIDCOLLECTION(obj)
!! CALL XDMFWRITEHDF5(obj, 'my_output.h5'//CHAR(0))
CALL XDMFWRITE(obj, filename)
CALL XDMFWRITE(obj, filename, 10, .TRUE.)
CALL XDMFCLOSE(obj)
......
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