Commit ed10d434 authored by Ken Leiter (Civ's avatar Ken Leiter (Civ

ENH: Start separating XdmfItem properties from their respective classes - XdmfTopologyType.

parent d9c8a53c
......@@ -29,6 +29,7 @@ set(XdmfSources
XdmfItem
XdmfObject
XdmfTopology
XdmfTopologyType
XdmfVisitor
)
......
......@@ -33,6 +33,7 @@ namespace boost {
#include <XdmfItem.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
#include <XdmfTopologyType.hpp>
#include <XdmfVisitor.hpp>
%}
......@@ -48,3 +49,4 @@ namespace boost {
%include XdmfGeometryType.hpp
%include XdmfGrid.hpp
%include XdmfTopology.hpp
%include XdmfTopologyType.hpp
......@@ -552,6 +552,32 @@ def XdmfGrid_New():
return _Xdmf.XdmfGrid_New()
XdmfGrid_New = _Xdmf.XdmfGrid_New
class XdmfTopology(XdmfItem):
__swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value)
__swig_getmethods__ = {}
for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfTopology_New
if _newclass:New = staticmethod(_Xdmf.XdmfTopology_New)
def getTopologyType(self): return _Xdmf.XdmfTopology_getTopologyType(self)
def setTopologyType(self, *args): return _Xdmf.XdmfTopology_setTopologyType(self, *args)
def getNumberElements(self): return _Xdmf.XdmfTopology_getNumberElements(self)
def setNumberElements(self, *args): return _Xdmf.XdmfTopology_setNumberElements(self, *args)
def getTopologyTypeAsString(self): return _Xdmf.XdmfTopology_getTopologyTypeAsString(self)
def getNodesPerElement(self): return _Xdmf.XdmfTopology_getNodesPerElement(self)
def printSelf(self): return _Xdmf.XdmfTopology_printSelf(self)
def write(self, *args): return _Xdmf.XdmfTopology_write(self, *args)
XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister
XdmfTopology_swigregister(XdmfTopology)
def XdmfTopology_New():
return _Xdmf.XdmfTopology_New()
XdmfTopology_New = _Xdmf.XdmfTopology_New
class XdmfTopologyType(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopologyType, name, value)
......@@ -721,31 +747,5 @@ def XdmfTopologyType_ThreeDCoRectMesh():
return _Xdmf.XdmfTopologyType_ThreeDCoRectMesh()
XdmfTopologyType_ThreeDCoRectMesh = _Xdmf.XdmfTopologyType_ThreeDCoRectMesh
class XdmfTopology(XdmfItem):
__swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value)
__swig_getmethods__ = {}
for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfTopology_New
if _newclass:New = staticmethod(_Xdmf.XdmfTopology_New)
def getTopologyType(self): return _Xdmf.XdmfTopology_getTopologyType(self)
def setTopologyType(self, *args): return _Xdmf.XdmfTopology_setTopologyType(self, *args)
def getNumberElements(self): return _Xdmf.XdmfTopology_getNumberElements(self)
def setNumberElements(self, *args): return _Xdmf.XdmfTopology_setNumberElements(self, *args)
def getTopologyTypeAsString(self): return _Xdmf.XdmfTopology_getTopologyTypeAsString(self)
def getNodesPerElement(self): return _Xdmf.XdmfTopology_getNodesPerElement(self)
def printSelf(self): return _Xdmf.XdmfTopology_printSelf(self)
def write(self, *args): return _Xdmf.XdmfTopology_write(self, *args)
XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister
XdmfTopology_swigregister(XdmfTopology)
def XdmfTopology_New():
return _Xdmf.XdmfTopology_New()
XdmfTopology_New = _Xdmf.XdmfTopology_New
......@@ -72,4 +72,4 @@ private:
std::string mName;
};
#endif /* XDMFATTRIBUTETYPE_HPP_ */
#endif /* XDMFGEOMETRYTYPE_HPP_ */
This diff is collapsed.
......@@ -8,160 +8,6 @@
#include "XdmfTopology.hpp"
#include "XdmfVisitor.hpp"
// Supported XdmfTopologyTypes
XdmfTopologyType XdmfTopologyType::NoTopologyType()
{
return XdmfTopologyType(0, "NoTopology", NoCellType);
}
XdmfTopologyType XdmfTopologyType::Polyvertex()
{
return XdmfTopologyType(1, "Polyvertex", Linear);
}
XdmfTopologyType XdmfTopologyType::Polyline()
{
return XdmfTopologyType(1, "Polyline", Linear);
}
XdmfTopologyType XdmfTopologyType::Polygon(const int& nodesPerElement)
{
return XdmfTopologyType(nodesPerElement, "Polygon", Linear);
}
XdmfTopologyType XdmfTopologyType::Triangle()
{
return XdmfTopologyType(3, "Triangle", Linear);
}
XdmfTopologyType XdmfTopologyType::Quadrilateral()
{
return XdmfTopologyType(4, "Quadrilateral", Linear);
}
XdmfTopologyType XdmfTopologyType::Tetrahedron()
{
return XdmfTopologyType(4, "Tetrahedron", Linear);
}
XdmfTopologyType XdmfTopologyType::Pyramid()
{
return XdmfTopologyType(5, "Pyramid", Linear);
}
XdmfTopologyType XdmfTopologyType::Wedge()
{
return XdmfTopologyType(6, "Wedge", Linear);
}
XdmfTopologyType XdmfTopologyType::Hexahedron()
{
return XdmfTopologyType(8, "Hexahedron", Linear);
}
XdmfTopologyType XdmfTopologyType::Edge_3()
{
return XdmfTopologyType(3, "Edge_3", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Triangle_6()
{
return XdmfTopologyType(6, "Triangle_6", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Quadrilateral_8()
{
return XdmfTopologyType(8, "Quadrilateral_8", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Tetrahedron_10()
{
return XdmfTopologyType(10, "Tetrahedron_10", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Pyramid_13()
{
return XdmfTopologyType(13, "Pyramid_13", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Wedge_15()
{
return XdmfTopologyType(15, "Wedge_15", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Hexahedron_20()
{
return XdmfTopologyType(20, "Hexahedron_20", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Mixed()
{
return XdmfTopologyType(0, "Mixed", Arbitrary);
}
XdmfTopologyType XdmfTopologyType::TwoDSMesh()
{
return XdmfTopologyType(1, "2DSMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::TwoDRectMesh()
{
return XdmfTopologyType(1, "2DRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::TwoDCoRectMesh()
{
return XdmfTopologyType(1, "2DCoRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDSMesh()
{
return XdmfTopologyType(1, "3DSMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDRectMesh()
{
return XdmfTopologyType(1, "3DRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDCoRectMesh()
{
return XdmfTopologyType(1, "3DCoRectMesh", Structured);
}
XdmfTopologyType::XdmfTopologyType(const XdmfTopologyType& topType):
mNodesPerElement(topType.mNodesPerElement),
mName(topType.mName),
mCellType(topType.mCellType)
{
}
XdmfTopologyType& XdmfTopologyType::operator=(const XdmfTopologyType& topType)
{
if(this != &topType)
{
mNodesPerElement = topType.mNodesPerElement;
mName = topType.mName;
mCellType = topType.mCellType;
}
return *this;
}
int XdmfTopologyType::getNodesPerElement() const
{
return mNodesPerElement;
}
std::string XdmfTopologyType::getName() const
{
return mName;
}
XdmfTopologyType::CellType XdmfTopologyType::getCellType() const
{
return mCellType;
}
XdmfTopology::XdmfTopology() :
mTopologyType(XdmfTopologyType::NoTopologyType()),
mNumberElements(0)
......
......@@ -10,105 +10,7 @@
// Includes
#include "XdmfItem.hpp"
class XdmfTopologyType {
public:
enum CellType {
NoCellType, Linear, Quadratic, Arbitrary, Structured
};
// Supported Xdmf Topology Types
static XdmfTopologyType NoTopologyType();
static XdmfTopologyType Polyvertex();
static XdmfTopologyType Polyline();
static XdmfTopologyType Polygon(const int&);
static XdmfTopologyType Triangle();
static XdmfTopologyType Quadrilateral();
static XdmfTopologyType Tetrahedron();
static XdmfTopologyType Pyramid();
static XdmfTopologyType Wedge();
static XdmfTopologyType Hexahedron();
static XdmfTopologyType Edge_3();
static XdmfTopologyType Triangle_6();
static XdmfTopologyType Quadrilateral_8();
static XdmfTopologyType Tetrahedron_10();
static XdmfTopologyType Pyramid_13();
static XdmfTopologyType Wedge_15();
static XdmfTopologyType Hexahedron_20();
static XdmfTopologyType Mixed();
static XdmfTopologyType TwoDSMesh();
static XdmfTopologyType TwoDRectMesh();
static XdmfTopologyType TwoDCoRectMesh();
static XdmfTopologyType ThreeDSMesh();
static XdmfTopologyType ThreeDRectMesh();
static XdmfTopologyType ThreeDCoRectMesh();
/**
* Get the number of nodes per element associated with this topology type.
*
* @return an int containing number of nodes per element.
*/
int getNodesPerElement() const;
/**
* Get the name of this topology type
*
* @return a string containing the name.
*/
std::string getName() const;
/**
* Get the cell type associated with this topology type
*
* @return a CellType containing the cell type.
*/
CellType getCellType() const;
/*
* Compare two XdmfTopology types for equality.
*
* @param an XdmfTopologyType to compare equality to.
* @return true iff the XdmfTopologyTypes are equal.
*/
bool operator==(const XdmfTopologyType& top) const
{
return mNodesPerElement == top.mNodesPerElement && mName.compare(top.mName) == 0 && mCellType == top.mCellType;
}
/**
* Compare two XdmfTopology types for inequality
*
* @param XdmfTopologyType to compare inequality to.
* @return true iff the XdmfTopologyTypes are not equal.
*/
bool operator!=(const XdmfTopologyType& top) const
{
return !this->operator ==(top);
}
XdmfTopologyType(const XdmfTopologyType&);
XdmfTopologyType& operator=(const XdmfTopologyType&);
protected:
/**
* Protected constructor for XdmfTopologyType. The constructor is protected because all topology types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron()
*/
XdmfTopologyType(const int& nodesPerElement, const std::string& name, const CellType& cellType) :
mNodesPerElement(nodesPerElement),
mName(name),
mCellType(cellType)
{};
private:
int mNodesPerElement;
std::string mName;
CellType mCellType;
};
#include "XdmfTopologyType.hpp"
class XdmfTopology : public XdmfItem {
......
/*
* XdmfTopologyType.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfTopologyType.hpp"
// Supported XdmfTopologyTypes
XdmfTopologyType XdmfTopologyType::NoTopologyType()
{
return XdmfTopologyType(0, "NoTopology", NoCellType);
}
XdmfTopologyType XdmfTopologyType::Polyvertex()
{
return XdmfTopologyType(1, "Polyvertex", Linear);
}
XdmfTopologyType XdmfTopologyType::Polyline()
{
return XdmfTopologyType(1, "Polyline", Linear);
}
XdmfTopologyType XdmfTopologyType::Polygon(const int& nodesPerElement)
{
return XdmfTopologyType(nodesPerElement, "Polygon", Linear);
}
XdmfTopologyType XdmfTopologyType::Triangle()
{
return XdmfTopologyType(3, "Triangle", Linear);
}
XdmfTopologyType XdmfTopologyType::Quadrilateral()
{
return XdmfTopologyType(4, "Quadrilateral", Linear);
}
XdmfTopologyType XdmfTopologyType::Tetrahedron()
{
return XdmfTopologyType(4, "Tetrahedron", Linear);
}
XdmfTopologyType XdmfTopologyType::Pyramid()
{
return XdmfTopologyType(5, "Pyramid", Linear);
}
XdmfTopologyType XdmfTopologyType::Wedge()
{
return XdmfTopologyType(6, "Wedge", Linear);
}
XdmfTopologyType XdmfTopologyType::Hexahedron()
{
return XdmfTopologyType(8, "Hexahedron", Linear);
}
XdmfTopologyType XdmfTopologyType::Edge_3()
{
return XdmfTopologyType(3, "Edge_3", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Triangle_6()
{
return XdmfTopologyType(6, "Triangle_6", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Quadrilateral_8()
{
return XdmfTopologyType(8, "Quadrilateral_8", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Tetrahedron_10()
{
return XdmfTopologyType(10, "Tetrahedron_10", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Pyramid_13()
{
return XdmfTopologyType(13, "Pyramid_13", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Wedge_15()
{
return XdmfTopologyType(15, "Wedge_15", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Hexahedron_20()
{
return XdmfTopologyType(20, "Hexahedron_20", Quadratic);
}
XdmfTopologyType XdmfTopologyType::Mixed()
{
return XdmfTopologyType(0, "Mixed", Arbitrary);
}
XdmfTopologyType XdmfTopologyType::TwoDSMesh()
{
return XdmfTopologyType(1, "2DSMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::TwoDRectMesh()
{
return XdmfTopologyType(1, "2DRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::TwoDCoRectMesh()
{
return XdmfTopologyType(1, "2DCoRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDSMesh()
{
return XdmfTopologyType(1, "3DSMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDRectMesh()
{
return XdmfTopologyType(1, "3DRectMesh", Structured);
}
XdmfTopologyType XdmfTopologyType::ThreeDCoRectMesh()
{
return XdmfTopologyType(1, "3DCoRectMesh", Structured);
}
XdmfTopologyType::XdmfTopologyType(const int& nodesPerElement, const std::string& name, const CellType& cellType) :
mNodesPerElement(nodesPerElement),
mName(name),
mCellType(cellType)
{}
XdmfTopologyType::XdmfTopologyType(const XdmfTopologyType& topologyType):
mNodesPerElement(topologyType.mNodesPerElement),
mName(topologyType.mName),
mCellType(topologyType.mCellType)
{
}
XdmfTopologyType& XdmfTopologyType::operator=(const XdmfTopologyType& topologyType)
{
if(this != &topologyType)
{
mNodesPerElement = topologyType.mNodesPerElement;
mName = topologyType.mName;
mCellType = topologyType.mCellType;
}
return *this;
}
bool XdmfTopologyType::operator==(const XdmfTopologyType& topologyType) const
{
return mNodesPerElement == topologyType.mNodesPerElement && mName.compare(topologyType.mName) == 0 && mCellType == topologyType.mCellType;
}
bool XdmfTopologyType::operator!=(const XdmfTopologyType& topologyType) const
{
return !this->operator==(topologyType);
}
int XdmfTopologyType::getNodesPerElement() const
{
return mNodesPerElement;
}
std::string XdmfTopologyType::getName() const
{
return mName;
}
XdmfTopologyType::CellType XdmfTopologyType::getCellType() const
{
return mCellType;
}
/*
* XdmfTopologyType.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFTOPOLOGYTYPE_HPP_
#define XDMFTOPOLOGYTYPE_HPP_
#include <string>
class XdmfTopologyType {
public:
enum CellType {
NoCellType, Linear, Quadratic, Arbitrary, Structured
};
// Supported Xdmf Topology Types
static XdmfTopologyType NoTopologyType();
static XdmfTopologyType Polyvertex();
static XdmfTopologyType Polyline();
static XdmfTopologyType Polygon(const int&);
static XdmfTopologyType Triangle();
static XdmfTopologyType Quadrilateral();
static XdmfTopologyType Tetrahedron();
static XdmfTopologyType Pyramid();
static XdmfTopologyType Wedge();
static XdmfTopologyType Hexahedron();
static XdmfTopologyType Edge_3();
static XdmfTopologyType Triangle_6();
static XdmfTopologyType Quadrilateral_8();
static XdmfTopologyType Tetrahedron_10();
static XdmfTopologyType Pyramid_13();
static XdmfTopologyType Wedge_15();
static XdmfTopologyType Hexahedron_20();
static XdmfTopologyType Mixed();
static XdmfTopologyType TwoDSMesh();
static XdmfTopologyType TwoDRectMesh();
static XdmfTopologyType TwoDCoRectMesh();
static XdmfTopologyType ThreeDSMesh();
static XdmfTopologyType ThreeDRectMesh();
static XdmfTopologyType ThreeDCoRectMesh();
/**
* Get the number of nodes per element associated with this topology type.
*
* @return an int containing number of nodes per element.
*/
int getNodesPerElement() const;
/**
* Get the name of this topology type
*
* @return a string containing the name.
*/
std::string getName() const;
/**
* Get the cell type associated with this topology type
*
* @return a CellType containing the cell type.
*/
CellType getCellType() const;
/*
* Compare two XdmfTopologyTypes for equality.
*
* @param an XdmfTopologyType to compare equality to.
* @return true iff the XdmfTopologyTypes are equal.
*/
bool operator==(const XdmfTopologyType& topologyType) const;
/**
* Compare two XdmfTopologyTypes for inequality
*
* @param XdmfTopologyType to compare inequality to.
* @return true iff the XdmfTopologyTypes are not equal.
*/
bool operator!=(const XdmfTopologyType& topologyType) const;
XdmfTopologyType(const XdmfTopologyType& topologyType);
XdmfTopologyType& operator=(const XdmfTopologyType& topologyType);
protected:
/**
* Protected constructor for XdmfTopologyType. The constructor is protected because all topology types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron()
*/
XdmfTopologyType(const int& nodesPerElement, const std::string& name, const CellType& cellType);
private:
int mNodesPerElement;
std::string mName;
CellType mCellType;
};
#endif /* XDMFTOPOLOGYTYPE_HPP_ */
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