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
// XdmfCore Includes
#include <Xdmf.hpp>
#include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
......@@ -74,6 +75,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
// XdmfCore Includes
#include <Xdmf.hpp>
#include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfCoreItemFactory.hpp>
#include <XdmfCoreReader.hpp>
......
......@@ -96,6 +96,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
set(XdmfCoreSources
XdmfArray
XdmfArrayReference
XdmfArrayType
XdmfCoreItemFactory
XdmfCoreReader
......
......@@ -30,10 +30,9 @@
#include <math.h>
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include "XdmfFunction.hpp"
#include "XdmfArrayReference.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfHeavyDataController.hpp"
#include "XdmfSubset.hpp"
#include "XdmfVisitor.hpp"
#include "XdmfError.hpp"
......@@ -565,8 +564,7 @@ XdmfArray::XdmfArray() :
mArrayPointerNumValues(0),
mName(""),
mTmpReserveSize(0),
mReadMode(XdmfArray::Controller),
mFunction(shared_ptr<XdmfFunction>())
mReadMode(XdmfArray::Controller)
{
}
......@@ -657,12 +655,6 @@ XdmfArray::getDimensionsString() const
dimensions.size());
}
shared_ptr<XdmfFunction>
XdmfArray::getFunction()
{
return mFunction;
}
std::map<std::string, std::string>
XdmfArray::getItemProperties() const
{
......@@ -709,10 +701,10 @@ XdmfArray::getSize() const
mArray);
}
shared_ptr<XdmfSubset>
XdmfArray::getSubset()
shared_ptr<XdmfArrayReference>
XdmfArray::getReference()
{
return mSubset;
return mReference;
}
void *
......@@ -1184,11 +1176,8 @@ XdmfArray::read()
case XdmfArray::Controller:
this->readController();
break;
case XdmfArray::Function:
this->readFunction();
break;
case XdmfArray::Subset:
this->readSubset();
case XdmfArray::Reference:
this->readReference();
break;
default:
try {
......@@ -1248,16 +1237,9 @@ XdmfArray::readController()
}
void
XdmfArray::readFunction()
XdmfArray::readReference()
{
shared_ptr<XdmfArray> tempArray = mFunction->read();
this->swap(tempArray);
}
void
XdmfArray::readSubset()
{
shared_ptr<XdmfArray> tempArray = mSubset->read();
shared_ptr<XdmfArray> tempArray = mReference->read();
this->swap(tempArray);
}
......@@ -1277,12 +1259,6 @@ XdmfArray::reserve(const unsigned int size)
mArray);
}
void
XdmfArray::setFunction(shared_ptr<XdmfFunction> newFunction)
{
mFunction = newFunction;
}
void
XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newController)
{
......@@ -1306,9 +1282,9 @@ XdmfArray::setReadMode(XdmfArray::ReadMode newStatus)
}
void
XdmfArray::setSubset(shared_ptr<XdmfSubset> newSubset)
XdmfArray::setReference(shared_ptr<XdmfArrayReference> newReference)
{
mSubset = newSubset;
mReference = newReference;
}
void
......
......@@ -31,8 +31,7 @@ class XdmfHeavyDataController;
// Includes
#include "XdmfCore.hpp"
#include "XdmfItem.hpp"
#include "XdmfFunction.hpp"
#include "XdmfSubset.hpp"
#include "XdmfArrayReference.hpp"
#include <boost/shared_array.hpp>
#include <boost/variant.hpp>
......@@ -103,8 +102,7 @@ public:
enum ReadMode {
Controller,
Function,
Subset
Reference
};
/**
......@@ -287,36 +285,6 @@ public:
*/
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::string getItemTag() const;
......@@ -352,7 +320,7 @@ public:
/**
* 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:
*
......@@ -361,8 +329,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setReference
* @until //#setReference
* @skipline //#setReadMode
* @until //#setReadMode
* @skipline //#getReadMode
......@@ -374,8 +342,8 @@ public:
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setReference
* @until #//setReference
* @skipline #//setReadMode
* @until #//setReadMode
* @skipline #//getReadMode
......@@ -411,7 +379,7 @@ public:
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:
*
......@@ -420,24 +388,24 @@ public:
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setSubset
* @until //#setSubset
* @skipline //#getSubset
* @until //#getSubset
* @skipline //#setReference
* @until //#setReference
* @skipline //#getReference
* @until //#getReference
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setSubset
* @until #//setSubset
* @skipline #//getSubset
* @until #//getSubset
* @skipline #//setReference
* @until #//setReference
* @skipline #//getReference
* @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.
......@@ -1052,8 +1020,7 @@ public:
void readController();
/**
* Accumulates the data via the function associated with the array and
* swaps the data with the data currently in the array.
* Reads the data pointed to by the array reference into the array.
*
* Example of use:
*
......@@ -1062,50 +1029,22 @@ public:
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#readFunction
* @until //#readFunction
*
* @skipline //#setReference
* @until //#setReference
* @skipline //#readReference
* @until //#readReference
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//readFunction
* @until #//readFunction
* @skipline #//setReference
* @until #//setReference
* @skipline #//readReference
* @until #//readReference
*/
void readFunction();
/**
* 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();
void readReference();
/**
* Release all data currently held in memory.
......@@ -1231,7 +1170,7 @@ public:
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:
*
......@@ -1240,8 +1179,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setReference
* @until //#setReference
*
*
* Python
......@@ -1249,12 +1188,12 @@ public:
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setReference
* @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.
......@@ -1283,7 +1222,7 @@ public:
/**
* 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:
*
......@@ -1292,8 +1231,8 @@ public:
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setReference
* @until //#setReference
* @skipline //#setReadMode
* @until //#setReadMode
*
......@@ -1303,8 +1242,8 @@ public:
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setReference
* @until #//setReference
* @skipline #//setReadMode
* @until #//setReadMode
*
......@@ -1312,31 +1251,6 @@ public:
*/
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
* arrayPointer array. No copy is made. Modifications to the array
......@@ -1580,8 +1494,7 @@ private:
std::string mName;
unsigned int mTmpReserveSize;
ReadMode mReadMode;
shared_ptr<XdmfFunction> mFunction;
shared_ptr<XdmfSubset> mSubset;
shared_ptr<XdmfArrayReference> mReference;
};
......
/*****************************************************************************/
/* 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;
}
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfArrayReference.hpp */
/* */
/* 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. */
/* */
/*****************************************************************************/
#ifndef XDMFARRAYREFERENCE_HPP_
#define XDMFARRAYREFERENCE_HPP_
// Includes
#include "XdmfCore.hpp"
#include "XdmfArray.hpp"
class XdmfArray;
/**
* @brief Serves as a link between an array and one or more arrays containing data it pulls from.
*
* The Array Reference class provides the basic framework for the writing and
* reading of the Function and Subset classes by allowing properties and tags
* to be migrated to them.
*/
class XDMFCORE_EXPORT XdmfArrayReference : public XdmfItem {
public:
virtual ~XdmfArrayReference();
LOKI_DEFINE_VISITABLE(XdmfArrayReference, XdmfItem);
/**
* Gets the properties of the array that the reference will generate when read from file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#initexpression
* @until //#initexpression
* @skipline //#setConstructedProperties
* @until //#setConstructedProperties
* @skipline //#getConstructedProperties
* @until //#getConstructedProperties
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//initexpression
* @until #//initexpression
* @skipline #//setConstructedProperties
* @until #//setConstructedProperties
* @skipline #//getConstructedProperties
* @until #//getConstructedProperties
*
* @return The properties of the array to be generated
*/
std::map<std::string, std::string> getConstructedProperties();
/**
* Gets the type of array that the reference will generate when read from file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#initexpression
* @until //#initexpression
* @skipline //#setConstructedType
* @until //#setConstructedType
* @skipline //#getConstructedType
* @until //#getConstructedType
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//initexpression
* @until #//initexpression
* @skipline #//setConstructedType
* @until #//setConstructedType
* @skipline #//getConstructedType
* @until #//getConstructedType
*
* @return The tag of the type to be generated
*/
std::string getConstructedType();
/**
* Parses the reference and generates an array containing the values that
* the reference produces.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#initexpression
* @until //#initexpression
* @skipline //#read
* @until //#read
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//initexpression
* @until #//initexpression
* @skipline #//read
* @until #//read
*
* @return The array generated by the reference
*/
virtual shared_ptr<XdmfArray> read() = 0;
/**
* Sets the properties of array that the reference will generate when read from file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#initexpression
* @until //#initexpression
* @skipline //#setConstructedProperties
* @until //#setConstructedProperties
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//initexpression
* @until #//initexpression
* @skipline #//setConstructedProperties
* @until #//setConstructedProperties
*
* @param newProperties The properties of the array to be generated
*/
void
setConstructedProperties(std::map<std::string, std::string> newProperties);
/**
* Sets the type of array that the reference will generate when read from file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfFunction.cpp
* @skipline //#initexpression
* @until //#initexpression
* @skipline //#setConstructedType
* @until //#setConstructedType
*
* Python
*
* @dontinclude XdmfExampleFunction.py
* @skipline #//initexpression
* @until #//initexpression
* @skipline #//setConstructedType
* @until #//setConstructedType
*
* @param newType The tag of the type to be generated
*/
void setConstructedType(std::string newType);
protected:
XdmfArrayReference();
std::string mConstructedType;
std::map<std::string, std::string> mConstructedProperties;
private:
XdmfArrayReference(const XdmfArrayReference &); // Not implemented.
void operator=(const XdmfArrayReference &); // Not implemented.
};
#endif /* XDMFARRAYREFERENCE_HPP_ */
......@@ -7,6 +7,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%module XdmfCore
%{
#include <XdmfArray.hpp>
#include <XdmfArrayReference.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfCore.hpp>
#include <XdmfCoreItemFactory.hpp>
......@@ -432,6 +433,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
// Shared Pointer Templates
%shared_ptr(XdmfArray)
%shared_ptr(XdmfArrayReference)
%shared_ptr(XdmfArrayType)
%shared_ptr(XdmfCoreItemFactory)
%shared_ptr(XdmfCoreReader)
......@@ -462,6 +464,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%include XdmfSparseMatrix.hpp
%include XdmfSystemUtils.hpp
%include XdmfVisitor.hpp
%include XdmfArrayReference.hpp
%include XdmfFunction.hpp
%include XdmfHeavyDataController.hpp
%include XdmfHeavyDataWriter.hpp
......
......@@ -24,6 +24,8 @@
#include "XdmfArray.hpp"
#include "XdmfCoreItemFactory.hpp"
#include "XdmfError.hpp"
#include "XdmfFunction.hpp"
#include "XdmfSubset.hpp"
#include <boost/tokenizer.hpp>
XdmfCoreItemFactory::XdmfCoreItemFactory()
......@@ -109,21 +111,19 @@ XdmfCoreItemFactory::createItem(const std::string & itemTag,
newArrayChildren));
returnArray->insert(0, parsedArray, 0, parsedArray->getSize());
returnArray->setFunction(XdmfFunction::New(expressionToParse,
variableCollection));
returnArray->setReadMode(XdmfArray::Function);
returnArray->setReference(XdmfFunction::New(expressionToParse,
variableCollection));
returnArray->setReadMode(XdmfArray::Reference);
return returnArray;
}
else {
parsedArray->setFunction(XdmfFunction::New(expressionToParse,
variableCollection));
parsedArray->setReadMode(XdmfArray::Function);
parsedArray->setReference(XdmfFunction::New(expressionToParse,
variableCollection));
parsedArray->setReadMode(XdmfArray::Reference);
return parsedArray;
}
}
else if(itemTag.compare(XdmfSubset::ItemTag) == 0) {
//TODO
std::map<std::string, std::string>::const_iterator type =
itemProperties.find("ConstructedType");
std::string arraySubType;
......@@ -185,8 +185,8 @@ XdmfCoreItemFactory::createItem(const std::string & itemTag,
strideVector,
dimensionVector);
returnArray->setSubset(newSubset);
returnArray->setReadMode(XdmfArray::Subset);
returnArray->setReference(newSubset);
returnArray->setReadMode(XdmfArray::Reference);
return returnArray;
......