Commit 0a9fbd05 authored by David E DeMarle's avatar David E DeMarle

Merge branch 'add_polyhedron_support' into 'master'

Add support for Polyhedron cells

Elements of type Polyhedron (i.e. N face cells, where each face is a M edge polygon) are in the following format: 
[nCellFaces, nFace0Pts, id0_0, id0_1, ..., nFace1Pts, id1_0, id1_1, ..., ...]

This has first been proposed in a MR to VTK (vtk/vtk!1255), which contains the necessary changes to VTK. The VTK MR also has example/test files attached that demonstrated the functionality.

Ping: @demarle 


See merge request !5
parents 6e1c1724 2433ab90
...@@ -97,6 +97,18 @@ XdmfTopology::getNumberElements() const ...@@ -97,6 +97,18 @@ XdmfTopology::getNumberElements() const
numberElements += 1; numberElements += 1;
index += numberNodes + 2; index += numberNodes + 2;
} }
else if(topologyType == XdmfTopologyType::Polyhedron()) {
// get number of face
const unsigned int numberFaces =
this->getValue<unsigned int>(index + 1);
// skip to first face
index += 2;
// iterate over all faces and add number of nodes per face to index
for(unsigned int i=0; i<numberFaces; ++i) {
index += this->getValue<unsigned int>(index) + 1;
}
numberElements += 1;
}
else { else {
// add 1 to element count and move to next element id // add 1 to element count and move to next element id
numberElements += 1; numberElements += 1;
......
...@@ -51,6 +51,10 @@ class XdmfTopologyType; ...@@ -51,6 +51,10 @@ class XdmfTopologyType;
* *
* The tetrahedron is composed of nodes 20, 25, 100, and 200. The * The tetrahedron is composed of nodes 20, 25, 100, and 200. The
* polygon is composed of nodes 300 to 304. * polygon is composed of nodes 300 to 304.
*
* Elements of type Polyhedron (i.e. N face cells, where each face is a M edge
* polygon) are in the following format:
* [nCellFaces, nFace0Pts, id0_0, id0_1, ..., nFace1Pts, id1_0, id1_1, ..., ...]
*/ */
class XDMF_EXPORT XdmfTopology : public XdmfArray { class XDMF_EXPORT XdmfTopology : public XdmfArray {
......
...@@ -145,6 +145,15 @@ XdmfTopologyType::Hexahedron() ...@@ -145,6 +145,15 @@ XdmfTopologyType::Hexahedron()
return p; return p;
} }
shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Polyhedron()
{
std::vector<shared_ptr<const XdmfTopologyType> > faces;
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(0, 0, faces, 0, "Polyhedron", Linear, 0x10));
return p;
}
shared_ptr<const XdmfTopologyType> shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Edge_3() XdmfTopologyType::Edge_3()
{ {
...@@ -473,6 +482,9 @@ XdmfTopologyType::New(const unsigned int id) ...@@ -473,6 +482,9 @@ XdmfTopologyType::New(const unsigned int id)
else if(id == XdmfTopologyType::Hexahedron()->getID()) { else if(id == XdmfTopologyType::Hexahedron()->getID()) {
return XdmfTopologyType::Hexahedron(); return XdmfTopologyType::Hexahedron();
} }
else if(id == XdmfTopologyType::Polyhedron()->getID()) {
return XdmfTopologyType::Polyhedron();
}
else if(id == XdmfTopologyType::Edge_3()->getID()) { else if(id == XdmfTopologyType::Edge_3()->getID()) {
return XdmfTopologyType::Edge_3(); return XdmfTopologyType::Edge_3();
} }
...@@ -643,6 +655,9 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties) ...@@ -643,6 +655,9 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
else if(typeVal.compare("HEXAHEDRON") == 0) { else if(typeVal.compare("HEXAHEDRON") == 0) {
return Hexahedron(); return Hexahedron();
} }
else if(typeVal.compare("POLYHEDRON") == 0) {
return Polyhedron();
}
else if(typeVal.compare("EDGE_3") == 0) { else if(typeVal.compare("EDGE_3") == 0) {
return Edge_3(); return Edge_3();
} }
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
* Tetrahedron - 4 Triangular Faces * Tetrahedron - 4 Triangular Faces
* Wedge - 4 Triangular Faces, Quadrilateral Base * Wedge - 4 Triangular Faces, Quadrilateral Base
* Hexahedron - 6 Quadrilateral Faces * Hexahedron - 6 Quadrilateral Faces
* Polyhedron - N Face Cell, where each Face is a M Edge Polygon
* Edge_3 - 3 Node Quadratic Line * Edge_3 - 3 Node Quadratic Line
* Triangle_6 - 6 Node Quadratic Triangle * Triangle_6 - 6 Node Quadratic Triangle
* Quadrilateral_8 - 8 Node Quadratic Quadrilateral * Quadrilateral_8 - 8 Node Quadratic Quadrilateral
...@@ -120,7 +121,7 @@ public: ...@@ -120,7 +121,7 @@ public:
*/ */
static shared_ptr<const XdmfTopologyType> NoTopologyType(); static shared_ptr<const XdmfTopologyType> NoTopologyType();
static shared_ptr<const XdmfTopologyType> Polyvertex(); static shared_ptr<const XdmfTopologyType> Polyvertex();
static shared_ptr<const XdmfTopologyType> static shared_ptr<const XdmfTopologyType>
Polyline(const unsigned int nodesPerElement); Polyline(const unsigned int nodesPerElement);
static shared_ptr<const XdmfTopologyType> static shared_ptr<const XdmfTopologyType>
Polygon(const unsigned int nodesPerElement); Polygon(const unsigned int nodesPerElement);
...@@ -130,6 +131,7 @@ public: ...@@ -130,6 +131,7 @@ public:
static shared_ptr<const XdmfTopologyType> Pyramid(); static shared_ptr<const XdmfTopologyType> Pyramid();
static shared_ptr<const XdmfTopologyType> Wedge(); static shared_ptr<const XdmfTopologyType> Wedge();
static shared_ptr<const XdmfTopologyType> Hexahedron(); static shared_ptr<const XdmfTopologyType> Hexahedron();
static shared_ptr<const XdmfTopologyType> Polyhedron();
static shared_ptr<const XdmfTopologyType> Edge_3(); static shared_ptr<const XdmfTopologyType> Edge_3();
static shared_ptr<const XdmfTopologyType> Triangle_6(); static shared_ptr<const XdmfTopologyType> Triangle_6();
static shared_ptr<const XdmfTopologyType> Quadrilateral_8(); static shared_ptr<const XdmfTopologyType> Quadrilateral_8();
...@@ -300,7 +302,7 @@ public: ...@@ -300,7 +302,7 @@ public:
* @skipline //#getName * @skipline //#getName
* @until //#getName * @until //#getName
* *
* Python * Python
* *
* @dontinclude XdmfExampleTopologyType.py * @dontinclude XdmfExampleTopologyType.py
* @skipline #//getName * @skipline #//getName
......
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