Commit 9c36e7b4 authored by Jerry Clarke's avatar Jerry Clarke
Browse files

implement XdmfTime::Evaluate()

parent 4f5f0e43
......@@ -937,6 +937,7 @@ class XdmfTime(XdmfElement):
def GetFunction(*args): return _Xdmf.XdmfTime_GetFunction(*args)
def SetFunction(*args): return _Xdmf.XdmfTime_SetFunction(*args)
def SetTimeFromParent(*args): return _Xdmf.XdmfTime_SetTimeFromParent(*args)
def Evaluate(*args): return _Xdmf.XdmfTime_Evaluate(*args)
XdmfTime_swigregister = _Xdmf.XdmfTime_swigregister
XdmfTime_swigregister(XdmfTime)
......
......@@ -4160,7 +4160,47 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfElement_SetElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
SWIGINTERN PyObject *_wrap_XdmfElement_SetElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfElement *arg1 = (XdmfElement *) 0 ;
XdmfXmlNode arg2 = (XdmfXmlNode) 0 ;
XdmfInt32 arg3 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
int val3 ;
int ecode3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfElement_SetElement",&obj0,&obj1,&obj2)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfElement, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfElement_SetElement" "', argument " "1"" of type '" "XdmfElement *""'");
}
arg1 = reinterpret_cast< XdmfElement * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p__xmlNode, 0 | 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfElement_SetElement" "', argument " "2"" of type '" "XdmfXmlNode""'");
}
arg2 = reinterpret_cast< XdmfXmlNode >(argp2);
ecode3 = SWIG_AsVal_int(obj2, &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "XdmfElement_SetElement" "', argument " "3"" of type '" "XdmfInt32""'");
}
arg3 = static_cast< XdmfInt32 >(val3);
result = (XdmfInt32)(arg1)->SetElement(arg2,arg3);
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfElement_SetElement__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfElement *arg1 = (XdmfElement *) 0 ;
XdmfXmlNode arg2 = (XdmfXmlNode) 0 ;
......@@ -4191,6 +4231,57 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfElement_SetElement(PyObject *self, PyObject *args) {
int argc;
PyObject *argv[4];
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 3); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
if (argc == 2) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_XdmfElement_SetElement__SWIG_1(self, args);
}
}
}
if (argc == 3) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfElement, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p__xmlNode, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_int(argv[2], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_XdmfElement_SetElement__SWIG_0(self, args);
}
}
}
}
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfElement_SetElement'.\n Possible C/C++ prototypes are:\n SetElement(XdmfXmlNode,XdmfInt32)\n SetElement(XdmfXmlNode)\n");
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfElement_GetElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfElement *arg1 = (XdmfElement *) 0 ;
......@@ -22931,6 +23022,201 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfTime *arg1 = (XdmfTime *) 0 ;
XdmfGrid *arg2 = (XdmfGrid *) 0 ;
XdmfArray *arg3 = (XdmfArray *) 0 ;
XdmfInt32 arg4 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
void *argp3 = 0 ;
int res3 = 0 ;
int val4 ;
int ecode4 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OOOO:XdmfTime_Evaluate",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'");
}
arg1 = reinterpret_cast< XdmfTime * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'");
}
arg2 = reinterpret_cast< XdmfGrid * >(argp2);
res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 );
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTime_Evaluate" "', argument " "3"" of type '" "XdmfArray *""'");
}
arg3 = reinterpret_cast< XdmfArray * >(argp3);
ecode4 = SWIG_AsVal_int(obj3, &val4);
if (!SWIG_IsOK(ecode4)) {
SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "XdmfTime_Evaluate" "', argument " "4"" of type '" "XdmfInt32""'");
}
arg4 = static_cast< XdmfInt32 >(val4);
result = (XdmfInt32)(arg1)->Evaluate(arg2,arg3,arg4);
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfTime *arg1 = (XdmfTime *) 0 ;
XdmfGrid *arg2 = (XdmfGrid *) 0 ;
XdmfArray *arg3 = (XdmfArray *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
void *argp3 = 0 ;
int res3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OOO:XdmfTime_Evaluate",&obj0,&obj1,&obj2)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'");
}
arg1 = reinterpret_cast< XdmfTime * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'");
}
arg2 = reinterpret_cast< XdmfGrid * >(argp2);
res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_XdmfArray, 0 | 0 );
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "XdmfTime_Evaluate" "', argument " "3"" of type '" "XdmfArray *""'");
}
arg3 = reinterpret_cast< XdmfArray * >(argp3);
result = (XdmfInt32)(arg1)->Evaluate(arg2,arg3);
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfTime *arg1 = (XdmfTime *) 0 ;
XdmfGrid *arg2 = (XdmfGrid *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:XdmfTime_Evaluate",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTime, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTime_Evaluate" "', argument " "1"" of type '" "XdmfTime *""'");
}
arg1 = reinterpret_cast< XdmfTime * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_XdmfGrid, 0 | 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfTime_Evaluate" "', argument " "2"" of type '" "XdmfGrid *""'");
}
arg2 = reinterpret_cast< XdmfGrid * >(argp2);
result = (XdmfInt32)(arg1)->Evaluate(arg2);
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfTime_Evaluate(PyObject *self, PyObject *args) {
int argc;
PyObject *argv[5];
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 4); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
if (argc == 2) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_XdmfTime_Evaluate__SWIG_2(self, args);
}
}
}
if (argc == 3) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_XdmfTime_Evaluate__SWIG_1(self, args);
}
}
}
}
if (argc == 4) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XdmfTime, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_XdmfGrid, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_XdmfArray, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_int(argv[3], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_XdmfTime_Evaluate__SWIG_0(self, args);
}
}
}
}
}
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'XdmfTime_Evaluate'.\n Possible C/C++ prototypes are:\n Evaluate(XdmfGrid *,XdmfArray *,XdmfInt32)\n Evaluate(XdmfGrid *,XdmfArray *)\n Evaluate(XdmfGrid *)\n");
return NULL;
}
SWIGINTERN PyObject *XdmfTime_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
......@@ -23424,6 +23710,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfTime_GetFunction", _wrap_XdmfTime_GetFunction, METH_VARARGS, NULL},
{ (char *)"XdmfTime_SetFunction", _wrap_XdmfTime_SetFunction, METH_VARARGS, NULL},
{ (char *)"XdmfTime_SetTimeFromParent", _wrap_XdmfTime_SetTimeFromParent, METH_VARARGS, NULL},
{ (char *)"XdmfTime_Evaluate", _wrap_XdmfTime_Evaluate, METH_VARARGS, NULL},
{ (char *)"XdmfTime_swigregister", XdmfTime_swigregister, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
......
......@@ -27,6 +27,7 @@
#include "XdmfDOM.h"
#include "XdmfArray.h"
#include "XdmfDataItem.h"
#include "XdmfGrid.h"
XdmfTime::XdmfTime() {
this->SetElementName("Time");
......@@ -149,6 +150,70 @@ XdmfInt32 XdmfTime::Build(){
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfTime::Evaluate(XdmfGrid *Grid, XdmfArray *ArrayToFill, XdmfInt32 Append){
XdmfInt64 i, n, nelements;
XdmfTime *gt;
if(!ArrayToFill){
XdmfErrorMessage("Array to fill is NULL");
return(XDMF_FAIL);
}
if(Append){
nelements = ArrayToFill->GetNumberOfElements();
}else{
nelements = 0;
}
gt = Grid->GetTime();
if(gt){
switch(gt->GetTimeType()){
case XDMF_TIME_SINGLE :
nelements += 1;
ArrayToFill->SetNumberOfElements(nelements);
ArrayToFill->SetValueFromFloat64(nelements - 1, gt->GetValue());
// cout << "Setting val " << nelements - 1 << " = " << gt->GetValue() << endl;
break;
case XDMF_TIME_RANGE :
case XDMF_TIME_LIST :
// cout << "Adding " << gt->GetArray()->GetValues() << endl;
n = gt->GetArray()->GetNumberOfElements();
nelements += n;
ArrayToFill->SetNumberOfElements(nelements);
for(i=0 ; i < n ; i++){
ArrayToFill->SetValueFromFloat64(nelements - n + i, gt->GetArray()->GetValueAsFloat64(i));
}
// cout << "Array = " << ArrayToFill->GetValues() << endl;
break;
case XDMF_TIME_HYPERSLAB :
n = gt->GetArray()->GetValueAsInt64(2);
nelements += n;
ArrayToFill->SetNumberOfElements(nelements);
for(i=0 ; i < n ; i++){
ArrayToFill->SetValueFromFloat64(nelements - n + i,
gt->GetArray()->GetValueAsFloat64(0) + (gt->GetArray()->GetValueAsFloat64(1) * i));
}
// cout << "Array = " << ArrayToFill->GetValues() << endl;
break;
default :
break;
}
}
for(i=0 ; i < Grid->GetNumberOfChildren() ; i++){
// Append children's times
if(this->Evaluate(Grid->GetChild(i), ArrayToFill, 1) != XDMF_SUCCESS) return(XDMF_FAIL);
}
if(this->TimeType == XDMF_TIME_RANGE) {
XdmfFloat64 minval, maxval;
minval = ArrayToFill->GetMinAsFloat64();
maxval = ArrayToFill->GetMaxAsFloat64();
ArrayToFill->SetNumberOfElements(2);
ArrayToFill->SetValueFromFloat64(0, minval);
ArrayToFill->SetValueFromFloat64(1, maxval);
}
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfTime::SetTimeFromParent(XdmfTime *ParentTime, XdmfInt64 Index){
XdmfArray *TimeArray;
......@@ -172,15 +237,19 @@ XdmfTime::SetTimeFromParent(XdmfTime *ParentTime, XdmfInt64 Index){
this->Value = TimeArray->GetValueAsFloat64(0) + (TimeArray->GetValueAsFloat64(1) * Index);
XdmfDebug("Setting Time Value to " << this->Value);
break;
case XDMF_TIME_LIST:
case XDMF_TIME_LIST :
TimeArray = ParentTime->GetArray();
if(!TimeArray){
XdmfErrorMessage("TimeType is List but there is no array");
return(XDMF_FAIL);
}
this->TimeType = XDMF_TIME_SINGLE;
this->Value = TimeArray->GetValueAsFloat64(Index);
XdmfDebug("Setting Time Value to " << this->Value);
this->SetValue(TimeArray->GetValueAsFloat64(Index));
XdmfDebug("Setting Time Value to " << this->GetValue());
break;
case XDMF_TIME_RANGE :
this->TimeType = XDMF_TIME_RANGE;
this->Array = ParentTime->GetArray();
break;
default :
XdmfErrorMessage("Unknown or Invalid TimeType");
......
......@@ -100,6 +100,8 @@ public:
XdmfSetStringMacro(Function);
//! Set Time From Parent Information
XdmfInt32 SetTimeFromParent(XdmfTime *ParentTime, XdmfInt64 Index);
//! Fills in the sets of times that a particular grid is valid.
XdmfInt32 Evaluate(XdmfGrid *Grid, XdmfArray *ArrayToFill = NULL, XdmfInt32 Append = 0);
protected:
XdmfInt32 TimeType;
XdmfFloat64 Value;
......
Supports Markdown
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