Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CrayzeeWulf
Xdmf
Commits
101ba7bc
Commit
101ba7bc
authored
Aug 22, 2013
by
Andrew J. Burns (Cont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added XdmfSubset
parent
5e38d232
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1684 additions
and
147 deletions
+1684
-147
Xdmf.i
Xdmf.i
+2
-0
core/CMakeLists.txt
core/CMakeLists.txt
+1
-0
core/XdmfArray.cpp
core/XdmfArray.cpp
+70
-25
core/XdmfArray.hpp
core/XdmfArray.hpp
+187
-65
core/XdmfArray.tpp
core/XdmfArray.tpp
+2
-0
core/XdmfCore.i
core/XdmfCore.i
+8
-0
core/XdmfCoreItemFactory.cpp
core/XdmfCoreItemFactory.cpp
+74
-1
core/XdmfDSMDriver.hpp
core/XdmfDSMDriver.hpp
+1
-1
core/XdmfFunction.hpp
core/XdmfFunction.hpp
+41
-27
core/XdmfHeavyDataController.cpp
core/XdmfHeavyDataController.cpp
+7
-4
core/XdmfSubset.cpp
core/XdmfSubset.cpp
+334
-0
core/XdmfSubset.hpp
core/XdmfSubset.hpp
+470
-0
core/XdmfWriter.cpp
core/XdmfWriter.cpp
+53
-3
core/tests/Python/TestXdmfError.py
core/tests/Python/TestXdmfError.py
+0
-1
examples/Cxx/ExampleXdmfArray.cpp
examples/Cxx/ExampleXdmfArray.cpp
+56
-6
examples/Cxx/ExampleXdmfSubset.cpp
examples/Cxx/ExampleXdmfSubset.cpp
+120
-0
examples/Python/XdmfExampleArray.py
examples/Python/XdmfExampleArray.py
+51
-6
examples/Python/XdmfExampleSubset.py
examples/Python/XdmfExampleSubset.py
+109
-0
tests/Cxx/CMakeLists.txt
tests/Cxx/CMakeLists.txt
+4
-0
tests/Cxx/TestXdmfFunction.cpp
tests/Cxx/TestXdmfFunction.cpp
+1
-1
tests/Cxx/TestXdmfSubset.cpp
tests/Cxx/TestXdmfSubset.cpp
+80
-0
tests/Python/CMakeLists.txt
tests/Python/CMakeLists.txt
+2
-1
tests/Python/SplitTime.py
tests/Python/SplitTime.py
+0
-2
tests/Python/TestXdmfFunctionRead.py
tests/Python/TestXdmfFunctionRead.py
+1
-1
tests/Python/WriteTime.py
tests/Python/WriteTime.py
+8
-3
utils/XdmfUtils.i
utils/XdmfUtils.i
+2
-0
No files found.
Xdmf.i
View file @
101ba7bc
...
...
@@ -34,6 +34,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#
include
<
XdmfItemProperty
.
hpp
>
#
include
<
XdmfSharedPtr
.
hpp
>
#
include
<
XdmfSparseMatrix
.
hpp
>
#
include
<
XdmfSubset
.
hpp
>
#
include
<
XdmfSystemUtils
.
hpp
>
#
include
<
XdmfVisitor
.
hpp
>
#
include
<
XdmfWriter
.
hpp
>
...
...
@@ -84,6 +85,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#
include
<
XdmfItemProperty
.
hpp
>
#
include
<
XdmfSharedPtr
.
hpp
>
#
include
<
XdmfSparseMatrix
.
hpp
>
#
include
<
XdmfSubset
.
hpp
>
#
include
<
XdmfSystemUtils
.
hpp
>
#
include
<
XdmfVisitor
.
hpp
>
#
include
<
XdmfWriter
.
hpp
>
...
...
core/CMakeLists.txt
View file @
101ba7bc
...
...
@@ -105,6 +105,7 @@ set(XdmfCoreSources
XdmfItem
XdmfItemProperty
XdmfSparseMatrix
XdmfSubset
XdmfSystemUtils
${
CMAKE_BINARY_DIR
}
/XdmfVersion
XdmfVisitor
...
...
core/XdmfArray.cpp
View file @
101ba7bc
...
...
@@ -33,6 +33,7 @@
#include "XdmfFunction.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfHeavyDataController.hpp"
#include "XdmfSubset.hpp"
#include "XdmfVisitor.hpp"
#include "XdmfError.hpp"
...
...
@@ -564,7 +565,7 @@ XdmfArray::XdmfArray() :
mArrayPointerNumValues
(
0
),
mName
(
""
),
mTmpReserveSize
(
0
),
m
WriteAsFunction
(
false
),
m
ReadMode
(
XdmfArray
::
Controller
),
mFunction
(
shared_ptr
<
XdmfFunction
>
())
{
}
...
...
@@ -695,6 +696,12 @@ XdmfArray::getName() const
return
mName
;
}
XdmfArray
::
ReadMode
XdmfArray
::
getReadMode
()
const
{
return
mReadMode
;
}
unsigned
int
XdmfArray
::
getSize
()
const
{
...
...
@@ -702,6 +709,12 @@ XdmfArray::getSize() const
mArray
);
}
shared_ptr
<
XdmfSubset
>
XdmfArray
::
getSubset
()
{
return
mSubset
;
}
void
*
XdmfArray
::
getValuesInternal
()
{
...
...
@@ -723,12 +736,6 @@ XdmfArray::getValuesString() const
mArray
);
}
bool
XdmfArray
::
getWriteAsFunction
()
{
return
mWriteAsFunction
;
}
shared_ptr
<
XdmfHeavyDataController
>
XdmfArray
::
getHeavyDataController
()
{
...
...
@@ -747,16 +754,6 @@ XdmfArray::getHeavyDataController() const
}
}
void
XdmfArray
::
setHeavyDataController
(
shared_ptr
<
XdmfHeavyDataController
>
newController
)
{
// Since this is replacing the previous version which was designed to
// completely replace the controller of the array
// It will clear the current controllers before adding the new one in
mHeavyDataControllers
.
clear
();
mHeavyDataControllers
.
push_back
(
newController
);
}
void
XdmfArray
::
initialize
(
const
shared_ptr
<
const
XdmfArrayType
>
arrayType
,
const
unsigned
int
size
)
...
...
@@ -851,8 +848,8 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex,
&&
valuesStartIndex
.
size
()
==
numValues
.
size
()
&&
numValues
.
size
()
==
valuesStride
.
size
())
&&
(
numInserted
.
size
()
==
startIndex
.
size
()
&&
startIndex
.
size
()
==
m
Dimensions
.
size
()
&&
m
Dimensions
.
size
()
==
arrayStride
.
size
()))
{
&&
startIndex
.
size
()
==
this
->
get
Dimensions
()
.
size
()
&&
this
->
get
Dimensions
()
.
size
()
==
arrayStride
.
size
()))
{
// Pull data from values
std
::
vector
<
unsigned
int
>
dimTotalVector
;
unsigned
int
dimTotal
=
1
;
...
...
@@ -965,8 +962,8 @@ XdmfArray::insert(const std::vector<unsigned int> startIndex,
}
}
else
if
(
!
(
numInserted
.
size
()
==
startIndex
.
size
()
&&
startIndex
.
size
()
==
m
Dimensions
.
size
()
&&
m
Dimensions
.
size
()
==
arrayStride
.
size
()))
{
&&
startIndex
.
size
()
==
this
->
get
Dimensions
()
.
size
()
&&
this
->
get
Dimensions
()
.
size
()
==
arrayStride
.
size
()))
{
try
{
XdmfError
::
message
(
XdmfError
::
FATAL
,
"Error: Number of starts, strides, and/or values "
...
...
@@ -1181,6 +1178,31 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
void
XdmfArray
::
read
()
{
switch
(
mReadMode
)
{
case
XdmfArray
::
Controller
:
this
->
readController
();
break
;
case
XdmfArray
::
Function
:
this
->
readFunction
();
break
;
case
XdmfArray
::
Subset
:
this
->
readSubset
();
break
;
default:
try
{
XdmfError
::
message
(
XdmfError
::
FATAL
,
"Error: Invalid Read Mode"
);
}
catch
(
XdmfError
e
)
{
throw
e
;
}
}
}
void
XdmfArray
::
readController
()
{
if
(
mHeavyDataControllers
.
size
()
>
1
)
{
this
->
release
();
...
...
@@ -1232,6 +1254,13 @@ XdmfArray::readFunction()
this
->
swap
(
tempArray
);
}
void
XdmfArray
::
readSubset
()
{
shared_ptr
<
XdmfArray
>
tempArray
=
mSubset
->
read
();
this
->
swap
(
tempArray
);
}
void
XdmfArray
::
release
()
{
...
...
@@ -1248,6 +1277,22 @@ XdmfArray::reserve(const unsigned int size)
mArray
);
}
void
XdmfArray
::
setFunction
(
shared_ptr
<
XdmfFunction
>
newFunction
)
{
mFunction
=
newFunction
;
}
void
XdmfArray
::
setHeavyDataController
(
shared_ptr
<
XdmfHeavyDataController
>
newController
)
{
// Since this is replacing the previous version which was designed to
// completely replace the controller of the array
// It will clear the current controllers before adding the new one in
mHeavyDataControllers
.
clear
();
mHeavyDataControllers
.
push_back
(
newController
);
}
void
XdmfArray
::
setName
(
const
std
::
string
&
name
)
{
...
...
@@ -1255,15 +1300,15 @@ XdmfArray::setName(const std::string & name)
}
void
XdmfArray
::
set
Function
(
shared_ptr
<
XdmfFunction
>
newFunction
)
XdmfArray
::
set
ReadMode
(
XdmfArray
::
ReadMode
newStatus
)
{
m
Function
=
newFunction
;
m
ReadMode
=
newStatus
;
}
void
XdmfArray
::
set
WriteAsFunction
(
bool
newStatus
)
XdmfArray
::
set
Subset
(
shared_ptr
<
XdmfSubset
>
newSubset
)
{
m
WriteAsFunction
=
newS
tatus
;
m
Subset
=
newS
ubset
;
}
void
...
...
core/XdmfArray.hpp
View file @
101ba7bc
...
...
@@ -32,6 +32,7 @@ class XdmfHeavyDataController;
#include "XdmfCore.hpp"
#include "XdmfItem.hpp"
#include "XdmfFunction.hpp"
#include "XdmfSubset.hpp"
#include <boost/shared_array.hpp>
#include <boost/variant.hpp>
...
...
@@ -100,6 +101,12 @@ class XDMFCORE_EXPORT XdmfArray : public XdmfItem {
public:
enum
ReadMode
{
Controller
,
Function
,
Subset
};
/**
* Create a new XdmfArray.
*
...
...
@@ -343,6 +350,41 @@ public:
*/
std
::
string
getName
()
const
;
/**
* Gets the method this array will be written/read.
* Possible choices are: Controller, Function, and Subset
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setReadMode
* @until //#setReadMode
* @skipline //#getReadMode
* @until //#getReadMode
*
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setReadMode
* @until #//setReadMode
* @skipline #//getReadMode
* @until #//getReadMode
*
* @return What method will be used when reading/writing the array
*/
ReadMode
getReadMode
()
const
;
/**
* Get the number of values stored in this array.
*
...
...
@@ -368,6 +410,35 @@ public:
*/
unsigned
int
getSize
()
const
;
/**
* Gets 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
* @skipline //#getSubset
* @until //#getSubset
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setSubset
* @until #//setSubset
* @skipline #//getSubset
* @until #//getSubset
*
* @return The subset being pulled from
*/
shared_ptr
<
XdmfSubset
>
getSubset
();
/**
* Get a copy of a single value stored in this array.
*
...
...
@@ -533,40 +604,6 @@ public:
*/
std
::
string
getValuesString
()
const
;
/**
* Gets if this array will be written as a function when written to file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setWriteAsFunction
* @until //#setWriteAsFunction
* @skipline //#getWriteAsFunction
* @until //#getWriteAsFunction
*
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setWriteAsFunction
* @until #//setWriteAsFunction
* @skipline #//getWriteAsFunction
* @until #//getWriteAsFunction
*
* @return Whether the array will be written as a function
*/
bool
getWriteAsFunction
();
/**
* Initialize the array to a specific size.
*
...
...
@@ -983,6 +1020,37 @@ public:
*/
void
read
();
/**
* Reads data from the attached controllers to the internal data storage.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#getHeavyDataController
* @until //#getHeavyDataController
* @skipline //#setHeavyDataController
* @until //#setHeavyDataController
* @skipline //#readController
* @until //#readController
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//getHeavyDataController
* @until #//getHeavyDataController
* @skipline #//setHeavyDataController
* @until #//setHeavyDataController
* @skipline #//readController
* @until #//readController
*/
void
readController
();
/**
* Accumulates the data via the function associated with the array and
* swaps the data with the data currently in the array.
...
...
@@ -1012,6 +1080,33 @@ public:
*/
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
();
/**
* Release all data currently held in memory.
*
...
...
@@ -1186,6 +1281,62 @@ public:
*/
void
setName
(
const
std
::
string
&
name
);
/**
* Sets the method this array will be written/read.
* Possible choices are: Controller, Function, and Subset
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setReadMode
* @until //#setReadMode
*
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setReadMode
* @until #//setReadMode
*
* @param newStatus The method that the array will be read/written
*/
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
...
...
@@ -1280,36 +1431,6 @@ public:
template
<
typename
T
>
void
setValuesInternal
(
const
shared_ptr
<
std
::
vector
<
T
>
>
array
);
/**
* Sets whether the array will be written as a function when written to file.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfArray.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setFunction
* @until //#setFunction
* @skipline //#setWriteAsFunction
* @until //#setWriteAsFunction
*
*
* Python
*
* @dontinclude XdmfExampleArray.py
* @skipline #//initialization
* @until #//initialization
* @skipline #//setFunction
* @until #//setFunction
* @skipline #//setWriteAsFunction
* @until #//setWriteAsFunction
*
* @param newStatus Whether the array will be set to be written as a function
*/
void
setWriteAsFunction
(
bool
newStatus
=
false
);
/**
* Exchange the contents of the vector with the contents of this
* array. No copy is made. The internal arrays are swapped.
...
...
@@ -1458,8 +1579,9 @@ private:
std
::
vector
<
unsigned
int
>
mDimensions
;
std
::
string
mName
;
unsigned
int
mTmpReserveSize
;
bool
mWriteAsFunction
;
ReadMode
mReadMode
;
shared_ptr
<
XdmfFunction
>
mFunction
;
shared_ptr
<
XdmfSubset
>
mSubset
;
};
...
...
core/XdmfArray.tpp
View file @
101ba7bc
...
...
@@ -718,6 +718,8 @@ XdmfArray::resize(const unsigned int numValues,
numValues
,
value
),
mArray
);
std
::
vector
<
unsigned
int
>
newDimensions
;
newDimensions
.
push_back
(
numValues
);
}
template
<
typename
T
>
...
...
core/XdmfCore.i
View file @
101ba7bc
...
...
@@ -32,6 +32,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#
include
<
XdmfItemProperty
.
hpp
>
#
include
<
XdmfSharedPtr
.
hpp
>
#
include
<
XdmfSparseMatrix
.
hpp
>
#
include
<
XdmfSubset
.
hpp
>
#
include
<
XdmfSystemUtils
.
hpp
>
#
include
<
XdmfVersion
.
hpp
>
#
include
<
XdmfVisitor
.
hpp
>
...
...
@@ -61,6 +62,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#
include
<
XdmfItemProperty
.
hpp
>
#
include
<
XdmfSharedPtr
.
hpp
>
#
include
<
XdmfSparseMatrix
.
hpp
>
#
include
<
XdmfSubset
.
hpp
>
#
include
<
XdmfSystemUtils
.
hpp
>
#
include
<
XdmfVersion
.
hpp
>
#
include
<
XdmfVisitor
.
hpp
>
...
...
@@ -166,6 +168,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
#
ifdef
SWIGPYTHON
/*This converts XdmfErrors to Python RuntimeErrors*/
%
exception
{
try
...
...
@@ -350,6 +353,8 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
/*trying to transfer python functions*/
/*note, accessing private members is impossible from swig.*/
/*class to wrap python functions to be compatible with the XdmfFunction code*/
class
PythonFunction
:
public
XdmfFunction
::
XdmfFunctionInternal
{
public
:
static
shared_ptr
<
PythonFunction
>
...
...
@@ -393,6 +398,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
PyObject
*
mInternalFunction
;
}
;
/*class to wrap python functions to be compatible with the XdmfFunction Operation code*/
class
PythonOperation
:
public
XdmfFunction
::
XdmfOperationInternal
{
public
:
static
shared_ptr
<
PythonOperation
>
...
...
@@ -490,6 +496,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%
shared_ptr
(
XdmfItem
)
%
shared_ptr
(
XdmfItemProperty
)
%
shared_ptr
(
XdmfSparseMatrix
)
%
shared_ptr
(
XdmfSubset
)
%
shared_ptr
(
XdmfVisitor
)
%
shared_ptr
(
XdmfWriter
)
...
...
@@ -510,6 +517,7 @@ swig -v -c++ -python -o XdmfCorePython.cpp XdmfCore.i
%
include
XdmfFunction
.
hpp
%
include
XdmfHeavyDataController
.
hpp
%
include
XdmfHeavyDataWriter
.
hpp
%
include
XdmfSubset
.
hpp
%
include
XdmfCoreItemFactory
.
hpp
%
include
XdmfCoreReader
.
hpp
...
...
core/XdmfCoreItemFactory.cpp
View file @
101ba7bc
...
...
@@ -24,6 +24,7 @@
#include "XdmfArray.hpp"
#include "XdmfCoreItemFactory.hpp"
#include "XdmfError.hpp"
#include <boost/tokenizer.hpp>
XdmfCoreItemFactory
::
XdmfCoreItemFactory
()
{
...
...
@@ -97,7 +98,7 @@ XdmfCoreItemFactory::createItem(const std::string & itemTag,
// The properties and children aren't really needed
// to generate the object, but the factory still requires them.
std
::
vector
<
shared_ptr
<
XdmfItem
>
>
newArrayChildren
;
shared_ptr
<
XdmfArray
>
returnArray
=
XdmfArray
::
New
();
shared_ptr
<
XdmfArray
>
returnArray
=
shared_ptr
<
XdmfArray
>
();
// This should generate an item that corresponds to the tag provided
// the casting ensures that it is a subtype of array
...
...
@@ -110,13 +111,85 @@ XdmfCoreItemFactory::createItem(const std::string & itemTag,
returnArray
->
insert
(
0
,
parsedArray
,
0
,
parsedArray
->
getSize
());
returnArray
->
setFunction
(
XdmfFunction
::
New
(
expressionToParse
,
variableCollection
));
returnArray
->
setReadMode
(
XdmfArray
::
Function
);
return
returnArray
;
}
else
{
parsedArray
->
setFunction
(
XdmfFunction
::
New
(
expressionToParse
,
variableCollection
));
parsedArray
->
setReadMode
(
XdmfArray
::
Function
);
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
;
if
(
type
==
itemProperties
.
end
())
{
// If no type is specified an array is generated
arraySubType
=
XdmfArray
::
ItemTag
;
}
else
{
arraySubType
=
type
->
second
;
}
std
::
vector
<
shared_ptr
<
XdmfItem
>
>
newArrayChildren
;
shared_ptr
<
XdmfArray
>
returnArray
=
shared_ptr
<
XdmfArray
>
();
returnArray
=
shared_dynamic_cast
<
XdmfArray
>
(
createItem
(
arraySubType
,
itemProperties
,
newArrayChildren
));