Back to index

salome-med  6.5.0
Static Public Member Functions | Static Public Attributes
MyFunction< T, U > Class Template Reference

#include <MEDMEM_SWIG_Templates.hxx>

List of all members.

Static Public Member Functions

static void EvalPy2Cpp (const U *coord, T *outputValues)

Static Public Attributes

static PyObject * _pyFunc = 0
static int _nbOfComponent = 0
static int _spaceDim = 0

Detailed Description

template<class T, class U>
class MyFunction< T, U >

Definition at line 65 of file MEDMEM_SWIG_Templates.hxx.


Member Function Documentation

template<class T , class U >
static void MyFunction< T, U >::EvalPy2Cpp ( const U *  coord,
T *  outputValues 
) [inline, static]

Definition at line 70 of file MEDMEM_SWIG_Templates.hxx.

      {
        int i=0,err;
        PyObject * tuple=PyTuple_New(_spaceDim);
          for(i=0;i<_spaceDim;i++)
            {
              err=PyTuple_SetItem(tuple,i,Binding<U>::Traducer(coord[i]));
              if (err != 0)
                throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
            }
          PyObject * function_ret = PyObject_CallObject(_pyFunc,tuple);
          if ( !function_ret )
          {
            throw MEDMEM::MEDEXCEPTION(MEDMEM::STRING("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (possibly wrong nb of arguments that must be equal to space dimension = ")<< _spaceDim << ")");
          }
          err = PyList_Check(function_ret);
          if (!err)
              {
                Py_DECREF(function_ret);
                throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (its return value must be a list");
              }
          int size=PyList_Size(function_ret);
          if (size!=_nbOfComponent)
            {
              Py_DECREF(function_ret);
              throw MEDMEM::MEDEXCEPTION(MEDMEM::STRING("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (its return value must be a list of size equal to _nbOfComponent = ") << _nbOfComponent << ")");
            }
          for(i=0;i<_nbOfComponent;i++)
            {
              PyObject * tmp=PyList_GetItem(function_ret,i);
              err = Binding<T>::Checker(tmp);
              if (!err)
                  {
                    Py_DECREF(function_ret);
                    throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its return value type)");
                  }
              outputValues[i]=Binding<T>::Traducer(tmp);
            }
      }

Member Data Documentation

template<class T , class U >
int MyFunction< T, U >::_nbOfComponent = 0 [static]

Definition at line 68 of file MEDMEM_SWIG_Templates.hxx.

template<class T , class U >
PyObject * MyFunction< T, U >::_pyFunc = 0 [static]

Definition at line 67 of file MEDMEM_SWIG_Templates.hxx.

template<class T , class U >
int MyFunction< T, U >::_spaceDim = 0 [static]

Definition at line 69 of file MEDMEM_SWIG_Templates.hxx.


The documentation for this class was generated from the following file: