Changeset 18453
- Timestamp:
- 08/21/14 09:20:51 (11 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/bamg/Mesh.cpp
r18064 r18453 227 227 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/ 228 228 229 //if(vertices) delete [] vertices;230 if 231 if 232 if 233 //if (orderedvertices)delete [] orderedvertices;234 if 235 if 236 if 237 if 238 if 239 240 if (&Gh){229 if(vertices) delete [] vertices; 230 if(edges) delete [] edges; 231 if(triangles) delete [] triangles; 232 if(quadtree) delete quadtree; 233 if(orderedvertices) delete [] orderedvertices; 234 if(subdomains) delete [] subdomains; 235 if(VerticesOnGeomEdge) delete [] VerticesOnGeomEdge; 236 if(VerticesOnGeomVertex) delete [] VerticesOnGeomVertex; 237 if(VertexOnBThVertex) delete [] VertexOnBThVertex; 238 if(VertexOnBThEdge) delete [] VertexOnBThEdge; 239 240 if(&Gh){ 241 241 if (Gh.NbRef>0) Gh.NbRef--; 242 242 else if (Gh.NbRef==0) delete &Gh; 243 243 } 244 if (&BTh && (&BTh != this)){244 if(&BTh && (&BTh != this)){ 245 245 if (BTh.NbRef>0) BTh.NbRef--; 246 246 else if (BTh.NbRef==0) delete &BTh; … … 2726 2726 2727 2727 /*Allocate if maxnbv_in>0*/ 2728 if (maxnbv_in){2728 if(maxnbv_in){ 2729 2729 vertices=new BamgVertex[maxnbv]; 2730 2730 _assert_(vertices); … … 2734 2734 _assert_(triangles); 2735 2735 } 2736 else 2736 else{ 2737 2737 vertices=NULL; 2738 2738 orderedvertices=NULL; -
issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r16521 r18453 49 49 50 50 /*read background mesh*/ 51 Mesh Th(index_data,x_data,y_data,nods_data,nels_data);51 Mesh* Th=new Mesh(index_data,x_data,y_data,nods_data,nels_data); 52 52 53 53 /*Get reference number (for subdomains)*/ 54 long* reft = xNew<long>(Th .nbt);55 Th .TriangleReferenceList(reft);56 Th .CreateSingleVertexToTriangleConnectivity();54 long* reft = xNew<long>(Th->nbt); 55 Th->TriangleReferenceList(reft); 56 Th->CreateSingleVertexToTriangleConnectivity(); 57 57 58 58 /*Get domain boundaries*/ … … 79 79 /*Get current point coordinates*/ 80 80 r.x=x_interp[i]; r.y=y_interp[i]; 81 I2 I=Th .R2ToI2(r);81 I2 I=Th->R2ToI2(r); 82 82 83 83 /*Find triangle holding r/I*/ 84 Triangle &tb=*Th .TriangleFindFromCoord(I,dete);84 Triangle &tb=*Th->TriangleFindFromCoord(I,dete); 85 85 86 86 /*point inside convex*/ … … 92 92 areacoord[2]= (double) dete[2]/tb.det; 93 93 /*3 vertices of the triangle*/ 94 i0=Th .GetId(tb[0]);95 i1=Th .GetId(tb[1]);96 i2=Th .GetId(tb[2]);94 i0=Th->GetId(tb[0]); 95 i1=Th->GetId(tb[1]); 96 i2=Th->GetId(tb[2]); 97 97 /*triangle number*/ 98 it=Th .GetId(tb);98 it=Th->GetId(tb); 99 99 100 100 /*Inside convex but outside mesh*/ … … 120 120 areacoord[OppositeVertex[k]] = 1 - aa -bb; 121 121 //3 vertices of the triangle 122 i0=Th .GetId(tc[0]);123 i1=Th .GetId(tc[1]);124 i2=Th .GetId(tc[2]);122 i0=Th->GetId(tc[0]); 123 i1=Th->GetId(tc[1]); 124 i2=Th->GetId(tc[2]); 125 125 //triangle number 126 it=Th .GetId(tc);126 it=Th->GetId(tc); 127 127 } 128 128 } … … 145 145 146 146 /*clean-up and return*/ 147 delete Th; 147 148 xDelete<long>(reft); 148 149 *pdata_interp=data_interp; -
issm/trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
r15105 r18453 76 76 77 77 /*end module: */ 78 xDelete<int>(index); 79 xDelete<double>(x_data); 80 xDelete<double>(y_data); 81 xDelete<double>(data); 82 xDelete<double>(x_interp); 83 xDelete<double>(y_interp); 84 xDelete<double>(data_interp); 85 delete options; 78 86 MODULEEND(); 79 87 } -
issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
r15165 r18453 35 35 PyObject* array=NULL; 36 36 37 dims[0]=(npy_intp)M; 38 dims[1]=(npy_intp)N; 39 array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix); 37 /*copy matrix: */ 38 double* matrix_python=xNew<double>(M*N); 39 memcpy(matrix_python,matrix,M*N*sizeof(double)); 40 41 dims[0]=(npy_intp)M; 42 dims[1]=(npy_intp)N; 43 array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix_python); 40 44 41 45 PyTuple_SetItem(tuple, index, array); … … 47 51 PyObject* array=NULL; 48 52 49 /*intermediary:*/50 long* lmatrix=NULL;51 int i;52 53 53 /*transform into long matrix: */ 54 l matrix=xNew<long>(M*N);55 for(i =0;i<M*N;i++)lmatrix[i]=(long)matrix[i];54 long* lmatrix=xNew<long>(M*N); 55 for(int i=0;i<M*N;i++)lmatrix[i]=(long)matrix[i]; 56 56 57 57 dims[0]=(npy_intp)M; … … 67 67 PyObject* array=NULL; 68 68 69 dims[0]=(npy_intp)M; 70 dims[1]=(npy_intp)N; 71 array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix); 69 /*copy matrix: */ 70 bool* matrix_python=xNew<bool>(M*N); 71 memcpy(matrix_python,matrix,M*N*sizeof(bool)); 72 73 dims[0]=(npy_intp)M; 74 dims[1]=(npy_intp)N; 75 array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix_python); 72 76 73 77 PyTuple_SetItem(tuple, index, array); … … 76 80 void WriteData(PyObject* py_tuple, int index, double* vector, int M){ 77 81 78 double *buffer = NULL;79 82 npy_intp dim = 10; 80 83 PyObject *array = NULL; 81 84 82 /*Copy vector*/ 83 buffer=xNew<double>(M); 84 for(int i=0;i<M;i++)buffer[i]=vector[i]; 85 86 /*copy vector: */ 87 double* vector_python=xNew<double>(M); 88 memcpy(vector_python,vector,M*sizeof(double)); 85 89 86 90 dim=(npy_intp)M; 87 array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE, buffer);91 array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,vector_python); 88 92 89 93 PyTuple_SetItem(py_tuple, index, array);
Note:
See TracChangeset
for help on using the changeset viewer.