[cig-commits] r13170 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:11:39 PDT 2008


Author: luis
Date: 2008-10-29 15:11:39 -0700 (Wed, 29 Oct 2008)
New Revision: 13170

Modified:
   cs/cigma/trunk/src/py_ElementBlock.cpp
   cs/cigma/trunk/src/py_NodeCoordinates.cpp
   cs/cigma/trunk/src/py_Points.cpp
   cs/cigma/trunk/src/py_Quadrature.cpp
Log:
Use simpler numpy_util::makeArray function for rank 2 arrays.

Modified: cs/cigma/trunk/src/py_ElementBlock.cpp
===================================================================
--- cs/cigma/trunk/src/py_ElementBlock.cpp	2008-10-29 22:11:36 UTC (rev 13169)
+++ cs/cigma/trunk/src/py_ElementBlock.cpp	2008-10-29 22:11:39 UTC (rev 13170)
@@ -12,13 +12,9 @@
 
 py_eb_array::py_eb_array(int nel, int ndofs) : eb_array(), data(0)
 {
-    std::vector<int> dims;
-    dims.push_back(nel);
-    dims.push_back(ndofs);
-    this->data = numpy_util::makeArray(dims, PyArray_INT);
-
     this->nel = nel;
     this->ndofs = ndofs;
+    this->data = numpy_util::makeArray(nel, ndofs, PyArray_INT);
     this->connect = (int *) numpy_util::data(this->data);
 }
 

Modified: cs/cigma/trunk/src/py_NodeCoordinates.cpp
===================================================================
--- cs/cigma/trunk/src/py_NodeCoordinates.cpp	2008-10-29 22:11:36 UTC (rev 13169)
+++ cs/cigma/trunk/src/py_NodeCoordinates.cpp	2008-10-29 22:11:39 UTC (rev 13170)
@@ -50,13 +50,9 @@
 
 py_nc_array::py_nc_array(int npts, int nsd) : nc_array(), data(0)
 {
-    std::vector<int> dims;
-    dims.push_back(npts);
-    dims.push_back(nsd);
-    this->data = numpy_util::makeArray(dims, PyArray_DOUBLE);
-
     this->nno = npts;
     this->nsd = nsd;
+    this->data = numpy_util::makeArray(npts, nsd, PyArray_DOUBLE);
     this->coords = (double *) numpy_util::data(this->data);
 }
 

Modified: cs/cigma/trunk/src/py_Points.cpp
===================================================================
--- cs/cigma/trunk/src/py_Points.cpp	2008-10-29 22:11:36 UTC (rev 13169)
+++ cs/cigma/trunk/src/py_Points.cpp	2008-10-29 22:11:39 UTC (rev 13170)
@@ -17,19 +17,9 @@
 template <typename T, int dim>
 pyPoints<T,dim>::pyPoints(int npts) : Points<T,dim>(npts), na_data(0)
 {
-    std::vector<int> dims;
-    dims.push_back(npts);
-    dims.push_back(dim);
-    this->na_data = numpy_util::makeArray(dims, numpy_util::getEnum<T>());
     this->npts = npts;
+    this->na_data = numpy_util::makeArray(npts, dim, numpy_util::getEnum<T>());
     this->data = (T *)numpy_util::data(this->na_data);
-    for (int i = 0; i < npts; i++)
-    {
-        for (int j = 0; j < dim; j++)
-        {
-            this->data[dim*i + j] = 0;
-        }
-    }
 }
 
 template <typename T, int dim>

Modified: cs/cigma/trunk/src/py_Quadrature.cpp
===================================================================
--- cs/cigma/trunk/src/py_Quadrature.cpp	2008-10-29 22:11:36 UTC (rev 13169)
+++ cs/cigma/trunk/src/py_Quadrature.cpp	2008-10-29 22:11:39 UTC (rev 13170)
@@ -13,42 +13,22 @@
 
 pyQuadrature::pyQuadrature(int npts, int ndim) : Quadrature(), na_points(0), na_weights(0)
 {
-    this->npts = npts;
-    this->ndim = ndim;
-
-    std::vector<int> point_dims;
-    point_dims.push_back(npts);
-    point_dims.push_back(ndim);
-    
-    na_points = numpy_util::makeArray(point_dims, PyArray_DOUBLE);
+    na_points = numpy_util::makeArray(npts, ndim, PyArray_DOUBLE);
     na_weights = numpy_util::makeArray(npts, PyArray_DOUBLE);
     
+    this->npts = npts;
+    this->ndim = ndim;
     this->points = (double *)numpy_util::data(na_points);
     this->weights = (double *)numpy_util::data(na_weights);
-
-    /* makeArray actually returns a zero'd out array...
-    for (int q = 0; q < npts; q++)
-    {   
-        this->weights[q] = 0;
-        for (int j = 0; j < ndim; j++)
-        {   
-            this->points[ndim*q + j] = 0;
-        }
-    } */
 }
 
 pyQuadrature::pyQuadrature(const Quadrature &Q) : Quadrature(), na_points(0), na_weights(0)
 {
+    na_points = numpy_util::makeArray(Q.n_points(), Q.n_dim(), PyArray_DOUBLE);
+    na_weights = numpy_util::makeArray(Q.n_points(), PyArray_DOUBLE);
+    
     this->npts = Q.n_points();
     this->ndim = Q.n_dim();
-
-    std::vector<int> point_dims;
-    point_dims.push_back(npts);
-    point_dims.push_back(ndim);
-
-    na_points = numpy_util::makeArray(point_dims, PyArray_DOUBLE);
-    na_weights = numpy_util::makeArray(npts, PyArray_DOUBLE);
-    
     this->points = (double *)numpy_util::data(na_points);
     this->weights = (double *)numpy_util::data(na_weights);
 



More information about the CIG-COMMITS mailing list