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

wrapped function and subset into superclass XdmfArrayReference to allow for...

wrapped function and subset into superclass XdmfArrayReference to allow for easier implementation of new array references
parent 59106d95
...@@ -15,6 +15,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -15,6 +15,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
// XdmfCore Includes // XdmfCore Includes
#include <Xdmf.hpp> #include <Xdmf.hpp>
#include <XdmfArray.hpp> #include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp> #include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp> #include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp> #include <XdmfCoreReader.hpp>
...@@ -74,6 +75,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -74,6 +75,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
// XdmfCore Includes // XdmfCore Includes
#include <Xdmf.hpp> #include <Xdmf.hpp>
#include <XdmfArray.hpp> #include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp> #include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp> #include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp> #include <XdmfCoreReader.hpp>
......
...@@ -96,6 +96,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in ...@@ -96,6 +96,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
set(XdmfCoreSources set(XdmfCoreSources
XdmfArray XdmfArray
XdmfArrayReference
XdmfArrayType XdmfArrayType
XdmfCoreItemFactory XdmfCoreItemFactory
XdmfCoreReader XdmfCoreReader
......
...@@ -30,10 +30,9 @@ ...@@ -30,10 +30,9 @@
#include <math.h> #include <math.h>
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
#include "XdmfArrayType.hpp" #include "XdmfArrayType.hpp"
#include "XdmfFunction.hpp" #include "XdmfArrayReference.hpp"
#include "XdmfHDF5Controller.hpp" #include "XdmfHDF5Controller.hpp"
#include "XdmfHeavyDataController.hpp" #include "XdmfHeavyDataController.hpp"
#include "XdmfSubset.hpp"
#include "XdmfVisitor.hpp" #include "XdmfVisitor.hpp"
#include "XdmfError.hpp" #include "XdmfError.hpp"
...@@ -565,8 +564,7 @@ XdmfArray::XdmfArray() : ...@@ -565,8 +564,7 @@ XdmfArray::XdmfArray() :
mArrayPointerNumValues(0), mArrayPointerNumValues(0),
mName(""), mName(""),
mTmpReserveSize(0), mTmpReserveSize(0),
mReadMode(XdmfArray::Controller), mReadMode(XdmfArray::Controller)
mFunction(shared_ptr<XdmfFunction>())
{ {
} }
...@@ -657,12 +655,6 @@ XdmfArray::getDimensionsString() const ...@@ -657,12 +655,6 @@ XdmfArray::getDimensionsString() const
dimensions.size()); dimensions.size());
} }
shared_ptr<XdmfFunction>
XdmfArray::getFunction()
{
return mFunction;
}
std::map<std::string, std::string> std::map<std::string, std::string>
XdmfArray::getItemProperties() const XdmfArray::getItemProperties() const
{ {
...@@ -709,10 +701,10 @@ XdmfArray::getSize() const ...@@ -709,10 +701,10 @@ XdmfArray::getSize() const
mArray); mArray);
} }
shared_ptr<XdmfSubset> shared_ptr<XdmfArrayReference>
XdmfArray::getSubset() XdmfArray::getReference()
{ {
return mSubset; return mReference;
} }
void * void *
...@@ -1184,11 +1176,8 @@ XdmfArray::read() ...@@ -1184,11 +1176,8 @@ XdmfArray::read()
case XdmfArray::Controller: case XdmfArray::Controller:
this->readController(); this->readController();
break; break;
case XdmfArray::Function: case XdmfArray::Reference:
this->readFunction(); this->readReference();
break;
case XdmfArray::Subset:
this->readSubset();
break; break;
default: default:
try { try {
...@@ -1248,16 +1237,9 @@ XdmfArray::readController() ...@@ -1248,16 +1237,9 @@ XdmfArray::readController()
} }
void void
XdmfArray::readFunction() XdmfArray::readReference()
{ {
shared_ptr<XdmfArray> tempArray = mFunction->read(); shared_ptr<XdmfArray> tempArray = mReference->read();
this->swap(tempArray);
}
void
XdmfArray::readSubset()
{
shared_ptr<XdmfArray> tempArray = mSubset->read();
this->swap(tempArray); this->swap(tempArray);
} }
...@@ -1277,12 +1259,6 @@ XdmfArray::reserve(const unsigned int size) ...@@ -1277,12 +1259,6 @@ XdmfArray::reserve(const unsigned int size)
mArray); mArray);
} }
void
XdmfArray::setFunction(shared_ptr<XdmfFunction> newFunction)
{
mFunction = newFunction;
}
void void
XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newController) XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newController)
{ {
...@@ -1306,9 +1282,9 @@ XdmfArray::setReadMode(XdmfArray::ReadMode newStatus) ...@@ -1306,9 +1282,9 @@ XdmfArray::setReadMode(XdmfArray::ReadMode newStatus)
} }
void void
XdmfArray::setSubset(shared_ptr<XdmfSubset> newSubset) XdmfArray::setReference(shared_ptr<XdmfArrayReference> newReference)
{ {
mSubset = newSubset; mReference = newReference;
} }
void void
......
...@@ -31,8 +31,7 @@ class XdmfHeavyDataController; ...@@ -31,8 +31,7 @@ class XdmfHeavyDataController;
// Includes // Includes
#include "XdmfCore.hpp" #include "XdmfCore.hpp"
#include "XdmfItem.hpp" #include "XdmfItem.hpp"
#include "XdmfFunction.hpp" #include "XdmfArrayReference.hpp"
#include "XdmfSubset.hpp"
#include <boost/shared_array.hpp> #include <boost/shared_array.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
...@@ -103,8 +102,7 @@ public: ...@@ -103,8 +102,7 @@ public:
enum ReadMode { enum ReadMode {
Controller, Controller,
Function, Reference
Subset
}; };
/** /**
...@@ -287,36 +285,6 @@ public: ...@@ -287,36 +285,6 @@ public:
*/ */
std::string getDimensionsString() const; std::string getDimensionsString() const;
/**
* Gets the function that the array will fill from when readFunction is called
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#getFunction
* @until //#getFunction
*
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//getFunction
* @until #//getFunction
*
* @return The function associated with this array
*/
shared_ptr<XdmfFunction> getFunction();
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
std::string getItemTag() const; std::string getItemTag() const;
...@@ -352,7 +320,7 @@ public: ...@@ -352,7 +320,7 @@ public:
/** /**
* Gets the method this array will be written/read. * Gets the method this array will be written/read.
* Possible choices are: Controller, Function, and Subset * Possible choices are: Controller, and Reference
* *
* Example of use: * Example of use:
* *
...@@ -361,8 +329,8 @@ public: ...@@ -361,8 +329,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp * @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization * @skipline //#initialization
* @until //#initialization * @until //#initialization
* @skipline //#setFunction * @skipline //#setReference
* @until //#setFunction * @until //#setReference
* @skipline //#setReadMode * @skipline //#setReadMode
* @until //#setReadMode * @until //#setReadMode
* @skipline //#getReadMode * @skipline //#getReadMode
...@@ -374,8 +342,8 @@ public: ...@@ -374,8 +342,8 @@ public:
* @dontinclude XdmfExampleArray.py * @dontinclude XdmfExampleArray.py
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* @skipline #//setFunction * @skipline #//setReference
* @until #//setFunction * @until #//setReference
* @skipline #//setReadMode * @skipline #//setReadMode
* @until #//setReadMode * @until #//setReadMode
* @skipline #//getReadMode * @skipline #//getReadMode
...@@ -411,7 +379,7 @@ public: ...@@ -411,7 +379,7 @@ public:
unsigned int getSize() const; unsigned int getSize() const;
/** /**
* Gets the subset that the array will pull from when reading from a subset. * Gets the array reference that the array will pull from when reading from a reference.
* *
* Example of use: * Example of use:
* *
...@@ -420,24 +388,24 @@ public: ...@@ -420,24 +388,24 @@ public:
* @dontinclude ExampleXdmfArray.cpp * @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization * @skipline //#initialization
* @until //#initialization * @until //#initialization
* @skipline //#setSubset * @skipline //#setReference
* @until //#setSubset * @until //#setReference
* @skipline //#getSubset * @skipline //#getReference
* @until //#getSubset * @until //#getReference
* *
* Python * Python
* *
* @dontinclude XdmfExampleArray.py * @dontinclude XdmfExampleArray.py
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* @skipline #//setSubset * @skipline #//setReference
* @until #//setSubset * @until #//setReference
* @skipline #//getSubset * @skipline #//getReference
* @until #//getSubset * @until #//getReference
* *
* @return The subset being pulled from * @return The reference being pulled from
*/ */
shared_ptr<XdmfSubset> getSubset(); shared_ptr<XdmfArrayReference> getReference();
/** /**
* Get a copy of a single value stored in this array. * Get a copy of a single value stored in this array.
...@@ -1052,8 +1020,7 @@ public: ...@@ -1052,8 +1020,7 @@ public:
void readController(); void readController();
/** /**
* Accumulates the data via the function associated with the array and * Reads the data pointed to by the array reference into the array.
* swaps the data with the data currently in the array.
* *
* Example of use: * Example of use:
* *
...@@ -1062,50 +1029,22 @@ public: ...@@ -1062,50 +1029,22 @@ public:
* @dontinclude ExampleXdmfArray.cpp * @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization * @skipline //#initialization
* @until //#initialization * @until //#initialization
* @skipline //#setFunction * @skipline //#setReference
* @until //#setFunction * @until //#setReference
* @skipline //#readFunction * @skipline //#readReference
* @until //#readFunction * @until //#readReference
*
* *
* Python * Python
* *
* @dontinclude XdmfExampleArray.py * @dontinclude XdmfExampleArray.py
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* @skipline #//setFunction * @skipline #//setReference
* @until #//setFunction * @until #//setReference
* @skipline #//readFunction * @skipline #//readReference
* @until #//readFunction * @until #//readReference
*/ */
void readFunction(); void readReference();
/**
* Reads the data pointed to by the subset into the array.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setSubset
* @until //#setSubset
* @skipline //#readSubset
* @until //#readSubset
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setSubset
* @until #//setSubset
* @skipline #//readSubset
* @until #//readSubset
*/
void readSubset();
/** /**
* Release all data currently held in memory. * Release all data currently held in memory.
...@@ -1231,7 +1170,7 @@ public: ...@@ -1231,7 +1170,7 @@ public:
const T & value = 0); const T & value = 0);
/** /**
* Sets the function from which the Array will fill when readFunction is called. * Sets the array reference from which the Array will fill when readReference is called.
* *
* Example of use: * Example of use:
* *
...@@ -1240,8 +1179,8 @@ public: ...@@ -1240,8 +1179,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp * @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization * @skipline //#initialization
* @until //#initialization * @until //#initialization
* @skipline //#setFunction * @skipline //#setReference
* @until //#setFunction * @until //#setReference
* *
* *
* Python * Python
...@@ -1249,12 +1188,12 @@ public: ...@@ -1249,12 +1188,12 @@ public:
* @dontinclude XdmfExampleArray.py * @dontinclude XdmfExampleArray.py
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* @skipline #//setFunction * @skipline #//setReference
* @until #//setFunction * @until #//setReference
* *
* @param newFunction The function to be associated with this array * @param newReference The reference to be associated with this array
*/ */
void setFunction(shared_ptr<XdmfFunction> newFunction); void setReference(shared_ptr<XdmfArrayReference> newReference);
/** /**
* Set the name of the array. * Set the name of the array.
...@@ -1283,7 +1222,7 @@ public: ...@@ -1283,7 +1222,7 @@ public:
/** /**
* Sets the method this array will be written/read. * Sets the method this array will be written/read.
* Possible choices are: Controller, Function, and Subset * Possible choices are: Controller, and Reference
* *
* Example of use: * Example of use:
* *
...@@ -1292,8 +1231,8 @@ public: ...@@ -1292,8 +1231,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp * @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization * @skipline //#initialization
* @until //#initialization * @until //#initialization
* @skipline //#setFunction * @skipline //#setReference
* @until //#setFunction * @until //#setReference
* @skipline //#setReadMode * @skipline //#setReadMode
* @until //#setReadMode * @until //#setReadMode
* *
...@@ -1303,8 +1242,8 @@ public: ...@@ -1303,8 +1242,8 @@ public:
* @dontinclude XdmfExampleArray.py * @dontinclude XdmfExampleArray.py
* @skipline #//initialization * @skipline #//initialization
* @until #//initialization * @until #//initialization
* @skipline #//setFunction * @skipline #//setReference
* @until #//setFunction * @until #//setReference
* @skipline #//setReadMode * @skipline #//setReadMode
* @until #//setReadMode * @until #//setReadMode
* *
...@@ -1312,31 +1251,6 @@ public: ...@@ -1312,31 +1251,6 @@ public:
*/ */
void setReadMode(ReadMode newStatus = XdmfArray::Controller); void setReadMode(ReadMode newStatus = XdmfArray::Controller);
/**
* Sets the subset that the array will pull from when reading from a subset.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setSubset
* @until //#setSubset
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setSubset
* @until #//setSubset
*
* @param newSubset The subset to pull data from on read
*/
void setSubset(shared_ptr<XdmfSubset> newSubset);
/** /**
* Sets the values of this array to the values stored in the * Sets the values of this array to the values stored in the
* arrayPointer array. No copy is made. Modifications to the array * arrayPointer array. No copy is made. Modifications to the array
...@@ -1580,8 +1494,7 @@ private: ...@@ -1580,8 +1494,7 @@ private:
std::string mName; std::string mName;
unsigned int mTmpReserveSize; unsigned int mTmpReserveSize;
ReadMode mReadMode; ReadMode mReadMode;
shared_ptr<XdmfFunction> mFunction; shared_ptr<XdmfArrayReference> mReference;
shared_ptr<XdmfSubset> mSubset;
}; };
......
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfFunction.cpp */
/* */
/* Author: */
/* Andrew Burns */
/* andrew.j.burns2@us.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2013 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include "XdmfArrayReference.hpp"
#include <stack>
#include <math.h>
#include <boost/assign.hpp>
#include "XdmfError.hpp"
XdmfArrayReference::XdmfArrayReference():
mConstructedType("")
{
}
XdmfArrayReference::~XdmfArrayReference()
{
}
std::map<std::string, std::string>
XdmfArrayReference::getConstructedProperties()
{
return mConstructedProperties;
}
std::string
XdmfArrayReference::getConstructedType()
{
return mConstructedType;
}
void
XdmfArrayReference::setConstructedProperties(std::map<std::string, std::string> newProperties)
{
mConstructedProperties = newProperties;
}
void
XdmfArrayReference::setConstructedType(std::string newType)
{
mConstructedType = newType;
}