Gitlab updates will be applied at 1:30pm, (17:30 UTC), today. No downtime expected.

Commit 0d48e726 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add methods to get faces per element and nodes per element from

XdmfTopologyType.
parent 86eefce2
......@@ -88,6 +88,44 @@ public:
return p;
}
unsigned int
getEdgesPerElement() const
{
const unsigned int dimensions =
mCurvilinearGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 4;
}
else if(dimensions == 3) {
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getEdgesPerElement");
}
return 0;
}
unsigned int
getFacesPerElement() const
{
const unsigned int dimensions =
mCurvilinearGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 1;
}
else if(dimensions == 3) {
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeCurvilinear::getFacesPerElement");
}
return 0;
}
unsigned int
getNodesPerElement() const
{
......@@ -119,7 +157,7 @@ public:
private:
XdmfTopologyTypeCurvilinear(const XdmfCurvilinearGrid * const curvilinearGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1110),
XdmfTopologyType(0, 0, 0, "foo", XdmfTopologyType::Structured, 0x1110),
mCurvilinearGrid(curvilinearGrid)
{
}
......
......@@ -187,6 +187,44 @@ public:
return p;
}
unsigned int
getEdgesPerElement() const
{
const unsigned int dimensions =
mRectilinearGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 4;
}
else if(dimensions == 3) {
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getEdgesPerElement");
}
return 0;
}
unsigned int
getFacesPerElement() const
{
const unsigned int dimensions =
mRectilinearGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 1;
}
else if(dimensions == 3) {
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRectilinear::getFacesPerElement");
}
return 0;
}
unsigned int
getNodesPerElement() const
{
......@@ -218,7 +256,7 @@ public:
private:
XdmfTopologyTypeRectilinear(const XdmfRectilinearGrid * const rectilinearGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1101),
XdmfTopologyType(0, 0, 0, "foo", XdmfTopologyType::Structured, 0x1101),
mRectilinearGrid(rectilinearGrid)
{
}
......
......@@ -181,6 +181,42 @@ public:
return p;
}
unsigned int
getEdgesPerElement() const
{
const unsigned int dimensions = mRegularGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 4;
}
else if(dimensions == 3) {
return 12;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getEdgesPerElement");
}
return 0;
}
unsigned int
getFacesPerElement() const
{
const unsigned int dimensions = mRegularGrid->getDimensions()->getSize();
if(dimensions == 2) {
return 1;
}
else if(dimensions == 3) {
return 6;
}
else {
XdmfError::message(XdmfError::FATAL,
"Grid dimensions not 2 or 3 in "
"XdmfTopologyTypeRegular::getFacesPerElement");
}
return 0;
}
unsigned int
getNodesPerElement() const
{
......@@ -211,7 +247,7 @@ public:
private:
XdmfTopologyTypeRegular(const XdmfRegularGrid * const regularGrid) :
XdmfTopologyType(0, "foo", XdmfTopologyType::Structured, 0x1102),
XdmfTopologyType(0, 0, 0, "foo", XdmfTopologyType::Structured, 0x1102),
mRegularGrid(regularGrid)
{
}
......
......@@ -31,7 +31,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::NoTopologyType()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(0, "NoTopology", NoCellType, 0x0));
p(new XdmfTopologyType(0, 0, 0, "NoTopology", NoCellType, 0x0));
return p;
}
......@@ -39,7 +39,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Polyvertex()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(1, "Polyvertex", Linear, 0x1));
p(new XdmfTopologyType(1, 0, 0, "Polyvertex", Linear, 0x1));
return p;
}
......@@ -54,7 +54,8 @@ XdmfTopologyType::Polyline(const unsigned int nodesPerElement)
return type->second;
}
shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(nodesPerElement, "Polyline", Linear, 0x2));
p(new XdmfTopologyType(nodesPerElement, 0, nodesPerElement - 1,
"Polyline", Linear, 0x2));
previousTypes[nodesPerElement] = p;
return p;
}
......@@ -70,7 +71,8 @@ XdmfTopologyType::Polygon(const unsigned int nodesPerElement)
return type->second;
}
shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(nodesPerElement, "Polygon", Linear, 0x3));
p(new XdmfTopologyType(nodesPerElement, 1, nodesPerElement,
"Polygon", Linear, 0x3));
previousTypes[nodesPerElement] = p;
return p;
}
......@@ -79,7 +81,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Triangle()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(3, "Triangle", Linear, 0x4));
p(new XdmfTopologyType(3, 1, 3, "Triangle", Linear, 0x4));
return p;
}
......@@ -87,7 +89,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Quadrilateral()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(4, "Quadrilateral", Linear, 0x5));
p(new XdmfTopologyType(4, 1, 4, "Quadrilateral", Linear, 0x5));
return p;
}
......@@ -95,7 +97,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Tetrahedron()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(4, "Tetrahedron", Linear, 0x6));
p(new XdmfTopologyType(4, 4, 6, "Tetrahedron", Linear, 0x6));
return p;
}
......@@ -103,7 +105,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Pyramid()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(5, "Pyramid", Linear, 0x7));
p(new XdmfTopologyType(5, 5, 8, "Pyramid", Linear, 0x7));
return p;
}
......@@ -111,7 +113,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Wedge()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(6, "Wedge", Linear, 0x8));
p(new XdmfTopologyType(6, 5, 9, "Wedge", Linear, 0x8));
return p;
}
......@@ -119,7 +121,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(8, "Hexahedron", Linear, 0x9));
p(new XdmfTopologyType(8, 6, 12, "Hexahedron", Linear, 0x9));
return p;
}
......@@ -127,7 +129,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Edge_3()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(3, "Edge_3", Quadratic, 0x22));
p(new XdmfTopologyType(3, 0, 1, "Edge_3", Quadratic, 0x22));
return p;
}
......@@ -135,7 +137,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Triangle_6()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(6, "Triangle_6", Quadratic, 0x24));
p(new XdmfTopologyType(6, 1, 3, "Triangle_6", Quadratic, 0x24));
return p;
}
......@@ -143,7 +145,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Quadrilateral_8()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(8, "Quadrilateral_8", Quadratic, 0x25));
p(new XdmfTopologyType(8, 1, 4, "Quadrilateral_8", Quadratic, 0x25));
return p;
}
......@@ -151,7 +153,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Quadrilateral_9()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(9, "Quadrilateral_9", Quadratic, 0x23));
p(new XdmfTopologyType(9, 1, 4, "Quadrilateral_9", Quadratic, 0x23));
return p;
}
......@@ -159,7 +161,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Tetrahedron_10()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(10, "Tetrahedron_10", Quadratic, 0x26));
p(new XdmfTopologyType(10, 4, 6, "Tetrahedron_10", Quadratic, 0x26));
return p;
}
......@@ -167,7 +169,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Pyramid_13()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(13, "Pyramid_13", Quadratic, 0x27));
p(new XdmfTopologyType(13, 5, 8, "Pyramid_13", Quadratic, 0x27));
return p;
}
......@@ -175,7 +177,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Wedge_15()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(15, "Wedge_15", Quadratic, 0x28));
p(new XdmfTopologyType(15, 5, 9, "Wedge_15", Quadratic, 0x28));
return p;
}
......@@ -183,7 +185,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Wedge_18()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(18, "Wedge_18", Quadratic, 0x29));
p(new XdmfTopologyType(18, 5, 9, "Wedge_18", Quadratic, 0x29));
return p;
}
......@@ -191,7 +193,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_20()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(20, "Hexahedron_20", Quadratic, 0x30));
p(new XdmfTopologyType(20, 6, 12, "Hexahedron_20", Quadratic, 0x30));
return p;
}
......@@ -199,7 +201,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_24()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(24, "Hexahedron_24", Quadratic, 0x31));
p(new XdmfTopologyType(24, 6, 12, "Hexahedron_24", Quadratic, 0x31));
return p;
}
......@@ -207,7 +209,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_27()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(27, "Hexahedron_27", Quadratic, 0x32));
p(new XdmfTopologyType(27, 6, 12, "Hexahedron_27", Quadratic, 0x32));
return p;
}
......@@ -215,7 +217,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_64()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(64, "Hexahedron_64", Cubic, 0x33));
p(new XdmfTopologyType(64, 6, 12, "Hexahedron_64", Cubic, 0x33));
return p;
}
......@@ -223,7 +225,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_125()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(125, "Hexahedron_125", Quartic, 0x34));
p(new XdmfTopologyType(125, 6, 12, "Hexahedron_125", Quartic, 0x34));
return p;
}
......@@ -231,7 +233,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_216()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(216, "Hexahedron_216", Quintic, 0x35));
p(new XdmfTopologyType(216, 6, 12, "Hexahedron_216", Quintic, 0x35));
return p;
}
......@@ -240,7 +242,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_343()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(343, "Hexahedron_343", Sextic, 0x36));
p(new XdmfTopologyType(343, 6, 12, "Hexahedron_343", Sextic, 0x36));
return p;
}
......@@ -249,7 +251,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_512()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(512, "Hexahedron_512", Septic, 0x37));
p(new XdmfTopologyType(512, 6, 12, "Hexahedron_512", Septic, 0x37));
return p;
}
......@@ -258,7 +260,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_729()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(729, "Hexahedron_729", Octic, 0x38));
p(new XdmfTopologyType(729, 6, 12, "Hexahedron_729", Octic, 0x38));
return p;
}
......@@ -267,7 +269,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_1000()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(1000, "Hexahedron_1000", Nonic, 0x39));
p(new XdmfTopologyType(1000, 6, 12, "Hexahedron_1000", Nonic, 0x39));
return p;
}
......@@ -275,7 +277,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Hexahedron_1331()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(1331, "Hexahedron_1331", Decic, 0x40));
p(new XdmfTopologyType(1331, 6, 12, "Hexahedron_1331", Decic, 0x40));
return p;
}
......@@ -284,7 +286,7 @@ shared_ptr<const XdmfTopologyType>
XdmfTopologyType::Mixed()
{
static shared_ptr<const XdmfTopologyType>
p(new XdmfTopologyType(0, "Mixed", Arbitrary, 0x70));
p(new XdmfTopologyType(0, 0, 0, "Mixed", Arbitrary, 0x70));
return p;
}
......@@ -385,10 +387,14 @@ XdmfTopologyType::New(const unsigned int id)
}
XdmfTopologyType::XdmfTopologyType(const unsigned int nodesPerElement,
const unsigned int facesPerElement,
const unsigned int edgesPerElement,
const std::string & name,
const CellType cellType,
const unsigned int id) :
mCellType(cellType),
mEdgesPerElement(edgesPerElement),
mFacesPerElement(facesPerElement),
mID(id),
mName(name),
mNodesPerElement(nodesPerElement)
......@@ -527,6 +533,18 @@ XdmfTopologyType::getCellType() const
return mCellType;
}
unsigned int
XdmfTopologyType::getEdgesPerElement() const
{
return mEdgesPerElement;
}
unsigned int
XdmfTopologyType::getFacesPerElement() const
{
return mFacesPerElement;
}
unsigned int
XdmfTopologyType::getID() const
{
......
......@@ -145,6 +145,20 @@ public:
*/
CellType getCellType() const;
/**
* Get the number of edges per element associated with this topology type.
*
* @return an unsigned int containing the number of edges per element.
*/
virtual unsigned int getEdgesPerElement() const;
/**
* Get the number of faces per element associated with this topology type.
*
* @return an unsigned int containing the number of faces per element.
*/
virtual unsigned int getFacesPerElement() const;
/**
* Get the id of this cell type, necessary in order to create grids
* containing mixed cells.
......@@ -180,6 +194,8 @@ protected:
* XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron()
*/
XdmfTopologyType(const unsigned int nodesPerElement,
const unsigned int facesPerElement,
const unsigned int edgesPerElement,
const std::string & name,
const CellType cellType,
const unsigned int id);
......@@ -193,6 +209,8 @@ private:
New(const std::map<std::string, std::string> & itemProperties);
const CellType mCellType;
const unsigned int mEdgesPerElement;
const unsigned int mFacesPerElement;
const unsigned int mID;
const std::string mName;
const unsigned int mNodesPerElement;
......
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