Skip to content

Commit

Permalink
fix last fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Perez committed Oct 25, 2024
1 parent 7ce35cd commit ea74dab
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions src/Profiles/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,94 +8,106 @@ using namespace std;
// 1D
double Function_Python1D::valueAt( double time )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, time );
v = PyTools::runPyFunction( py_profile, time );
SMILEI_PY_RELEASE_GIL
return v;
}
double Function_Python1D::valueAt( vector<double>, double time )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, time );
v = PyTools::runPyFunction( py_profile, time );
SMILEI_PY_RELEASE_GIL
return v;
}
double Function_Python1D::valueAt( vector<double> x_cell )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0] );
v = PyTools::runPyFunction( py_profile, x_cell[0] );
SMILEI_PY_RELEASE_GIL
return v;
}

// 2D
double Function_Python2D::valueAt( vector<double> x_cell, double time )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0], time );
v = PyTools::runPyFunction( py_profile, x_cell[0], time );
SMILEI_PY_RELEASE_GIL
return v;
}
double Function_Python2D::valueAt( vector<double> x_cell )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1] );
v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1] );
SMILEI_PY_RELEASE_GIL
return v;
}
// 2D complex
std::complex<double> Function_Python2D::complexValueAt( vector<double> x_cell, double time )
{
std::complex<double> v;
SMILEI_PY_ACQUIRE_GIL
std::complex<double> v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], time );
v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], time );
SMILEI_PY_RELEASE_GIL
return v;
}
std::complex<double> Function_Python2D::complexValueAt( vector<double> x_cell )
{
std::complex<double> v;
SMILEI_PY_ACQUIRE_GIL
std::complex<double> v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1] );
v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1] );
SMILEI_PY_RELEASE_GIL
return v;
}

// 3D
double Function_Python3D::valueAt( vector<double> x_cell, double time )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], time );
v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], time );
SMILEI_PY_RELEASE_GIL
return v;
}
double Function_Python3D::valueAt( vector<double> x_cell )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2] );
v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2] );
SMILEI_PY_RELEASE_GIL
return v;
}
// 3D complex
std::complex<double> Function_Python3D::complexValueAt( vector<double> x_cell, double time )
{
std::complex<double> v;
SMILEI_PY_ACQUIRE_GIL
std::complex<double> v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1], time );
v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1], time );
SMILEI_PY_RELEASE_GIL
return v;
}

// 4D
double Function_Python4D::valueAt( vector<double> x_cell, double time )
{
double v;
SMILEI_PY_ACQUIRE_GIL
double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2], time );
v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2], time );
SMILEI_PY_RELEASE_GIL
return v;
}
// 4D complex
std::complex<double> Function_Python4D::complexValueAt( vector<double> x_cell, double time )
{
std::complex<double> v;
SMILEI_PY_ACQUIRE_GIL
std::complex<double> v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1], x_cell[2], time );
v = PyTools::runPyFunction<std::complex<double>>( py_profile, x_cell[0], x_cell[1], x_cell[2], time );
SMILEI_PY_RELEASE_GIL
return v;
}
Expand All @@ -104,30 +116,34 @@ std::complex<double> Function_Python4D::complexValueAt( vector<double> x_cell, d
#ifdef SMILEI_USE_NUMPY
PyArrayObject *Function_Python1D::valueAt( std::vector<PyArrayObject *> x )
{
PyArrayObject * v;
SMILEI_PY_ACQUIRE_GIL
PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], NULL );
v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], NULL );
SMILEI_PY_RELEASE_GIL
return v;
}
PyArrayObject *Function_Python2D::valueAt( std::vector<PyArrayObject *> x )
{
PyArrayObject * v;
SMILEI_PY_ACQUIRE_GIL
PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL );
v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL );
SMILEI_PY_RELEASE_GIL
return v;
}
PyArrayObject *Function_Python3D::valueAt( std::vector<PyArrayObject *> x )
{
PyArrayObject * v;
SMILEI_PY_ACQUIRE_GIL
PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], NULL );
v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], NULL );
SMILEI_PY_RELEASE_GIL
return v;
}
PyArrayObject *Function_Python2D::complexValueAt( std::vector<PyArrayObject *> x )
{
PyArrayObject *cvalues;
SMILEI_PY_ACQUIRE_GIL
PyObject *values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL );
PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
Py_DECREF( values );
SMILEI_PY_RELEASE_GIL
return cvalues;
Expand All @@ -137,55 +153,61 @@ PyArrayObject *Function_Python2D::complexValueAt( std::vector<PyArrayObject *> x

PyArrayObject *Function_Python1D::valueAt( std::vector<PyArrayObject *>, double time )
{
PyArrayObject * ret;
SMILEI_PY_ACQUIRE_GIL
PyObject *t = PyFloat_FromDouble( time );
PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, t, NULL );
ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, t, NULL );
Py_DECREF( t );
SMILEI_PY_RELEASE_GIL
return ret;
}
PyArrayObject *Function_Python2D::valueAt( std::vector<PyArrayObject *> x, double time )
{
PyArrayObject * ret;
SMILEI_PY_ACQUIRE_GIL
PyObject *t = PyFloat_FromDouble( time );
PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], t, NULL );
ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], t, NULL );
Py_DECREF( t );
SMILEI_PY_RELEASE_GIL
return ret;
}
PyArrayObject *Function_Python3D::valueAt( std::vector<PyArrayObject *> x, double time )
{
PyArrayObject * ret;
SMILEI_PY_ACQUIRE_GIL
PyObject *t = PyFloat_FromDouble( time );
PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], t, NULL );
ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], t, NULL );
Py_DECREF( t );
SMILEI_PY_RELEASE_GIL
return ret;
}
PyArrayObject *Function_Python4D::valueAt( std::vector<PyArrayObject *> x, double time )
{
PyArrayObject * ret;
SMILEI_PY_ACQUIRE_GIL
PyObject *t = PyFloat_FromDouble( time );
PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL );
ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL );
Py_DECREF( t );
SMILEI_PY_RELEASE_GIL
return ret;
}PyArrayObject *Function_Python4D::complexValueAt( std::vector<PyArrayObject *> x, double time )
{
PyArrayObject *cvalues;
SMILEI_PY_ACQUIRE_GIL
PyObject *t = PyFloat_FromDouble( time );
PyObject * values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL );
Py_DECREF( t );
PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
Py_DECREF( values );
SMILEI_PY_RELEASE_GIL
return cvalues;
}
PyArrayObject *Function_Python4D::complexValueAt( std::vector<PyArrayObject *> x, PyArrayObject *t )
{
PyArrayObject *cvalues;
SMILEI_PY_ACQUIRE_GIL
PyObject *values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL );
PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast<char *>("astype"), const_cast<char *>("s"), const_cast<char *>("complex"), NULL );
Py_DECREF( values );
SMILEI_PY_RELEASE_GIL
return cvalues;
Expand Down

0 comments on commit ea74dab

Please sign in to comment.