[MOAB-dev] commit/MOAB: tautges: Matrix3: adding array() functions like those in CartVect

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Sep 11 17:36:00 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/db11f24c17fe/
Changeset:   db11f24c17fe
Branch:      master
User:        tautges
Date:        2013-09-12 00:35:52
Summary:     Matrix3: adding array() functions like those in CartVect
ScdInterface.hpp: correcting comments in construct_box function prototype.
TupleList: getting rid of poorly-named variables like "size".
MBTest: getting rid of many narrowing conversion warnings.

Affected #:  5 files

diff --git a/src/moab/Matrix3.hpp b/src/moab/Matrix3.hpp
index 1e9406c..08d38da 100644
--- a/src/moab/Matrix3.hpp
+++ b/src/moab/Matrix3.hpp
@@ -211,6 +211,12 @@ inline Matrix3( double v00, double v01, double v02,
   inline double& operator()(unsigned i) { return d[i]; }
   inline double operator()(unsigned i) const { return d[i]; }
   
+    // get pointer to array of nine doubles
+  inline double* array()
+      { return d; }
+  inline const double* array() const
+      { return d; }
+
   inline Matrix3& operator+=( const Matrix3& m ){
       d[0] += m.d[0]; d[1] += m.d[1]; d[2] += m.d[2];
       d[3] += m.d[3]; d[4] += m.d[4]; d[5] += m.d[5];

diff --git a/src/moab/ScdInterface.hpp b/src/moab/ScdInterface.hpp
index df8c772..0726b13 100644
--- a/src/moab/ScdInterface.hpp
+++ b/src/moab/ScdInterface.hpp
@@ -163,8 +163,8 @@ public:
      * the mesh, call the destroy_mesh function on the ScdBox object first, before destroying it.
      * \param low Lower corner in parameter space
      * \param high Higher corner in parameter space
-     * \param coords Coordinates of vertices, interleaved (xyzxyz...); if NULL, no coords are set
-     * \param num_coords Number of coordinate values; if zero, no coords are set
+     * \param coords Coordinates of vertices, interleaved (xyzxyz...); if NULL, coords are set to parametric values
+     * \param num_coords Number of coordinate values
      * \param new_box Reference to box of structured mesh
      * \param lperiodic[3] If lperiodic[s] != 0, direction s is locally periodic
      * \param par_data If non-NULL, this will get stored on the ScdBox once created, contains info

diff --git a/src/parallel/TupleList.cpp b/src/parallel/TupleList.cpp
index 5b64b49..ad5b055 100644
--- a/src/parallel/TupleList.cpp
+++ b/src/parallel/TupleList.cpp
@@ -18,39 +18,39 @@ namespace moab {
     exit(1);
   }
 
-  TupleList::buffer::buffer(size_t p_size)
+  TupleList::buffer::buffer(size_t sz)
   {
     ptr = NULL;
-    size=0;
-    this->buffer_init_(p_size, __FILE__);
+    buffSize=0;
+    this->buffer_init_(sz, __FILE__);
   }
 
   TupleList::buffer::buffer()
   {
-    size=0;
+    buffSize=0;
     ptr = NULL;
   }  
 
   void TupleList::buffer::buffer_init_(size_t sizeIn, const char *file)
   {
-    this->size = sizeIn;
-    void *res = malloc(this->size);
-    if (!res && size > 0) 
-      fail("%s: allocation of %d bytes failed\n",file,(int)size);
+    this->buffSize = sizeIn;
+    void *res = malloc(this->buffSize);
+    if (!res && buffSize > 0) 
+      fail("%s: allocation of %d bytes failed\n",file,(int)buffSize);
     ptr = (char*) res;
   }
 
   void TupleList::buffer::buffer_reserve_(size_t min, const char *file)
   {
-    if(this->size < min) {
-      size_t newSize = this->size;
+    if(this->buffSize < min) {
+      size_t newSize = this->buffSize;
       newSize += newSize/2 + 1;
       if (newSize < min) newSize = min;
       void *res = realloc (ptr, newSize);
       if (!res && newSize > 0) 
-	fail("%s: allocation of %d bytes failed\n",file,(int)this->size);
+	fail("%s: allocation of %d bytes failed\n",file,(int)this->buffSize);
       ptr = (char*) res;
-      this->size = newSize;
+      this->buffSize = newSize;
     }
   }
 
@@ -58,7 +58,7 @@ namespace moab {
   { 
     free(ptr);
     ptr = NULL; 
-    size = 0;
+    buffSize = 0;
   }
 
   TupleList::TupleList(uint p_mi, uint p_ml,
@@ -90,37 +90,37 @@ namespace moab {
     this->ml = p_ml;
     this->mul = p_mul;
     this->mr = p_mr;
-    size_t size;
+    size_t sz;
 
     if (max*mi > 0) {
-      size = max*mi*sizeof(sint);
-      void *resi = malloc(size);
+      sz = max*mi*sizeof(sint);
+      void *resi = malloc(sz);
       if(!resi && max*mi > 0) 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
       vi = (sint*) resi;
     } else
       vi = NULL;
     if (max*ml > 0) {
-      size = max*ml*sizeof(slong);
-      void *resl = malloc(size);
+      sz = max*ml*sizeof(slong);
+      void *resl = malloc(sz);
       if(!resl && max*ml > 0) 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
       vl = (slong*) resl;
     } else
       vl = NULL;
     if (max*mul > 0) {
-      size = max*mul*sizeof(ulong);
-      void *resu = malloc(size);
+      sz = max*mul*sizeof(ulong);
+      void *resu = malloc(sz);
       if(!resu && max*mul > 0) 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
       vul = (ulong*) resu;
     } else
       vul = NULL;
     if (max*mr > 0) {
-      size = max*mr*sizeof(realType);
-      void *resr = malloc(size);
+      sz = max*mr*sizeof(realType);
+      void *resr = malloc(sz);
       if(!resr && max*ml > 0) 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
       vr=(realType*) resr;
     } else
       vr = NULL;
@@ -136,40 +136,40 @@ namespace moab {
   ErrorCode TupleList::resize(uint maxIn)
   {
     this->max = maxIn;
-    size_t size;
+    size_t sz;
 
     if (vi || (max*mi > 0)){
-      size = max*mi*sizeof(sint);
-      void *resi = realloc(vi, size);
+      sz = max*mi*sizeof(sint);
+      void *resi = realloc(vi, sz);
       if(!resi && max*mi > 0){ 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
 	return moab::MB_MEMORY_ALLOCATION_FAILED;
       }
       vi = (sint*) resi;
     }
     if (vl || (max*ml > 0)){
-      size = max*ml*sizeof(slong);
-      void *resl = realloc(vl, size);
+      sz = max*ml*sizeof(slong);
+      void *resl = realloc(vl, sz);
       if(!resl && max*ml > 0){ 
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
 	return moab::MB_MEMORY_ALLOCATION_FAILED;
       }
       vl = (slong*) resl;
     }
     if (vul || (max*mul > 0)){
-      size = max*mul*sizeof(ulong);
-      void *resu = realloc(vul, size);
+      sz = max*mul*sizeof(ulong);
+      void *resu = realloc(vul, sz);
       if(!resu && max*mul > 0){
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
 	return moab::MB_MEMORY_ALLOCATION_FAILED;
       }
       vul = (ulong*) resu;
     }
     if (vr || (max*mr > 0)){
-      size = max*mr*sizeof(realType);
-      void *resr = realloc(vr, size);
+      sz = max*mr*sizeof(realType);
+      void *resr = realloc(vr, sz);
       if(!resr && max*mr > 0){
-	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)size);
+	fail("%s: allocation of %d bytes failed\n",__FILE__,(int)sz);
 	return moab::MB_MEMORY_ALLOCATION_FAILED;
       }
       vr = (realType*) resr;

diff --git a/src/parallel/moab/TupleList.hpp b/src/parallel/moab/TupleList.hpp
index ba963fb..8cbd388 100644
--- a/src/parallel/moab/TupleList.hpp
+++ b/src/parallel/moab/TupleList.hpp
@@ -114,12 +114,12 @@ namespace moab
     class buffer
     {
     public:
-      size_t size;
+      size_t buffSize;
       char *ptr;
   
       /**Constructor which sets an initial capacity of the buffer
        */
-      buffer(size_t p_size);
+      buffer(size_t sz);
 
       /**Default constructor (Note:  buffer must be initialized before use!)
        */
@@ -129,7 +129,7 @@ namespace moab
   
       /**Initializes the buffer to have a capacity of size
        */
-      void buffer_init_(size_t p_size, const char *file);
+      void buffer_init_(size_t sz, const char *file);
 
       /**Ensures that the buffer has at least a capacity of min
        */
@@ -140,7 +140,7 @@ namespace moab
       void reset ();
   
       //Aliases for using the buffer methods
-#define buffer_init(size) buffer_init_(size,__FILE__)
+#define buffer_init(sz) buffer_init_(sz,__FILE__)
 #define buffer_reserve(min) buffer_reserve_(min,__FILE__)
 
     };

diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index df947cf..66e8501 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -6131,7 +6131,7 @@ ErrorCode mb_skin_curve_test_common( bool use_adj )
   
   std::vector<EntityHandle> verts;
   for (unsigned i = 0; i < 10; ++i) {
-    double coords[] = { i, 0, 0 };
+    double coords[] = { static_cast<double>(i), 0, 0 };
     EntityHandle h;
     mb->create_vertex( coords, h );
     verts.push_back(h);
@@ -6675,7 +6675,7 @@ ErrorCode mb_skin_poly_test()
   EntityHandle verts[3][16];
   for (int i = 0; i < 3; ++i) {
     for (int j = 0; j < 16; ++j) {
-      double coords[3] = { coords2D[j][0], coords2D[j][1], 2*i };
+      double coords[3] = { coords2D[j][0], coords2D[j][1], static_cast<double>(2*i) };
       rval = mb.create_vertex( coords, verts[i][j] );
       if (MB_SUCCESS != rval) return rval;
     }
@@ -6997,7 +6997,7 @@ ErrorCode mb_skin_higher_order_regions_common( bool use_adj )
   for (int i = 0; i < 5; ++i) 
     for (int j = 0; j < 3; ++j)
       for (int k = 0; k < 3; ++k) {
-        double coords[] = { i, j, k };
+        double coords[] = { static_cast<double>(i), static_cast<double>(j), static_cast<double>(k) };
         rval = mb.create_vertex( coords, verts[i][j][k] );
         if (MB_SUCCESS != rval) return rval;
       }
@@ -7261,7 +7261,7 @@ ErrorCode mb_skin_subset_common( int dimension, bool use_adj )
   EntityHandle verts[2][7] = { {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0} };
   for (int d = 1; d < dimension; ++d) {
     for (int i = 0; i < 7; ++i) {
-      double coords[3] = { coords2D[i][0], coords2D[i][1], d-1 };
+      double coords[3] = { coords2D[i][0], coords2D[i][1], static_cast<double>(d-1) };
       rval = mb.create_vertex( coords, verts[d-1][i] );
       if (MB_SUCCESS != rval) return rval;
       if (i != 4 && i != 5)
@@ -7375,7 +7375,7 @@ ErrorCode mb_skin_full_common( int dimension, bool use_adj )
   EntityHandle v[2][6] = { {0,0,0,0,0,0}, {0,0,0,0,0,0} };
   for (int d = 1; d < dimension; ++d) {
     for (int i = 0; i < 6; ++i) {
-      double coords[3] = { coords2D[i][0], coords2D[i][1], d-1 };
+      double coords[3] = { coords2D[i][0], coords2D[i][1], static_cast<double>(d-1) };
       rval = mb.create_vertex( coords, v[d-1][i] );
       if (MB_SUCCESS != rval) return rval;
     }
@@ -7476,7 +7476,7 @@ ErrorCode mb_skin_adjacent_surf_patches()
   EntityHandle vtx[num_vtx];
   for (int i = 0; i < 6; ++i) {
     for (int j = 0; j < 5; ++j) {
-      double coords[3] = {i, j, 0};
+      double coords[3] = {static_cast<double>(i), static_cast<double>(j), 0};
       rval = mb.create_vertex( coords, vtx[6*j+i] );
       if (MB_SUCCESS != rval) return rval;
     }

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list