Commit 20c84d1e authored by Kenneth Leiter's avatar Kenneth Leiter
Browse files

ENH: Add several topologies to Xdmf, including XDMF_HEX_24 and XDMF_HEX_27. ...

ENH: Add several topologies to Xdmf, including XDMF_HEX_24 and XDMF_HEX_27.  Modify Exodus Reader and VTK Reader to correctly assign new topology types.
parent e2f2ed50
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.39
# Version 1.3.37
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
......@@ -10,18 +10,12 @@ if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_Xdmf', [dirname(__file__)])
except ImportError:
import _Xdmf
return _Xdmf
if fp is not None:
try:
_mod = imp.load_module('_Xdmf', fp, pathname, description)
finally:
fp.close()
return _mod
_mod = imp.load_module('_Xdmf', fp, pathname, description)
finally:
if fp is not None: fp.close()
return _mod
_Xdmf = swig_import_helper()
del swig_import_helper
else:
......@@ -67,6 +61,7 @@ except AttributeError:
_FILE_OFFSET_BITS = _Xdmf._FILE_OFFSET_BITS
SIZEOF_LONG_LONG = _Xdmf.SIZEOF_LONG_LONG
XDMF_VERSION = _Xdmf.XDMF_VERSION
XDMF_VERSION_STRING = _Xdmf.XDMF_VERSION_STRING
XDMF_SUCCESS = _Xdmf.XDMF_SUCCESS
......@@ -934,7 +929,10 @@ XDMF_QUAD_8 = _Xdmf.XDMF_QUAD_8
XDMF_TET_10 = _Xdmf.XDMF_TET_10
XDMF_PYRAMID_13 = _Xdmf.XDMF_PYRAMID_13
XDMF_WEDGE_15 = _Xdmf.XDMF_WEDGE_15
XDMF_WEDGE_18 = _Xdmf.XDMF_WEDGE_18
XDMF_HEX_20 = _Xdmf.XDMF_HEX_20
XDMF_HEX_24 = _Xdmf.XDMF_HEX_24
XDMF_HEX_27 = _Xdmf.XDMF_HEX_27
XDMF_MIXED = _Xdmf.XDMF_MIXED
XDMF_2DSMESH = _Xdmf.XDMF_2DSMESH
XDMF_2DRECTMESH = _Xdmf.XDMF_2DRECTMESH
......
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.39
* Version 1.3.37
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
......@@ -143,28 +143,11 @@ template <typename T> T SwigValueInit() {
# define _SCL_SECURE_NO_DEPRECATE
#endif
 
/* Python.h has to appear first */
/* The following logic gets around the python library linking error while building
* Debug version of the Xdmf library with visual studio, which is a well-know python "bug/feature"
* If python wrapping is on, and XDMF_REGENERATE_WRAPPER is turned on in CMake,
* the generated XdmfPython.cxx in binary directory needs to be modified as follows
* to get around the link error. */
#if defined(WIN32)
# ifdef _DEBUG
# undef _DEBUG
# if defined(_MSC_VER) && _MSC_VER >= 1400
# define _CRT_NOFORCE_MANIFEST 1
# endif
# include <Python.h>
# define _DEBUG
# else
# include <Python.h>
# endif
#else
# include <Python.h>
#endif
 
 
/* Python.h has to appear first */
#include <Python.h>
/* -----------------------------------------------------------------------------
* swigrun.swg
*
......@@ -789,35 +772,17 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
# define SWIG_Python_str_FromFormat PyString_FromFormat
#endif
 
/* Warning: This function will allocate a new string in Python 3,
* so please call SWIG_Python_str_DelForPy3(x) to free the space.
*/
SWIGINTERN char*
SWIG_Python_str_AsChar(PyObject *str)
{
#if PY_VERSION_HEX >= 0x03000000
char *cstr;
char *newstr;
int len;
str = PyUnicode_AsUTF8String(str);
PyBytes_AsStringAndSize(str, &cstr, &len);
newstr = (char *) malloc(len+1);
memcpy(newstr, cstr, len+1);
Py_XDECREF(str);
return newstr;
return PyBytes_AsString(str);
#else
return PyString_AsString(str);
#endif
}
 
#if PY_VERSION_HEX >= 0x03000000
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#else
# define SWIG_Python_str_DelForPy3(x)
#endif
SWIGINTERN PyObject*
SWIG_Python_str_FromChar(const char *c)
{
......@@ -972,13 +937,11 @@ SWIG_Python_AddErrorMsg(const char* mesg)
 
if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
if (value) {
char *tmp;
PyObject *old_str = PyObject_Str(value);
PyErr_Clear();
Py_XINCREF(type);
 
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
SWIG_Python_str_DelForPy3(tmp);
PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg);
Py_DECREF(old_str);
Py_DECREF(value);
} else {
......@@ -1513,16 +1476,13 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
SWIGRUNTIME int
SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
char *str;
#ifdef METH_NOARGS
PyObject *repr = SwigPyObject_repr(v);
#else
PyObject *repr = SwigPyObject_repr(v, NULL);
#endif
if (repr) {
str = SWIG_Python_str_AsChar(repr);
fputs(str, fp);
SWIG_Python_str_DelForPy3(str);
fputs(SWIG_Python_str_AsChar(repr), fp);
Py_DECREF(repr);
return 0;
} else {
......@@ -1769,11 +1729,7 @@ _PySwigObject_type(void) {
0, /*nb_coerce*/
#endif
(unaryfunc)SwigPyObject_long, /*nb_int*/
#if PY_VERSION_HEX < 0x03000000
(unaryfunc)SwigPyObject_long, /*nb_long*/
#else
0, /*nb_reserved*/
#endif
(unaryfunc)0, /*nb_float*/
#if PY_VERSION_HEX < 0x03000000
(unaryfunc)SwigPyObject_oct, /*nb_oct*/
......@@ -1813,11 +1769,7 @@ _PySwigObject_type(void) {
(getattrfunc)0, /* tp_getattr */
#endif
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03000000
0, /* tp_reserved in 3.0.1 */
#else
(cmpfunc)SwigPyObject_compare, /* tp_compare */
#endif
(cmpfunc)SwigPyObject_compare, /* tp_compare */
(reprfunc)SwigPyObject_repr, /* tp_repr */
&SwigPyObject_as_number, /* tp_as_number */
0, /* tp_as_sequence */
......@@ -1988,18 +1940,14 @@ _PySwigPacked_type(void) {
(printfunc)SwigPyPacked_print, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX>=0x03000000
0, /* tp_reserved in 3.0.1 */
#else
(cmpfunc)SwigPyPacked_compare, /* tp_compare */
#endif
(reprfunc)SwigPyPacked_repr, /* tp_repr */
0, /* tp_as_number */
(cmpfunc)SwigPyPacked_compare, /* tp_compare */
(reprfunc)SwigPyPacked_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)SwigPyPacked_str, /* tp_str */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)SwigPyPacked_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
......@@ -2343,6 +2291,7 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
} else {
#if PY_VERSION_HEX >= 0x03000000
inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
Py_INCREF(data->newargs);
PyObject_SetAttr(inst, SWIG_This(), swig_this);
Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
#else
......@@ -2583,23 +2532,21 @@ SWIG_Python_TypeQuery(const char *type)
 
SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
char *tmp;
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
PyErr_Format(type, "%s %s", mesg, SWIG_Python_str_AsChar(old_str));
} else {
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg);
}
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
}
return 1;
......@@ -2651,7 +2598,6 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
SWIG_Python_str_DelForPy3(cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
......@@ -2673,12 +2619,10 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
PyErr_Clear();
#if SWIG_POINTER_EXCEPTION
if (flags) {
if (flags & SWIG_POINTER_EXCEPTION) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
#endif
}
return result;
}
......@@ -2775,7 +2719,7 @@ static swig_module_info swig_module = {swig_types, 49, 0, 0, 0, 0};
#endif
#define SWIG_name "_Xdmf"
 
#define SWIGVERSION 0x010339
#define SWIGVERSION 0x010337
#define SWIG_VERSION SWIGVERSION
 
 
......@@ -3134,27 +3078,19 @@ SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
{
#if PY_VERSION_HEX>=0x03000000
if (PyUnicode_Check(obj))
if (PyUnicode_Check(obj))
#else
if (PyString_Check(obj))
if (PyString_Check(obj))
#endif
{
char *cstr; Py_ssize_t len;
#if PY_VERSION_HEX>=0x03000000
if (!alloc && cptr) {
/* We can't allow converting without allocation, since the internal
representation of string in Python 3 is UCS-2/UCS-4 but we require
a UTF-8 representation.
TODO(bhy) More detailed explanation */
return SWIG_RuntimeError;
}
obj = PyUnicode_AsUTF8String(obj);
PyBytes_AsStringAndSize(obj, &cstr, &len);
if(alloc) *alloc = SWIG_NEWOBJ;
#else
PyString_AsStringAndSize(obj, &cstr, &len);
#endif
if (cptr) {
if (cptr) {
if (alloc) {
/*
In python the user should not be able to modify the inner
......@@ -3179,16 +3115,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
*alloc = SWIG_OLDOBJ;
}
} else {
#if PY_VERSION_HEX>=0x03000000
assert(0); /* Should never reach here in Python 3 */
#endif
*cptr = SWIG_Python_str_AsChar(obj);
}
}
if (psize) *psize = len + 1;
#if PY_VERSION_HEX>=0x03000000
Py_XDECREF(obj);
#endif
return SWIG_OK;
} else {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
......@@ -33576,11 +33506,9 @@ extern "C" {
SWIGINTERN int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
char *tmp;
PyObject *str = swig_varlink_str(v);
fprintf(fp,"Swig global variables ");
fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
SWIG_Python_str_DelForPy3(tmp);
fprintf(fp,"%s\n", SWIG_Python_str_AsChar(str));
Py_DECREF(str);
return 0;
}
......@@ -33816,7 +33744,10 @@ PyObject*
void
#endif
SWIG_init(void) {
PyObject *m, *d;
PyObject *m, *d;
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef SWIG_module = {
PyModuleDef_HEAD_INIT,
......@@ -33829,12 +33760,7 @@ SWIG_init(void) {
NULL,
NULL
};
#endif
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&SWIG_module);
#else
m = Py_InitModule((char *) SWIG_name, SwigMethods);
......@@ -33846,6 +33772,7 @@ SWIG_init(void) {
SWIG_Python_SetConstant(d, "_FILE_OFFSET_BITS",SWIG_From_int(static_cast< int >(64)));
SWIG_Python_SetConstant(d, "SIZEOF_LONG_LONG",SWIG_From_int(static_cast< int >(8)));
SWIG_Python_SetConstant(d, "XDMF_VERSION",SWIG_From_double(static_cast< double >(2.1)));
SWIG_Python_SetConstant(d, "XDMF_VERSION_STRING",SWIG_FromCharPtr("2.1"));
SWIG_Python_SetConstant(d, "XDMF_SUCCESS",SWIG_From_int(static_cast< int >(1)));
......@@ -33918,7 +33845,10 @@ SWIG_init(void) {
SWIG_Python_SetConstant(d, "XDMF_TET_10",SWIG_From_int(static_cast< int >(0x0026)));
SWIG_Python_SetConstant(d, "XDMF_PYRAMID_13",SWIG_From_int(static_cast< int >(0x0027)));
SWIG_Python_SetConstant(d, "XDMF_WEDGE_15",SWIG_From_int(static_cast< int >(0x0028)));
SWIG_Python_SetConstant(d, "XDMF_HEX_20",SWIG_From_int(static_cast< int >(0x0029)));
SWIG_Python_SetConstant(d, "XDMF_WEDGE_18",SWIG_From_int(static_cast< int >(0x0029)));
SWIG_Python_SetConstant(d, "XDMF_HEX_20",SWIG_From_int(static_cast< int >(0x0030)));
SWIG_Python_SetConstant(d, "XDMF_HEX_24",SWIG_From_int(static_cast< int >(0x0031)));
SWIG_Python_SetConstant(d, "XDMF_HEX_27",SWIG_From_int(static_cast< int >(0x0032)));
SWIG_Python_SetConstant(d, "XDMF_MIXED",SWIG_From_int(static_cast< int >(0x0070)));
SWIG_Python_SetConstant(d, "XDMF_2DSMESH",SWIG_From_int(static_cast< int >(0x0100)));
SWIG_Python_SetConstant(d, "XDMF_2DRECTMESH",SWIG_From_int(static_cast< int >(0x0101)));
......@@ -186,10 +186,16 @@ if ( XDMF_WORD_CMP( topologyType, "NOTOPOLOGY") ){
newTopologyType = XDMF_PYRAMID_13;
} else if( XDMF_WORD_CMP( topologyType, "WEDGE_15") ){
newTopologyType = XDMF_WEDGE_15;
} else if( XDMF_WORD_CMP( topologyType, "WEDGE_18") ){
newTopologyType = XDMF_WEDGE_18;
} else if( XDMF_WORD_CMP( topologyType, "HEX_20") ){
newTopologyType = XDMF_HEX_20;
} else if( XDMF_WORD_CMP( topologyType, "HEXAHEDRON_20") ){
newTopologyType = XDMF_HEX_20;
} else if( XDMF_WORD_CMP( topologyType, "HEXAHEDRON_24") ){
newTopologyType = XDMF_HEX_24;
} else if( XDMF_WORD_CMP( topologyType, "HEXAHEDRON_27") ){
newTopologyType = XDMF_HEX_27;
} else if( XDMF_WORD_CMP( topologyType, "MIXED") ){
newTopologyType = XDMF_MIXED;
} else if( XDMF_WORD_CMP( topologyType, "2DSMESH") ){
......@@ -249,8 +255,14 @@ XdmfTopology::GetTopologyTypeAsString( void ) {
return("Pyramid_13");
case XDMF_WEDGE_15 :
return("Wedge_15");
case XDMF_WEDGE_18 :
return("Wedge_18");
case XDMF_HEX_20 :
return("Hexahedron_20");
case XDMF_HEX_24 :
return("Hexahedron_24");
case XDMF_HEX_27 :
return("Hexahedron_27");
case XDMF_MIXED :
return("Mixed");
case XDMF_2DSMESH :
......@@ -324,9 +336,18 @@ XdmfInt32 nodesPerElement = 0;
case XDMF_WEDGE_15 :
nodesPerElement = 15;
break;
case XDMF_WEDGE_18 :
nodesPerElement = 18;
break;
case XDMF_HEX_20 :
nodesPerElement = 20;
break;
case XDMF_HEX_24 :
nodesPerElement = 24;
break;
case XDMF_HEX_27 :
nodesPerElement = 27;
break;
case XDMF_MIXED :
nodesPerElement = 0;
break;
......@@ -494,9 +515,18 @@ if(this->TopologyType == XDMF_MIXED){
case XDMF_WEDGE_15 :
npe = 15;
break;
case XDMF_WEDGE_18 :
npe = 18;
break;
case XDMF_HEX_20 :
npe = 20;
break;
case XDMF_HEX_24 :
npe = 24;
break;
case XDMF_HEX_27 :
npe = 27;
break;
default :
XdmfErrorMessage("Unknown Cell Type = " << celltype);
break;
......
......@@ -50,7 +50,10 @@
#define XDMF_TET_10 0x0026
#define XDMF_PYRAMID_13 0x0027
#define XDMF_WEDGE_15 0x0028
#define XDMF_HEX_20 0x0029
#define XDMF_WEDGE_18 0x0029
#define XDMF_HEX_20 0x0030
#define XDMF_HEX_24 0x0031
#define XDMF_HEX_27 0x0032
#define XDMF_MIXED 0x0070
#define XDMF_2DSMESH 0x0100
#define XDMF_2DRECTMESH 0x0101
......@@ -81,8 +84,11 @@ Currently supported BASE topologies are :
QUADRILATERAL_8 ..... 8 Node High Order Quadrilateral
TETRAHEDRON_10 ...... 10 Node High Order Tetrahedron
PYRAMID_13 .......... 13 Node High Order Pyramid
WEDGE_15 ............ 15 Node High Order Wedge
HEXAHEDRON_20 ....... 20 Node High Order Hexahedron
WEDGE_15 ............ 15 Node High Order Wedge (Quadratic Wedge)
WEDGE_18 ............ 18 Node High Order Wedge (Bi-Quadratic Wedge)
HEXAHEDRON_20 ....... 20 Node High Order Hexahedron (Quadratic Hexahedron)
HEXAHEDRON_24 ....... 24 Node High Order Hexahedron (Bi-Quadratic Hexahedron)
HEXAHEDRON_27 ....... 27 Node High Order Hexahedron (Tri-Quadratic Hexahedron)
MIXED ............... A Mixture of Unstructured Base Topologies
2DSMESH ............. General ( Curved )
2DRECTMESH .......... Rectilinear
......@@ -128,8 +134,8 @@ Currently supported BASE topologies are :
XML Attribute : Name = Any String
XML Attribute : TopologyType = Polyvertex | Polyline | Polygon |
Triangle | Quadrilateral | Tetrahedron | Pyramid| Wedge | Hexahedron |
Edge_3 | Triagle_6 | Quadrilateral_8 | Tetrahedron_10 | Pyramid_13 |
Wedge_15 | Hexahedron_20 |
Edge_3 | Triangle_6 | Quadrilateral_8 | Tetrahedron_10 | Pyramid_13 |
Wedge_15 | Wedge_18 | Hexahedron_20 | Hexahedron_24 | Hexahedron_27 |
Mixed |
2DSMesh | 2DRectMesh | 2DCoRectMesh |
3DSMesh | 3DRectMesh | 3DCoRectMesh
......
......@@ -96,9 +96,7 @@ XdmfInt32 XdmfExodusReader::DetermineXdmfCellType(char * exoElemType, int numPoi
}
else if (elemType.substr(0,3) == "HEX" && numPointsPerCell == 27)
{
// VTK_TRIQUADRATIC_HEXAHEDRON;
// Currently unsupported in Xdmf
return XDMF_NOTOPOLOGY;
return XDMF_HEX_27;
}
else if (elemType.substr(0,3) == "QUA" && numPointsPerCell == 8)
{
......@@ -330,7 +328,7 @@ XdmfGrid * XdmfExodusReader::read(const char * fileName, XdmfElement * parentEle
}
// This is taken from VTK's vtkExodusIIReader and adapted to fit Xdmf element types, which have the same ordering as VTK.
if(topType == XDMF_HEX_20)
if(topType == XDMF_HEX_20 || topType == XDMF_HEX_27)
{
int * ptr = conn;
int k;
......@@ -351,9 +349,21 @@ XdmfGrid * XdmfExodusReader::read(const char * fileName, XdmfElement * parentEle
{
*ptr = itmp[k];
}
if(topType == XDMF_HEX_27)
{
for ( k = 0; k < 4; ++k, ++ptr )
{
itmp[k] = *ptr;
*ptr = ptr[3];
}
*(ptr++) = itmp[1];
*(ptr++) = itmp[2];
*(ptr++) = itmp[0];
}
}
}
else if (topType == XDMF_WEDGE_15)
else if (topType == XDMF_WEDGE_15 || topType == XDMF_WEDGE_18)
{
int * ptr = conn;
int k;
......@@ -374,6 +384,16 @@ XdmfGrid * XdmfExodusReader::read(const char * fileName, XdmfElement * parentEle
{
*ptr = itmp[k];
}
if(topType == XDMF_WEDGE_18)
{
itmp[0] = *(ptr);
itmp[1] = *(ptr+1);
itmp[2] = *(ptr+2);
*(ptr++) = itmp[1];
*(ptr++) = itmp[2];
*(ptr++) = itmp[0];
}
}
}
......
......@@ -483,7 +483,10 @@ int vtkXdmfDomain::GetDataDimensionality(XdmfGrid* xmfGrid)
case XDMF_TET_10 :
case XDMF_PYRAMID_13 :
case XDMF_WEDGE_15 :
case XDMF_WEDGE_18 :
case XDMF_HEX_20 :
case XDMF_HEX_24 :
case XDMF_HEX_27 :
case XDMF_MIXED :
return 1; // unstructured data-sets have no inherent dimensionality.
......
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