Commit 76c7a7f7 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

change numpy dimension type to unsigned int

parent 0602c9bb
...@@ -28,20 +28,30 @@ ...@@ -28,20 +28,30 @@
import_array(); import_array();
%} %}
// below we change the type of dimension of numpy array.
// By default it's an "int", but we have std::vector object returning size()
// method as dimension, and which are of type "unsigned int"
// This may cause a problem with BIG simulations. Indeed a simulation with 1.1 billions particles
// store in a xyz positions array a size of 3.3 billions which overtake size of SIGNED int, which go
// only to 2^31 bits = 2.14 billons !!!!! (damn nasty bug....)
%numpy_typemaps(double, NPY_DOUBLE, unsigned int)
%numpy_typemaps(float , NPY_FLOAT , unsigned int)
%numpy_typemaps(int , NPY_INT , unsigned int)
// getArrayX return 1D numpy float array // getArrayX return 1D numpy float array
%apply ( int* DIM1, float ** ARGOUTVIEW_ARRAY1 ) %apply (unsigned int* DIM1, float ** ARGOUTVIEW_ARRAY1 )
{( int* size, float ** farray )}; {( unsigned int* size, float ** farray )};
//%apply ( int* DIM1, int ** ARGOUTVIEW_ARRAY1 ) //%apply ( int* DIM1, int ** ARGOUTVIEW_ARRAY1 )
// {( int* size, int ** iarray )}; // {( int* size, int ** iarray )};
// getArrayX return 1D numpy double array // getArrayX return 1D numpy double array
%apply ( int* DIM1, double ** ARGOUTVIEW_ARRAY1 ) %apply (unsigned int* DIM1, double ** ARGOUTVIEW_ARRAY1 )
{( int* size, double ** farray )}; {( unsigned int* size, double ** farray )};
// getArrayX return 1D numpy int array // getArrayX return 1D numpy int array
%apply ( int* DIM1, int ** ARGOUTVIEW_ARRAY1 ) %apply (unsigned int* DIM1, int ** ARGOUTVIEW_ARRAY1 )
{( int* size, int ** iarray )}; {( unsigned int* size, int ** iarray )};
// getValueX return float/double/int value // getValueX return float/double/int value
...@@ -56,35 +66,35 @@ ...@@ -56,35 +66,35 @@
//float //float
%rename(getValueF) getData(const std::string,float *); %rename(getValueF) getData(const std::string,float *);
%rename(getArrayF) getData(const std::string,const std::string,int *,float **); %rename(getArrayF) getData(const std::string,const std::string,unsigned int *,float **);
%rename(getArrayF) getData(const std::string,int *,float **); %rename(getArrayF) getData(const std::string,unsigned int *,float **);
//double //double
%rename(getValueF) getData(const std::string,double *); %rename(getValueF) getData(const std::string,double *);
%rename(getArrayF) getData(const std::string,const std::string,int *,double **); %rename(getArrayF) getData(const std::string,const std::string,unsigned int *,double **);
%rename(getArrayF) getData(const std::string,int *, double **); %rename(getArrayF) getData(const std::string,unsigned int *, double **);
//int //int
%rename(getValueI) getData(const std::string,int *); %rename(getValueI) getData(const std::string,int *);
%rename(getArrayI) getData(const std::string,const std::string,int *,int **); %rename(getArrayI) getData(const std::string,const std::string,unsigned int *,int **);
%rename(getArrayI) getData(const std::string,int *,int **); %rename(getArrayI) getData(const std::string,unsigned int *,int **);
%apply (int DIM1 , float * INPLACE_ARRAY1) {( int size, float * farray)}; %apply (unsigned int DIM1 , float * INPLACE_ARRAY1) {(unsigned int size, float * farray)};
%apply (int DIM1 , double* INPLACE_ARRAY1) {( int size, double* farray)}; %apply (unsigned int DIM1 , double* INPLACE_ARRAY1) {(unsigned int size, double* farray)};
%apply (int DIM1 , int * INPLACE_ARRAY1) {( int size, int * iarray)}; %apply (unsigned int DIM1 , int * INPLACE_ARRAY1) {(unsigned int size, int * iarray)};
// rename methods because of overloading limitations with swig c++ // rename methods because of overloading limitations with swig c++
// float // float
%rename(setValueF) setData(const std::string,float); %rename(setValueF) setData(const std::string,float);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string,int ,float *,const bool _addr=false); %rename(setArrayF_do_not_used) setData(const std::string,const std::string,unsigned int ,float *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,int ,float *,const bool _addr=false); %rename(setArrayF_do_not_used) setData(const std::string,unsigned int ,float *,const bool _addr=false);
// double // double
%rename(setValueF) setData(const std::string,double); %rename(setValueF) setData(const std::string,double);
%rename(setArrayF_do_not_used) setData(const std::string,const std::string,int ,double *,const bool _addr=false); %rename(setArrayF_do_not_used) setData(const std::string,const std::string, unsigned int ,double *,const bool _addr=false);
%rename(setArrayF_do_not_used) setData(const std::string,int ,double *,const bool _addr=false); %rename(setArrayF_do_not_used) setData(const std::string,unsigned int ,double *,const bool _addr=false);
// int // int
%rename(setValueI) setData(const std::string,int,const bool _addr=false); %rename(setValueI) setData(const std::string,int,const bool _addr=false);
%rename(setArrayI) setData(const std::string,const std::string,int ,int *,const bool _addr=false); %rename(setArrayI) setData(const std::string,const std::string,unsigned int ,int *,const bool _addr=false);
%rename(setArrayI) setData(const std::string,int ,int *); %rename(setArrayI) setData(const std::string,unsigned int ,int *);
// Parse the original header file // Parse the original header file
%include "uns.h" %include "uns.h"
...@@ -92,14 +102,14 @@ ...@@ -92,14 +102,14 @@
%extend uns::CunsOut2 { %extend uns::CunsOut2 {
// we rewrite setArrayF because numpy array size is different from nbody for 3D arrays // we rewrite setArrayF because numpy array size is different from nbody for 3D arrays
int setArrayF(const std::string comp,const std::string prop, int setArrayF(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr=false) { unsigned int size,T * farray, const bool _addr=false) {
if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3; if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3;
int status = $self->snapshot->setData(comp,prop,size,farray,_addr); int status = $self->snapshot->setData(comp,prop,size,farray,_addr);
return status; return status;
} }
// we rewrite setArrayF because numpy array size is different from nbody for 3D arrays // we rewrite setArrayF because numpy array size is different from nbody for 3D arrays
int setArrayF(const std::string prop, int setArrayF(const std::string prop,
int size,T * farray, const bool _addr=false) { unsigned int size,T * farray, const bool _addr=false) {
if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3; if (prop=="pos" || prop=="vel" || prop=="acc") size /= 3;
int status = $self->snapshot->setData(prop,size,farray,_addr); int status = $self->snapshot->setData(prop,size,farray,_addr);
return status; return status;
......
...@@ -273,7 +273,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -273,7 +273,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
// allocate work arrays // allocate work arrays
ngrida=ngridfile[ilevel][icpu]; ngrida=ngridfile[ilevel][icpu];
if (verbose) { if (verbose) {
std::cerr << "ngrida="<<ngrida<<" nvarg="<<nvarg<<"\n"; //std::cerr << "ngrida="<<ngrida<<" nvarg="<<nvarg<<"\n";
} }
double * xg=NULL, *var=NULL, *varg=NULL; double * xg=NULL, *var=NULL, *varg=NULL;
int * son=NULL; int * son=NULL;
......
...@@ -185,7 +185,7 @@ template <class T> int CunsIn2<T>::nextFrame(const char * _bits) { ...@@ -185,7 +185,7 @@ template <class T> int CunsIn2<T>::nextFrame(const char * _bits) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// getData // getData
template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop, template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop,
int * size,T ** farray) { unsigned int * size,T ** farray) {
T * data=NULL; T * data=NULL;
int nbody=0; int nbody=0;
*size=0; *size=0;
...@@ -201,7 +201,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s ...@@ -201,7 +201,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// getData // getData
template <class T> bool CunsIn2<T>::getData(const std::string prop, template <class T> bool CunsIn2<T>::getData(const std::string prop,
int * size,T ** farray) { unsigned int * size,T ** farray) {
T * data=NULL; T * data=NULL;
int nbody=0; int nbody=0;
*size=0; *size=0;
...@@ -224,7 +224,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string prop,T * fvalue) ...@@ -224,7 +224,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string prop,T * fvalue)
// getData // getData
// int // int
template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop, template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::string prop,
int * size,int ** iarray) { unsigned int * size,int ** iarray) {
int * data=NULL; int * data=NULL;
int nbody=0; int nbody=0;
*size=0; *size=0;
...@@ -240,7 +240,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s ...@@ -240,7 +240,7 @@ template <class T> bool CunsIn2<T>::getData(const std::string comp,const std::s
// getData // getData
// int // int
template <class T> bool CunsIn2<T>::getData(const std::string prop, template <class T> bool CunsIn2<T>::getData(const std::string prop,
int * size,int ** iarray) { unsigned int * size,int ** iarray) {
int * data=NULL; int * data=NULL;
int nbody=0; int nbody=0;
*size=0; *size=0;
...@@ -306,14 +306,14 @@ template <class T> CunsOut2<T>::~CunsOut2() ...@@ -306,14 +306,14 @@ template <class T> CunsOut2<T>::~CunsOut2()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// setData comp prop farray // setData comp prop farray
template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop, template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr) { unsigned int size,T * farray, const bool _addr) {
int status = snapshot->setData(comp,prop,size,farray,_addr); int status = snapshot->setData(comp,prop,size,farray,_addr);
return status; return status;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// setData prop farray // setData prop farray
template <class T> int CunsOut2<T>::setData(const std::string prop, template <class T> int CunsOut2<T>::setData(const std::string prop,
int size,T * farray, const bool _addr) { unsigned int size,T * farray, const bool _addr) {
int status = snapshot->setData(prop,size,farray,_addr); int status = snapshot->setData(prop,size,farray,_addr);
return status; return status;
} }
...@@ -326,14 +326,14 @@ template <class T> int CunsOut2<T>::setData(const std::string prop,T fvalue) { ...@@ -326,14 +326,14 @@ template <class T> int CunsOut2<T>::setData(const std::string prop,T fvalue) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// setData comp prop iarray // setData comp prop iarray
template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop, template <class T> int CunsOut2<T>::setData(const std::string comp,const std::string prop,
int size,int * iarray, const bool _addr) { unsigned int size,int * iarray, const bool _addr) {
int status = snapshot->setData(comp,prop,size,iarray,_addr); int status = snapshot->setData(comp,prop,size,iarray,_addr);
return status; return status;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// setData prop iarray // setData prop iarray
template <class T> int CunsOut2<T>::setData(const std::string prop, template <class T> int CunsOut2<T>::setData(const std::string prop,
int size,int * iarray, const bool _addr) { unsigned int size,int * iarray, const bool _addr) {
int status = snapshot->setData(prop,size,iarray,_addr); int status = snapshot->setData(prop,size,iarray,_addr);
return status; return status;
} }
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
namespace uns { namespace uns {
const std::string VERSION="1.2.0.pre-june-17th-2016"; // UNSIO version const std::string VERSION="1.2.0.pre-November-24th-2016"; // UNSIO version
inline std::string getVersion() { return uns::VERSION; } inline std::string getVersion() { return uns::VERSION; }
...@@ -150,16 +150,16 @@ enum StringData { ...@@ -150,16 +150,16 @@ enum StringData {
int nextFrame(const char * _bits); int nextFrame(const char * _bits);
// T // T
bool getData(const std::string comp,const std::string prop, bool getData(const std::string comp,const std::string prop,
int * size,T ** farray); unsigned int * size,T ** farray);
bool getData(const std::string prop, bool getData(const std::string prop,
int * size,T ** farray); unsigned int * size,T ** farray);
bool getData(const std::string prop,T * fvalue); bool getData(const std::string prop,T * fvalue);
// int // int
bool getData(const std::string comp,const std::string prop, bool getData(const std::string comp,const std::string prop,
int * size,int ** iarray); unsigned int * size,int ** iarray);
bool getData(const std::string prop, bool getData(const std::string prop,
int * size,int ** iarray); unsigned int * size,int ** iarray);
bool getData(const std::string prop,int * ivalue); bool getData(const std::string prop,int * ivalue);
...@@ -230,16 +230,16 @@ typedef CunsIn2<double> CunsInD; ...@@ -230,16 +230,16 @@ typedef CunsIn2<double> CunsInD;
// py wrapper // py wrapper
// setData FLOAT/DOUBLE // setData FLOAT/DOUBLE
int setData(const std::string comp,const std::string prop, int setData(const std::string comp,const std::string prop,
int size,T * farray, const bool _addr=false); unsigned int size,T * farray, const bool _addr=false);
int setData(const std::string prop, int setData(const std::string prop,
int size,T * farray, const bool _addr=false); unsigned int size,T * farray, const bool _addr=false);
int setData(const std::string prop, int setData(const std::string prop,
T fvalue); T fvalue);
// setData INT // setData INT
int setData(const std::string comp,const std::string prop, int setData(const std::string comp,const std::string prop,
int size,int * iarray, const bool _addr=false); unsigned int size,int * iarray, const bool _addr=false);
int setData(const std::string prop, int setData(const std::string prop,
int size,int * iarray, const bool _addr=false); unsigned int size,int * iarray, const bool _addr=false);
int setData(const std::string prop, int setData(const std::string prop,
int ivalue); int ivalue);
......
...@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring) ...@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring)
// return the Component Range Vector belonging to the UNS's object "index" // return the Component Range Vector belonging to the UNS's object "index"
void getCrv(int index) void getCrv(int index)
{ {
assert(index<(unsigned int)unsv.size()); assert((unsigned int)index<unsv.size());
crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange(); crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange();
//ComponentRange::list(crv); //ComponentRange::list(crv);
} }
......
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