Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xdmf
Xdmf
Commits
a1ab48d8
Commit
a1ab48d8
authored
May 25, 2010
by
Kenneth Leiter
Browse files
ENH: Continue implementing XdmfPartitioner.
parent
f5cd8422
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
XdmfArray.hpp
View file @
a1ab48d8
...
...
@@ -129,6 +129,14 @@ public:
*/
std
::
string
getType
()
const
;
/**
* Get a copy of a single value stored in this array.
*
* @return the requested value.
*/
template
<
typename
T
>
T
getValueCopy
(
const
unsigned
int
index
)
const
;
/**
* Get a smart pointer to the values stored in this array.
*
...
...
@@ -137,6 +145,14 @@ public:
template
<
typename
T
>
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
getValues
();
/**
* Get a smart pointer to the values stored in this array (const version).
*
* @return a smart pointer to the internal vector of values stored in this array.
*/
//template <typename T>
//const boost::shared_ptr<const std::vector<T> > getValues() const;
/**
* Get a copy of the values stored in this array
*
...
...
@@ -149,14 +165,6 @@ public:
template
<
typename
T
>
void
getValuesCopy
(
const
unsigned
int
startIndex
,
T
*
valuesPointer
,
const
unsigned
int
numValues
=
1
,
const
unsigned
int
arrayStride
=
1
,
const
unsigned
int
valuesStride
=
1
)
const
;
/**
* Get a smart pointer to the values stored in this array (const version).
*
* @return a smart pointer to the internal vector of values stored in this array.
*/
//template <typename T>
//const boost::shared_ptr<const std::vector<T> > getValues() const;
/**
* Get a pointer to the values stored in this array (const version).
*
...
...
XdmfArray.tpp
View file @
a1ab48d8
...
...
@@ -144,6 +144,14 @@ void XdmfArray::copyValues(const unsigned int startIndex, const T * const values
boost
::
apply_visitor
(
CopyValues
<
T
>
(
startIndex
,
valuesPointer
,
numValues
,
arrayStride
,
valuesStride
),
mArray
);
}
template
<
typename
T
>
T
XdmfArray
::
getValueCopy
(
const
unsigned
int
index
)
const
{
T
toReturn
;
this
->
getValuesCopy
(
index
,
&
toReturn
,
1
);
return
toReturn
;
}
template
<
typename
T
>
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
XdmfArray
::
getValues
()
{
...
...
XdmfGeometry.cpp
View file @
a1ab48d8
...
...
@@ -5,6 +5,7 @@
* Author: kleiter
*/
#include
"XdmfArray.hpp"
#include
"XdmfGeometry.hpp"
XdmfGeometry
::
XdmfGeometry
()
:
...
...
@@ -38,6 +39,15 @@ std::string XdmfGeometry::getItemTag() const
return
ItemTag
;
}
unsigned
int
XdmfGeometry
::
getNumberPoints
()
const
{
if
(
mGeometryType
.
getDimensions
()
==
0
)
{
return
0
;
}
return
this
->
getArray
()
->
getSize
()
/
mGeometryType
.
getDimensions
();
}
void
XdmfGeometry
::
populateItem
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
,
std
::
vector
<
boost
::
shared_ptr
<
XdmfItem
>
>
&
childItems
)
{
mGeometryType
=
XdmfGeometryType
::
New
(
itemProperties
);
...
...
XdmfGeometry.hpp
View file @
a1ab48d8
...
...
@@ -31,6 +31,11 @@ public:
std
::
string
getItemTag
()
const
;
/**
* Get the number of points stored in this geometry.
*/
unsigned
int
getNumberPoints
()
const
;
/**
* Set the XdmfGeometryType associated with this geometry.
*
...
...
XdmfGeometryType.cpp
View file @
a1ab48d8
...
...
@@ -135,7 +135,7 @@ bool XdmfGeometryType::operator!=(const XdmfGeometryType& geometryType) const
return
!
this
->
operator
==
(
geometryType
);
}
int
XdmfGeometryType
::
getDimensions
()
const
unsigned
int
XdmfGeometryType
::
getDimensions
()
const
{
return
mDimensions
;
}
...
...
XdmfGeometryType.hpp
View file @
a1ab48d8
...
...
@@ -44,7 +44,7 @@ public:
*
* @return an int containing number of dimensions.
*/
int
getDimensions
()
const
;
unsigned
int
getDimensions
()
const
;
void
getProperties
(
std
::
map
<
std
::
string
,
std
::
string
>
&
collectedProperties
)
const
;
...
...
@@ -83,7 +83,7 @@ private:
static
XdmfGeometryType
New
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
);
int
mDimensions
;
unsigned
int
mDimensions
;
std
::
string
mName
;
};
...
...
XdmfGrid.cpp
View file @
a1ab48d8
...
...
@@ -37,11 +37,24 @@ boost::shared_ptr<XdmfAttribute> XdmfGrid::getAttribute(const unsigned int index
boost
::
shared_ptr
<
const
XdmfAttribute
>
XdmfGrid
::
getAttribute
(
const
unsigned
int
index
)
const
{
if
(
index
>=
mAttributes
.
size
())
return
boost
::
const_pointer_cast
<
XdmfAttribute
>
(
static_cast
<
const
XdmfGrid
&>
(
*
this
).
getAttribute
(
index
));
}
boost
::
shared_ptr
<
XdmfAttribute
>
XdmfGrid
::
getAttribute
(
const
std
::
string
&
attributeName
)
{
for
(
std
::
vector
<
boost
::
shared_ptr
<
XdmfAttribute
>
>::
const_iterator
iter
=
mAttributes
.
begin
();
iter
!=
mAttributes
.
end
();
++
iter
)
{
assert
(
false
);
if
((
*
iter
)
->
getName
().
compare
(
attributeName
)
==
0
)
{
return
*
iter
;
}
}
return
mAttributes
[
index
];
return
boost
::
shared_ptr
<
XdmfAttribute
>
();
}
boost
::
shared_ptr
<
const
XdmfAttribute
>
XdmfGrid
::
getAttribute
(
const
std
::
string
&
attributeName
)
const
{
return
boost
::
const_pointer_cast
<
XdmfAttribute
>
(
static_cast
<
const
XdmfGrid
&>
(
*
this
).
getAttribute
(
attributeName
));
}
boost
::
shared_ptr
<
XdmfGeometry
>
XdmfGrid
::
getGeometry
()
...
...
@@ -51,7 +64,7 @@ boost::shared_ptr<XdmfGeometry> XdmfGrid::getGeometry()
boost
::
shared_ptr
<
const
XdmfGeometry
>
XdmfGrid
::
getGeometry
()
const
{
return
mGeometry
;
return
boost
::
const_pointer_cast
<
XdmfGeometry
>
(
static_cast
<
const
XdmfGrid
&>
(
*
this
).
getGeometry
())
;
}
std
::
map
<
std
::
string
,
std
::
string
>
XdmfGrid
::
getItemProperties
()
const
...
...
@@ -92,11 +105,7 @@ boost::shared_ptr<XdmfSet> XdmfGrid::getSet(const unsigned int index)
boost
::
shared_ptr
<
const
XdmfSet
>
XdmfGrid
::
getSet
(
const
unsigned
int
index
)
const
{
if
(
index
>=
mSets
.
size
())
{
assert
(
false
);
}
return
mSets
[
index
];
return
boost
::
const_pointer_cast
<
XdmfSet
>
(
static_cast
<
const
XdmfGrid
&>
(
*
this
).
getSet
(
index
));
}
boost
::
shared_ptr
<
XdmfTopology
>
XdmfGrid
::
getTopology
()
...
...
@@ -106,7 +115,7 @@ boost::shared_ptr<XdmfTopology> XdmfGrid::getTopology()
boost
::
shared_ptr
<
const
XdmfTopology
>
XdmfGrid
::
getTopology
()
const
{
return
mTopology
;
return
boost
::
const_pointer_cast
<
XdmfTopology
>
(
static_cast
<
const
XdmfGrid
&>
(
*
this
).
getTopology
())
;
}
void
XdmfGrid
::
insert
(
boost
::
shared_ptr
<
XdmfAttribute
>
attribute
)
...
...
XdmfGrid.hpp
View file @
a1ab48d8
...
...
@@ -42,6 +42,22 @@ public:
*/
boost
::
shared_ptr
<
const
XdmfAttribute
>
getAttribute
(
const
unsigned
int
index
)
const
;
/**
* Get an XdmfAttribute attached to this grid by name.
*
* @param attributeName the name of the XdmfAttribute to retrieve.
* @return requested XdmfAttribute, if not found a NULL pointer is returned.
*/
boost
::
shared_ptr
<
XdmfAttribute
>
getAttribute
(
const
std
::
string
&
attributeName
);
/**
* Get an XdmfAttribute attached to this grid by name (const version).
*
* @param attributeName the name of the XdmfAttribute to retrieve.
* @return requested XdmfAttribute, if not found a NULL pointer is returned.
*/
boost
::
shared_ptr
<
const
XdmfAttribute
>
getAttribute
(
const
std
::
string
&
attributeName
)
const
;
/**
* Get the XdmfGeometry associated with this grid.
*
...
...
XdmfHDF5Controller.cpp
View file @
a1ab48d8
...
...
@@ -17,7 +17,7 @@ XdmfHDF5Controller::XdmfHDF5Controller(const std::string & hdf5DataSetPath, cons
mHDF5FilePath
=
hdf5DataSetPath
.
substr
(
0
,
colonLocation
);
if
(
colonLocation
+
1
!=
mHDF5FilePath
.
size
())
{
mDataSetName
=
hdf5DataSetPath
.
substr
(
colonLocation
+
1
,
mHDF5File
Path
.
size
());
mDataSetName
=
hdf5DataSetPath
.
substr
(
colonLocation
+
1
,
hdf5DataSet
Path
.
size
());
}
else
{
...
...
XdmfTopology.cpp
View file @
a1ab48d8
...
...
@@ -40,11 +40,11 @@ std::map<std::string, std::string> XdmfTopology::getItemProperties() const
unsigned
int
XdmfTopology
::
getNumberElements
()
const
{
if
(
this
->
get
TopologyType
()
.
getNodesPerElement
()
==
0
)
if
(
m
TopologyType
.
getNodesPerElement
()
==
0
)
{
return
0
;
}
return
this
->
getArray
()
->
getSize
()
/
this
->
get
TopologyType
()
.
getNodesPerElement
();
return
this
->
getArray
()
->
getSize
()
/
m
TopologyType
.
getNodesPerElement
();
}
XdmfTopologyType
XdmfTopology
::
getTopologyType
()
const
...
...
XdmfTopologyType.cpp
View file @
a1ab48d8
...
...
@@ -93,6 +93,21 @@ XdmfTopologyType XdmfTopologyType::Hexahedron_20()
return
XdmfTopologyType
(
20
,
"Hexahedron_20"
,
Quadratic
);
}
XdmfTopologyType
XdmfTopologyType
::
Hexahedron_24
()
{
return
XdmfTopologyType
(
20
,
"Hexahedron_24"
,
Quadratic
);
}
XdmfTopologyType
XdmfTopologyType
::
Hexahedron_27
()
{
return
XdmfTopologyType
(
20
,
"Hexahedron_27"
,
Quadratic
);
}
XdmfTopologyType
XdmfTopologyType
::
Hexahedron_64
()
{
return
XdmfTopologyType
(
20
,
"Hexahedron_64"
,
Cubic
);
}
XdmfTopologyType
XdmfTopologyType
::
Mixed
()
{
return
XdmfTopologyType
(
0
,
"Mixed"
,
Arbitrary
);
...
...
@@ -221,6 +236,18 @@ XdmfTopologyType XdmfTopologyType::New(const std::map<std::string, std::string>
{
return
Hexahedron_20
();
}
else
if
(
typeVal
.
compare
(
"Hexahedron_24"
)
==
0
)
{
return
Hexahedron_24
();
}
else
if
(
typeVal
.
compare
(
"Hexahedron_27"
)
==
0
)
{
return
Hexahedron_27
();
}
else
if
(
typeVal
.
compare
(
"Hexahedron_64"
)
==
0
)
{
return
Hexahedron_64
();
}
else
if
(
typeVal
.
compare
(
"Mixed"
)
==
0
)
{
return
Mixed
();
...
...
XdmfTopologyType.hpp
View file @
a1ab48d8
...
...
@@ -42,7 +42,7 @@ public:
friend
class
XdmfTopology
;
enum
CellType
{
NoCellType
,
Linear
,
Quadratic
,
Arbitrary
,
Structured
NoCellType
,
Linear
,
Quadratic
,
Cubic
,
Arbitrary
,
Structured
};
// Supported Xdmf Topology Types
...
...
@@ -63,6 +63,9 @@ public:
static
XdmfTopologyType
Pyramid_13
();
static
XdmfTopologyType
Wedge_15
();
static
XdmfTopologyType
Hexahedron_20
();
static
XdmfTopologyType
Hexahedron_24
();
static
XdmfTopologyType
Hexahedron_27
();
static
XdmfTopologyType
Hexahedron_64
();
static
XdmfTopologyType
Mixed
();
static
XdmfTopologyType
TwoDSMesh
();
static
XdmfTopologyType
TwoDRectMesh
();
...
...
tests/Cxx/TestXdmfGridCollection.cpp
View file @
a1ab48d8
...
...
@@ -32,7 +32,7 @@ int main(int argc, char* argv[])
gridCollection
->
insert
(
childGrid2
);
gridCollection
->
setGridCollectionType
(
XdmfGridCollectionType
::
Temporal
());
assert
(
gridCollection
->
getGridCollectionType
()
==
XdmfGridCollectionType
::
Temporal
());
boost
::
shared_ptr
<
XdmfWriter
>
writer
=
XdmfWriter
::
New
(
"TestXdmfGridCollection1.xmf"
);
gridCollection
->
accept
(
writer
);
...
...
utils/CMakeLists.txt
View file @
a1ab48d8
option
(
BUILD_PARTITIONER OFF
)
set
(
XdmfUtilsExectutables
)
set
(
XdmfUtilsSources
)
set
(
XdmfUtilsLibraries
)
set
(
XdmfUtilsLi
nkLi
braries
Xdmf
)
if
(
BUILD_PARTITIONER
)
find_package
(
Metis REQUIRED
)
if
(
METIS_FOUND
)
include_directories
(
${
METIS_INCLUDE_DIR
}
)
endif
(
METIS_FOUND
)
set
(
XdmfUtilsSources
${
XdmfUtilsSources
}
XdmfPartitioner
)
set
(
XdmfUtilsLibraries
${
XdmfUtilsLibraries
}
${
METIS_LIBRARY
}
)
find_package
(
Metis REQUIRED
)
if
(
METIS_FOUND
)
include_directories
(
${
METIS_INCLUDE_DIR
}
)
endif
(
METIS_FOUND
)
set
(
XdmfUtilsExectutables
${
XdmfUtilsExectutables
}
XdmfPartitioner
)
set
(
XdmfUtilsSources
${
XdmfUtilsSources
}
XdmfPartitioner
)
set
(
XdmfUtilsLinkLibraries
${
XdmfUtilsLinkLibraries
}
${
METIS_LIBRARIES
}
)
endif
(
BUILD_PARTITIONER
)
add_library
(
XdmfUtils
${
XdmfUtilsSources
}
)
target_link_libraries
(
XdmfUtils Xdmf
)
target_link_libraries
(
XdmfUtils
${
XdmfUtilsLinkLibraries
}
)
foreach
(
executable
${
XdmfUtilsExectutables
}
)
add_executable
(
${
executable
}
${
executable
}
)
set_target_properties
(
${
executable
}
PROPERTIES COMPILE_FLAGS -DBUILD_EXE
)
target_link_libraries
(
${
executable
}
XdmfUtils
)
endforeach
(
executable
${
XdmfUtilsExectutables
}
)
\ No newline at end of file
utils/XdmfPartitioner.cpp
View file @
a1ab48d8
This diff is collapsed.
Click to expand it.
utils/XdmfPartitioner.hpp
View file @
a1ab48d8
...
...
@@ -3,17 +3,12 @@
// Forward Declarations
class
XdmfGrid
;
class
XdmfGridCollection
;
class
XdmfHDF5Writer
;
// Includes
#include
"XdmfObject.hpp"
/**
* @brief Handles computed values attached to an XdmfGrid.
*
* XdmfAttribute contains two properties that should be set, XdmfAttributeCenter and XdmfAttributeType.
* XdmfAttribute is a subclass of XdmfDataItem, meaning it contains an XdmfArray to store values
/*!
* @brief XdmfPartitioner partitions an XdmfGrid using the metis library.
*
...
...
@@ -45,10 +40,12 @@ public:
*
* @param gridToPartition an XdmfGrid to partition.
* @param numberOfPartitions the number of pieces to partition the grid into.
* @param heavyDataWriter an XdmfHDF5Writer to write the partitioned mesh to.
*
* @return
XdmfGrid*
a spatial collection containing partitioned grids.
* @return a spatial collection containing partitioned grids.
*/
boost
::
shared_ptr
<
XdmfGrid
>
partition
(
boost
::
shared_ptr
<
XdmfGrid
>
gridToPartition
,
const
unsigned
int
numberOfPartitions
);
boost
::
shared_ptr
<
XdmfGridCollection
>
partition
(
boost
::
shared_ptr
<
XdmfGrid
>
gridToPartition
,
const
unsigned
int
numberOfPartitions
,
boost
::
shared_ptr
<
XdmfHDF5Writer
>
heavyDataWriter
);
protected:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment