[MOAB-dev] commit/MOAB: 20 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Sep 17 11:55:28 CDT 2013


20 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/ab0fa9f440c4/
Changeset:   ab0fa9f440c4
Branch:      None
User:        iulian07
Date:        2013-08-18 03:59:02
Summary:     add transport example

first case of Nair-Lauritzen paper; quasi-smooth cosine bells, and
reversing flow after midpoint should recover the initial conditions
So far using only constant approximation for tracer concentrations
test is done in serial so far; parallel needs more work, but the
stage is set for parallel

Affected #:  9 files

diff --git a/tools/mbcslam/CslamUtils.cpp b/tools/mbcslam/CslamUtils.cpp
index ad30c9d..4d21b41 100644
--- a/tools/mbcslam/CslamUtils.cpp
+++ b/tools/mbcslam/CslamUtils.cpp
@@ -806,6 +806,22 @@ double area_on_sphere_lHuiller(Interface * mb, EntityHandle set, double R)
   }
   return total_area;
 }
+
+double area_spherical_element(Interface * mb, EntityHandle elem, double R)
+{
+  const EntityHandle * verts;
+  int num_nodes;
+  ErrorCode rval = mb->get_connectivity(elem, verts, num_nodes);
+  if (MB_SUCCESS != rval)
+    return -1;
+  std::vector<double> coords(3 * num_nodes);
+  // get coordinates
+  rval = mb->get_coords(verts, num_nodes, &coords[0]);
+  if (MB_SUCCESS != rval)
+    return -1;
+  return area_spherical_polygon_lHuiller(&coords[0], num_nodes, R);
+
+}
 /*
  *
  */
@@ -861,6 +877,28 @@ void departure_point_case1(CartVect & arrival_point, double t, double delta_t, C
   departure_point = spherical_to_cart(sph_dep);
   return;
 }
+
+void velocity_case1(CartVect & arrival_point, double t, CartVect & velo)
+{
+  // always assume radius is 1 here?
+  SphereCoords sph = cart_to_spherical(arrival_point);
+  double T=5; // duration of integration (5 units)
+  double k = 2.4; //flow parameter
+  /*     radius needs to be within some range   */
+  double  sl2 = sin(sph.lon/2);
+  double pit = M_PI * t / T;
+  //double omega = M_PI/T;
+  double coslat = cos(sph.lat);
+  double sinlat = sin(sph.lat);
+  double sinlon = sin(sph.lon);
+  double coslon = cos(sph.lon);
+  double u = k * sl2*sl2 * sin(2*sph.lat) * cos(pit);
+  double v = k/2 * sinlon * coslat * cos(pit);
+  velo[0] = - u * sinlon - v * sinlat * coslon;
+  velo[1] = u * coslon - v * sinlat * sinlon;
+  velo[2] = v * coslat;
+
+}
 // break the nonconvex quads into triangles; remove the quad from the set? yes.
 // maybe radius is not needed;
 //
@@ -1133,4 +1171,47 @@ ErrorCode create_span_quads(Interface * mb, EntityHandle euler_set, int rank)
   return MB_SUCCESS;
 
 }
+
+// distance along a great circle on a sphere of radius 1
+// page 4
+double distance_on_sphere(double la1, double te1, double la2, double te2)
+{
+  return acos(sin(te1)*sin(te2)+cos(te1)*cos(te2)*cos(la1-la2));
+}
+// page 4 Nair Lauritzen paper
+// param will be: (la1, te1), (la2, te2), b, c; hmax=1, r=1/2
+double quasi_smooth_field(double lam, double tet, double * params)
+{
+  double la1 = params[0];
+  double te1 = params[1];
+  double la2 = params[2];
+  double te2 = params[3];
+  double b = params[4];
+  double c = params[5];
+  double hmax = params[6]; // 1;
+  double r = params[7] ; // 0.5;
+  double r1 = distance_on_sphere(lam, tet, la1, te1);
+  double r2 = distance_on_sphere(lam, tet, la2, te2);
+  double value = b;
+  if (r1<r)
+  {
+    value += c*hmax/2*(1+cos(M_PI*r1/r));
+  }
+  if (r2<r)
+  {
+    value += c*hmax/2*(1+cos(M_PI*r2/r));
+  }
+  return value;
+}
+// page 4
+double smooth_field(double lam, double tet, double * params)
+{
+  return 0.;
+}
+// page 5
+double slotted_cylinder_field(double lam, double tet, double * params)
+{
+  return 0.;
+}
+
 } //namespace moab

diff --git a/tools/mbcslam/CslamUtils.hpp b/tools/mbcslam/CslamUtils.hpp
index e039d96..0f9b573 100644
--- a/tools/mbcslam/CslamUtils.hpp
+++ b/tools/mbcslam/CslamUtils.hpp
@@ -126,6 +126,7 @@ double distance_on_great_circle(CartVect & p1, CartVect & p2);
 
 void departure_point_case1(CartVect & arrival_point, double t, double delta_t, CartVect & departure_point);
 
+void velocity_case1(CartVect & arrival_point, double t, CartVect & velo);
 // break the nonconvex quads into triangles; remove the quad from the set? yes.
 // maybe radius is not needed;
 //
@@ -134,5 +135,19 @@ ErrorCode enforce_convexity(Interface * mb, EntityHandle set, int rank = 0);
 // looking at DP tag, create the spanning quads, write a file (with rank) and
 // then delete the new entities (vertices) and the set of quads
 ErrorCode create_span_quads(Interface * mb, EntityHandle euler_set, int rank);
+
+// distance along a great circle on a sphere of radius 1
+double distance_on_sphere(double la1, double te1, double la2, double te2);
+// page 4 Nair Lauritzen paper
+// param will be: (la1, te1), (la2, te2), b, c; hmax=1, r=1/2
+double quasi_smooth_field(double lam, double tet, double * params);
+// page 4
+double smooth_field(double lam, double tet, double * params);
+// page 5
+double slotted_cylinder_field(double lam, double tet, double * params);
+
+double area_spherical_element(Interface * mb, EntityHandle  elem, double R);
+
+
 }
 #endif /* CSLAMUTILS_HPP_ */

diff --git a/tools/mbcslam/Intx2Mesh.cpp b/tools/mbcslam/Intx2Mesh.cpp
index 6ddadfb..f986fd6 100644
--- a/tools/mbcslam/Intx2Mesh.cpp
+++ b/tools/mbcslam/Intx2Mesh.cpp
@@ -17,12 +17,6 @@
 
 namespace moab {
 
-#define ERRORR(rval, str) \
-    if (MB_SUCCESS != rval) {std::cout << str << "\n"; return rval;}
-
-#define ERRORV(rval, str) \
-    if (MB_SUCCESS != rval) {std::cout << str << "\n"; return ;}
-
 Intx2Mesh::Intx2Mesh(Interface * mbimpl):mb(mbimpl), parcomm(NULL), myTree(NULL)
 {
   dbg_1=0;
@@ -406,6 +400,10 @@ void Intx2Mesh::clean()
   }
   //extraNodesMap.clear();
   extraNodesVec.clear();
+  // also, delete some bit tags, used to mark processed reds and blues
+  mb->tag_delete(RedFlagTag);// to mark blue quads already considered
+  mb->tag_delete(BlueFlagTag);
+
 }
 ErrorCode Intx2Mesh::initialize_local_kdtree(EntityHandle euler_set)
 {

diff --git a/tools/mbcslam/Intx2Mesh.hpp b/tools/mbcslam/Intx2Mesh.hpp
index 8f5947d..21e56e4 100644
--- a/tools/mbcslam/Intx2Mesh.hpp
+++ b/tools/mbcslam/Intx2Mesh.hpp
@@ -25,6 +25,12 @@
 
 namespace moab {
 
+#define ERRORR(rval, str) \
+    if (MB_SUCCESS != rval) {std::cout << str << "\n"; return rval;}
+
+#define ERRORV(rval, str) \
+    if (MB_SUCCESS != rval) {std::cout << str << "\n"; return ;}
+
 // forward declarations
 class ParallelComm;
 class AdaptiveKDTree;

diff --git a/tools/mbcslam/Intx2MeshOnSphere.cpp b/tools/mbcslam/Intx2MeshOnSphere.cpp
index 4fea220..a875d7b 100644
--- a/tools/mbcslam/Intx2MeshOnSphere.cpp
+++ b/tools/mbcslam/Intx2MeshOnSphere.cpp
@@ -414,4 +414,50 @@ bool Intx2MeshOnSphere::is_inside_element(double xyz[3], EntityHandle eh)
     return true;
   return false;
 }
+
+ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagElem)
+{
+  // get all polygons out of out_set; then see where are they coming from
+  Range polys;
+  ErrorCode rval = mb->get_entities_by_dimension(out_set, 2, polys);
+  ERRORR(rval, "can't get polygons out");
+
+  // rs2 is the red rage, arrival; rs1 is blue, departure;
+  // we start from rs2 existing, then we have to update something
+  std::vector<double>  currentVals(rs2.size());
+  rval = mb->tag_get_data(tagElem, rs2, &currentVals[0]);
+  ERRORR(rval, "can't get existing tag values");
+
+  // for each polygon, we have 2 indices: red and blue parents
+  // we need index blue to update index red?
+  std::vector<double> newValues(rs2.size(), 0.);// initialize with 0 all of them
+  // area of the polygon * conc on red (old) current quantity
+  // finaly, divide by the area of the red
+  for (Range::iterator it= polys.begin(); it!=polys.end(); it++)
+  {
+    EntityHandle poly=*it;
+    int blueIndex, redIndex;
+    rval =  mb->tag_get_data(blueParentTag, &poly, 1, &blueIndex);
+    ERRORR(rval, "can't get blue tag");
+    EntityHandle blue = rs1[blueIndex];
+    rval =  mb->tag_get_data(redParentTag, &poly, 1, &redIndex);
+    ERRORR(rval, "can't get red tag");
+    EntityHandle red=rs2[redIndex];
+    // big assumption here, red and blue are "parallel" ;we should have an index from
+    // blue to red (so a deformed blue corresponds to an arrival red)
+    double areap = area_spherical_element(mb, poly, R);
+    newValues[blueIndex] += currentVals[redIndex]*areap;
+  }
+  // now divide by red area (current)
+  int j=0;
+  for (Range::iterator it=rs2.begin(); it!=rs2.end(); it++, j++ )
+  {
+    EntityHandle red = *it;
+    double areaRed = area_spherical_element(mb, red, R);
+    newValues[j]/=areaRed;
+  }
+  rval = mb->tag_set_data(tagElem, rs2, &newValues[0]);
+  ERRORR(rval, "can't set new values tag");
+  return MB_SUCCESS;
+}
 } /* namespace moab */

diff --git a/tools/mbcslam/Intx2MeshOnSphere.hpp b/tools/mbcslam/Intx2MeshOnSphere.hpp
index 77cd830..c2a3066 100644
--- a/tools/mbcslam/Intx2MeshOnSphere.hpp
+++ b/tools/mbcslam/Intx2MeshOnSphere.hpp
@@ -31,6 +31,8 @@ public:
 
   bool is_inside_element(double xyz[3], EntityHandle eh);
 
+  ErrorCode update_tracer_data(EntityHandle out_set, Tag & tagElem);
+
 private:
   int plane; // current gnomonic plane
   double R; // radius of the sphere

diff --git a/tools/mbcslam/Makefile.am b/tools/mbcslam/Makefile.am
index 68a1812..bf5ae85 100644
--- a/tools/mbcslam/Makefile.am
+++ b/tools/mbcslam/Makefile.am
@@ -40,20 +40,16 @@ cfgdir = $(libdir)
 
 TESTS = intx_on_sphere_test  intx_in_plane_test  spec_visu_test spherical_area_test \
          case1_test  intx_mpas
-noinst_PROGRAMS =  cslam_par_test
-if NETCDF_FILE
-  noinst_PROGRAMS += process_arm
-endif
+noinst_PROGRAMS =  cslam_par_test diffusion 
 
 check_PROGRAMS = $(TESTS) 
 intx_on_sphere_test_SOURCES = intx_on_sphere_test.cpp
+diffusion_SOURCES = diffusion.cpp
 intx_in_plane_test_SOURCES = intx_in_plane_test.cpp
 spec_visu_test_SOURCES = spec_visu_test.cpp
 spherical_area_test_SOURCES = spherical_area_test.cpp
 case1_test_SOURCES = case1_test.cpp
 intx_mpas_SOURCES = intx_mpas.cpp
-process_arm_SOURCES = process_arm.cpp
-
 cslam_par_test_SOURCES = cslam_par_test.cpp
 cslam_par_test_LDADD = $(LDADD) $(top_builddir)/tools/mbcoupler/libmbcoupler.la 
 EXTRA_DIST  = lagrangeHomme.vtk  \
@@ -73,4 +69,4 @@ MOSTLYCLEANFILES = intersect1.h5m \
                    intx1.vtk \
                    SpanEdges0.h5m \
                    SpanQuads0.h5m 
-            
+           

diff --git a/tools/mbcslam/diffusion.cpp b/tools/mbcslam/diffusion.cpp
new file mode 100644
index 0000000..1519200
--- /dev/null
+++ b/tools/mbcslam/diffusion.cpp
@@ -0,0 +1,402 @@
+/*
+ * diffusion.cpp
+ *
+ *  Created on: Aug 12, 2013
+ *
+ */
+
+/* trigger a diffusion computation in serial, first;
+  we will start from an unstructured mesh on a sphere;
+  do case 1: give some tracers a "slotted cylinder" ; compute the initial concentrations
+  along a slotted cylinder, and see how it varies in time;
+  use formula from Nair & Lauritzen paper:
+  A class of deformational flow test cases for linear transport problems
+on the sphere; see CSLAM Utils case1
+  scalar fields are defined at page 4-5 in the paper
+
+  steps:
+   first create an initial tracer field, and save it as field on a sphere
+   (initial time step 0)
+   then use velocities (non-divergent, first), to transport the tracer on
+   the sphere, according to some flow fields
+*/
+// copy from intx_mpas test
+
+#include <iostream>
+#include <sstream>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "moab/Core.hpp"
+#include "moab/Interface.hpp"
+#include "Intx2MeshOnSphere.hpp"
+#include <math.h>
+#include "moab/ProgOptions.hpp"
+#include "MBTagConventions.hpp"
+#include "TestUtil.hpp"
+#include "moab/ParallelComm.hpp"
+
+#include "CslamUtils.hpp"
+
+
+// non smooth scalar field
+// some input data
+double gtol = 1.e-9; // this is for geometry tolerance
+
+double radius = 1.;// in m:  6371220.
+
+int numSteps = 50; // number of times with velocity displayed at points
+double T = 5;
+
+#ifdef MESHDIR
+std::string TestDir( STRINGIFY(MESHDIR) );
+#else
+std::string TestDir(".");
+#endif
+
+// for M_PI
+#include <math.h>
+
+#define STRINGIFY_(X) #X
+#define STRINGIFY(X) STRINGIFY_(X)
+
+using namespace moab;
+ErrorCode add_field_value(Interface * mb, EntityHandle euler_set, int rank, Tag & tagTracer, Tag & tagElem)
+{
+  ErrorCode rval = MB_SUCCESS;
+
+  /*
+   * get all plys first, then vertices, then move them on the surface of the sphere
+   *  radius is 1., most of the time
+   *
+   */
+  Range polygons;
+  rval = mb->get_entities_by_dimension(euler_set, 2, polygons);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+  Range connecVerts;
+  rval = mb->get_connectivity(polygons, connecVerts);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+
+
+  void *data; // pointer to the LOC in memory, for each vertex
+  int count;
+
+  rval = mb->tag_iterate(tagTracer, connecVerts.begin(), connecVerts.end(), count, data);
+  CHECK_ERR(rval);
+  // here we are checking contiguity
+  assert(count == (int) connecVerts.size());
+  double * ptr_DP=(double*)data;
+  // lambda is for longitude, theta for latitude
+   // param will be: (la1, te1), (la2, te2), b, c; hmax=1, r=1/2
+  // nondivergent flow, page 5, case 1, (la1, te1) = (M_PI, M_PI/3)
+  //                                    (la2, te2) = (M_PI, -M_PI/3)
+  //                 la1,    te1    la2    te2     b     c  hmax  r
+  double params[] = { M_PI, M_PI/3, M_PI, -M_PI/3, 0.1, 0.9, 1., 0.5};
+  for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+  {
+    EntityHandle oldV=*vit;
+    CartVect posi;
+    rval = mb->get_coords(&oldV, 1, &(posi[0]) );
+    CHECK_ERR(rval);
+
+    SphereCoords sphCoord = cart_to_spherical(posi);
+
+    ptr_DP[0]=quasi_smooth_field(sphCoord.lon, sphCoord.lat, params);;
+
+    ptr_DP++; // increment to the next node
+  }
+
+  // add average value for quad/polygon (average corners)
+  // do some averages
+
+
+  Range::iterator iter = polygons.begin();
+  while (iter != polygons.end())
+  {
+    rval = mb->tag_iterate(tagElem, iter, polygons.end(), count, data);
+    CHECK_ERR(rval);
+    double * ptr=(double*)data;
+    for (int i=0; i<count; i++, iter++, ptr++)
+    {
+      const moab::EntityHandle * conn = NULL;
+      int num_nodes = 0;
+      rval = mb->get_connectivity(*iter, conn, num_nodes);
+      CHECK_ERR(rval);
+      if (num_nodes==0)
+        return MB_FAILURE;
+      std::vector<double> nodeVals(num_nodes);
+      double average=0.;
+      rval = mb->tag_get_data(tagTracer, conn, num_nodes, &nodeVals[0] );
+      CHECK_ERR(rval);
+      for (int j=0; j<num_nodes; j++)
+        average+=nodeVals[j];
+      average/=num_nodes;
+      *ptr = average;
+    }
+
+  }
+
+  std::stringstream iniPos;
+  iniPos<<"def" << rank<<".vtk";
+  rval = mb->write_file(iniPos.str().c_str(), 0, 0, &euler_set, 1);
+  CHECK_ERR(rval);
+
+  // now we can delete the tags? not yet
+  return MB_SUCCESS;
+}
+
+ErrorCode compute_velocity_case1(Interface * mb, EntityHandle euler_set, Tag & tagh, int rank, int tStep)
+{
+  ErrorCode rval = MB_SUCCESS;
+
+  Range polygons;
+  rval = mb->get_entities_by_dimension(euler_set, 2, polygons);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+  Range connecVerts;
+  rval = mb->get_connectivity(polygons, connecVerts);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+  void *data; // pointer to the velo in memory, for each vertex
+  int count;
+
+  rval = mb->tag_iterate(tagh, connecVerts.begin(), connecVerts.end(), count, data);
+  CHECK_ERR(rval);
+  // here we are checking contiguity
+  assert(count == (int) connecVerts.size());
+  double * ptr_velo=(double*)data;
+  // lambda is for longitude, theta for latitude
+
+  for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+  {
+    EntityHandle oldV=*vit;
+    CartVect posi;
+    rval = mb->get_coords(&oldV, 1, &(posi[0]) );
+    CHECK_ERR(rval);
+    CartVect velo ;
+    double t = T * tStep/numSteps; //
+    velocity_case1(posi, t, velo);
+
+    ptr_velo[0]= velo[0];
+    ptr_velo[1]= velo[1];
+    ptr_velo[2]= velo[2];
+
+    // increment to the next node
+    ptr_velo+=3;// to next velocity
+  }
+  std::stringstream velos;
+  velos<<"velo0" << rank<<"_"<<tStep<<  ".vtk";
+  rval = mb->write_file(velos.str().c_str(), 0, 0, &euler_set, 1);
+  CHECK_ERR(rval);
+
+  return MB_SUCCESS;
+}
+ErrorCode compute_tracer_case1(Interface * mb, EntityHandle euler_set,
+    EntityHandle lagr_set, EntityHandle out_set,
+    Tag & tagElem, int rank, int tStep)
+{
+  ErrorCode rval = MB_SUCCESS;
+
+  double t = tStep*T/numSteps; // numSteps is global; so is T
+  double delta_t = T/numSteps; // this is global too, actually
+  Range polys;
+  rval = mb->get_entities_by_dimension(euler_set, 2, polys);
+  CHECK_ERR(rval);
+
+  Range connecVerts;
+  rval = mb->get_connectivity(polys, connecVerts);
+  CHECK_ERR(rval);
+
+  std::map<EntityHandle, EntityHandle> newNodes;
+  for (Range::iterator vit = connecVerts.begin(); vit != connecVerts.end();
+      vit++)
+  {
+    EntityHandle oldV = *vit;
+    CartVect posi;
+    rval = mb->get_coords(&oldV, 1, &(posi[0]));
+    CHECK_ERR(rval);
+    // cslam utils, case 1
+    CartVect newPos;
+    departure_point_case1(posi, t, delta_t, newPos);
+    newPos = radius * newPos;
+    EntityHandle new_vert;
+    rval = mb->create_vertex(&(newPos[0]), new_vert);
+    CHECK_ERR(rval);
+    newNodes[oldV] = new_vert;
+  }
+  for (Range::iterator it = polys.begin(); it != polys.end(); it++)
+  {
+    EntityHandle q = *it;
+    int nnodes;
+    const EntityHandle * conn;
+    rval = mb->get_connectivity(q, conn, nnodes);
+    CHECK_ERR(rval);
+    EntityType typeElem = mb->type_from_handle(q);
+    std::vector<EntityHandle> new_conn(nnodes);
+    for (int i = 0; i < nnodes; i++)
+    {
+      EntityHandle v1 = conn[i];
+      new_conn[i] = newNodes[v1];
+    }
+    EntityHandle newElement;
+    rval = mb->create_element(typeElem, &new_conn[0], nnodes, newElement);
+    CHECK_ERR(rval);
+    rval = mb->add_entities(lagr_set, &newElement, 1);
+    CHECK_ERR(rval);
+  }
+  // so we have now the departure at the previous time
+  // intersect the 2 meshes (what about some checking of convexity?) for sufficient
+  // small dt, it is not an issue;
+  Intx2MeshOnSphere worker(mb);
+  worker.SetRadius(1.);
+
+  worker.SetErrorTolerance(gtol);
+  // std::cout << "error tolerance epsilon_1=" << gtol << "\n";
+
+  rval = worker.intersect_meshes(lagr_set, euler_set, out_set);
+  CHECK_ERR(rval);
+  // serially: lagr is the same order as euler;
+  // we need to update now the tracer information on each element, based on
+  // initial value and areas of each resulting polygons
+  rval = worker.update_tracer_data(out_set, tagElem);
+  CHECK_ERR(rval);
+
+  std::stringstream newTracer;
+  newTracer<<"Tracer" << rank<<"_"<<tStep<<  ".vtk";
+  rval = mb->write_file(newTracer.str().c_str(), 0, 0, &euler_set, 1);
+  CHECK_ERR(rval);
+
+  std::stringstream newIntx;
+  newIntx<<"newIntx" << rank<<"_"<<tStep<<  ".vtk";
+  rval = mb->write_file(newIntx.str().c_str(), 0, 0, &out_set, 1);
+  CHECK_ERR(rval);
+  // delete now the polygons and the lagr set ents
+  // also, all verts that are not in euler set
+  Range allVerts;
+  rval = mb->get_entities_by_dimension(0, 0, allVerts);
+  CHECK_ERR(rval);
+
+  Range allElems;
+  rval = mb->get_entities_by_dimension(0, 2, allElems);
+  CHECK_ERR(rval);
+  Range todeleteVerts = subtract(allVerts, connecVerts);
+
+  Range todeleteElem = subtract(allElems, polys);
+
+  rval = mb->clear_meshset(&out_set, 1);
+  CHECK_ERR(rval);
+
+  rval = mb->clear_meshset(&lagr_set, 1);
+  CHECK_ERR(rval);
+
+  rval = mb->delete_entities(todeleteElem);
+  CHECK_ERR(rval);
+  rval = mb->delete_entities(todeleteVerts);
+  CHECK_ERR(rval);
+  return rval;
+}
+int main(int argc, char **argv)
+{
+
+  MPI_Init(&argc, &argv);
+
+  std::string extra_read_opts;
+  // read a homme file, partitioned in 16 so far
+  std::string fileN= TestDir + "/HN16.h5m";
+  const char *filename_mesh1 = fileN.c_str();
+  if (argc > 1)
+  {
+    int index = 1;
+    while (index < argc)
+    {
+      if (!strcmp(argv[index], "-gtol")) // this is for geometry tolerance
+      {
+        gtol = atof(argv[++index]);
+      }
+
+      if (!strcmp(argv[index], "-input"))
+      {
+        filename_mesh1 = argv[++index];
+      }
+
+      if (!strcmp(argv[index], "-O"))
+      {
+        extra_read_opts = std::string(argv[++index]);
+      }
+
+      index++;
+    }
+  }
+  // start copy
+  std::string opts = std::string("PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION")+
+            std::string(";PARALLEL_RESOLVE_SHARED_ENTS")+extra_read_opts;
+  Core moab;
+  Interface & mb = moab;
+  EntityHandle euler_set;
+  ErrorCode rval;
+  rval = mb.create_meshset(MESHSET_SET, euler_set);
+  CHECK_ERR(rval);
+
+  rval = mb.load_file(filename_mesh1, &euler_set, opts.c_str());
+
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  CHECK_ERR(rval);
+
+  rval = pcomm->check_all_shared_handles();
+  CHECK_ERR(rval);
+  // end copy
+  int rank = pcomm->proc_config().proc_rank();
+
+  if (0==rank)
+    std::cout << " case 1: use -gtol " << gtol <<
+        " -R " << radius << " -input " << filename_mesh1 << "\n";
+
+  Tag tagTracer = 0;
+  std::string tag_name("Tracer");
+  rval = mb.tag_get_handle(tag_name.c_str(), 1, MB_TYPE_DOUBLE, tagTracer, MB_TAG_DENSE | MB_TAG_CREAT);
+  CHECK_ERR(rval);
+
+  Tag tagElem = 0;
+  std::string tag_name2("TracerAverage");
+  rval = mb.tag_get_handle(tag_name2.c_str(), 1, MB_TYPE_DOUBLE, tagElem, MB_TAG_DENSE | MB_TAG_CREAT);
+  CHECK_ERR(rval);
+  // add a field value, quasi smooth first
+  rval = add_field_value(&mb, euler_set, rank, tagTracer, tagElem);
+  CHECK_ERR(rval);
+
+
+  // do some velocity fields at some time steps; with animations
+  // first delete the
+
+
+
+  Tag tagh = 0;
+  std::string tag_name3("Case1");
+  rval = mb.tag_get_handle(tag_name3.c_str(), 3, MB_TYPE_DOUBLE, tagh, MB_TAG_DENSE | MB_TAG_CREAT);
+  CHECK_ERR(rval);
+  EntityHandle out_set, lagr_set;
+  rval = mb.create_meshset(MESHSET_SET, out_set);
+  CHECK_ERR(rval);
+  rval = mb.create_meshset(MESHSET_SET, lagr_set);
+  CHECK_ERR(rval);
+  for (int i=1; i<numSteps+1; i++)
+  {
+    // time depends on i; t = i*T/numSteps: ( 0, T/numSteps, 2*T/numSteps, ..., T )
+    rval = compute_velocity_case1(&mb, euler_set, tagh, rank, i);
+    CHECK_ERR(rval);
+
+    // this is to actually compute concentrations, using the current concentrations
+    //
+    rval = compute_tracer_case1(&mb, euler_set, lagr_set, out_set,
+        tagElem, rank, i);
+
+  }
+  return 0;
+}

diff --git a/tools/mbcslam/process_arm.cpp b/tools/mbcslam/process_arm.cpp
deleted file mode 100644
index ba7642c..0000000
--- a/tools/mbcslam/process_arm.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * process_arm.cpp
- *
- *  Created on: April 18, 2013
- */
-
-// process the files from Mark; also, link against netcdf directly, because we will use
-// netcdf calls to read data, the same as in ReadNC and ReadNCDF
-//
-//
-#include <iostream>
-#include <sstream>
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "moab/Core.hpp"
-#include "moab/Interface.hpp"
-#include "moab/ReadUtilIface.hpp"
-#include "moab/AdaptiveKDTree.hpp"
-
-#include "CslamUtils.hpp"
-
-#include "netcdf.h"
-
-#include <algorithm>
-#include <string>
-#include <assert.h>
-
-#include <cmath>
-
-
-using namespace moab;
-
-#define INS_ID(stringvar, prefix, id) \
-          sprintf(stringvar, prefix, id)
-
-#define GET_DIM(ncdim, name, val)\
-    {                            \
-    int gdfail = nc_inq_dimid(ncFile, name, &ncdim);          \
-    if (NC_NOERR == gdfail) {                                             \
-      size_t tmp_val;                                                   \
-      gdfail = nc_inq_dimlen(ncFile, ncdim, &tmp_val);                        \
-      if (NC_NOERR != gdfail) {                                           \
-        std::cout<<"couldn't get dimension length for" << name<< " \n"; \
-        return 1;                                              \
-      }                                                                 \
-      else val = tmp_val;                                               \
-    } else val = 0;}
-
-#define GET_DIMB(ncdim, name, varname, id, val) \
-          INS_ID(name, varname, id); \
-          GET_DIM(ncdim, name, val);
-
-#define GET_VAR(name, id, dims) \
-    {                           \
-    id = -1;\
-    int gvfail = nc_inq_varid(ncFile, name, &id);   \
-    if (NC_NOERR == gvfail) {       \
-    int ndims;\
-    gvfail = nc_inq_varndims(ncFile, id, &ndims);\
-    if (NC_NOERR == gvfail) {\
-    dims.resize(ndims);    \
-    gvfail = nc_inq_vardimid(ncFile, id, &dims[0]);}}}
-
-#define GET_1D_INT_VAR(name, id, vals) \
-    {GET_VAR(name, id, vals);  \
-  if (-1 != id) {\
-    size_t ntmp;\
-    int ivfail = nc_inq_dimlen(ncFile, vals[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    ivfail = nc_get_vara_int(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != ivfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable " <<name <<"\n";\
-      return 1;}}}
-
-
-#define GET_1D_DBL_VAR(name, id, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    dvfail = nc_get_vara_double(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-/*
-int get_2d_flt_var(int ncFile, const char * name, int index, std::vector<float> & vals)
-{
-  int id;
-  std::vector<int> dum_dims;
-  GET_VAR(name, id, dum_dims);
-  if (-1 != id) {
-    size_t ntmp;
-  int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);
-  vals.resize(ntmp);
-  size_t ntmp1[2] = {index, 0};
-
-  int ntimes;
-  dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntimes);
-  if (index>=ntimes) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  size_t count[2] ={1, ntmp};
-  dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);
-  if (NC_NOERR != dvfail) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  return 0;
-}
-*/
-/* get the variable along an index */
-#define GET_2D_FLT_VAR(name, id, index, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp, ntmp2;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);\
-    dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp2);\
-    vals.resize(ntmp);\
-    size_t ntmp1[2] = {index, 0}; \
-    if (index>=ntmp2) { \
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n"; \
-      return 1; \
-    } \
-    size_t count[2] ={1, ntmp}; \
-    dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-int main(int argc, char ** argv)
-{
-
-  int num_el = 50000;
-  if (argc>1)
-  {
-    num_el = atoi(argv[1]);
-  }
-  std::cout << "num_el=" << num_el << "\n";
-
-  Core moab;
-  Interface & mb = moab;
-  ErrorCode rval;
-
-  int ncFile, temp_dim;        // netcdf/exodus file
-
-  // now, open the data file and read the lat, lon and U850 and V850
-  const char *data_file = "fc5_arm12.cam2.h2.0004-12-12-00000.nc";
-
-  int fail = nc_open(data_file, 0, &ncFile);
-  if (NC_NOWRITE != fail) {
-    std::cout<<"ReadNCDF:: problem opening Netcdf/Exodus II "<<data_file <<"\n";
-    return 1;
-  }
-  int ncol;
-  GET_DIM(temp_dim, "ncol", ncol);
-  std::cout << "ncol:" << ncol << "\n";
-
-  std::vector<double> lat;
-  std::vector<double> lon;
-  GET_1D_DBL_VAR("lat", temp_dim, lat);
-
-  GET_1D_DBL_VAR("lon", temp_dim, lon);
-
-  std::cout<< " lat, lon 0" << lat[0] << " " << lon[0] << "\n";
-  std::cout<< " lat, lon 1" << lat[1] << " " << lon[1] << "\n";
-  std::cout << " size: " << lat.size() << "\n";
-
-  // see if the mesh from metadata makes sense
-  // create quads with the connectivity from conn array
-
-  ReadUtilIface* readMeshIface;
-  mb.query_interface( readMeshIface );
-  if (NULL==readMeshIface)
-    return 1;
-  EntityHandle node_handle = 0;
-  std::vector<double*> arrays;
-  rval = readMeshIface->get_node_coords(3, ncol,
-      1, node_handle, arrays);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  SphereCoords  sp;
-  sp.R = 1.;
-  Tag gid;
-  rval = mb.tag_get_handle("GLOBAL_ID", 1, MB_TYPE_INTEGER,
-      gid, MB_TAG_SPARSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-      return 1;
-  std::vector<int> gids(ncol);
-
-  double conversion_factor = M_PI/180.;
-  for (int k=0; k<ncol; k++)
-  {
-    sp.lat=lat[k]*conversion_factor;
-    sp.lon=lon[k]*conversion_factor;
-    CartVect pos=spherical_to_cart (sp);
-    arrays[0][k]=pos[0];
-    arrays[1][k]=pos[1];
-    arrays[2][k]=pos[2];
-    gids[k]=k+1;
-  }
-
-  Range nodes(node_handle, node_handle+ncol-1);
-  rval = mb.tag_set_data(gid, nodes, &gids[0]);
-  if (MB_SUCCESS!= rval)
-       return 1;
-
-  EntityHandle newSet;
-  rval = mb.create_meshset(MESHSET_SET, newSet);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  // so the nodes will be part
-  mb.add_entities(newSet, nodes);
-
-  // build a kd tree with the vertices
-  EntityHandle tree_root;
-  AdaptiveKDTree kd(&mb, true);
-  rval = kd.build_tree(nodes, tree_root);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  unsigned int  min_depth, max_depth;
-  rval = kd.depth(tree_root, min_depth, max_depth);
-  if (MB_SUCCESS != rval)
-     return 1;
-  std::cout << "min_depth, max_depth " << min_depth << " " << max_depth << "\n";
-  // now, read the conn file created using spectral visu, and see how they fit
-  // this can be directly imported to moab
-  const char *myconn_file = "spec.R2.vtk";
-  EntityHandle euler_set;
-  rval = mb.create_meshset(MESHSET_SET, euler_set);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  rval = mb.load_file(myconn_file, &euler_set);
-
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  mb.list_entities(&euler_set, 1);
-
-  Range specQuads;
-  rval = mb.get_entities_by_dimension(euler_set, 2, specQuads );
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  Range vertices;
-  rval = mb.get_connectivity(specQuads, vertices);
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  // do a mapping, from position of vertices to the vertices in the kd tree.
-  // find the closest vertex to each of this
-  std::vector<EntityHandle> mappedTo(vertices.size());
-  std::vector<double> mycoords(vertices.size()*3);
-  rval = mb.get_coords(vertices, &mycoords[0]);
-  double * ptr = &mycoords[0];
-  size_t num_verts=vertices.size();
-  for (size_t i=0; i<num_verts; i++, ptr+=3)
-  {
-    CartVect pos(ptr); // take 3 coordinates
-    std::vector<EntityHandle> leaves;
-    rval = kd.leaves_within_distance( tree_root,
-                                          ptr,
-                                          0.001,
-                                        leaves);
-    if (MB_SUCCESS != rval)
-      return 1;
-    Range closeVerts;
-    for (std::vector<EntityHandle>::iterator vit = leaves.begin(); vit != leaves.end(); vit++)
-    {
-      rval= mb.get_entities_by_handle(*vit, closeVerts, Interface::UNION);
-      if (moab::MB_SUCCESS != rval)
-        return 1;
-    }
-    if (closeVerts.size()<1)
-    {
-      std::cout << "increase tolerance, no points close to " << pos << "\n";
-      return 1;
-    }
-    std::vector<CartVect> coordsTarget(closeVerts.size());
-    rval = mb.get_coords(closeVerts, &(coordsTarget[0][0]));
-    if (MB_SUCCESS != rval)
-      return 1;
-    double minDist2=(pos-coordsTarget[0]).length_squared();
-    EntityHandle closestVertex=closeVerts[0];
-    for (unsigned int j=1; j<closeVerts.size(); j++)
-    {
-      double dist2=(pos-coordsTarget[j]).length_squared();
-      if (minDist2>dist2)
-      {
-        closestVertex = closeVerts[j];
-        minDist2=dist2;
-      }
-    }
-    if (minDist2 > 0.00001)
-    {
-      std::cout << " problem with node " << vertices[i] << "  min dist2:" << minDist2 << "\n";
-      return 1;
-    }
-    mappedTo [i] = closestVertex;
-  }
-
-  num_el = (int)specQuads.size();
-  // tmp_ptr is of type int* and points at the same place as conn
-  EntityHandle * conn = 0;
-
-  EntityHandle elh;
-
-  readMeshIface->get_element_connect(
-          num_el,
-          4,
-          MBQUAD,
-          1,
-          elh,
-          conn);
-
-  EntityHandle firstVertMyMesh=vertices[0];
-  for (int k=0; k<num_el; k++)
-  {
-    const EntityHandle * myconn=0;
-    EntityHandle specElem = specQuads[k];
-    int num_nodes=0;
-    rval = mb.get_connectivity(specElem, myconn, num_nodes);
-    if (MB_SUCCESS != rval || num_nodes !=4)
-      return 1;
-
-    int start_el = k*4;
-    for (int j=0; j<4; j++)
-       conn[start_el+j] = mappedTo[myconn[j]-firstVertMyMesh];
-  }
-  std::cout << " conn:" << conn[0] << " " << conn[1] << " " << conn[3]<< "\n";
-  Range erange(elh, elh+num_el-1);
-
-  mb.add_entities(newSet, erange);
-  std::vector<int> gidels(num_el);
-  Tag gid2;
-  rval = mb.tag_get_handle("GLOBAL_ID_EL", 1, MB_TYPE_INTEGER,
-        gid2, MB_TAG_SPARSE|MB_TAG_CREAT);
-
-  if (MB_SUCCESS != rval)
-      return 1;
-  for (int k=0; k<num_el; k++)
-    gidels[k]=k+1;
-  mb.tag_set_data(gid2, erange, &gidels[0]);
-
-  int times;
-  GET_DIM(temp_dim, "time", times);
-  Tag velotag;
-  rval = mb.tag_get_handle("VELO", 3, MB_TYPE_DOUBLE,
-            velotag, MB_TAG_DENSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  for (size_t tt=0; tt<56 /*(size_t)times*/; tt++)
-  {
-    // now, read velocities from file:
-    // read the U850 and V850 variables
-    std::vector<float> u850;
-    GET_2D_FLT_VAR("U850", temp_dim, tt, u850);
-    std::vector<float> v850;
-    GET_2D_FLT_VAR("V850", temp_dim, tt, v850);
-
-    std::cout << " U850:" << u850[0] << " " << u850[1] << " " << u850[5] << " "<< u850.size()<<"\n";
-    std::cout << " V850:" << v850[0] << " " << v850[1] << " " << v850[5] << " "<< u850.size()<<"\n";
-    // ok, use radius as 6371km; not needed
-
-    std::vector<CartVect> velo850(ncol);
-
-    std::stringstream fileName;
-    fileName << "VELO0" <<  tt << ".h5m";
-    std::cout << " read velocities at 850 for time:" << tt << "\n";
-
-
-    for (int k=0; k<ncol; k++)
-    {
-      double latRad=lat[k]*conversion_factor;
-      double lonRad=lon[k]*conversion_factor;
-      CartVect U(-sin(lonRad), cos(lonRad), 0.);
-      CartVect V(-sin(latRad)*cos(lonRad), -sin(latRad)*cos(lonRad), cos(latRad));
-      velo850[k]=U*u850[k] +V*v850[k];
-    }
-    rval = mb.tag_set_data(velotag, nodes, &(velo850[0][0]));
-    if (MB_SUCCESS!= rval)
-      return 1;
-    rval = mb.write_mesh(fileName.str().c_str(), &newSet, 1);
-    if (MB_SUCCESS!= rval)
-      return 1;
-  }
-
-
-
-  return 0;
-}


https://bitbucket.org/fathomteam/moab/commits/059ee63ab988/
Changeset:   059ee63ab988
Branch:      None
User:        iulian07
Date:        2013-08-28 20:12:25
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  24 files

diff --git a/doc/MetaData/metadata.h b/doc/MetaData/metadata.h
index 8f81cff..3e822b9 100644
--- a/doc/MetaData/metadata.h
+++ b/doc/MetaData/metadata.h
@@ -619,7 +619,7 @@ various tags representing information read from the file. These tags are describ
 Reading unstructured NC files in the HOMME format is also supported. Currently a trivial
 element-based partition is the only option for parallel reading. As the data is unstructured, it is necessary to have a connectivity file to define the vertex adjacencies. The default convention is to have a file called HommeMapping.nc in the same directory as the the variable data file. If this convention is not followed, the connectivity file can be specified with the option -O CONN=”/path/to/connectivity.nc”. An example of mbconvert using the parallel read capability is shown below:
 
-<B>  mpiexec -np 2 tools/mbconvert -O TRIVIAL_PARTITION -O DEBUG_IO=1 -o DEBUG_IO=9 -o PARALLEL=WRITE_PART /nfs2/hayes6/meshlab/homme_data/camrun.cam2.h0.0000-01-01-16200.nc output.h5m </B>
+<B>  mpiexec -np 2 tools/mbconvert -O TRIVIAL -O DEBUG_IO=1 -o DEBUG_IO=9 -o PARALLEL=WRITE_PART /nfs2/hayes6/meshlab/homme_data/camrun.cam2.h0.0000-01-01-16200.nc output.h5m </B>
 
 Several other things to note about reading climate data files into MOAB:
 - Time-dependent variables: MOAB currently has no mechanism for time-dependent tags. Therefore, time-dependent variables are represented using one tag per timestep, with the tag name set as the variable name plus the timestep index. Thus, the first few timesteps for the variable TEMPERATURE would be represented in tags named TEMPERATURE0, TEMPERATURE1, etc.
@@ -699,7 +699,7 @@ dimension.
 <tr><td>__<var_name>_DIMS 
 </td>
-<td>C*n 
+<td>H*n 
 </td><td>S</td><td>For each variable, the tag handles for the

diff --git a/src/GeomTopoTool.cpp b/src/GeomTopoTool.cpp
index a302f0c..8f74453 100644
--- a/src/GeomTopoTool.cpp
+++ b/src/GeomTopoTool.cpp
@@ -901,7 +901,7 @@ ErrorCode GeomTopoTool::geometrize_surface_set(EntityHandle surface, EntityHandl
 
 
   Skinner tool(mdbImpl);
-  rval = tool.find_skin(surface_ents, 1, edge_ents);
+  rval = tool.find_skin(0, surface_ents, 1, edge_ents);
   if (MB_SUCCESS != rval)
     return rval;
   if (debugFlag)
@@ -1472,7 +1472,7 @@ bool GeomTopoTool::check_model()
     if (MB_SUCCESS!=rval)
       RETFALSE(" can't get surface elements from the face set ", faceSet)
 
-    rval = tool.find_skin(surface_ents, 1, edge_ents);
+    rval = tool.find_skin(0, surface_ents, 1, edge_ents);
     if (MB_SUCCESS != rval)
       RETFALSE("can't skin a surface ", surface_ents[0])
 

diff --git a/src/MergeMesh.cpp b/src/MergeMesh.cpp
index 3ea7623..71119a3 100644
--- a/src/MergeMesh.cpp
+++ b/src/MergeMesh.cpp
@@ -61,7 +61,7 @@ moab::ErrorCode MergeMesh::merge_entities(moab::Range &elems,
   // get the skin of the entities
   moab::Skinner skinner(mbImpl);
   moab::Range skin_range;
-  moab::ErrorCode result = skinner.find_skin(elems, 0, skin_range);
+  moab::ErrorCode result = skinner.find_skin(0, elems, 0, skin_range);
   if (moab::MB_SUCCESS != result) return result;
 
   // create a tag to mark merged-to entity; reuse tree_root
@@ -232,7 +232,7 @@ moab::ErrorCode MergeMesh::merge_higher_dimensions(moab::Range &elems)
   for(int dim = 1; dim <3; dim++){
     skinEnts.clear();
     moreDeadEnts.clear();
-    result = skinner.find_skin(elems, dim, skinEnts);
+    result = skinner.find_skin(0, elems, dim, skinEnts);
     //Go through each skin entity and see if it shares adjacancies with another entity
     for(moab::Range::iterator skinIt = skinEnts.begin(); skinIt != skinEnts.end(); skinIt++){
       adj.clear();

diff --git a/src/Skinner.cpp b/src/Skinner.cpp
index 5869777..57b3d51 100644
--- a/src/Skinner.cpp
+++ b/src/Skinner.cpp
@@ -185,7 +185,7 @@ void Skinner::add_adjacency(EntityHandle entity,
   }
 }
 
-ErrorCode Skinner::find_geometric_skin(Range &forward_target_entities) 
+ErrorCode Skinner::find_geometric_skin(const EntityHandle meshset, Range &forward_target_entities)
 {
     // attempts to find whole model skin, using geom topo sets first then
     // normal find_skin function
@@ -203,7 +203,7 @@ ErrorCode Skinner::find_geometric_skin(Range &forward_target_entities)
   Range face_sets;
   int two = 2;
   const void *two_ptr = &two;
-  result = thisMB->get_entities_by_type_and_tag(0, MBENTITYSET, &geom_tag, &two_ptr, 1,
+  result = thisMB->get_entities_by_type_and_tag(meshset, MBENTITYSET, &geom_tag, &two_ptr, 1,
                                                  face_sets);
 
   Range::iterator it;
@@ -240,7 +240,8 @@ ErrorCode Skinner::find_geometric_skin(Range &forward_target_entities)
   return result;
 }
 
-ErrorCode Skinner::find_skin( const Range& source_entities,
+ErrorCode Skinner::find_skin( const EntityHandle meshset,
+                              const Range& source_entities,
                               bool get_vertices,
                               Range& output_handles,
                               Range* output_reverse_handles,
@@ -264,7 +265,8 @@ ErrorCode Skinner::find_skin( const Range& source_entities,
     this_core->a_entity_factory()->create_vert_elem_adjacencies();
     
   if (this_core && this_core->a_entity_factory()->vert_elem_adjacencies())
-    return find_skin_vertices( source_entities, 
+    return find_skin_vertices( meshset,
+                               source_entities,
                                get_vertices ? &output_handles : 0,
                                get_vertices ? 0 : &output_handles,
                                output_reverse_handles,
@@ -276,7 +278,7 @@ ErrorCode Skinner::find_skin( const Range& source_entities,
   if (!source_entities.all_of_dimension(d))
     return MB_TYPE_OUT_OF_RANGE;
   
-  rval = thisMB->get_entities_by_dimension( 0, d-1, prev );
+  rval = thisMB->get_entities_by_dimension( meshset, d-1, prev );
   if (MB_SUCCESS != rval)
     return rval;
   
@@ -297,7 +299,7 @@ ErrorCode Skinner::find_skin( const Range& source_entities,
   
   if (!create_skin_elements) {
     Range new_skin;
-    rval = thisMB->get_entities_by_dimension( 0, d-1, new_skin);
+    rval = thisMB->get_entities_by_dimension( meshset, d-1, new_skin);
     if (MB_SUCCESS != rval)
       return rval;
     new_skin = subtract( new_skin, prev );
@@ -1062,13 +1064,14 @@ bool Skinner::has_larger_angle(EntityHandle &entity1,
 }
 
   // get skin entities of prescribed dimension
-ErrorCode Skinner::find_skin(const Range &entities,
+ErrorCode Skinner::find_skin(const EntityHandle this_set,
+                             const Range &entities,
                                  int dim,
                                  Range &skin_entities,
                                  bool create_vert_elem_adjs) 
 {
   Range tmp_skin;
-  ErrorCode result = find_skin(entities, (dim==0), tmp_skin, 0, 
+  ErrorCode result = find_skin(this_set, entities, (dim==0), tmp_skin, 0,
                                  create_vert_elem_adjs, true);
   if (MB_SUCCESS != result || tmp_skin.empty()) return result;
   
@@ -1086,7 +1089,8 @@ ErrorCode Skinner::find_skin(const Range &entities,
   return result;
 }
 
-ErrorCode Skinner::find_skin_vertices( const Range& entities,
+ErrorCode Skinner::find_skin_vertices( const EntityHandle this_set,
+                                       const Range& entities,
                                            Range* skin_verts,
                                            Range* skin_elems,
                                            Range* skin_rev_elems,
@@ -1104,7 +1108,7 @@ ErrorCode Skinner::find_skin_vertices( const Range& entities,
     // are we skinning all entities
   size_t count = entities.size();
   int num_total;
-  rval = thisMB->get_number_entities_by_dimension( 0, dim, num_total );
+  rval = thisMB->get_number_entities_by_dimension( this_set, dim, num_total );
   if (MB_SUCCESS != rval)
     return rval;
   bool all = (count == (size_t)num_total);

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 0fca661..b013472 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -316,7 +316,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
 
   // Finally, read into that space
   int success;
-  std::vector<int> requests(vdatas.size() * tstep_nums.size()), statuss(vdatas.size() * tstep_nums.size());
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end() )
        continue; // This is a dummy one, we don't have it; we created it for the dummy tag
@@ -327,28 +326,28 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
         case NC_BYTE:
         case NC_CHAR:
           success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              (char*) data NCREQ);
+              (char*) data);
           ERRORS(success, "Failed to read char data.");
           break;
         case NC_DOUBLE:
           success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              (double*) data NCREQ);
+              (double*) data);
           ERRORS(success, "Failed to read double data.");
           break;
         case NC_FLOAT: {
           success = NCFUNCAG(_vara_float)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              (float*) data NCREQ);
+              (float*) data);
           ERRORS(success, "Failed to read float data.");
           break;
         }
         case NC_INT:
           success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              (int*) data NCREQ);
+              (int*) data);
           ERRORS(success, "Failed to read int data.");
           break;
         case NC_SHORT:
           success = NCFUNCAG(_vara_short)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              (short*) data NCREQ);
+              (short*) data);
           ERRORS(success, "Failed to read short data.");
           break;
         default:
@@ -362,11 +361,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
     }
   }
 
-#ifdef NCWAIT
-  int success = ncmpi_wait_all(fileId, requests.size(), &requests[0], &statuss[0]);
-  ERRORS(success, "Failed on wait_all.");
-#endif
-
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
@@ -501,13 +495,13 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
 
   // Check to make sure it's a float or double
   if (NC_DOUBLE == (*vmit).second.varDataType) {
-    fail = NCFUNCA(get_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
+    fail = NCFUNCAG(_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
     if (fail)
       ERRORS(MB_FAILURE, "Failed to get coordinate values.");
   }
   else if (NC_FLOAT == (*vmit).second.varDataType) {
     std::vector<float> tcvals(tcount);
-    fail = NCFUNCA(get_vars_float)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &tcvals[0]);
+    fail = NCFUNCAG(_vars_float)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &tcvals[0]);
     if (fail)
       ERRORS(MB_FAILURE, "Failed to get coordinate values.");
     std::copy(tcvals.begin(), tcvals.end(), cvals.begin());
@@ -1152,7 +1146,6 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
 
   // Finally, read into that space
   int success;
-  std::vector<int> requests(vdatas.size() * tstep_nums.size()), statuss(vdatas.size() * tstep_nums.size());
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     std::size_t sz = vdatas[i].sz;
 
@@ -1167,7 +1160,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         case NC_CHAR: {
           std::vector<char> tmpchardata(sz);
           success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              &tmpchardata[0] NCREQ);
+              &tmpchardata[0]);
           if (vdatas[i].numLev != 1)
             // Switch from k varying slowest to k varying fastest
             success = kji_to_jik(ni, nj, nk, data, &tmpchardata[0]);
@@ -1181,7 +1174,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         case NC_DOUBLE: {
           std::vector<double> tmpdoubledata(sz);
           success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              &tmpdoubledata[0] NCREQ);
+              &tmpdoubledata[0]);
           if (vdatas[i].numLev != 1)
             // Switch from k varying slowest to k varying fastest
             success = kji_to_jik(ni, nj, nk, data, &tmpdoubledata[0]);
@@ -1195,7 +1188,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         case NC_FLOAT: {
           std::vector<float> tmpfloatdata(sz);
           success = NCFUNCAG(_vara_float)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              &tmpfloatdata[0] NCREQ);
+              &tmpfloatdata[0]);
           if (vdatas[i].numLev != 1)
             // Switch from k varying slowest to k varying fastest
             success = kji_to_jik(ni, nj, nk, data, &tmpfloatdata[0]);
@@ -1209,7 +1202,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         case NC_INT: {
           std::vector<int> tmpintdata(sz);
           success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              &tmpintdata[0] NCREQ);
+              &tmpintdata[0]);
           if (vdatas[i].numLev != 1)
             // Switch from k varying slowest to k varying fastest
             success = kji_to_jik(ni, nj, nk, data, &tmpintdata[0]);
@@ -1223,7 +1216,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         case NC_SHORT: {
           std::vector<short> tmpshortdata(sz);
           success = NCFUNCAG(_vara_short)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[t][0], &vdatas[i].readCounts[t][0],
-              &tmpshortdata[0] NCREQ);
+              &tmpshortdata[0]);
           if (vdatas[i].numLev != 1)
             // Switch from k varying slowest to k varying fastest
             success = kji_to_jik(ni, nj, nk, data, &tmpshortdata[0]);
@@ -1243,11 +1236,6 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
     }
   }
 
-#ifdef NCWAIT
-  int success = ncmpi_wait_all(fileId, requests.size(), &requests[0], &statuss[0]);
-  ERRORS(success, "Failed on wait_all.");
-#endif
-
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);

diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index aabdbde..98aa9c6 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -128,7 +128,7 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
     char posval[10];
     int success = NCFUNC(get_att_text)(_fileId, (*vmit).second.varId, "positive", posval);
     if (0 == success && !strcmp(posval, "down")) {
-      for (std::vector<double>::iterator dvit = zVertVals.begin(); dvit != zVertVals.end(); ++dvit)
+      for (std::vector<double>::iterator dvit = levVals.begin(); dvit != levVals.end(); ++dvit)
         (*dvit) *= -1.0;
     }
   }
@@ -200,6 +200,7 @@ ErrorCode NCHelperHOMME::check_existing_mesh()
 
       // Restore localGidVerts
       std::copy(gids.rbegin(), gids.rend(), range_inserter(localGidVerts));
+      nLocalVertices = localGidVerts.size();
     }
   }
 
@@ -233,7 +234,8 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
 
   int success;
 
-  int rank = 0, procs = 1;
+  int rank = 0;
+  int procs = 1;
 #ifdef USE_MPI
   bool& isParallel = _readNC->isParallel;
   if (isParallel) {
@@ -274,18 +276,19 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
     ERRORR(MB_FAILURE, "Failed to get number of quads.");
   }
   int num_quads = conn_vals[idx];
-  if (num_quads != nVertices - 2) {
-    dbgOut.tprintf(1, "Warning: number of quads from %s and vertices from %s are inconsistent; nverts = %d, nquads = %d.\n",
-        conn_fname.c_str(), fileName.c_str(), nVertices, num_quads);
+  if (num_quads != nCells) {
+    dbgOut.tprintf(1, "Warning: number of quads from %s and cells from %s are inconsistent; num_quads = %d, nCells = %d.\n",
+        conn_fname.c_str(), fileName.c_str(), num_quads, nCells);
   }
 
   // Get the connectivity into tmp_conn2 and permute into tmp_conn
   int cornerVarId;
   success = NCFUNC(inq_varid)(connectId, "element_corners", &cornerVarId);
   ERRORS(success, "Failed to get variable id.");
-  NCDF_SIZE tmp_starts[2] = {0, 0}, tmp_counts[2] = {4, static_cast<size_t>(num_quads)};
+  NCDF_SIZE tmp_starts[2] = {0, 0};
+  NCDF_SIZE tmp_counts[2] = {4, static_cast<NCDF_SIZE>(num_quads)};
   std::vector<int> tmp_conn(4 * num_quads), tmp_conn2(4 * num_quads);
-  success = NCFUNCAG(_vara_int)(connectId, cornerVarId, tmp_starts, tmp_counts, &tmp_conn2[0] NCREQ);
+  success = NCFUNCAG(_vara_int)(connectId, cornerVarId, tmp_starts, tmp_counts, &tmp_conn2[0]);
   ERRORS(success, "Failed to get temporary connectivity.");
   success = NCFUNC(close)(connectId);
   ERRORS(success, "Failed on close.");
@@ -330,7 +333,7 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
   if (!spectralMesh) {
     rval = _readNC->readMeshIface->get_element_connect(num_coarse_quads, 4,
                                               MBQUAD, 0, start_quad, conn_arr,
-                                                // might have to create gather mesh later
+                                              // Might have to create gather mesh later
                                               (create_gathers ? num_coarse_quads + num_quads : num_coarse_quads));
     ERRORR(rval, "Failed to create quads.");
     tmp_range.insert(start_quad, start_quad + num_coarse_quads - 1);
@@ -348,21 +351,21 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
     ERRORR(rval, "Failed to get fine connectivity of spectral elements.");
   }
 
-  unsigned int num_local_verts = localGidVerts.size();
-  unsigned int num_total_verts = nVertices;
-
   // Create vertices
+  nLocalVertices = localGidVerts.size();
   std::vector<double*> arrays;
-  rval = _readNC->readMeshIface->get_node_coords(3, num_local_verts, 0, start_vertex, arrays,
-                                          // might have to create gather mesh later
-                                        (create_gathers ? num_local_verts + num_total_verts : num_local_verts));
-  ERRORR(rval, "Couldn't create vertices in ucd mesh.");
+  rval = _readNC->readMeshIface->get_node_coords(3, nLocalVertices, 0, start_vertex, arrays,
+                                        // Might have to create gather mesh later
+                                        (create_gathers ? nLocalVertices + nVertices : nLocalVertices));
+  ERRORR(rval, "Couldn't create vertices in HOMME mesh.");
 
   // Set vertex coordinates
   Range::iterator rit;
-  double *xptr = arrays[0], *yptr = arrays[1], *zptr = arrays[2];
+  double* xptr = arrays[0];
+  double* yptr = arrays[1];
+  double* zptr = arrays[2];
   int i;
-  for (i = 0, rit = localGidVerts.begin(); i < (int)num_local_verts; i++, ++rit) {
+  for (i = 0, rit = localGidVerts.begin(); i < nLocalVertices; i++, ++rit) {
     assert(*rit < xVertVals.size() + 1);
     xptr[i] = xVertVals[(*rit) - 1]; // lon
     yptr[i] = yVertVals[(*rit) - 1]; // lat
@@ -370,7 +373,7 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
 
   // Convert lon/lat/rad to x/y/z
   const double pideg = acos(-1.0) / 180.0;
-  for (i = 0; i < (int)num_local_verts; i++) {
+  for (i = 0; i < nLocalVertices; i++) {
     double cosphi = cos(pideg * yptr[i]);
     double zmult = sin(pideg * yptr[i]);
     double xmult = cosphi * cos(xptr[i] * pideg);
@@ -382,12 +385,12 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
   }
 
   // Get ptr to gid memory for vertices
-  Range vert_range(start_vertex, start_vertex + num_local_verts - 1);
+  Range vert_range(start_vertex, start_vertex + nLocalVertices - 1);
   void* data;
   int count;
   rval = mbImpl->tag_iterate(mGlobalIdTag, vert_range.begin(), vert_range.end(), count, data);
   ERRORR(rval, "Failed to get tag iterator.");
-  assert(count == (int) num_local_verts);
+  assert(count == nLocalVertices);
   int* gid_data = (int*) data;
   std::copy(localGidVerts.begin(), localGidVerts.end(), gid_data);
 
@@ -395,16 +398,15 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
   if (mpFileIdTag) {
     rval = mbImpl->tag_iterate(*mpFileIdTag, vert_range.begin(), vert_range.end(), count, data);
     ERRORR(rval, "Failed to get tag iterator on file id tag.");
-    assert(count == (int) num_local_verts);
+    assert(count == nLocalVertices);
     gid_data = (int*) data;
     std::copy(localGidVerts.begin(), localGidVerts.end(), gid_data);
   }
 
   // Create map from file ids to vertex handles, used later to set connectivity
   std::map<EntityHandle, EntityHandle> vert_handles;
-  for (rit = localGidVerts.begin(), i = 0; rit != localGidVerts.end(); ++rit, i++) {
+  for (rit = localGidVerts.begin(), i = 0; rit != localGidVerts.end(); ++rit, i++)
     vert_handles[*rit] = start_vertex + i;
-  }
 
   // Compute proper handles in connectivity using offset
   for (int q = 0; q < 4 * num_coarse_quads; q++) {
@@ -421,9 +423,9 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
 
   // Add new vertices and elements to the set
   faces.merge(tmp_range);
-  tmp_range.insert(start_vertex, start_vertex + num_local_verts - 1);
+  tmp_range.insert(start_vertex, start_vertex + nLocalVertices - 1);
   rval = mbImpl->add_entities(_fileSet, tmp_range);
-  ERRORR(rval, "Couldn't add new vertices and quads/hexes to file set.");
+  ERRORR(rval, "Couldn't add new vertices and quads to file set.");
 
   // Mark the set with the spectral order
   Tag sporder;
@@ -440,11 +442,13 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
     // Create vertices
     arrays.clear();
     // Don't need to specify allocation number here, because we know enough verts were created before
-    rval = _readNC->readMeshIface->get_node_coords(3, num_total_verts, 0, start_vertex, arrays);
-    ERRORR(rval, "Couldn't create vertices in ucd mesh for gather set.");
+    rval = _readNC->readMeshIface->get_node_coords(3, nVertices, 0, start_vertex, arrays);
+    ERRORR(rval, "Couldn't create vertices in HOMME mesh for gather set.");
 
-    xptr = arrays[0], yptr = arrays[1], zptr = arrays[2];
-    for (i = 0; i < (int)num_total_verts; i++) {
+    xptr = arrays[0];
+    yptr = arrays[1];
+    zptr = arrays[2];
+    for (i = 0; i < nVertices; i++) {
       double cosphi = cos(pideg * yVertVals[i]);
       double zmult = sin(pideg * yVertVals[i]);
       double xmult = cosphi * cos(xVertVals[i] * pideg);
@@ -456,21 +460,21 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
     }
 
     // Get ptr to gid memory for vertices
-    Range gather_verts(start_vertex, start_vertex + num_total_verts - 1);
+    Range gather_verts(start_vertex, start_vertex + nVertices - 1);
     rval = mbImpl->tag_iterate(mGlobalIdTag, gather_verts.begin(), gather_verts.end(), count, data);
     ERRORR(rval, "Failed to get tag iterator.");
-    assert(count == (int) num_total_verts);
+    assert(count == nVertices);
     gid_data = (int*) data;
-    for (int j = 1; j <= (int) num_total_verts; j++)
+    for (int j = 1; j <= nVertices; j++)
       gid_data[j - 1] = j;
     // Set the file id tag too, it should be bigger something not interfering with global id
     if (mpFileIdTag) {
       rval = mbImpl->tag_iterate(*mpFileIdTag, gather_verts.begin(), gather_verts.end(), count, data);
       ERRORR(rval, "Failed to get tag iterator in file id tag.");
-      assert(count == (int) num_total_verts);
+      assert(count == nVertices);
       gid_data = (int*) data;
-      for (int j = 1; j <= (int) num_total_verts; j++)
-        gid_data[j - 1] = num_total_verts + j; // bigger than global id tag
+      for (int j = 1; j <= nVertices; j++)
+        gid_data[j - 1] = nVertices + j; // bigger than global id tag
     }
 
     rval = mbImpl->add_entities(gather_set, gather_verts);
@@ -485,7 +489,7 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
     gather_quads.insert(start_quad, start_quad + num_quads - 1);
     std::copy(&tmp_conn[0], &tmp_conn[4 * num_quads], conn_arr);
     for (i = 0; i != 4 * num_quads; i++)
-      conn_arr[i] += start_vertex - 1; // connectivity array is shifted by where the gather verts start
+      conn_arr[i] += start_vertex - 1; // Connectivity array is shifted by where the gather verts start
     rval = mbImpl->add_entities(gather_set, gather_quads);
     ERRORR(rval, "Couldn't add quads to gather set.");
   }
@@ -616,7 +620,7 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC
           // We will start from the first localGidVerts, actually; we will reset that
           // later on, anyway, in a loop
           vdatas[i].readStarts[t].push_back(localGidVerts[0] - 1);
-          vdatas[i].readCounts[t].push_back(localGidVerts.size());
+          vdatas[i].readCounts[t].push_back(nLocalVertices);
           assert(vdatas[i].readStarts[t].size() == vdatas[i].varDims.size());
           range = &verts;
           break;
@@ -700,9 +704,9 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_async(std::vector<ReadNC::V
 
             // Do a partial read, in each subrange
             // wait outside this loop
-            success = NCFUNCAG2(_vara_double)(_fileId, vdatas[i].varId,
+            success = NCFUNCREQG(_vara_double)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpdoubledata[indexInDoubleArray]) NCREQ2);
+                            &(tmpdoubledata[indexInDoubleArray]), &requests[idxReq++]);
             ERRORS(success, "Failed to read double data in loop");
             // We need to increment the index in double array for the
             // next subrange
@@ -746,9 +750,9 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_async(std::vector<ReadNC::V
 
             // Do a partial read, in each subrange
             // wait outside this loop
-            success = NCFUNCAG2(_vara_float)(_fileId, vdatas[i].varId,
+            success = NCFUNCREQG(_vara_float)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpfloatdata[indexInFloatArray]) NCREQ2);
+                            &(tmpfloatdata[indexInFloatArray]), &requests[idxReq++]);
             ERRORS(success, "Failed to read float data in loop");
             // We need to increment the index in float array for the
             // next subrange
@@ -814,7 +818,6 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData
 
   // Finally, read into that space
   int success;
-  std::vector<int> requests(vdatas.size() * tstep_nums.size()), statuss(vdatas.size() * tstep_nums.size());
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     std::size_t sz = vdatas[i].sz;
 
@@ -854,7 +857,7 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData
 
             success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpdoubledata[indexInDoubleArray]) NCREQ);
+                            &(tmpdoubledata[indexInDoubleArray]));
             ERRORS(success, "Failed to read float data in loop");
             // We need to increment the index in double array for the
             // next subrange
@@ -895,7 +898,7 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData
 
             success = NCFUNCAG(_vara_float)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpfloatdata[indexInFloatArray]) NCREQ);
+                            &(tmpfloatdata[indexInFloatArray]));
             ERRORS(success, "Failed to read float data in loop");
             // We need to increment the index in float array for the
             // next subrange
@@ -930,11 +933,6 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData
     }
   }
 
-#ifdef NCWAIT
-  int success = ncmpi_wait_all(fileId, requests.size(), &requests[0], &statuss[0]);
-  ERRORS(success, "Failed on wait_all.");
-#endif
-
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index eedb525..c78956c 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -147,9 +147,9 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
   int success = NCFUNC(inq_varid)(_fileId, "verticesOnEdge", &verticesOnEdgeVarId);
   ERRORS(success, "Failed to get variable id of verticesOnEdge.");
   NCDF_SIZE tmp_starts[2] = {0, 0};
-  NCDF_SIZE tmp_counts[2] = {static_cast<size_t>(nEdges), 2};
+  NCDF_SIZE tmp_counts[2] = {static_cast<NCDF_SIZE>(nEdges), 2};
   verticesOnEdge.resize(nEdges * 2);
-  success = NCFUNCAG(_vara_int)(_fileId, verticesOnEdgeVarId, tmp_starts, tmp_counts, &verticesOnEdge[0] NCREQ);
+  success = NCFUNCAG(_vara_int)(_fileId, verticesOnEdgeVarId, tmp_starts, tmp_counts, &verticesOnEdge[0]);
   ERRORS(success, "Failed to read variable values of verticesOnEdge.");
 
   // Determine the entity location type of a variable
@@ -267,8 +267,10 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   Interface*& mbImpl = _readNC->mbImpl;
   Tag& mGlobalIdTag = _readNC->mGlobalIdTag;
   const Tag*& mpFileIdTag = _readNC->mpFileIdTag;
+  int& gatherSetRank = _readNC->gatherSetRank;
 
-  int rank = 0, procs = 1;
+  int rank = 0;
+  int procs = 1;
 #ifdef USE_MPI
   bool& isParallel = _readNC->isParallel;
   if (isParallel) {
@@ -278,11 +280,14 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   }
 #endif
 
-  ErrorCode rval;
+  // Need to know whether we'll be creating gather mesh
+  bool create_gathers = false;
+  if (rank == gatherSetRank)
+    create_gathers = true;
 
   // Compute the number of local cells on this proc
   nLocalCells = int(std::floor(1.0 * nCells / procs));
-  // start_cell_idx is the starting cell index in the MPAS file for this proc
+  // start_cell_idx is the starting global cell index in the MPAS file for this proc
   int start_cell_idx = rank * nLocalCells;
   // iextra = # cells extra after equal split over procs
   int iextra = nCells % procs;
@@ -290,82 +295,83 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
     nLocalCells++;
   start_cell_idx += std::min(rank, iextra);
   start_cell_idx++; // 0 based -> 1 based
-
   localGidCells.insert(start_cell_idx, start_cell_idx + nLocalCells - 1);
 
-  // Read number of edges on each cell
+  // Read number of edges on each local cell
   int nEdgesOnCellVarId;
   int success = NCFUNC(inq_varid)(_fileId, "nEdgesOnCell", &nEdgesOnCellVarId);
   ERRORS(success, "Failed to get variable id of nEdgesOnCell.");
-  NCDF_SIZE tmp_starts_1[1] = {static_cast<size_t>(start_cell_idx - 1)};
-  NCDF_SIZE tmp_counts_1[1] = {static_cast<size_t>(nLocalCells)};
-  std::vector<int> num_edges_on_cell(nLocalCells);
-  success = NCFUNCAG(_vara_int)(_fileId, nEdgesOnCellVarId, tmp_starts_1, tmp_counts_1, &num_edges_on_cell[0] NCREQ);
+  NCDF_SIZE tmp_starts_1[1] = {static_cast<NCDF_SIZE>(start_cell_idx - 1)};
+  NCDF_SIZE tmp_counts_1[1] = {static_cast<NCDF_SIZE>(nLocalCells)};
+  std::vector<int> num_edges_on_local_cells(nLocalCells);
+  success = NCFUNCAG(_vara_int)(_fileId, nEdgesOnCellVarId, tmp_starts_1, tmp_counts_1, &num_edges_on_local_cells[0]);
   ERRORS(success, "Failed to read variable values of nEdgesOnCell.");
 
-  // Read vertices on each cell (connectivity)
+  // Read vertices on each local cell (connectivity)
   int verticesOnCellVarId;
   success = NCFUNC(inq_varid)(_fileId, "verticesOnCell", &verticesOnCellVarId);
   ERRORS(success, "Failed to get variable id of verticesOnCell.");
-  NCDF_SIZE tmp_starts_2[2] = {static_cast<size_t>(start_cell_idx - 1), 0};
-  NCDF_SIZE tmp_counts_2[2] = {static_cast<size_t>(nLocalCells), maxCellEdges};
-  std::vector<int> vertices_on_cell(nLocalCells * maxCellEdges);
-  success = NCFUNCAG(_vara_int)(_fileId, verticesOnCellVarId, tmp_starts_2, tmp_counts_2, &vertices_on_cell[0] NCREQ);
+  NCDF_SIZE tmp_starts_2[2] = {static_cast<NCDF_SIZE>(start_cell_idx - 1), 0};
+  NCDF_SIZE tmp_counts_2[2] = {static_cast<NCDF_SIZE>(nLocalCells), maxCellEdges};
+  std::vector<int> vertices_on_local_cells(nLocalCells * maxCellEdges);
+  success = NCFUNCAG(_vara_int)(_fileId, verticesOnCellVarId, tmp_starts_2, tmp_counts_2, &vertices_on_local_cells[0]);
   ERRORS(success, "Failed to read variable values of verticesOnCell.");
 
-  // Read edges on each cell
+  // Read edges on each local cell
   int edgesOnCellVarId;
   success = NCFUNC(inq_varid)(_fileId, "edgesOnCell", &edgesOnCellVarId);
   ERRORS(success, "Failed to get variable id of edgesOnCell.");
-  NCDF_SIZE tmp_starts_3[2] = {static_cast<size_t>(start_cell_idx - 1), 0};
-  NCDF_SIZE tmp_counts_3[2] = {static_cast<size_t>(nLocalCells), maxCellEdges};
-  std::vector<int> edges_on_cell(nLocalCells * maxCellEdges);
-  success = NCFUNCAG(_vara_int)(_fileId, edgesOnCellVarId, tmp_starts_3, tmp_counts_3, &edges_on_cell[0] NCREQ);
+  NCDF_SIZE tmp_starts_3[2] = {static_cast<NCDF_SIZE>(start_cell_idx - 1), 0};
+  NCDF_SIZE tmp_counts_3[2] = {static_cast<NCDF_SIZE>(nLocalCells), maxCellEdges};
+  std::vector<int> edges_on_local_cells(nLocalCells * maxCellEdges);
+  success = NCFUNCAG(_vara_int)(_fileId, edgesOnCellVarId, tmp_starts_3, tmp_counts_3, &edges_on_local_cells[0]);
   ERRORS(success, "Failed to read variable values of edgesOnCell.");
 
-  // Divide cells into groups based on the number of edges
-  std::vector<int> cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
+  // Divide local cells into groups based on the number of edges
+  std::vector<int> local_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
   for (int i = 0; i < nLocalCells; i++) {
     int cell_index = start_cell_idx + i; // Global cell index
-    int num_edges = num_edges_on_cell[i];
-    cells_with_n_edges[num_edges].push_back(cell_index);
+    int num_edges = num_edges_on_local_cells[i];
+    local_cells_with_n_edges[num_edges].push_back(cell_index);
   }
 
   // For each non-empty cell group, create cells and set connectivity array initially based on file ids
+  ErrorCode rval;
   EntityHandle start_element;
-  EntityHandle* conn_arr_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
+  EntityHandle* conn_arr_local_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
   Range tmp_range;
   void* data;
   int count;
   int* gid_data;
-  std::set<int> local_vertices_set;
+  std::set<int> local_verts_set;
   std::set<int> local_edges_set;
   numCellGroups = 0;
   for (int i = 3; i <= maxCellEdges; i++) {
-    int num_cells = cells_with_n_edges[i].size();
+    int num_cells = local_cells_with_n_edges[i].size();
     if (num_cells > 0) {
       numCellGroups++;
 
-      rval = _readNC->readMeshIface->get_element_connect(num_cells, i, MBPOLYGON, 0, start_element, conn_arr_cells_with_n_edges[i], num_cells);
+      rval = _readNC->readMeshIface->get_element_connect(num_cells, i, MBPOLYGON, 0, start_element, conn_arr_local_cells_with_n_edges[i], num_cells);
+      ERRORR(rval, "Couldn't create local cells in MPAS mesh.");
+      Range local_cell_range(start_element, start_element + num_cells - 1);
       tmp_range.insert(start_element, start_element + num_cells - 1);
       faces.insert(start_element, start_element + num_cells - 1);
 
-      // Get ptr to gid memory for cells
-      Range cell_range(start_element, start_element + num_cells - 1);
-      rval = mbImpl->tag_iterate(mGlobalIdTag, cell_range.begin(), cell_range.end(), count, data);
+      // Get ptr to gid memory for local cells
+      rval = mbImpl->tag_iterate(mGlobalIdTag, local_cell_range.begin(), local_cell_range.end(), count, data);
       ERRORR(rval, "Failed to get tag iterator on global id tag.");
       assert(count == (int) num_cells);
       gid_data = (int*) data;
-      std::copy(cells_with_n_edges[i].begin(), cells_with_n_edges[i].end(), gid_data);
+      std::copy(local_cells_with_n_edges[i].begin(), local_cells_with_n_edges[i].end(), gid_data);
 
       for (int j = 0; j < num_cells; j++) {
-        int cell_idx = cells_with_n_edges[i][j]; // Global cell index
+        int cell_idx = local_cells_with_n_edges[i][j]; // Global cell index
         cellHandleToGlobalID[start_element + j] = cell_idx;
         cell_idx -= start_cell_idx; // Local cell index
         for (int k = 0; k < i; k++) {
-          conn_arr_cells_with_n_edges[i][i * j + k] = vertices_on_cell[cell_idx * maxCellEdges + k];
-          local_vertices_set.insert(vertices_on_cell[cell_idx * maxCellEdges + k]);
-          local_edges_set.insert(edges_on_cell[cell_idx * maxCellEdges + k]);
+          conn_arr_local_cells_with_n_edges[i][i * j + k] = vertices_on_local_cells[cell_idx * maxCellEdges + k];
+          local_verts_set.insert(vertices_on_local_cells[cell_idx * maxCellEdges + k]);
+          local_edges_set.insert(edges_on_local_cells[cell_idx * maxCellEdges + k]);
         }
       }
     }
@@ -379,13 +385,16 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   ERRORR(rval, "Trouble setting data for __NUM_CELL_GROUPS tag.");
 
   // Collect localGid for vertices
-  std::copy(local_vertices_set.rbegin(), local_vertices_set.rend(), range_inserter(localGidVerts));
+  std::copy(local_verts_set.rbegin(), local_verts_set.rend(), range_inserter(localGidVerts));
   nLocalVertices = localGidVerts.size();
 
   // Create local vertices
   EntityHandle start_vertex;
   std::vector<double*> arrays;
-  rval = _readNC->readMeshIface->get_node_coords(3, nLocalVertices, 0, start_vertex, arrays);
+  rval = _readNC->readMeshIface->get_node_coords(3, nLocalVertices, 0, start_vertex, arrays,
+                                        // Might have to create gather mesh later
+                                        (create_gathers ? nLocalVertices + nVertices : nLocalVertices));
+  ERRORR(rval, "Couldn't create local vertices in MPAS mesh.");
   tmp_range.insert(start_vertex, start_vertex + nLocalVertices - 1);
 
   // Set coordinates for local vertices
@@ -401,9 +410,9 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
     zptr[vert_idx] = zVertVals[(*rit) - 1];
   }
 
-  // Get ptr to gid memory for vertices
-  Range vert_range(start_vertex, start_vertex + nLocalVertices - 1);
-  rval = mbImpl->tag_iterate(mGlobalIdTag, vert_range.begin(), vert_range.end(), count, data);
+  // Get ptr to gid memory for local vertices
+  Range local_verts_range(start_vertex, start_vertex + nLocalVertices - 1);
+  rval = mbImpl->tag_iterate(mGlobalIdTag, local_verts_range.begin(), local_verts_range.end(), count, data);
   ERRORR(rval, "Failed to get tag iterator on global id tag.");
   assert(count == (int) nLocalVertices);
   gid_data = (int*) data;
@@ -411,7 +420,7 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
   // Duplicate global id data, which will be used to resolve sharing
   if (mpFileIdTag) {
-    rval = mbImpl->tag_iterate(*mpFileIdTag, vert_range.begin(), vert_range.end(), count, data);
+    rval = mbImpl->tag_iterate(*mpFileIdTag, local_verts_range.begin(), local_verts_range.end(), count, data);
     ERRORR(rval, "Failed to get tag iterator on file id tag.");
     assert(count == (int) nLocalVertices);
     gid_data = (int*) data;
@@ -425,12 +434,12 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
 
   // For each non-empty cell group, set connectivity array with proper local vertices handles
   for (int i = 3; i <= maxCellEdges; i++) {
-    int num_cells = cells_with_n_edges[i].size();
+    int num_cells = local_cells_with_n_edges[i].size();
     if (num_cells > 0) {
       for (int j = 0; j < num_cells; j++) {
         for (int k = 0; k < i; k++) {
-          EntityHandle global_vert_id = conn_arr_cells_with_n_edges[i][i * j + k];
-          conn_arr_cells_with_n_edges[i][i * j + k] = vert_handles[global_vert_id];
+          EntityHandle global_vert_id = conn_arr_local_cells_with_n_edges[i][i * j + k];
+          conn_arr_local_cells_with_n_edges[i][i * j + k] = vert_handles[global_vert_id];
         }
       }
     }
@@ -443,22 +452,25 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   // Create local edges
   EntityHandle start_edge;
   EntityHandle* conn_arr_edges;
-  rval = _readNC->readMeshIface->get_element_connect(nLocalEdges, 2, MBEDGE, 0, start_edge, conn_arr_edges);
+  rval = _readNC->readMeshIface->get_element_connect(nLocalEdges, 2, MBEDGE, 0, start_edge, conn_arr_edges,
+                                            // Might have to create gather mesh later
+                                            (create_gathers ? nLocalEdges + nEdges : nLocalEdges));
+  ERRORR(rval, "Couldn't create local edges in MPAS mesh.");
+  Range local_edges_range(start_edge, start_edge + nLocalEdges - 1);
   tmp_range.insert(start_edge, start_edge + nLocalEdges - 1);
 
   // Set vertices for local edges
   int edge_idx;
-  for (rit = localGidEdges.begin(), edge_idx = 0; rit != localGidEdges.end(); ++rit, edge_idx += 2) {
+  for (rit = localGidEdges.begin(), edge_idx = 0; rit != localGidEdges.end(); ++rit, edge_idx++) {
     EntityHandle gloabl_edge_id = *rit;
     EntityHandle gloabl_vert_id_1 = verticesOnEdge[(gloabl_edge_id - 1) * 2 + 0];
     EntityHandle gloabl_vert_id_2 = verticesOnEdge[(gloabl_edge_id - 1) * 2 + 1];
-    conn_arr_edges[edge_idx] = vert_handles[gloabl_vert_id_1];
-    conn_arr_edges[edge_idx + 1] = vert_handles[gloabl_vert_id_2];
+    conn_arr_edges[edge_idx * 2 + 0] = vert_handles[gloabl_vert_id_1];
+    conn_arr_edges[edge_idx * 2 + 1] = vert_handles[gloabl_vert_id_2];
   }
 
   // Get ptr to gid memory for edges
-  Range edge_range(start_edge, start_edge + nLocalEdges - 1);
-  rval = mbImpl->tag_iterate(mGlobalIdTag, edge_range.begin(), edge_range.end(), count, data);
+  rval = mbImpl->tag_iterate(mGlobalIdTag, local_edges_range.begin(), local_edges_range.end(), count, data);
   ERRORR(rval, "Failed to get tag iterator on global id tag.");
   assert(count == (int) nLocalEdges);
   gid_data = (int*) data;
@@ -468,6 +480,128 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
   rval = _readNC->mbImpl->add_entities(_fileSet, tmp_range);
   ERRORR(rval, "Couldn't add new vertices/faces/edges to file set.");
 
+  if (create_gathers) {
+    EntityHandle gather_set;
+    rval = _readNC->readMeshIface->create_gather_set(gather_set);
+    ERRORR(rval, "Trouble creating gather set.");
+
+    // Create gather vertices
+    arrays.clear();
+    // Don't need to specify allocation number here, because we know enough verts were created before
+    rval = _readNC->readMeshIface->get_node_coords(3, nVertices, 0, start_vertex, arrays);
+    ERRORR(rval, "Couldn't create vertices in MPAS mesh for gather set.");
+    Range gather_verts_range(start_vertex, start_vertex + nVertices - 1);
+
+    xptr = arrays[0];
+    yptr = arrays[1];
+    zptr = arrays[2];
+    for (vert_idx = 0; vert_idx < nVertices; vert_idx++) {
+      xptr[vert_idx] = xVertVals[vert_idx];
+      yptr[vert_idx] = yVertVals[vert_idx];
+      zptr[vert_idx] = zVertVals[vert_idx];
+    }
+
+    // Get ptr to gid memory for gather vertices
+    rval = mbImpl->tag_iterate(mGlobalIdTag, gather_verts_range.begin(), gather_verts_range.end(), count, data);
+    ERRORR(rval, "Failed to get tag iterator on global id tag..");
+    assert(count == nVertices);
+    gid_data = (int*) data;
+    for (int j = 1; j <= nVertices; j++)
+      gid_data[j - 1] = j;
+    // Set the file id tag too, it should be bigger something not interfering with global id
+    if (mpFileIdTag) {
+      rval = mbImpl->tag_iterate(*mpFileIdTag, gather_verts_range.begin(), gather_verts_range.end(), count, data);
+      ERRORR(rval, "Failed to get tag iterator on file id tag.");
+      assert(count == nVertices);
+      gid_data = (int*) data;
+      for (int j = 1; j <= nVertices; j++)
+        gid_data[j - 1] = nVertices + j; // Bigger than global id tag
+    }
+
+    rval = mbImpl->add_entities(gather_set, gather_verts_range);
+    ERRORR(rval, "Couldn't add vertices to gather set.");
+
+    // Read number of edges on each gather cell
+    std::vector<int> num_edges_on_gather_cells(nCells);
+    tmp_starts_1[0] = 0;
+    tmp_counts_1[0] = static_cast<NCDF_SIZE>(nCells);
+#ifdef PNETCDF_FILE
+    // Enter independent I/O mode, since this read is only for the gather processor
+    success = NCFUNC(begin_indep_data)(_fileId);
+    ERRORS(success, "Failed to begin independent I/O mode.");
+    success = NCFUNCG(_vara_int)(_fileId, nEdgesOnCellVarId, tmp_starts_1, tmp_counts_1, &num_edges_on_gather_cells[0]);
+    ERRORS(success, "Failed to read variable values of nEdgesOnCell.");
+    success = NCFUNC(end_indep_data)(_fileId);
+    ERRORS(success, "Failed to end independent I/O mode.");
+#else
+    success = NCFUNCG(_vara_int)(_fileId, nEdgesOnCellVarId, tmp_starts_1, tmp_counts_1, &num_edges_on_gather_cells[0]);
+    ERRORS(success, "Failed to read variable values of nEdgesOnCell.");
+#endif
+    // Read vertices on each gather cell (connectivity)
+    std::vector<int> vertices_on_gather_cells(nCells * maxCellEdges);
+    tmp_starts_2[0] = 0;
+    tmp_starts_2[1] = 0;
+    tmp_counts_2[0] = nCells;
+    tmp_counts_2[1] = maxCellEdges;
+#ifdef PNETCDF_FILE
+    // Enter independent I/O mode, since this read is only for the gather processor
+    success = NCFUNC(begin_indep_data)(_fileId);
+    ERRORS(success, "Failed to begin independent I/O mode.");
+    success = NCFUNCG(_vara_int)(_fileId, verticesOnCellVarId, tmp_starts_2, tmp_counts_2, &vertices_on_gather_cells[0]);
+    ERRORS(success, "Failed to read variable values of verticesOnCell.");
+    success = NCFUNC(end_indep_data)(_fileId);
+    ERRORS(success, "Failed to end independent I/O mode.");
+#else
+    success = NCFUNCG(_vara_int)(_fileId, verticesOnCellVarId, tmp_starts_2, tmp_counts_2, &vertices_on_gather_cells[0]);
+    ERRORS(success, "Failed to read variable values of verticesOnCell.");
+#endif
+
+    // Divide gather cells into groups based on the number of edges
+    std::vector<int> gather_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
+    for (int i = 0; i < nCells; i++) {
+      int num_edges = num_edges_on_gather_cells[i];
+      gather_cells_with_n_edges[num_edges].push_back(i + 1); // 0 based -> 1 based
+    }
+
+    // For each non-empty cell group, create cells and set connectivity array
+    EntityHandle* conn_arr_gather_cells_with_n_edges[MAX_EDGES_PER_CELL + 1];
+    Range gather_cells_range;
+    for (int i = 3; i <= maxCellEdges; i++) {
+      int num_cells = gather_cells_with_n_edges[i].size();
+      if (num_cells > 0) {
+        rval = _readNC->readMeshIface->get_element_connect(num_cells, i, MBPOLYGON, 0, start_element, conn_arr_gather_cells_with_n_edges[i], num_cells);
+        ERRORR(rval, "Couldn't create cells in MPAS mesh for gather set.");
+        gather_cells_range.insert(start_element, start_element + num_cells - 1);
+        for (int j = 0; j < num_cells; j++) {
+          int cell_idx = gather_cells_with_n_edges[i][j]; // Global cell index
+          cell_idx--; // 1 based -> 0 based
+          for (int k = 0; k < i; k++)
+            // Connectivity array is shifted by where the gather verts start
+            conn_arr_gather_cells_with_n_edges[i][i * j + k] = (start_vertex - 1) + vertices_on_gather_cells[cell_idx * maxCellEdges + k];
+        }
+      }
+    }
+
+    rval = mbImpl->add_entities(gather_set, gather_cells_range);
+    ERRORR(rval, "Couldn't add cells to gather set.");
+
+    // Create gather edges
+    EntityHandle* conn_arr_gather_edges;
+
+    // Don't need to specify allocation number here, because we know enough edges were created before
+    rval = _readNC->readMeshIface->get_element_connect(nEdges, 2, MBEDGE, 0, start_edge, conn_arr_gather_edges);
+    ERRORR(rval, "Couldn't create edges in MPAS mesh for gather set.");
+    Range gather_edges_range(start_edge, start_edge + nEdges - 1);
+
+    std::copy(verticesOnEdge.begin(), verticesOnEdge.end(), conn_arr_gather_edges);
+    for (int i = 0; i < 2 * nEdges; i++)
+      // Connectivity array is shifted by where the gather verts start
+      conn_arr_gather_edges[i] += start_vertex - 1;
+
+    rval = mbImpl->add_entities(gather_set, gather_edges_range);
+    ERRORR(rval, "Couldn't add edges to gather set.");
+  }
+
   return MB_SUCCESS;
 }
 
@@ -746,9 +880,9 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset_async(std::vector<ReadNC::Va
 
             // Do a partial read, in each subrange
             // wait outside this loop
-            success = NCFUNCAG2(_vara_double)(_fileId, vdatas[i].varId,
+            success = NCFUNCREQG(_vara_double)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpdoubledata[indexInDoubleArray]) NCREQ2);
+                            &(tmpdoubledata[indexInDoubleArray]), &requests[idxReq++]);
             ERRORS(success, "Failed to read double data in loop");
             // We need to increment the index in double array for the
             // next subrange
@@ -756,7 +890,7 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset_async(std::vector<ReadNC::Va
           }
           assert(ic == pLocalGid->psize());
 
-          success = ncmpi_wait_all(_fileId, requests.size(), &requests[0], &statuss[0]);
+          success = NCFUNC(wait_all)(_fileId, requests.size(), &requests[0], &statuss[0]);
           ERRORS(success, "Failed on wait_all.");
 
           // Local cells are grouped by the number of edges on each cell, e.g. 5, 6 or 7
@@ -839,7 +973,6 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData>
   int success;
   Range* pLocalGid = NULL;
 
-  std::vector<int> requests(vdatas.size() * tstep_nums.size()), statuss(vdatas.size() * tstep_nums.size());
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     switch (vdatas[i].entLoc) {
       case ReadNC::ENTLOCVERT:
@@ -889,7 +1022,7 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData>
 
             success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId,
                 &(vdatas[i].readStarts[t][0]), &(vdatas[i].readCounts[t][0]),
-                            &(tmpdoubledata[indexInDoubleArray]) NCREQ);
+                            &(tmpdoubledata[indexInDoubleArray]));
             ERRORS(success, "Failed to read double data in loop");
             // We need to increment the index in double array for the
             // next subrange
@@ -946,11 +1079,6 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData>
     }
   }
 
-#ifdef NCWAIT
-  int success = ncmpi_wait_all(fileId, requests.size(), &requests[0], &statuss[0]);
-  ERRORS(success, "Failed on wait_all.");
-#endif
-
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);

diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index ab91ded..6776b45 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -23,37 +23,32 @@
 #include "DebugOutput.hpp"
 
 #ifdef USE_MPI
-#  include "moab_mpi.h"
-#  include "moab/ParallelComm.hpp"
+#include "moab_mpi.h"
+#include "moab/ParallelComm.hpp"
 #endif 
 
 #ifdef PNETCDF_FILE
-#  include "pnetcdf.h"
-#  define NCFUNC(func) ncmpi_ ## func
-#  define NCFUNCA(func) ncmpi_ ## func ## _all
-//! keep it this way , introduce another macro, used so far only for ucd mesh
-//#  define NCASYNCH
-#  ifdef NCASYNCH
-#    define NCREQ , &requests[j]
-#    define NCFUNCAG(func) ncmpi_iget ## func 
-#    define NCWAIT
-#  else
-#    define NCREQ2 , &requests[idxReq++]
-#    define NCFUNCAG2(func) ncmpi_iget ## func
-#    define NCREQ 
-#    define NCFUNCAG(func) ncmpi_get ## func ## _all
-#  endif
-#  define NCDF_SIZE MPI_Offset
-#  define NCDF_DIFF MPI_Offset
+#include "pnetcdf.h"
+#define NCFUNC(func) ncmpi_ ## func
+
+//! Collective I/O mode get
+#define NCFUNCAG(func) ncmpi_get ## func ## _all
+
+//! Independent I/O mode get
+#define NCFUNCG(func) ncmpi_get ## func
+
+//! Nonblocking get (request aggregation), used so far only for ucd mesh
+#define NCFUNCREQG(func) ncmpi_iget ## func
+
+#define NCDF_SIZE MPI_Offset
+#define NCDF_DIFF MPI_Offset
 #else
-#  include "netcdf.h"
-#define NCREQ
-#define NCGET get
-#  define NCFUNC(func) nc_ ## func
-#  define NCFUNCA(func) nc_ ## func
-#  define NCFUNCAG(func) nc_get ## func
-#  define NCDF_SIZE size_t
-#  define NCDF_DIFF ptrdiff_t
+#include "netcdf.h"
+#define NCFUNC(func) nc_ ## func
+#define NCFUNCAG(func) nc_get ## func
+#define NCFUNCG(func) nc_get ## func
+#define NCDF_SIZE size_t
+#define NCDF_DIFF ptrdiff_t
 #endif
 
 namespace moab {

diff --git a/src/io/Tqdcfr.cpp b/src/io/Tqdcfr.cpp
index dc841fc..b930ab6 100644
--- a/src/io/Tqdcfr.cpp
+++ b/src/io/Tqdcfr.cpp
@@ -2492,7 +2492,10 @@ ErrorCode Tqdcfr::parse_acis_attribs(const unsigned int entity_rec_num,
     records[entity_rec_num].entity = uidSetMap[uid];
   }
 
-  assert(records[entity_rec_num].entity);
+  if (0==records[entity_rec_num].entity)
+    return MB_SUCCESS; // we do not have a MOAB entity for this, skip
+
+  //assert(records[entity_rec_num].entity);
   
     // set the id
   if (id != -1) {

diff --git a/src/io/WriteCCMIO.cpp b/src/io/WriteCCMIO.cpp
index bc972f2..9eb80da 100644
--- a/src/io/WriteCCMIO.cpp
+++ b/src/io/WriteCCMIO.cpp
@@ -950,7 +950,7 @@ namespace moab {
     //================================================
     Range neuset_facets, skin_facets;
     Skinner skinner(mbImpl);
-    result = skinner.find_skin(all_elems, mDimension-1, skin_facets);
+    result = skinner.find_skin(0, all_elems, mDimension-1, skin_facets);
     CHKERR(result, "Failed to get skin facets.");
 
     // remove neumann set facets from skin facets, we have to output these

diff --git a/src/moab/Skinner.hpp b/src/moab/Skinner.hpp
index 94463af..7ec5450 100644
--- a/src/moab/Skinner.hpp
+++ b/src/moab/Skinner.hpp
@@ -54,7 +54,7 @@ public:
   //! destructor
   ~Skinner();
 
-  ErrorCode find_geometric_skin(Range &forward_target_entities);
+  ErrorCode find_geometric_skin(const EntityHandle meshset, Range &forward_target_entities);
   
     /**\brief will accept entities all of one dimension and 
      *        return entities of n-1 dimension; NOTE: get_vertices argument controls whether
@@ -72,7 +72,8 @@ public:
      *        of skin entities, otherwise only skin entities already extant 
      *        will be returned
      */
-  ErrorCode find_skin( const Range &entities,
+  ErrorCode find_skin( const EntityHandle meshset,
+                       const Range &entities,
                        bool get_vertices,
                        Range &output_handles,
                        Range *output_reverse_handles = 0,
@@ -97,7 +98,8 @@ public:
      *        of skin entities, otherwise only skin entities already extant 
      *        will be returned
      */
-  ErrorCode find_skin( const EntityHandle *entities,
+  ErrorCode find_skin( const EntityHandle this_set,
+                       const EntityHandle *entities,
                        int num_entities,
                        bool get_vertices,
                        Range &output_handles,
@@ -113,7 +115,8 @@ public:
      * \param create_vert_elem_adjs If true, this function will cause 
      *        vertex-element adjacencies to be generated
      */
-  ErrorCode find_skin(const Range &entities,
+  ErrorCode find_skin(const EntityHandle this_set,
+                      const Range &entities,
                       int dim,
                       Range &skin_entities,
                       bool create_vert_elem_adjs = false);
@@ -189,7 +192,8 @@ protected:
      *                    will contain only those skin elements that already
      *                    exist.
      */
-  ErrorCode find_skin_vertices( const Range& entities,
+  ErrorCode find_skin_vertices( const EntityHandle this_set,
+                                const Range& entities,
                                   Range* skin_verts = 0,
                                   Range* skin_elems = 0,
                                   Range* rev_elems = 0,
@@ -281,7 +285,8 @@ protected:
                      bool create_skin_elements);
 };
 
-inline ErrorCode Skinner::find_skin( const EntityHandle *entities,
+inline ErrorCode Skinner::find_skin( const EntityHandle this_set,
+                                     const EntityHandle *entities,
                                      int num_entities,
                                      bool get_vertices,
                                      Range &output_handles,
@@ -292,7 +297,7 @@ inline ErrorCode Skinner::find_skin( const EntityHandle *entities,
 {
   Range ents;
   std::copy(entities, entities+num_entities, range_inserter(ents));
-  return find_skin(ents, get_vertices, output_handles, output_reverse_handles, 
+  return find_skin(this_set, ents, get_vertices, output_handles, output_reverse_handles,
                    create_vert_elem_adjs, create_skin_elements, look_for_scd);
 }
       

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 90bab23..4977f91 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -3575,7 +3575,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     return resolve_shared_ents(this_set, proc_ents, resolve_dim, shared_dim, id_tag);
   }
   
-  ErrorCode ParallelComm::resolve_shared_ents(EntityHandle /*this_set*/,
+  ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                               Range &proc_ents,
                                               int resolve_dim,
                                               int shared_dim,
@@ -3630,7 +3630,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
     // find the skin
     Skinner skinner(mbImpl);
-    result = skinner.find_skin(skin_ents[skin_dim+1], false, skin_ents[skin_dim],
+    result = skinner.find_skin(this_set, skin_ents[skin_dim+1], false, skin_ents[skin_dim],
                                NULL, true, true, true);
     RRA("Failed to find skin.");
     myDebug->tprintf(1, "Found skin, now resolving.\n");
@@ -3643,11 +3643,12 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
       RRA("Failed getting skin adjacencies.");
     }
 
-    return resolve_shared_ents(proc_ents, skin_ents,
+    return resolve_shared_ents(this_set, proc_ents, skin_ents,
                                resolve_dim, shared_dim, id_tag);
   }
 
-  ErrorCode ParallelComm::resolve_shared_ents(Range &proc_ents,
+  ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
+                                              Range &proc_ents,
                                               Range skin_ents[],
                                               int resolve_dim,
                                               int shared_dim,
@@ -3671,7 +3672,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
       else if (tag_created) {
         // just created it, so we need global ids
-        result = assign_global_ids(0, skin_dim+1,true,true,true);
+        result = assign_global_ids(this_set, skin_dim+1,true,true,true);
         RRA("Failed assigning global ids.");
       }
     }
@@ -3711,7 +3712,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     // get total number of entities; will overshoot highest global id, but
     // that's ok
     int num_total[2] = {0, 0}, num_local[2] = {0, 0};
-    result = mbImpl->get_number_entities_by_dimension(0, 0, num_local);
+    result = mbImpl->get_number_entities_by_dimension(this_set, 0, num_local);
     if (MB_SUCCESS != result) return result;
     int failure = MPI_Allreduce(num_local, num_total, 1,
     MPI_INTEGER, MPI_SUM, procConfig.proc_comm());
@@ -3873,6 +3874,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
   ErrorCode ParallelComm::resolve_shared_ents(ParallelComm **pc, 
                                               const unsigned int np, 
+                                              EntityHandle this_set,
                                               const int part_dim) 
   {
     std::vector<Range> verts(np);
@@ -3882,9 +3884,9 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     for (p = 0; p < np; p++) {
       Skinner skinner(pc[p]->get_moab());
       Range part_ents, skin_ents;
-      rval = pc[p]->get_moab()->get_entities_by_dimension(0, part_dim, part_ents);
+      rval = pc[p]->get_moab()->get_entities_by_dimension(this_set, part_dim, part_ents);
       if (MB_SUCCESS != rval) return rval;
-      rval = skinner.find_skin(part_ents, false, skin_ents, 0, true, true, true);
+      rval = skinner.find_skin(this_set, part_ents, false, skin_ents, 0, true, true, true);
       if (MB_SUCCESS != rval) return rval;
       rval = pc[p]->get_moab()->get_adjacencies(skin_ents, 0, true, verts[p],
                                                 Interface::UNION);
@@ -3951,7 +3953,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
     std::set<unsigned int> psets;
     for (p = 0; p < np; p++) {
-      rval = pc[p]->create_interface_sets(part_dim, part_dim-1);
+      rval = pc[p]->create_interface_sets(this_set, part_dim, part_dim-1);
       if (MB_SUCCESS != rval) return rval;
       // establish comm procs and buffers for them
       psets.clear();
@@ -4332,7 +4334,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
 
 
-  ErrorCode ParallelComm::create_interface_sets(int resolve_dim, int shared_dim) 
+  ErrorCode ParallelComm::create_interface_sets(EntityHandle this_set, int resolve_dim, int shared_dim)
   {
     std::map<std::vector<int>, std::vector<EntityHandle> > proc_nvecs;
   
@@ -4355,9 +4357,9 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                                   
     Skinner skinner(mbImpl);
     Range skin_ents[4];
-    result = mbImpl->get_entities_by_dimension(0, resolve_dim, skin_ents[resolve_dim]);
+    result = mbImpl->get_entities_by_dimension(this_set, resolve_dim, skin_ents[resolve_dim]);
     RRA("");
-    result = skinner.find_skin(skin_ents[resolve_dim], false, 
+    result = skinner.find_skin(this_set, skin_ents[resolve_dim], false,
                                skin_ents[resolve_dim-1], 0, true, true, true);
     RRA("Failed to find skin.");
     if (shared_dim > 1) {
@@ -6896,7 +6898,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     Range entities;
     if (entities_in.empty()) 
       std::copy(sharedEnts.begin(), sharedEnts.end(), range_inserter(entities));
-    else entities = entities_in;
+    else
+      entities = entities_in;
 
     int dum_ack_buff;
 
@@ -6908,7 +6911,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
       result = filter_pstatus(tag_ents, PSTATUS_SHARED, PSTATUS_AND, *sit);
       RRA("Failed pstatus AND check.");
     
-      // remove nonowned entities
+      // remote nonowned entities
       if (!tag_ents.empty()) {
         result = filter_pstatus(tag_ents, PSTATUS_NOT_OWNED, PSTATUS_NOT);
         RRA("Failed pstatus NOT check.");
@@ -6999,7 +7002,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
       Range owned_ents;
       if (entities_in.empty()) 
         std::copy(sharedEnts.begin(), sharedEnts.end(), range_inserter(entities));
-      else owned_ents = entities_in;
+      else
+        owned_ents = entities_in;
       result = filter_pstatus(owned_ents, PSTATUS_NOT_OWNED, PSTATUS_NOT);
       RRA("Failure to get subset of owned entities");
   

diff --git a/src/parallel/ParallelMergeMesh.cpp b/src/parallel/ParallelMergeMesh.cpp
index e6e1cd1..f0b99c6 100644
--- a/src/parallel/ParallelMergeMesh.cpp
+++ b/src/parallel/ParallelMergeMesh.cpp
@@ -45,7 +45,7 @@ namespace moab{
     }
     
     //Get the local skin elements
-    rval = PopulateMySkinEnts(dim);
+    rval = PopulateMySkinEnts(0,dim);
     //If there is only 1 proc, we can return now
     if(rval != MB_SUCCESS || myPcomm->size() == 1){
       return rval;
@@ -107,12 +107,12 @@ namespace moab{
   }
 
   //Sets mySkinEnts with all of the skin entities on the processor
-  ErrorCode ParallelMergeMesh::PopulateMySkinEnts(int dim)
+  ErrorCode ParallelMergeMesh::PopulateMySkinEnts(const EntityHandle meshset,int dim)
   {
     /*Merge Mesh Locally*/
     //Get all dim dimensional entities
     Range ents;
-    ErrorCode rval = myMB->get_entities_by_dimension(0,dim,ents);
+    ErrorCode rval = myMB->get_entities_by_dimension(meshset,dim,ents);
     if(rval != MB_SUCCESS){
       return rval;
     }
@@ -137,7 +137,7 @@ namespace moab{
       -skinEnts[i] is the skin entities of dimension i*/  
     Skinner skinner(myMB);
     for(int skin_dim = dim; skin_dim >= 0; skin_dim--){
-      rval = skinner.find_skin(ents,skin_dim,mySkinEnts[skin_dim]);
+      rval = skinner.find_skin(meshset,ents,skin_dim,mySkinEnts[skin_dim]);
       if(rval != MB_SUCCESS){
 	return rval;
       }

diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index 55bdd93..90cbad6 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -437,7 +437,8 @@ namespace moab {
 
      * \param skin_ents[] entity skin array by user
      */
-    ErrorCode resolve_shared_ents(Range &proc_ents,
+    ErrorCode resolve_shared_ents(EntityHandle this_set,
+                                  Range &proc_ents,
 				  Range skin_ents[],
 				  int resolve_dim = 3,
 				  int shared_dim = -1,
@@ -445,6 +446,7 @@ namespace moab {
     
     static ErrorCode resolve_shared_ents(ParallelComm **pc, 
                                          const unsigned int np, 
+                                         EntityHandle this_set,
                                          const int to_dim);
 
     /** Remove shared sets.
@@ -865,7 +867,7 @@ namespace moab {
                                     int resolve_dim, int shared_dim);
 
     // do the same but working straight from sharedEnts
-    ErrorCode create_interface_sets(int resolve_dim, int shared_dim);
+    ErrorCode create_interface_sets(EntityHandle this_set, int resolve_dim, int shared_dim);
 
     ErrorCode tag_shared_verts(TupleList &shared_ents,
 			       std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs,

diff --git a/src/parallel/moab/ParallelMergeMesh.hpp b/src/parallel/moab/ParallelMergeMesh.hpp
index a995bd5..aea3061 100644
--- a/src/parallel/moab/ParallelMergeMesh.hpp
+++ b/src/parallel/moab/ParallelMergeMesh.hpp
@@ -39,7 +39,7 @@ namespace moab {
     //Wrapper of merge() that performs the merge
     ErrorCode PerformMerge();
     //Determine the local skin entities (fills mySkinEnts)
-    ErrorCode PopulateMySkinEnts(int dim);
+    ErrorCode PopulateMySkinEnts(const EntityHandle meshset,int dim);
     //Get the global bounding box
     ErrorCode GetGlobalBox(double *gbox);
     //Fill out the local myTup before the first gather-scatter

diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index 7394c63..df947cf 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -4442,7 +4442,7 @@ ErrorCode mb_merge_test()
       //get Hexes from model
   }
   result = MB->get_entities_by_type(0, MBHEX, entities);
-  Skinner_Obj.find_skin(entities,false,forward_lower,&reverse_lower);
+  Skinner_Obj.find_skin(0,entities,false,forward_lower,&reverse_lower);
   cout <<"num hexes = "<<entities.size()<<"\n";
   cout <<"fl = "<<forward_lower.size()<<" rl = "<<reverse_lower.size()<<"\n";
   
@@ -6146,7 +6146,7 @@ ErrorCode mb_skin_curve_test_common( bool use_adj )
   
   Range skin;
   Skinner tool(mb);
-  rval = tool.find_skin( edges, 0, skin, use_adj );
+  rval = tool.find_skin( 0, edges, 0, skin, use_adj );
   if (MB_SUCCESS != rval) {
     std::cerr << "Skinner failure at " __FILE__ ":" << __LINE__ << std::endl;
     return MB_FAILURE;
@@ -6169,7 +6169,7 @@ ErrorCode mb_skin_curve_test_common( bool use_adj )
   EntityHandle edge = edges.front();
   Range range(edge,edge);
   skin.clear();
-  rval = tool.find_skin( range, 0, skin, use_adj );
+  rval = tool.find_skin( 0, range, 0, skin, use_adj );
   if (MB_SUCCESS != rval) {
     std::cerr << "Skinner failure at " __FILE__ ":" << __LINE__ << std::endl;
     return MB_FAILURE;
@@ -6238,7 +6238,7 @@ ErrorCode mb_skin_surface_test_common( bool use_adj )
   
   Range skin;
   Skinner tool(mb);
-  rval = tool.find_skin( source, 1, skin, use_adj );
+  rval = tool.find_skin( 0, source, 1, skin, use_adj );
   if (MB_SUCCESS != rval) {
     std::cerr << "Skinner failure at " __FILE__ ":" << __LINE__ << std::endl;
     return MB_FAILURE;
@@ -6331,7 +6331,7 @@ ErrorCode mb_skin_volume_test_common( bool use_adj )
   
   Range skin;
   Skinner tool(mb);
-  rval = tool.find_skin( source, 2, skin, use_adj );
+  rval = tool.find_skin( 0, source, 2, skin, use_adj );
   if (MB_SUCCESS != rval) {
     std::cerr << "Skinner failure at " __FILE__ ":" << __LINE__ << std::endl;
     return MB_FAILURE;
@@ -6361,10 +6361,10 @@ ErrorCode mb_skin_scd_test()
   Skinner tool(mb);
   Range ents(this_box->start_element(), this_box->start_element()+this_box->num_elements()-1),
       scd_skin_ents, skin_ents;
-  rval = tool.find_skin(ents, false, scd_skin_ents, NULL, true, true, true);
+  rval = tool.find_skin(0, ents, false, scd_skin_ents, NULL, true, true, true);
   if (MB_SUCCESS != rval) return rval;
 
-  rval = tool.find_skin(ents, false, skin_ents, NULL, true, true, false);
+  rval = tool.find_skin(0, ents, false, skin_ents, NULL, true, true, false);
   if (MB_SUCCESS != rval) return rval;
 
     // should be same number of entities
@@ -6374,10 +6374,10 @@ ErrorCode mb_skin_scd_test()
   scd_skin_ents.clear();
   
     // now test getting faces and vertices, also with existing faces now
-  rval = tool.find_skin(ents, true, scd_skin_ents, NULL, true, true, true);
+  rval = tool.find_skin(0, ents, true, scd_skin_ents, NULL, true, true, true);
   if (MB_SUCCESS != rval) return rval;
 
-  rval = tool.find_skin(ents, true, skin_ents, NULL, true, true, false);
+  rval = tool.find_skin(0, ents, true, skin_ents, NULL, true, true, false);
   if (MB_SUCCESS != rval) return rval;
 
     // again, should have same numbers
@@ -6532,7 +6532,7 @@ ErrorCode mb_skin_verts_common( unsigned dim, bool skin_elems )
   
     // Get skin vertices using skinner
   Range actual;
-  rval = tool.find_skin( ents, !skin_elems, actual );
+  rval = tool.find_skin( 0, ents, !skin_elems, actual );
   if (MB_SUCCESS != rval)
     return rval;
  
@@ -6761,7 +6761,7 @@ ErrorCode mb_skin_poly_test()
   
   Skinner tool(&mb);
   Range skin;
-  rval = tool.find_skin( regions, true, skin, 0, true, false );
+  rval = tool.find_skin( 0, regions, true, skin, 0, true, false );
   if (MB_SUCCESS != rval) {
     std::cout << "Vertex skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -6784,7 +6784,7 @@ ErrorCode mb_skin_poly_test()
   }
   
   skin.clear();
-  rval = tool.find_skin( regions, false, skin, 0, true, false );
+  rval = tool.find_skin( 0, regions, false, skin, 0, true, false );
   if (MB_SUCCESS != rval) {
     std::cout << "Non-create face skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -6800,7 +6800,7 @@ ErrorCode mb_skin_poly_test()
   }
   
   skin.clear();
-  rval = tool.find_skin( regions, false, skin, 0, true, true );
+  rval = tool.find_skin( 0, regions, false, skin, 0, true, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Create face skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -6906,7 +6906,7 @@ ErrorCode mb_skin_higher_order_faces_common( bool use_adj )
   Skinner tool(&mb);
   Range skin;
   
-  rval = tool.find_skin( faces, true, skin, 0, use_adj, false );
+  rval = tool.find_skin( 0, faces, true, skin, 0, use_adj, false );
   if (MB_SUCCESS != rval) {
     std::cout << "Vertex skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -6919,7 +6919,7 @@ ErrorCode mb_skin_higher_order_faces_common( bool use_adj )
   const int skin_edges[5][3] = {
     {0,1,2}, {2,3,4}, {4,9,12}, {12,11,10}, {10,5,0} };
   skin.clear();
-  rval = tool.find_skin( faces, false, skin, 0, use_adj, true );
+  rval = tool.find_skin( 0, faces, false, skin, 0, use_adj, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Edge skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -7034,7 +7034,7 @@ ErrorCode mb_skin_higher_order_regions_common( bool use_adj )
   Skinner tool(&mb);
   Range skin;
 
-  rval = tool.find_skin( hexes, true, skin, 0, use_adj, false );
+  rval = tool.find_skin( 0, hexes, true, skin, 0, use_adj, false );
   if (MB_SUCCESS != rval) {
     std::cout << "Vertex skinning failed with: " << mb.get_error_string(rval) 
               << std::endl;
@@ -7057,7 +7057,7 @@ ErrorCode mb_skin_higher_order_regions_common( bool use_adj )
   }
   
   skin.clear();
-  rval = tool.find_skin( hexes, false, skin, 0, use_adj, true );
+  rval = tool.find_skin( 0, hexes, false, skin, 0, use_adj, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Element skinning failed with: " << mb.get_error_string(rval) << std::endl;
     return rval;
@@ -7202,7 +7202,7 @@ ErrorCode mb_skin_reversed_common( int dim, bool use_adj )
   
   Range forward, reverse;
   Skinner tool(&mb);
-  rval = tool.find_skin( elems, false, forward, &reverse, use_adj, true );
+  rval = tool.find_skin( 0, elems, false, forward, &reverse, use_adj, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Skinner failed." << std::endl;
     return rval;
@@ -7284,7 +7284,7 @@ ErrorCode mb_skin_subset_common( int dimension, bool use_adj )
   
   Range skin;
   Skinner tool(&mb);
-  rval = tool.find_skin( input, true, skin, 0, use_adj, false );
+  rval = tool.find_skin( 0, input, true, skin, 0, use_adj, false );
   if (MB_SUCCESS != rval) {
     std::cout << "Skinner failed to find skin vertices" << std::endl;
     return MB_FAILURE;
@@ -7303,7 +7303,7 @@ ErrorCode mb_skin_subset_common( int dimension, bool use_adj )
   std::vector<EntityHandle> sv( skin.begin(), skin.end() );
   std::vector<int> counts( sv.size(), 0 );
   skin.clear();
-  rval = tool.find_skin( input, false, skin, 0, use_adj, true );
+  rval = tool.find_skin( 0, input, false, skin, 0, use_adj, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Skinner failed to find skin elements" << std::endl;
     return MB_FAILURE;
@@ -7418,7 +7418,7 @@ ErrorCode mb_skin_full_common( int dimension, bool use_adj )
   
   Range skin;
   Skinner tool(&mb);
-  rval = tool.find_skin( input, false, skin, 0, use_adj, true );
+  rval = tool.find_skin( 0, input, false, skin, 0, use_adj, true );
   if (MB_SUCCESS != rval) {
     std::cout << "Skinner failed to find skin elements" << std::endl;
     return MB_FAILURE;
@@ -7552,7 +7552,7 @@ ErrorCode mb_skin_adjacent_surf_patches()
     Range edges[4];
     for (int grp = 0; grp < 4; ++grp) {
         // get the skin edges
-      rval = tool.find_skin( ranges[grp], 1, edges[grp], use_adj );
+      rval = tool.find_skin( 0, ranges[grp], 1, edges[grp], use_adj );
       if (MB_SUCCESS != rval) {
         std::cout << "Skinner failed for run " << run << " group " << grp << std::endl;
         return rval;

diff --git a/test/parallel/parallel_hdf5_test.cc b/test/parallel/parallel_hdf5_test.cc
index 680d4bd..2b2a1c8 100644
--- a/test/parallel/parallel_hdf5_test.cc
+++ b/test/parallel/parallel_hdf5_test.cc
@@ -335,9 +335,9 @@ void print_partitioned_entities( Interface& moab, bool list_non_shared = false )
           else {
             buffer << rank << ":\t" << topo_names_s[t] << " " << id << ":\t"
                    << "processors ";
-            for (int j = 0; j < MAX_SHARING_PROCS; ++j)
-              if (ent_procs[j] != -1)
-                buffer << ent_procs[j] << ", ";
+            for (int k = 0; k < MAX_SHARING_PROCS; ++k)
+              if (ent_procs[k] != -1)
+                buffer << ent_procs[k] << ", ";
             if (num_owned)
               buffer << " (owned by this processor)";
             buffer << std::endl;
@@ -856,7 +856,7 @@ void create_input_file( const char* file_name,
   if (create_bcsets) {
       // neumann set
     Range skin_ents;
-    rval = Skinner(&mb).find_skin(&elems[0], elems.size(), false, skin_ents);
+    rval = Skinner(&mb).find_skin(0, &elems[0], elems.size(), false, skin_ents);
     CHECK_ERR(rval);
     EntityHandle bcset;
     rval = mb.create_meshset( MESHSET_SET, bcset);

diff --git a/test/parallel/parmerge.cpp b/test/parallel/parmerge.cpp
index aef7987..f29445d 100644
--- a/test/parallel/parmerge.cpp
+++ b/test/parallel/parmerge.cpp
@@ -169,7 +169,7 @@ void print_output(moab::ParallelComm *pc, moab::Core *mb,
     skin.clear();
     ents.clear();
     mb->get_entities_by_dimension(0,3,ents);
-    skinner.find_skin(ents, 2, skin);
+    skinner.find_skin(0, ents, 2, skin);
     for(moab::Range::iterator s_rit = skin.begin(); 
         s_rit != skin.end(); s_rit++){
       pc->get_owner(*s_rit, tmp);

diff --git a/test/parallel/pcomm_serial.cpp b/test/parallel/pcomm_serial.cpp
index dd6752e..5e63851 100644
--- a/test/parallel/pcomm_serial.cpp
+++ b/test/parallel/pcomm_serial.cpp
@@ -81,7 +81,7 @@ int main( int argc, char* argv[] )
     CHECK_ERR(rval);
   }
   
-  rval = ParallelComm::resolve_shared_ents(&pc[0], nprocs, 3);
+  rval = ParallelComm::resolve_shared_ents(&pc[0], nprocs, 0, 3);
   CHECK_ERR(rval);
 
     // exchange interface cells

diff --git a/test/parallel/pcomm_unit.cpp b/test/parallel/pcomm_unit.cpp
index 5e1c5d3..f0eb372 100644
--- a/test/parallel/pcomm_unit.cpp
+++ b/test/parallel/pcomm_unit.cpp
@@ -326,7 +326,7 @@ ErrorCode create_shared_grid_2d(ParallelComm **pc, Range *verts, Range *quads)
     create_patch(pc[i]->get_moab(), verts[i], quads[i], 3, xyztmp, &gids[9*i]);
   }
 
-  ErrorCode rval = ParallelComm::resolve_shared_ents(pc, 4, 2);
+  ErrorCode rval = ParallelComm::resolve_shared_ents(pc, 4, 0, 2);
   CHECK_ERR(rval);
 
   return rval;
@@ -362,8 +362,8 @@ ErrorCode create_shared_grid_3d(ParallelComm **pc, Range *verts, Range *hexes)
                          (j-ijkmin[p][1])*nijk[p][0] + (i - ijkmin[p][0]))
 
   int p, i, j, k;
-  for (int p = 0; p < P; p++) {
-    for (int i = 0; i < 3; i++) {
+  for (p = 0; p < P; p++) {
+    for (i = 0; i < 3; i++) {
       nijk[p][i] =  ijkmax[p][i] - ijkmin[p][i] + 1;
       NIJK[i] = std::max(NIJK[i], nijk[p][i]);
     }
@@ -434,7 +434,7 @@ ErrorCode create_shared_grid_3d(ParallelComm **pc, Range *verts, Range *hexes)
     rval = pc[p]->get_moab()->write_file(fname.str().c_str());
     if (MB_SUCCESS != rval) return rval;
   }
-  rval = ParallelComm::resolve_shared_ents(pc, 4, 3);
+  rval = ParallelComm::resolve_shared_ents(pc, 4, 0, 3);
   CHECK_ERR(rval);
   return rval;
 }
@@ -1216,10 +1216,10 @@ void test_pack_set_parent_child()
     // look for a set with two child links (set3)
   set1 = set2 = set3 = 0;
   for (Range::iterator i = sets.begin(); i != sets.end(); ++i) {
-    int count;
-    rval = moab.num_child_meshsets( *i, &count );
+    int mcount;
+    rval = moab.num_child_meshsets( *i, &mcount );
     CHECK_ERR(rval);
-    if (count == 2) {
+    if (mcount == 2) {
       set3 = *i;
       break;
     }
@@ -1662,12 +1662,12 @@ void test_pack_variable_length_tag()
     rval = mb.get_coords( &*i, 1, coords );
     CHECK_ERR(rval);
     
-    int size;
+    int tsize;
     const void* valptr;
-    rval = mb.tag_get_by_ptr( tag, &*i, 1, &valptr, &size );
+    rval = mb.tag_get_by_ptr( tag, &*i, 1, &valptr, &tsize );
     CHECK_ERR(rval);
-    CHECK( size > 1 );
-    CHECK( size <= 4 );
+    CHECK( tsize > 1 );
+    CHECK( tsize <= 4 );
     
     const int* valarr = reinterpret_cast<const int*>(valptr);
     CHECK( valarr[0] >= 1 );
@@ -1889,14 +1889,14 @@ void test_filter_pstatus()
   rval = mb.get_entities_by_type( 0, MBVERTEX, dum_vertsr );
   CHECK_ERR(rval);
   vertsr.insert(dum_vertsr[0], dum_vertsr[8]);
-  for (unsigned int i = 0; i < 9; i++) verts.push_back(vertsr[i]);
+  for (int k = 0; k < 9; k++) verts.push_back(vertsr[k]);
 
   CHECK( !verts.empty() );
  
   ParallelComm *pcomm = new ParallelComm( &moab, MPI_COMM_WORLD );
 
   std::vector<int> procs(70, -1);
-  for (unsigned int i = 0; i < 6; i++) procs[i] = i;
+  for (int k = 0; k < 6; k++) procs[k] = k;
 
   std::vector<unsigned char> pvals(verts.size(), 0);
     // interface, owned

diff --git a/test/perf/perftool.cpp b/test/perf/perftool.cpp
index 26bf73d..c02273a 100644
--- a/test/perf/perftool.cpp
+++ b/test/perf/perftool.cpp
@@ -266,7 +266,7 @@ void skin_common( int interval, int dim, int num, bool use_adj )
   Skinner tool(gMB);
   
   t = clock();
-  rval = tool.find_skin( elems, true, verts, 0, use_adj, false );
+  rval = tool.find_skin( 0, elems, true, verts, 0, use_adj, false );
   t = clock() - t;
   if (MB_SUCCESS != rval) {
     std::cerr << "Search for skin vertices failed" << std::endl;
@@ -288,7 +288,7 @@ void skin_common( int interval, int dim, int num, bool use_adj )
     blockelems.merge( it, end );
     it = end;
     tt = clock();
-    rval = tool.find_skin( blockelems, true, verts, 0, use_adj, false );
+    rval = tool.find_skin( 0, blockelems, true, verts, 0, use_adj, false );
     t += clock() - tt;
     if (MB_SUCCESS != rval) {
       std::cerr << "Search for skin vertices failed" << std::endl;
@@ -312,7 +312,7 @@ void skin_common( int interval, int dim, int num, bool use_adj )
   
     skin.clear();
     t = clock();
-    rval = tool.find_skin( elems, false, skin, 0, use_adj, true );
+    rval = tool.find_skin( 0, elems, false, skin, 0, use_adj, true );
     t = clock() - t;
     if (MB_SUCCESS != rval) {
       std::cerr << "Search for skin vertices failed" << std::endl;
@@ -330,7 +330,7 @@ void skin_common( int interval, int dim, int num, bool use_adj )
       blockelems.merge( it, end );
       it = end;
       tt = clock();
-      rval = tool.find_skin( blockelems, false, skin, 0, use_adj, true );
+      rval = tool.find_skin( 0, blockelems, false, skin, 0, use_adj, true );
       t += clock() - tt;
       if (MB_SUCCESS != rval) {
         std::cerr << "Search for skin elements failed" << std::endl;

diff --git a/tools/dagmc/cub2h5m.cc b/tools/dagmc/cub2h5m.cc
index c45f349..535a689 100644
--- a/tools/dagmc/cub2h5m.cc
+++ b/tools/dagmc/cub2h5m.cc
@@ -1012,7 +1012,7 @@ ErrorCode add_dead_elems_to_impl_compl(Interface *MBI,
     // skin the volumes
     Skinner tool(MBI);
     Range skin_faces;
-    result = tool.find_skin(elems, 2, skin_faces, true);
+    result = tool.find_skin(0, elems, 2, skin_faces, true);
     assert(MB_SUCCESS == result);
     if (MB_SUCCESS != result)
       return result;

diff --git a/tools/depth.cpp b/tools/depth.cpp
index 1a63c52..080d1b7 100644
--- a/tools/depth.cpp
+++ b/tools/depth.cpp
@@ -126,7 +126,7 @@ void tag_depth( Interface& mb, Tag tag )
     if (--dim == 0)
       return; // no elements
   }
-  rval = tool.find_skin( elems, 0, verts ); check(rval);
+  rval = tool.find_skin( 0, elems, 0, verts ); check(rval);
   rval = get_adjacent_elems( mb, verts, elems ); check(rval);
   
   std::vector<int> data;

diff --git a/tools/skin.cpp b/tools/skin.cpp
index 9c126a0..66f0739 100644
--- a/tools/skin.cpp
+++ b/tools/skin.cpp
@@ -264,9 +264,9 @@ int main( int argc, char* argv[] )
   Range forward_lower, reverse_lower;
   Skinner tool( iface );
   if (use_scd) 
-    result = tool.find_skin( skin_ents, false, forward_lower, NULL, false, true, true);
+    result = tool.find_skin( 0, skin_ents, false, forward_lower, NULL, false, true, true);
   else
-    result = tool.find_skin( skin_ents, false, forward_lower, &reverse_lower );
+    result = tool.find_skin( 0, skin_ents, false, forward_lower, &reverse_lower );
   Range boundary;
   boundary.merge( forward_lower );
   boundary.merge( reverse_lower );


https://bitbucket.org/fathomteam/moab/commits/286d0b881d77/
Changeset:   286d0b881d77
Branch:      None
User:        iulian07
Date:        2013-08-30 00:00:36
Summary:     add -f option for transport example, for different starting fields

Affected #:  2 files

diff --git a/tools/mbcslam/CslamUtils.cpp b/tools/mbcslam/CslamUtils.cpp
index 4d21b41..39facca 100644
--- a/tools/mbcslam/CslamUtils.cpp
+++ b/tools/mbcslam/CslamUtils.cpp
@@ -1204,14 +1204,50 @@ double quasi_smooth_field(double lam, double tet, double * params)
   return value;
 }
 // page 4
+// params are now x1, y1, ..., y2, z2 (6 params)
+// plus h max and b0 (total of 8 params); radius is 1
 double smooth_field(double lam, double tet, double * params)
 {
-  return 0.;
+  SphereCoords sc;
+  sc.R = 1.;
+  sc.lat= tet;
+  sc.lon = lam;
+  double hmax = params[6];
+  double b0 = params[7];
+  CartVect xyz = spherical_to_cart(sc);
+  CartVect c1(params);
+  CartVect c2(params+3);
+  double expo1 = -b0 * (xyz-c1).length_squared();
+  double expo2 = -b0 * (xyz-c2).length_squared();
+  return hmax*( exp(expo1) + exp(expo2));
 }
 // page 5
 double slotted_cylinder_field(double lam, double tet, double * params)
 {
-  return 0.;
+  double la1 = params[0];
+  double te1 = params[1];
+  double la2 = params[2];
+  double te2 = params[3];
+  double b = params[4];
+  double c = params[5];
+  //double hmax = params[6]; // 1;
+  double r = params[6] ; // 0.5;
+  double r1 = distance_on_sphere(lam, tet, la1, te1);
+  double r2 = distance_on_sphere(lam, tet, la2, te2);
+  double value = b;
+  double d1=fabs(lam-la1);
+  double d2 = fabs(lam-la2);
+  double rp6 = r/6;
+  double rt5p12 = r*5/12;
+
+  if (r1<=r && r2<=r && d1>=rp6 && d2>=rp6)
+    value =c;
+  else if (r1<=r && d1<rp6 && tet-te1<-rt5p12)
+    value = c;
+  else if (r2<r && d2 < rp6 && tet-te2 > rt5p12)
+    value =c;
+
+  return value;
 }
 
 } //namespace moab

diff --git a/tools/mbcslam/diffusion.cpp b/tools/mbcslam/diffusion.cpp
index 1519200..3ca988c 100644
--- a/tools/mbcslam/diffusion.cpp
+++ b/tools/mbcslam/diffusion.cpp
@@ -49,6 +49,9 @@ double radius = 1.;// in m:  6371220.
 int numSteps = 50; // number of times with velocity displayed at points
 double T = 5;
 
+int case_number = 1; // 1, 2 (non-divergent) 3 divergent
+
+int field_type = 1 ; // 1 quasi smooth, 2 - smooth, 3 non-smooth,
 #ifdef MESHDIR
 std::string TestDir( STRINGIFY(MESHDIR) );
 #else
@@ -96,19 +99,66 @@ ErrorCode add_field_value(Interface * mb, EntityHandle euler_set, int rank, Tag
   // nondivergent flow, page 5, case 1, (la1, te1) = (M_PI, M_PI/3)
   //                                    (la2, te2) = (M_PI, -M_PI/3)
   //                 la1,    te1    la2    te2     b     c  hmax  r
-  double params[] = { M_PI, M_PI/3, M_PI, -M_PI/3, 0.1, 0.9, 1., 0.5};
-  for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+  if (field_type==1) // quasi smooth
   {
-    EntityHandle oldV=*vit;
-    CartVect posi;
-    rval = mb->get_coords(&oldV, 1, &(posi[0]) );
-    CHECK_ERR(rval);
+    double params[] = { M_PI, M_PI/3, M_PI, -M_PI/3, 0.1, 0.9, 1., 0.5};
+    for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+    {
+      EntityHandle oldV=*vit;
+      CartVect posi;
+      rval = mb->get_coords(&oldV, 1, &(posi[0]) );
+      CHECK_ERR(rval);
+
+      SphereCoords sphCoord = cart_to_spherical(posi);
+
+      ptr_DP[0]=quasi_smooth_field(sphCoord.lon, sphCoord.lat, params);;
+
+      ptr_DP++; // increment to the next node
+    }
+  }
+  else if (2 == field_type) // smooth
+  {
+    CartVect p1, p2;
+    SphereCoords spr;
+    spr.R = 1;
+    spr.lat = M_PI/3;
+    spr.lon= M_PI;
+    p1 = spherical_to_cart(spr);
+    spr.lat = -M_PI/3;
+    p2 = spherical_to_cart(spr);
+    //                  x1,    y1,     z1,    x2,   y2,    z2,   h_max, b0
+    double params[] = { p1[0], p1[1], p1[2], p2[0], p2[1], p2[2], 1,    5.};
+    for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+    {
+      EntityHandle oldV=*vit;
+      CartVect posi;
+      rval = mb->get_coords(&oldV, 1, &(posi[0]) );
+      CHECK_ERR(rval);
 
-    SphereCoords sphCoord = cart_to_spherical(posi);
+      SphereCoords sphCoord = cart_to_spherical(posi);
 
-    ptr_DP[0]=quasi_smooth_field(sphCoord.lon, sphCoord.lat, params);;
+      ptr_DP[0]=smooth_field(sphCoord.lon, sphCoord.lat, params);;
 
-    ptr_DP++; // increment to the next node
+      ptr_DP++; // increment to the next node
+    }
+  }
+  else if (3 == field_type) // slotted
+  {
+    //                   la1, te1,   la2, te2,       b,   c,   r
+    double params[] = { M_PI, M_PI/3, M_PI, -M_PI/3, 0.1, 0.9, 0.5};// no h_max
+    for (Range::iterator vit=connecVerts.begin();vit!=connecVerts.end(); vit++ )
+    {
+      EntityHandle oldV=*vit;
+      CartVect posi;
+      rval = mb->get_coords(&oldV, 1, &(posi[0]) );
+      CHECK_ERR(rval);
+
+      SphereCoords sphCoord = cart_to_spherical(posi);
+
+      ptr_DP[0]=slotted_cylinder_field(sphCoord.lon, sphCoord.lat, params);;
+
+      ptr_DP++; // increment to the next node
+    }
   }
 
   // add average value for quad/polygon (average corners)
@@ -142,7 +192,7 @@ ErrorCode add_field_value(Interface * mb, EntityHandle euler_set, int rank, Tag
   }
 
   std::stringstream iniPos;
-  iniPos<<"def" << rank<<".vtk";
+  iniPos<< "Tracer" << rank<<"_"<<0<<  ".vtk";// first time step
   rval = mb->write_file(iniPos.str().c_str(), 0, 0, &euler_set, 1);
   CHECK_ERR(rval);
 
@@ -192,7 +242,7 @@ ErrorCode compute_velocity_case1(Interface * mb, EntityHandle euler_set, Tag & t
     ptr_velo+=3;// to next velocity
   }
   std::stringstream velos;
-  velos<<"velo0" << rank<<"_"<<tStep<<  ".vtk";
+  velos<<"Tracer" << rank<<"_"<<tStep<<  ".vtk";
   rval = mb->write_file(velos.str().c_str(), 0, 0, &euler_set, 1);
   CHECK_ERR(rval);
 
@@ -331,6 +381,16 @@ int main(int argc, char **argv)
         extra_read_opts = std::string(argv[++index]);
       }
 
+      if (!strcmp(argv[index], "-f"))
+      {
+        field_type = atoi(argv[++index]);
+      }
+
+      if (!strcmp(argv[index], "-h"))
+      {
+        std::cout << "usage: -gtol <tol> -input <file> -O <extra_read_opts> -f <field_type> -h (this help)\n";
+        return 0;
+      }
       index++;
     }
   }


https://bitbucket.org/fathomteam/moab/commits/7e3687b9740a/
Changeset:   7e3687b9740a
Branch:      None
User:        iulian07
Date:        2013-08-30 00:01:36
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  6 files

diff --git a/doc/MetaData/metadata.h b/doc/MetaData/metadata.h
index 3e822b9..6d03665 100644
--- a/doc/MetaData/metadata.h
+++ b/doc/MetaData/metadata.h
@@ -129,13 +129,13 @@ Data: Entity sets; Tag(s): DIRICHLET_SET/I, NEUMANN_SET/I)
 Boundary conditions are often specified in terms of geometric model entities, similar to material types.  MOAB uses entity sets to store this information as well.  The DIRICHLET_SET and NEUMANN_SET tags are used to represent Dirichlet- and Neumann-type boundary condition sets, resp.  By convention, Neumann sets usually contain (indirectly) intermediate-dimension entities like edges in a 2D mesh or faces in a 3D mesh, while Dirichlet sets usually contain vertices.  In addition, Neumann sets are represented as sets of faces, rather than as sides of elements.  Faces can be ordered “forward” or “reverse” with respect to one of the bounding elements, depending on whether the right-hand normal points into or out of the element.  Forward-sense faces are added to the Neumann set.  Reverse-sense faces are put into a separate set; that set is tagged with the NEUSET_SENSE tag, with value = -1; and that reverse set is added to the Neummann set.
 
 <H3> Parallel Mesh Constructs </H3>
-(Data: Entity sets, entities; Tag(s): PARALLEL_PART/I, PARALLEL_PARTITION/I, PSTATUS/C*1, PARALLEL_SHARED_PROC/I, PARALLEL/SHARED_HANDLE/H, PARALLEL_SHARED_PROCS/I*NP, PARALLEL_SHARED_HANDLES/H*NP)
+(Data: Entity sets, entities; Tag(s): PARALLEL_PARTITION/I, PSTATUS/C*1, PARALLEL_SHARED_PROC/I, PARALLEL/SHARED_HANDLE/H, PARALLEL_SHARED_PROCS/I*NP, PARALLEL_SHARED_HANDLES/H*NP)
 
 On a parallel computer, MOAB can represent the mesh on each processor as well as information about entities shared with neighboring processors.  Some of this information is also relevant even when the mesh is represented on a serial machine.  MOAB uses several tag and set conventions to describe the parallel nature of a mesh.  This information is summarized here; for a more complete description of MOAB’s parallel mesh representation and functionality, see [ref-moabpar].
 
 - <B> Parallel partition, parts </B>
 
-Most parallel mesh applications use a domain decomposition approach, where each processor solves for a subset of the domain.  The set of entities solved by a given processor is referred to as a part, and the collection of parts together is called the partition.  MOAB stores each part in an entity set, marked with the PARALLEL_PART tag, whose value is the rank of the processor assigned that part; an entity set which contains all part sets is given the PARALLEL_PARTITION tag, whose value is currently meaningless.  The MBZoltan tool included as a tool in MOAB can partition a mesh for parallel solution, and writes the partition to the mesh in the form of parts and partitions.  Both these types of sets can be accessed in a serial mesh, e.g. for visualization.
+Most parallel mesh applications use a domain decomposition approach, where each processor solves for a subset of the domain.  The set of entities solved by a given processor is referred to as a part, and the collection of parts together is called the partition.  MOAB stores each part in an entity set, marked with the PARALLEL_PARTITION tag, whose value is the rank of the processor assigned that part; an entity set which contains all part sets is given the PARALLEL_PARTITIONING_TAG_NAME tag, whose value is currently meaningless.  The MBZoltan tool included as a tool in MOAB can partition a mesh for parallel solution, and writes the partition to the mesh in the form of parts and partitions.  Both these types of sets can be accessed in a serial mesh, e.g. for visualization.
 
 - <B> Part interfaces </B>
 
@@ -273,7 +273,7 @@ GEOM_SENSE_N_SENSES/I*N</td><tr><td>Parallel mesh constructs</td><td>E, S</td>
-<td>PARALLEL_PART/I, PARALLEL_PARTITION/I, PSTATUS/C*1, PARALLEL_SHARED_PROC/I, PARALLEL/SHARED_HANDLE/H, PARALLEL_SHARED_PROCS/I*NP, PARALLEL_SHARED_HANDLES/H*NP</td>
+<td>PARALLEL_MESH_PARTITIONING/I, PARALLEL_PARTITION/I, PSTATUS/C*1, PARALLEL_SHARED_PROC/I, PARALLEL/SHARED_HANDLE/H, PARALLEL_SHARED_PROCS/I*NP, PARALLEL_SHARED_HANDLES/H*NP</td><td> Data which describes parallel mesh</td></tr><tr>
@@ -380,19 +380,19 @@ GEOM_SENSE_N_SENSES/I*N</td><td>Entities or sets with common boundary condition </td></tr><tr>
-<td>PARALLEL_PART </td>
+<td>PARALLEL_PARTITION </td><td>I</td><td>S</td><td>Represent a part in a partition</td></tr><tr>
-<td>PARALLEL_PARTITION</td>
+<td>PARALLEL_MESH_PARTITIONING</td><td>I</td><td>S</td><td>Represents a partition of the mesh for parallel solution, which is a collection of parts</td></tr><tr>
-<td>__PARALLEL_SHARED_HANDLEd</td>
+<td>__PARALLEL_SHARED_HANDLE</td><td>H</td><td>E, S</td><td> Handle of this entity/set on sharing processor</td>
@@ -677,13 +677,19 @@ netcdf file. The length of this tag is the number of
 values stored for the dimension in the netcdf file.</td></tr><tr>
-<td>__<dim_name>_LOC_MIN MAX</td> 
+<td>__<dim_name>_LOC_MIN_MAX</td><td>2*(I or D)</td><td>S</td><td>The indices (0-based) of the local min and max
 values of dimension stored locally. For spatial
 dimensions like lon or lat, this will store the
-minimum and maximum indices in the loca</td>
+minimum and maximum indices in the local partition
+of the grid. For dimensions like time, where each
+processor represents the entire dimension, this will
+likely store 0 and the number of values for that
+dimension. Only one of __<dim_name>_LOC_VALS and
+__<dim_name>_LOC_MIN_MAX can be used for a given
+dimension.</td></tr><tr><td >__<dim_name>_LOC_VAL </td> 
@@ -693,8 +699,8 @@ minimum and maximum indices in the loca</td>
 locally. This tag only makes sense for dimensions
 that can be read in multiple pieces, such as time.
 Only one of __<dim_name>_LOC_VALS and
-_LOC_MIN_MAX can be used for a given
-dimension.
+__<dim_name>_LOC_MIN_MAX can be used for a given
+dimension.</td></tr><tr><td>__<var_name>_DIMS 

diff --git a/itaps/imesh/iMeshP_MOAB.cpp b/itaps/imesh/iMeshP_MOAB.cpp
index ab45811..e554fba 100644
--- a/itaps/imesh/iMeshP_MOAB.cpp
+++ b/itaps/imesh/iMeshP_MOAB.cpp
@@ -350,7 +350,7 @@ void iMeshP_createPartitionAll( iMesh_Instance instance,
   *partition_handle = 0;
 
   Tag prtn_tag;
-  ErrorCode rval = MOABI->tag_get_handle( PARALLEL_PARITIONING_TAG_NAME,
+  ErrorCode rval = MOABI->tag_get_handle( PARALLEL_PARTITIONING_TAG_NAME,
                                           1, MB_TYPE_INTEGER,
                                           prtn_tag,
                                           MB_TAG_SPARSE|MB_TAG_CREAT );

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 5adc52d..eee8a9e 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -57,7 +57,6 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   // is set too, with the same data, duplicated
   mpFileIdTag = file_id_tag;
 
-  std::string partition_tag_name;
   rval = parse_options(opts, var_names, tstep_nums, tstep_vals);
   ERRORR(rval, "Trouble parsing option string.");
 
@@ -167,13 +166,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
     myPcomm->partition_sets().insert(partn_set);
 
     // Write partition tag name on partition set
-    Tag part_tag;
-    rval = mbImpl->tag_get_handle(partitionTagName.c_str(), 1, MB_TYPE_INTEGER, part_tag);
-    if (MB_SUCCESS != rval) {
-      // Fall back to the partition tag
-      part_tag = myPcomm->partition_tag();
-    }
-
+    Tag part_tag = myPcomm->partition_tag();
     int dum_rank = myPcomm->proc_config().proc_rank();
     rval = mbImpl->tag_set_data(part_tag, &partn_set, 1, &dum_rank);
     if (MB_SUCCESS != rval)

diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index 6776b45..41c866a 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -207,7 +207,6 @@ private:
   bool noMesh;
   bool noVars;
   bool spectralMesh;
-  std::string partitionTagName;
   int gatherSetRank;
 
   //! Helper class instance

diff --git a/src/parallel/MBParallelConventions.h b/src/parallel/MBParallelConventions.h
index abda367..255eb9a 100644
--- a/src/parallel/MBParallelConventions.h
+++ b/src/parallel/MBParallelConventions.h
@@ -17,7 +17,7 @@
 /** \brief Tag on a meshset representing a parallel partition.
  *
  * When the mesh is partitioned for use in a parallel environment,
- * the each CPUs partiiton of the mesh is stored in a meshset with
+ * the each CPUs partition of the mesh is stored in a meshset with
  * this tag.  The value of the tag is an integer "part identifier".
  */
 #define PARALLEL_PARTITION_TAG_NAME "PARALLEL_PARTITION"
@@ -29,13 +29,13 @@
  * This tag labels an entity set for which the child sets are part(ition)s
  * that together are a single partitioning of the mesh.  I.e. There should
  * be no mesh entity that is contained in more than one child part(ition)
- * set, and typically every mesh entity of the dimenion used to partition
+ * set, and typically every mesh entity of the dimension used to partition
  * the mesh is contained in exactly one of the child sets.
  *
  * The data for this tag is a single integer value.  The value of
  * the tag is undefined.
  */
-#define PARALLEL_PARITIONING_TAG_NAME "PARALLEL_MESH_PARITIONING"
+#define PARALLEL_PARTITIONING_TAG_NAME "PARALLEL_MESH_PARTITIONING"
 
 /** \brief Tag storing which other processor a given entity is shared with
  *

diff --git a/test/parallel/mpastrvpart.cpp b/test/parallel/mpastrvpart.cpp
index 0999aa0..5cacd2c 100644
--- a/test/parallel/mpastrvpart.cpp
+++ b/test/parallel/mpastrvpart.cpp
@@ -3,7 +3,7 @@
 #include "moab/ParallelComm.hpp"
 #include "moab/ProgOptions.hpp"
 #include "MBParallelConventions.h"
-#include "moab/Util.hpp"
+#include "moab/ReadUtilIface.hpp"
 
 using namespace moab;
 
@@ -33,7 +33,6 @@ int main(int argc, char* argv[])
 void test_read_parallel_mpas_trivial()
 {
   partition_method = std::string(";PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS");
-
   test_read_parallel(1280, true, 1920, true);
 }
   
@@ -46,12 +45,15 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   rval = mb.create_meshset(MESHSET_SET, file_set);
   CHECK_ERR(rval);
 
-  std::string opt = std::string("PARALLEL=READ_PART") +
-      partition_method;
+  std::string opt = std::string("PARALLEL=READ_PART") + partition_method;
+  // Create gather set in processor 0
+  opt += std::string(";GATHER_SET=0");
   rval = mb.load_file(example, &file_set, opt.c_str());
   CHECK_ERR(rval);
 
   ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  int procs = pcomm->proc_config().proc_size();
+  int rank = pcomm->proc_config().proc_rank();
 
   rval = pcomm->check_all_shared_handles();
   CHECK_ERR(rval);
@@ -60,14 +62,57 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   Range verts;
   rval = mb.get_entities_by_type(0, MBVERTEX, verts);
   CHECK_ERR(rval);
+
+  int my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(2400, my_verts_num); // Gather set vertices included
+    else if (1 == rank)
+      CHECK_EQUAL(1122, my_verts_num); // Not owned vertices included
+  }
+
   rval = pcomm->filter_pstatus(verts, PSTATUS_NOT_OWNED, PSTATUS_NOT);
   CHECK_ERR(rval);
 
-  int my_verts_num = verts.size(), total_verts;
-  std::cout << "proc: " << pcomm->proc_config().proc_rank() << " verts:" << my_verts_num << "\n";
-  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(2400, my_verts_num); // Gather set vertices included
+    else if (1 == rank)
+      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
+  }
 
-  if (0 == pcomm->proc_config().proc_rank())
+  if (0 == rank) {
+    // Get gather set
+    EntityHandle gather_set;
+    ReadUtilIface* readUtilIface;
+    rval = mb.query_interface(readUtilIface);
+    CHECK_ERR(rval);
+    rval = readUtilIface->get_gather_set(gather_set);
+    CHECK_ERR(rval);
+
+    // Get gather set entities
+    Range gather_ents;
+    rval = mb.get_entities_by_handle(gather_set, gather_ents);
+    CHECK_ERR(rval);
+
+    // Remove gather set vertices in processor 0
+    verts = subtract(verts, gather_ents);
+  }
+
+  my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num); // Gather set vertices excluded
+    else if (1 == rank)
+      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
+  }
+
+  std::cout << "proc: " << rank << " verts:" << my_verts_num << "\n";
+
+  int total_verts;
+  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  if (0 == rank)
   {
     std::cout << "total vertices: " << total_verts << "\n";
     if (test_nb_nodes)
@@ -78,14 +123,57 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   Range edges;
   rval = mb.get_entities_by_type(0, MBEDGE, edges);
   CHECK_ERR(rval);
+
+  int my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(3358, my_edges_num); // Gather set edges included
+    else if (1 == rank)
+      CHECK_EQUAL(1444, my_edges_num); // Not owned edges included
+  }
+
   rval = pcomm->filter_pstatus(edges, PSTATUS_NOT_OWNED, PSTATUS_NOT);
   CHECK_ERR(rval);
 
-  int my_edges_num = edges.size(), total_edges;
-  std::cout << "proc: " << pcomm->proc_config().proc_rank() << " edges:" << my_edges_num << "\n";
-  MPI_Reduce(&my_edges_num, &total_edges, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(3358, my_edges_num); // Gather set edges included
+    else if (1 == rank)
+      CHECK_EQUAL(482, my_edges_num); // Not owned edges excluded
+  }
 
-  if (0 == pcomm->proc_config().proc_rank())
+  if (0 == rank) {
+    // Get gather set
+    EntityHandle gather_set;
+    ReadUtilIface* readUtilIface;
+    rval = mb.query_interface(readUtilIface);
+    CHECK_ERR(rval);
+    rval = readUtilIface->get_gather_set(gather_set);
+    CHECK_ERR(rval);
+
+    // Get gather set entities
+    Range gather_ents;
+    rval = mb.get_entities_by_handle(gather_set, gather_ents);
+    CHECK_ERR(rval);
+
+    // Remove gather set edges in processor 0
+    edges = subtract(edges, gather_ents);
+  }
+
+  my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(1438, my_edges_num); // Gather set edges excluded
+    else if (1 == rank)
+      CHECK_EQUAL(482, my_edges_num); // Not owned edges excluded
+  }
+
+  std::cout << "proc: " << rank << " edges:" << my_edges_num << "\n";
+
+  int total_edges;
+  MPI_Reduce(&my_edges_num, &total_edges, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  if (0 == rank)
   {
     std::cout << "total edges: " << total_edges << "\n";
     if (test_nb_edges)
@@ -112,6 +200,8 @@ void test_multiple_loads_of_same_file()
 
   // Create mesh, no variable
   opts="PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION_METHOD=TRIVIAL;VARIABLE=";
+  // Create gather set in processor 1
+  opts += std::string(";GATHER_SET=1");
   rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
@@ -119,4 +209,45 @@ void test_multiple_loads_of_same_file()
   opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=TRIVIAL;NOMESH;VARIABLE=ke;TIMESTEP=0";
   rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
+
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  int procs = pcomm->proc_config().proc_size();
+  int rank = pcomm->proc_config().proc_rank();
+
+  // Make check runs this test in two processors
+  if (2 == procs) {
+    Range verts;
+    rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+    CHECK_ERR(rval);
+
+    int my_verts_num = verts.size();
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num);
+    else if (1 == rank)
+      CHECK_EQUAL(2402, my_verts_num); // Gather set vertices included; Not owned vertices included
+
+    if (1 == rank) {
+      // Get gather set
+      EntityHandle gather_set;
+      ReadUtilIface* readUtilIface;
+      rval = mb.query_interface(readUtilIface);
+      CHECK_ERR(rval);
+      rval = readUtilIface->get_gather_set(gather_set);
+      CHECK_ERR(rval);
+
+      // Get gather set entities
+      Range gather_ents;
+      rval = mb.get_entities_by_handle(gather_set, gather_ents);
+      CHECK_ERR(rval);
+
+      // Remove gather set vertices in processor 1
+      verts = subtract(verts, gather_ents);
+    }
+
+    my_verts_num = verts.size();
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num);
+    else if (1 == rank)
+      CHECK_EQUAL(1122, my_verts_num); // Gather set vertices excluded; Not owned vertices included
+  }
 }


https://bitbucket.org/fathomteam/moab/commits/2bf0ee64afe9/
Changeset:   2bf0ee64afe9
Branch:      None
User:        iulian07
Date:        2013-08-30 19:55:09
Summary:     correct the non-smooth case
add more help

Affected #:  2 files

diff --git a/tools/mbcslam/CslamUtils.cpp b/tools/mbcslam/CslamUtils.cpp
index 39facca..90a13e3 100644
--- a/tools/mbcslam/CslamUtils.cpp
+++ b/tools/mbcslam/CslamUtils.cpp
@@ -1240,11 +1240,13 @@ double slotted_cylinder_field(double lam, double tet, double * params)
   double rp6 = r/6;
   double rt5p12 = r*5/12;
 
-  if (r1<=r && r2<=r && d1>=rp6 && d2>=rp6)
-    value =c;
-  else if (r1<=r && d1<rp6 && tet-te1<-rt5p12)
+  if (r1<=r &&  d1>=rp6)
+      value=c;
+  if (r2<=r &&  d2>=rp6)
+      value =c;
+  if (r1<=r && d1<rp6 && tet-te1<-rt5p12)
     value = c;
-  else if (r2<r && d2 < rp6 && tet-te2 > rt5p12)
+  if (r2<=r && d2<rp6 && tet-te2 > rt5p12)
     value =c;
 
   return value;

diff --git a/tools/mbcslam/diffusion.cpp b/tools/mbcslam/diffusion.cpp
index 3ca988c..70d1b6f 100644
--- a/tools/mbcslam/diffusion.cpp
+++ b/tools/mbcslam/diffusion.cpp
@@ -388,7 +388,9 @@ int main(int argc, char **argv)
 
       if (!strcmp(argv[index], "-h"))
       {
-        std::cout << "usage: -gtol <tol> -input <file> -O <extra_read_opts> -f <field_type> -h (this help)\n";
+        std::cout << "usage: -gtol <tol> -input <file> -O <extra_read_opts> \n   "
+        <<    "-f <field_type> -h (this help)\n";
+        std::cout << " filed type: 1: quasi-smooth; 2: smooth; 3: slotted cylinders (non-smooth)\n";
         return 0;
       }
       index++;
@@ -416,7 +418,7 @@ int main(int argc, char **argv)
 
   if (0==rank)
     std::cout << " case 1: use -gtol " << gtol <<
-        " -R " << radius << " -input " << filename_mesh1 << "\n";
+        " -R " << radius << " -input " << filename_mesh1 <<  " -f " << field_type << "\n";
 
   Tag tagTracer = 0;
   std::string tag_name("Tracer");


https://bitbucket.org/fathomteam/moab/commits/fa705299e58c/
Changeset:   fa705299e58c
Branch:      None
User:        iulian07
Date:        2013-09-04 00:59:38
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  17 files

diff --git a/.gitignore b/.gitignore
index 6d29b5e..967aaa7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -131,10 +131,12 @@ test/obb/obb_time
 test/obb/obb_tree_tool
 test/obb_test
 test/oldinc/test_oldinc
+test/read_mpas_nc
 test/parallel/*.h5m
 test/parallel/*.vtk
 test/parallel/mbparallelcomm_test
 test/parallel/mhdf_parallel
+test/parallel/mpastrvpart
 test/parallel/par_coupler_test
 test/parallel/par_intx_sph
 test/parallel/parallel_hdf5_test
@@ -158,6 +160,7 @@ test/perf/tstt_perf_binding
 test/range_test
 test/reorder_test
 test/scdseq_test
+test/scd_test_partn
 test/seq_man_test
 test/tag_test
 test/test_adj

diff --git a/doc/MetaData/metadata.h b/doc/MetaData/metadata.h
index 6d03665..d67ca27 100644
--- a/doc/MetaData/metadata.h
+++ b/doc/MetaData/metadata.h
@@ -649,27 +649,33 @@ centered variables correctly.
 </tr><tr><td>__DIM_NAMES </td>
-<td>C*var </td>
-<td>S </td>
+<td>C*var</td>
+<td>S</td><td>The dimension names, concatenated into a
 character string, with '\0' terminating each name.
- </td>
+</td>
+</tr>
+<tr>
+<td>__DIM_LENS </td>
+<td>I*var</td>
+<td>S</td>
+<td>A vector of integers, storing the length of
+each dimension.
+</td></tr><tr>
-<td>__DIM_NAMES 
+<td>__VAR_NAMES
 </td><td>C*var</td><td>S</td>
-<td>The variable names, concatenated into a character
-string, with '\0' terminating each name.
+<td>The variable names, concatenated into a
+character string, with '\0' terminating each name.
 </td></tr><tr><td><dim_name></td>
-<td>(I or 
-D)*va 
-</td>
+<td>(I or D)*var</td><td>S</td><td>For each dimension, the values for the dimension.
 The data type for this tag corresponds to that in the
@@ -678,7 +684,7 @@ values stored for the dimension in the netcdf file.</td></tr><tr><td>__<dim_name>_LOC_MIN_MAX</td>
-<td>2*(I or D)</td>
+<td>(I or D)*2</td><td>S</td><td>The indices (0-based) of the local min and max
 values of dimension stored locally. For spatial
@@ -692,8 +698,8 @@ __<dim_name>_LOC_MIN_MAX can be used for a given
 dimension.</td></tr><tr>
-<td >__<dim_name>_LOC_VAL </td> 
-<td>(I or D)*var </td>
+<td>__<dim_name>_LOC_VAL </td>
+<td>(I or D)*var</td><td>S</td><td>The indices (0-based) of the dimension stored
 locally. This tag only makes sense for dimensions
@@ -703,16 +709,22 @@ __<dim_name>_LOC_MIN_MAX can be used for a given
 dimension.</td></tr><tr>
+<td>__<dim_name>_GLOBAL_MIN_MAX</td>
+<td>(I or D)*2</td>
+<td>S</td>
+<td>The indices (0-based) of the global min and max
+values of dimension.</td>
+</tr>
+<tr><td>__<var_name>_DIMS 
 </td><td>H*n 
 </td><td>S</td>
-<td>For each variable, the tag handles for the
-dimensions defining this variable, in netcdf
-ordering (last dimension varying fastest). The
-length of this tag, n, is # dimensions for the
-variable * sizeof(TagHandle).
+<td>For each variable, this tag stores the tag
+handles for the n dimensions defining this variable,
+in netcdf ordering (last dimension varying fastest).
+The size of this tag is n * sizeof(TagHandle).
 </td></tr><tr>
@@ -729,7 +741,7 @@ Timestep index is 0-based.
 <tr><td>__GLOBAL_ATTRIBS 
 </td>
-<td>C*Var 
+<td>C*var
 </td><td>S</td><td>The global attributes, concatenated into a character
@@ -741,7 +753,7 @@ string, with ‘\0’ terminating each attribute name, ‘;’
 <tr><td>__GLOBAL_ATTRIBS_LEN 
 </td>
-<td>I*Var 
+<td>I*var
 </td><td>S</td><td>A vector of integers, marking the end position of
@@ -751,7 +763,7 @@ each attribute (name/data type/value) in __GLOBAL_ATTRIBS tag.
 <tr><td>__<var_name>_ATTRIBS 
 </td>
-<td>C*Var
+<td>C*var
 </td><td>S</td><td>The variable attributes, concatenated into a
@@ -763,7 +775,7 @@ character string, with ‘\0’ terminating each attribute
 <tr><td>__<var_name>_ATTRIBS_LEN 
 </td>
-<td>I*Var
+<td>I*var
 </td><td>S</td><td>A vector of integers, marking the end position of

diff --git a/itaps/imesh/iMesh_MOAB.cpp b/itaps/imesh/iMesh_MOAB.cpp
index 6d55492..d09fec1 100644
--- a/itaps/imesh/iMesh_MOAB.cpp
+++ b/itaps/imesh/iMesh_MOAB.cpp
@@ -3424,7 +3424,7 @@ void iMesh_createStructuredMesh(iMesh_Instance instance,
 }
 
 void iMesh_freeMemory(
-        iMesh_Instance instance,
+    iMesh_Instance /*instance*/,
           /**< [in] iMesh instance handle */
          void ** ptrToMem)
 {

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index 054b8dd..5413e3e 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -659,9 +659,12 @@ ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, EntityHandle se
   if (MB_SUCCESS != rval) return rval;
   
     // create interface sets
-  rval = pcomm->create_interface_sets(proc_nvecs, -1, -1);
+  rval = pcomm->create_interface_sets(proc_nvecs);
   if (MB_SUCCESS != rval) return rval;
 
+    // add the box to the PComm's partitionSets
+  pcomm->partition_sets().insert(box->box_set());
+
     // make sure buffers are allocated for communicating procs
   for (std::vector<int>::iterator pit = procs.begin(); pit != procs.end(); pit++)
     pcomm->get_buffers(*pit);

diff --git a/src/Skinner.cpp b/src/Skinner.cpp
index 57b3d51..b5fd24e 100644
--- a/src/Skinner.cpp
+++ b/src/Skinner.cpp
@@ -264,66 +264,13 @@ ErrorCode Skinner::find_skin( const EntityHandle meshset,
       !this_core->a_entity_factory()->vert_elem_adjacencies())
     this_core->a_entity_factory()->create_vert_elem_adjacencies();
     
-  if (this_core && this_core->a_entity_factory()->vert_elem_adjacencies())
-    return find_skin_vertices( meshset,
-                               source_entities,
-                               get_vertices ? &output_handles : 0,
-                               get_vertices ? 0 : &output_handles,
-                               output_reverse_handles,
-                               create_skin_elements );
+  return find_skin_vertices( meshset,
+                             source_entities,
+                             get_vertices ? &output_handles : 0,
+                             get_vertices ? 0 : &output_handles,
+                             output_reverse_handles,
+                             create_skin_elements );
   
-  Range forward, reverse;
-  Range prev;
-  const int d = CN::Dimension(TYPE_FROM_HANDLE(source_entities.front()));
-  if (!source_entities.all_of_dimension(d))
-    return MB_TYPE_OUT_OF_RANGE;
-  
-  rval = thisMB->get_entities_by_dimension( meshset, d-1, prev );
-  if (MB_SUCCESS != rval)
-    return rval;
-  
-  rval = find_skin_noadj( source_entities, forward, reverse );
-  if (MB_SUCCESS != rval)
-    return rval;
-  
-  if (get_vertices && !output_reverse_handles) {
-    forward.merge( reverse );
-    reverse.clear();
-  }
-  
-  if (get_vertices) {
-    rval = thisMB->get_connectivity( forward, output_handles );
-    if (MB_SUCCESS != rval)
-      return rval;
-  }
-  
-  if (!create_skin_elements) {
-    Range new_skin;
-    rval = thisMB->get_entities_by_dimension( meshset, d-1, new_skin);
-    if (MB_SUCCESS != rval)
-      return rval;
-    new_skin = subtract( new_skin, prev );
-    forward = subtract( forward, new_skin );
-    reverse = subtract( reverse, new_skin );
-    rval = thisMB->delete_entities( new_skin );
-    if (MB_SUCCESS != rval)
-      return rval;
-  }
-  
-  if (!get_vertices) {
-    if (output_handles.empty())
-      output_handles.swap( forward );
-    else
-      output_handles.merge( forward );
-    if (!output_reverse_handles)
-      output_handles.merge( reverse );
-    else if (output_reverse_handles->empty())
-      output_reverse_handles->swap( reverse );
-    else
-      output_reverse_handles->merge( reverse );
-  }
-  
-  return MB_SUCCESS;  
 }
 
 ErrorCode Skinner::find_skin_scd(const Range& source_entities,

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index b013472..f4fd618 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -57,7 +57,7 @@ NCHelper* NCHelper::get_nc_helper(ReadNC* readNC, int fileId, const FileOptions&
 ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums) {
   Interface*& mbImpl = _readNC->mbImpl;
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::AttData>& globalAtts = _readNC->globalAtts;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
   DebugOutput& dbgOut = _readNC->dbgOut;
@@ -94,7 +94,7 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   tag_name = "__DIM_NAMES";
   std::string dimnames;
   unsigned int dimNamesSz = dimNames.size();
-  for (unsigned int i = 0; i != dimNamesSz; ++i) {
+  for (unsigned int i = 0; i != dimNamesSz; i++) {
     dimnames.append(dimNames[i]);
     dimnames.push_back('\0');
   }
@@ -107,16 +107,15 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
-  // <__DIM_VALUES>
-  Tag dimValsTag = 0;
-  tag_name = "__DIM_VALUES";
-  int dimValsSz = (int)dimVals.size();
-
-  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimValsTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __DIM_VALUES tag.");
-  ptr = &(dimVals[0]);
-  rval = mbImpl->tag_set_by_ptr(dimValsTag, &_fileSet, 1, &ptr, &dimValsSz);
-  ERRORR(rval, "Trouble setting data for __DIM_VALUES tag.");
+  // <__DIM_LENS>
+  Tag dimLensTag = 0;
+  tag_name = "__DIM_LENS";
+  int dimLensSz = dimLens.size();
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimLensTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
+  ERRORR(rval, "Trouble creating __DIM_LENS tag.");
+  ptr = &(dimLens[0]);
+  rval = mbImpl->tag_set_by_ptr(dimLensTag, &_fileSet, 1, &ptr, &dimLensSz);
+  ERRORR(rval, "Trouble setting data for __DIM_LENS tag.");
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -138,8 +137,8 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
-  // __<dim_name>_LOC_MINMAX
-  for (unsigned int i = 0; i != dimNamesSz; ++i) {
+  // __<dim_name>_LOC_MINMAX (for time)
+  for (unsigned int i = 0; i != dimNamesSz; i++) {
     if (dimNames[i] == "time") {
       std::stringstream ss_tag_name;
       ss_tag_name << "__" << dimNames[i] << "_LOC_MINMAX";
@@ -157,28 +156,28 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
     }
   }
 
-  // __<dim_name>_LOC_VALS
-  for (unsigned int i = 0; i != dimNamesSz; ++i) {
-    if (dimNames[i] != "time")
-      continue;
-    std::vector<int> val;
-    if (!tstep_nums.empty())
-      val = tstep_nums;
-    else {
-      val.resize(tVals.size());
-      for (unsigned int j = 0; j != tVals.size(); ++j)
-        val[j] = j;
+  // __<dim_name>_LOC_VALS (for time)
+  for (unsigned int i = 0; i != dimNamesSz; i++) {
+    if (dimNames[i] == "time") {
+      std::vector<int> val;
+      if (!tstep_nums.empty())
+        val = tstep_nums;
+      else {
+        val.resize(tVals.size());
+        for (unsigned int j = 0; j != tVals.size(); j++)
+          val[j] = j;
+      }
+      Tag tagh = 0;
+      std::stringstream ss_tag_name;
+      ss_tag_name << "__" << dimNames[i] << "_LOC_VALS";
+      tag_name = ss_tag_name.str();
+      rval = mbImpl->tag_get_handle(tag_name.c_str(), val.size(), MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
+      ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
+      rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
+      ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
+      if (MB_SUCCESS == rval)
+        dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
     }
-    Tag tagh = 0;
-    std::stringstream ss_tag_name;
-    ss_tag_name << "__" << dimNames[i] << "_LOC_VALS";
-    tag_name = ss_tag_name.str();
-    rval = mbImpl->tag_get_handle(tag_name.c_str(), val.size(), MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
-    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-    ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
-    if (MB_SUCCESS == rval)
-      dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
   // __<var_name>_DIMS
@@ -191,7 +190,7 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
     if (varDimSz == 0)
       continue;
     varInfo[mapIter->first].varTags.resize(varDimSz, 0);
-    for (unsigned int i = 0; i != varDimSz; ++i) {
+    for (unsigned int i = 0; i != varDimSz; i++) {
       Tag tmptag = 0;
       std::string tmptagname = dimNames[varInfo[mapIter->first].varDims[i]];
       mbImpl->tag_get_handle(tmptagname.c_str(), 0, MB_TYPE_OPAQUE, tmptag, MB_TAG_ANY);
@@ -687,7 +686,7 @@ void NCHelper::init_dims_with_no_cvars_info()
 
 ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = MB_SUCCESS;
@@ -706,7 +705,7 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
       }
 
       // Assume point-based values for now?
-      if (-1 == tDim || dimVals[tDim] <= (int) t)
+      if (-1 == tDim || dimLens[tDim] <= (int) t)
         ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number.");
 
       // Set up the dimensions and counts
@@ -736,7 +735,7 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
           if (tDim != vdatas[i].varDims[idx]){
             // Push other variable dimensions, except time, which was already pushed
             vdatas[i].readStarts[t].push_back(0);
-            vdatas[i].readCounts[t].push_back(dimVals[vdatas[i].varDims[idx]]);
+            vdatas[i].readCounts[t].push_back(dimLens[vdatas[i].varDims[idx]]);
           }
         }
       }
@@ -813,6 +812,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   Tag& mGlobalIdTag = _readNC->mGlobalIdTag;
+  const Tag*& mpFileIdTag = _readNC->mpFileIdTag;
   DebugOutput& dbgOut = _readNC->dbgOut;
   ScdInterface* scdi = _readNC->scdi;
   ScdParData& parData = _readNC->parData;
@@ -843,12 +843,21 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
   assert(count == scd_box->num_vertices());
   int* gid_data = (int*) data;
 
+  // Duplicate global id data, which will be used to resolve sharing
+  int* fid_data;
+  if (mpFileIdTag) {
+    rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), topv, count, data);
+    ERRORR(rval, "Failed to get tag iterator on file id tag.");
+    assert(count == scd_box->num_vertices());
+    fid_data = (int*) data;
+  }
+
   // Set the vertex coordinates
   double *xc, *yc, *zc;
   rval = scd_box->get_coordinate_arrays(xc, yc, zc);
   ERRORR(rval, "Couldn't get vertex coordinate arrays.");
 
-  int i, j, k, il, jl, kl, itmp;
+  int i, j, k, il, jl, kl, itmp, id;
   int dil = lDims[3] - lDims[0] + 1;
   int djl = lDims[4] - lDims[1] + 1;
   int di = gDims[3] - gDims[0] + 1;
@@ -867,8 +876,13 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
         yc[pos] = jlVals[j];
         zc[pos] = (-1 == lDims[2] ? 0.0 : levVals[k]);
         itmp = (!locallyPeriodic[0] && globallyPeriodic[0] && il == gDims[3] ? gDims[0] : il);
-        *gid_data = (-1 != kl ? kl * di * dj : 0) + jl * di + itmp + 1;
+        id = (-1 != kl ? kl * di * dj : 0) + jl * di + itmp + 1;
+        *gid_data = id;
         gid_data++;
+        if (mpFileIdTag) {
+          *fid_data = id;
+          fid_data++;
+        }
       }
     }
   }
@@ -1011,7 +1025,7 @@ ErrorCode ScdNCHelper::read_scd_variable_setup(std::vector<std::string>& var_nam
 ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = MB_SUCCESS;
@@ -1061,7 +1075,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
       }
 
       // Assume point-based values for now?
-      if (-1 == tDim || dimVals[tDim] <= (int) t) {
+      if (-1 == tDim || dimLens[tDim] <= (int) t) {
         ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number.");
       }
       else if (vdatas[i].varDims[0] != tDim) {

diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index 7c80dc7..e5b3f08 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -53,7 +53,7 @@ ErrorCode NCHelperEuler::init_mesh_vals()
 {
   Interface*& mbImpl = _readNC->mbImpl;
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
   DebugOutput& dbgOut = _readNC->dbgOut;
   bool& isParallel = _readNC->isParallel;
@@ -71,7 +71,7 @@ ErrorCode NCHelperEuler::init_mesh_vals()
   }
   iCDim = idx;
   gCDims[0] = 0;
-  gCDims[3] = dimVals[idx] - 1;
+  gCDims[3] = dimLens[idx] - 1;
 
   // Check i periodicity and set globallyPeriodic[0]
   std::vector<double> til_vals(2);
@@ -92,7 +92,7 @@ ErrorCode NCHelperEuler::init_mesh_vals()
   }
   jCDim = idx;
   gCDims[1] = 0;
-  gCDims[4] = dimVals[idx] - 1;
+  gCDims[4] = dimLens[idx] - 1;
 
   // For Eul models, will always be non-periodic in j
   gDims[1] = 0;
@@ -111,7 +111,7 @@ ErrorCode NCHelperEuler::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'time' or 't' dimension.");
   }
   tDim = idx;
-  nTimeSteps = dimVals[idx];
+  nTimeSteps = dimLens[idx];
 
   // Look for level dimension
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "lev")) != dimNames.end())
@@ -122,7 +122,7 @@ ErrorCode NCHelperEuler::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'lev' or 'ilev' dimension.");
   }
   levDim = idx;
-  nLevels = dimVals[idx];
+  nLevels = dimLens[idx];
 
   // Parse options to get subset
   int rank = 0, procs = 1;
@@ -328,35 +328,49 @@ ErrorCode NCHelperEuler::init_mesh_vals()
       vd.entLoc = ReadNC::ENTLOCFACE;
   }
 
-  // <coordinate_dim_name>
-  std::vector<std::string> ijdimNames(4);
-  ijdimNames[0] = "__slon";
-  ijdimNames[1] = "__slat";
-  ijdimNames[2] = "__lon";
-  ijdimNames[3] = "__lat";
+  std::vector<std::string> ijdimNames(2);
+  ijdimNames[0] = "__lon";
+  ijdimNames[1] = "__lat";
 
+  std::stringstream ss_tag_name;
   std::string tag_name;
-  int val_len = 0;
+  Tag tagh;
+
+  // __<dim_name>_LOC_MINMAX (for lon and lat)
   for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    tag_name = ijdimNames[i];
-    void* val = NULL;
-    if (tag_name == "__slon") {
-      val = &ilVals[0];
-      val_len = ilVals.size();
+    std::vector<int> val(2, 0);
+    if (ijdimNames[i] == "__lon") {
+      val[0] = lCDims[0];
+      val[1] = lCDims[3];
     }
-    else if (tag_name == "__slat") {
-      val = &jlVals[0];
-      val_len = jlVals.size();
+    else if (ijdimNames[i] == "__lat") {
+      val[0] = lCDims[1];
+      val[1] = lCDims[4];
     }
-    else if (tag_name == "__lon") {
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_LOC_MINMAX";
+    tag_name = ss_tag_name.str();
+    rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
+    ERRORR(rval, "Trouble creating __<dim_name>_LOC_MINMAX tag.");
+    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
+    ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_MINMAX tag.");
+    if (MB_SUCCESS == rval)
+      dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+  }
+
+  // __<dim_name>_LOC_VALS (for lon and lat)
+  for (unsigned int i = 0; i != ijdimNames.size(); i++) {
+    void* val = NULL;
+    int val_len = 0;
+    if (ijdimNames[i] == "__lon") {
       val = &ilCVals[0];
       val_len = ilCVals.size();
     }
-    else if (tag_name == "__lat") {
+    else if (ijdimNames[i] == "__lat") {
       val = &jlCVals[0];
       val_len = jlCVals.size();
     }
-    Tag tagh = 0;
+
     DataType data_type;
 
     // Assume all has same data type as lon
@@ -378,61 +392,21 @@ ErrorCode NCHelperEuler::init_mesh_vals()
         ERRORR(MB_FAILURE, "Unrecognized data type");
         break;
     }
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_LOC_VALS";
+    tag_name = ss_tag_name.str();
     rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, data_type, tagh, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-    ERRORR(rval, "Trouble creating <coordinate_dim_name> tag.");
+    ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
     rval = mbImpl->tag_set_by_ptr(tagh, &_fileSet, 1, &val, &val_len);
-    ERRORR(rval, "Trouble setting data for <coordinate_dim_name> tag.");
-    if (MB_SUCCESS == rval)
-      dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
-  }
-
-  // __<coordinate_dim_name>_LOC_MINMAX
-  for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    std::stringstream ss_tag_name;
-    ss_tag_name << ijdimNames[i] << "_LOC_MINMAX";
-    tag_name = ss_tag_name.str();
-    Tag tagh = 0;
-    std::vector<int> val(2, 0);
-    if (ijdimNames[i] == "__slon") {
-      val[0] = lDims[0];
-      val[1] = lDims[3];
-    }
-    else if (ijdimNames[i] == "__slat") {
-      val[0] = lDims[1];
-      val[1] = lDims[4];
-    }
-    else if (ijdimNames[i] == "__lon") {
-      val[0] = lCDims[0];
-      val[1] = lCDims[3];
-    }
-    else if (ijdimNames[i] == "__lat") {
-      val[0] = lCDims[1];
-      val[1] = lCDims[4];
-    }
-    rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<coordinate_dim_name>_LOC_MINMAX tag.");
-    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-    ERRORR(rval, "Trouble setting data for __<coordinate_dim_name>_LOC_MINMAX tag.");
+    ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
-  // __<coordinate_dim_name>_GLOBAL_MINMAX
+  // __<dim_name>_GLOBAL_MINMAX (for lon and lat)
   for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    std::stringstream ss_tag_name;
-    ss_tag_name << ijdimNames[i] << "_GLOBAL_MINMAX";
-    tag_name = ss_tag_name.str();
-    Tag tagh = 0;
     std::vector<int> val(2, 0);
-    if (ijdimNames[i] == "__slon") {
-      val[0] = gDims[0];
-      val[1] = gDims[3];
-    }
-    else if (ijdimNames[i] == "__slat") {
-      val[0] = gDims[1];
-      val[1] = gDims[4];
-    }
-    else if (ijdimNames[i] == "__lon") {
+    if (ijdimNames[i] == "__lon") {
       val[0] = gCDims[0];
       val[1] = gCDims[3];
     }
@@ -440,10 +414,13 @@ ErrorCode NCHelperEuler::init_mesh_vals()
       val[0] = gCDims[1];
       val[1] = gCDims[4];
     }
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_GLOBAL_MINMAX";
+    tag_name = ss_tag_name.str();
     rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<coordinate_dim_name>_GLOBAL_MINMAX tag.");
+    ERRORR(rval, "Trouble creating __<dim_name>_GLOBAL_MINMAX tag.");
     rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-    ERRORR(rval, "Trouble setting data for __<coordinate_dim_name>_GLOBAL_MINMAX tag.");
+    ERRORR(rval, "Trouble setting data for __<dim_name>_GLOBAL_MINMAX tag.");
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }

diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index 8b21e36..dd555ff 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -46,7 +46,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
 {
   Interface*& mbImpl = _readNC->mbImpl;
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
   DebugOutput& dbgOut = _readNC->dbgOut;
   bool& isParallel = _readNC->isParallel;
@@ -64,7 +64,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
   }
   iDim = idx;
   gDims[0] = 0;
-  gDims[3] = dimVals[idx] - 1;
+  gDims[3] = dimLens[idx] - 1;
 
   // Then j
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "slat")) != dimNames.end())
@@ -74,7 +74,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
   }
   jDim = idx;
   gDims[1] = 0;
-  gDims[4] = dimVals[idx] - 1 + 2; // Add 2 for the pole points
+  gDims[4] = dimLens[idx] - 1 + 2; // Add 2 for the pole points
 
   // Look for names of center i/j dimensions
   // First i
@@ -85,7 +85,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
   }
   iCDim = idx;
   gCDims[0] = 0;
-  gCDims[3] = dimVals[idx] - 1;
+  gCDims[3] = dimLens[idx] - 1;
 
   // Check i periodicity and set globallyPeriodic[0]
   std::vector<double> til_vals(2);
@@ -106,7 +106,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
   }
   jCDim = idx;
   gCDims[1] = 0;
-  gCDims[4] = dimVals[idx] - 1;
+  gCDims[4] = dimLens[idx] - 1;
 
   // For FV models, will always be non-periodic in j
   assert(gDims[4] == gCDims[4] + 1);
@@ -124,7 +124,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'time' or 't' dimension.");
   }
   tDim = idx;
-  nTimeSteps = dimVals[idx];
+  nTimeSteps = dimLens[idx];
 
   // Get number of levels
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "lev")) != dimNames.end())
@@ -135,7 +135,7 @@ ErrorCode NCHelperFV::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'lev' or 'ilev' dimension.");
   }
   levDim = idx;
-  nLevels = dimVals[idx];
+  nLevels = dimLens[idx];
 
   // Parse options to get subset
   int rank = 0, procs = 1;
@@ -330,35 +330,67 @@ ErrorCode NCHelperFV::init_mesh_vals()
       vd.entLoc = ReadNC::ENTLOCEWEDGE;
   }
 
-  // <coordinate_dim_name>
   std::vector<std::string> ijdimNames(4);
   ijdimNames[0] = "__slon";
   ijdimNames[1] = "__slat";
   ijdimNames[2] = "__lon";
   ijdimNames[3] = "__lat";
 
+  std::stringstream ss_tag_name;
   std::string tag_name;
-  int val_len = 0;
+  Tag tagh;
+
+  // __<dim_name>_LOC_MINMAX (for slon, slat, lon and lat)
+  for (unsigned int i = 0; i != ijdimNames.size(); i++) {
+    std::vector<int> val(2, 0);
+    if (ijdimNames[i] == "__slon") {
+      val[0] = lDims[0];
+      val[1] = lDims[3];
+    }
+    else if (ijdimNames[i] == "__slat") {
+      val[0] = lDims[1];
+      val[1] = lDims[4];
+    }
+    else if (ijdimNames[i] == "__lon") {
+      val[0] = lCDims[0];
+      val[1] = lCDims[3];
+    }
+    else if (ijdimNames[i] == "__lat") {
+      val[0] = lCDims[1];
+      val[1] = lCDims[4];
+    }
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_LOC_MINMAX";
+    tag_name = ss_tag_name.str();
+    rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
+    ERRORR(rval, "Trouble creating __<dim_name>_LOC_MINMAX tag.");
+    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
+    ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_MINMAX tag.");
+    if (MB_SUCCESS == rval)
+      dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+  }
+
+  // __<dim_name>_LOC_VALS (for slon, slat, lon and lat)
   for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    tag_name = ijdimNames[i];
     void* val = NULL;
-    if (tag_name == "__slon") {
+    int val_len = 0;
+    if (ijdimNames[i] == "__slon") {
       val = &ilVals[0];
       val_len = ilVals.size();
     }
-    else if (tag_name == "__slat") {
+    else if (ijdimNames[i] == "__slat") {
       val = &jlVals[0];
       val_len = jlVals.size();
     }
-    else if (tag_name == "__lon") {
+    else if (ijdimNames[i] == "__lon") {
       val = &ilCVals[0];
       val_len = ilCVals.size();
     }
-    else if (tag_name == "__lat") {
+    else if (ijdimNames[i] == "__lat") {
       val = &jlCVals[0];
       val_len = jlCVals.size();
     }
-    Tag tagh = 0;
+
     DataType data_type;
 
     // Assume all has same data type as lon
@@ -380,51 +412,19 @@ ErrorCode NCHelperFV::init_mesh_vals()
         ERRORR(MB_FAILURE, "Unrecognized data type");
         break;
     }
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_LOC_VALS";
+    tag_name = ss_tag_name.str();
     rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, data_type, tagh, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-    ERRORR(rval, "Trouble creating <coordinate_dim_name> tag.");
+    ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
     rval = mbImpl->tag_set_by_ptr(tagh, &_fileSet, 1, &val, &val_len);
-    ERRORR(rval, "Trouble setting data for <coordinate_dim_name> tag.");
+    ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
-  // __<coordinate_dim_name>_LOC_MINMAX
+  // __<dim_name>_GLOBAL_MINMAX (for slon, slat, lon and lat)
   for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    std::stringstream ss_tag_name;
-    ss_tag_name << ijdimNames[i] << "_LOC_MINMAX";
-    tag_name = ss_tag_name.str();
-    Tag tagh = 0;
-    std::vector<int> val(2, 0);
-    if (ijdimNames[i] == "__slon") {
-      val[0] = lDims[0];
-      val[1] = lDims[3];
-    }
-    else if (ijdimNames[i] == "__slat") {
-      val[0] = lDims[1];
-      val[1] = lDims[4];
-    }
-    else if (ijdimNames[i] == "__lon") {
-      val[0] = lCDims[0];
-      val[1] = lCDims[3];
-    }
-    else if (ijdimNames[i] == "__lat") {
-      val[0] = lCDims[1];
-      val[1] = lCDims[4];
-    }
-    rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<coordinate_dim_name>_LOC_MINMAX tag.");
-    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-    ERRORR(rval, "Trouble setting data for __<coordinate_dim_name>_LOC_MINMAX tag.");
-    if (MB_SUCCESS == rval)
-      dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
-  }
-
-  // __<coordinate_dim_name>_GLOBAL_MINMAX
-  for (unsigned int i = 0; i != ijdimNames.size(); i++) {
-    std::stringstream ss_tag_name;
-    ss_tag_name << ijdimNames[i] << "_GLOBAL_MINMAX";
-    tag_name = ss_tag_name.str();
-    Tag tagh = 0;
     std::vector<int> val(2, 0);
     if (ijdimNames[i] == "__slon") {
       val[0] = gDims[0];
@@ -442,10 +442,13 @@ ErrorCode NCHelperFV::init_mesh_vals()
       val[0] = gCDims[1];
       val[1] = gCDims[4];
     }
+    ss_tag_name.clear();
+    ss_tag_name << ijdimNames[i] << "_GLOBAL_MINMAX";
+    tag_name = ss_tag_name.str();
     rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<coordinate_dim_name>_GLOBAL_MINMAX tag.");
+    ERRORR(rval, "Trouble creating __<dim_name>_GLOBAL_MINMAX tag.");
     rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-    ERRORR(rval, "Trouble setting data for __<coordinate_dim_name>_GLOBAL_MINMAX tag.");
+    ERRORR(rval, "Trouble setting data for __<dim_name>_GLOBAL_MINMAX tag.");
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }

diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index 98aa9c6..f883bd7 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -59,7 +59,7 @@ bool NCHelperHOMME::can_read_file(ReadNC* readNC, int fileId)
 ErrorCode NCHelperHOMME::init_mesh_vals()
 {
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
 
   ErrorCode rval;
@@ -75,7 +75,7 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'time' or 't' dimension.");
   }
   tDim = idx;
-  nTimeSteps = dimVals[idx];
+  nTimeSteps = dimLens[idx];
 
   // Get number of vertices (labeled as number of columns)
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "ncol")) != dimNames.end())
@@ -84,7 +84,7 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'ncol' dimension.");
   }
   vDim = idx;
-  nVertices = dimVals[idx];
+  nVertices = dimLens[idx];
 
   // Set number of cells
   nCells = nVertices - 2;
@@ -98,7 +98,7 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'lev' or 'ilev' dimension.");
   }
   levDim = idx;
-  nLevels = dimVals[idx];
+  nLevels = dimLens[idx];
 
   // Store lon values in xVertVals
   std::map<std::string, ReadNC::VarData>::iterator vmit;
@@ -569,7 +569,7 @@ ErrorCode NCHelperHOMME::read_ucd_variable_setup(std::vector<std::string>& var_n
 ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = MB_SUCCESS;
@@ -595,7 +595,7 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC
       }
 
       // Assume point-based values for now?
-      if (-1 == tDim || dimVals[tDim] <= (int) t) {
+      if (-1 == tDim || dimLens[tDim] <= (int) t) {
         ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number.");
       }
       else if (vdatas[i].varDims[0] != tDim) {

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index c78956c..45d1b00 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -37,7 +37,7 @@ bool NCHelperMPAS::can_read_file(ReadNC* readNC)
 ErrorCode NCHelperMPAS::init_mesh_vals()
 {
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
 
   ErrorCode rval;
@@ -47,7 +47,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
   // Get max edges per cell
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "maxEdges")) != dimNames.end()) {
     idx = vit - dimNames.begin();
-    maxCellEdges = dimVals[idx];
+    maxCellEdges = dimLens[idx];
     if (maxCellEdges > MAX_EDGES_PER_CELL) {
       ERRORR(MB_FAILURE, "maxEdges read from MPAS file has exceeded the limit");
     }
@@ -62,7 +62,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'Time' or 'time' dimension.");
   }
   tDim = idx;
-  nTimeSteps = dimVals[idx];
+  nTimeSteps = dimLens[idx];
 
   // Get number of cells
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "nCells")) != dimNames.end())
@@ -71,7 +71,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'nCells' dimension.");
   }
   cDim = idx;
-  nCells = dimVals[idx];
+  nCells = dimLens[idx];
 
   // Get number of edges
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "nEdges")) != dimNames.end())
@@ -80,7 +80,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'nEdges' dimension.");
   }
   eDim = idx;
-  nEdges = dimVals[idx];
+  nEdges = dimLens[idx];
 
   // Get number of vertices
   vDim = -1;
@@ -90,7 +90,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'nVertices' dimension.");
   }
   vDim = idx;
-  nVertices = dimVals[idx];
+  nVertices = dimLens[idx];
 
   // Get number of levels
   if ((vit = std::find(dimNames.begin(), dimNames.end(), "nVertLevels")) != dimNames.end())
@@ -99,7 +99,7 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     ERRORR(MB_FAILURE, "Couldn't find 'nVertLevels' dimension.");
   }
   levDim = idx;
-  nLevels = dimVals[idx];
+  nLevels = dimLens[idx];
 
   // Store xVertex values in xVertVals
   std::map<std::string, ReadNC::VarData>::iterator vmit;
@@ -697,7 +697,7 @@ ErrorCode NCHelperMPAS::read_ucd_variable_setup(std::vector<std::string>& var_na
 ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
-  std::vector<int>& dimVals = _readNC->dimVals;
+  std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = MB_SUCCESS;
@@ -747,7 +747,7 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC:
       }
 
       // Assume point-based values for now?
-      if (-1 == tDim || dimVals[tDim] <= (int) t) {
+      if (-1 == tDim || dimLens[tDim] <= (int) t) {
         ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number.");
       }
       else if (vdatas[i].varDims[0] != tDim) {

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index eee8a9e..50225df 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -294,9 +294,9 @@ ErrorCode ReadNC::read_header()
   dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
 
   // Read in dimensions into dimVals
-  result = get_dimensions(fileId, dimNames, dimVals);
+  result = get_dimensions(fileId, dimNames, dimLens);
   ERRORR(result, "Getting dimensions.");
-  dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimVals.size());
+  dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());
 
   // Read in variables into varInfo
   result = get_variables();
@@ -328,7 +328,7 @@ ErrorCode ReadNC::get_attributes(int var_id, int num_atts, std::map<std::string,
   return MB_SUCCESS;
 }
 
-ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_names, std::vector<int>& dim_vals)
+ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_names, std::vector<int>& dim_lens)
 {
   // Get the number of dimensions
   int num_dims;
@@ -341,18 +341,18 @@ ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_name
   }
 
   char dim_name[NC_MAX_NAME + 1];
-  NCDF_SIZE dum_len;
+  NCDF_SIZE dim_len;
   dim_names.resize(num_dims);
-  dim_vals.resize(num_dims);
+  dim_lens.resize(num_dims);
 
   for (int i = 0; i < num_dims; i++) {
-    success = NCFUNC(inq_dim)(file_id, i, dim_name, &dum_len);
+    success = NCFUNC(inq_dim)(file_id, i, dim_name, &dim_len);
     ERRORS(success, "Trouble getting dimension info.");
 
-    dim_vals[i] = dum_len;
     dim_names[i] = std::string(dim_name);
+    dim_lens[i] = dim_len;
 
-    dbgOut.tprintf(2, "Dimension %s, length=%u\n", dim_name, (unsigned int) dum_len);
+    dbgOut.tprintf(2, "Dimension %s, length=%u\n", dim_name, (unsigned int) dim_len);
   }
 
   return MB_SUCCESS;
@@ -367,7 +367,7 @@ ErrorCode ReadNC::get_variables()
 
   int ntimes = 0;
   if (vit != dimNames.end())
-    ntimes = dimVals[vit - dimNames.begin()];
+    ntimes = dimLens[vit - dimNames.begin()];
   if (!ntimes)
     ntimes = 1;
 

diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index 41c866a..e8b1845 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -138,7 +138,7 @@ private:
                            const char *prefix = "");
 
   //! Get all dimensions in the file
-  ErrorCode get_dimensions(int file_id, std::vector<std::string>& dim_names, std::vector<int>& dim_vals);
+  ErrorCode get_dimensions(int file_id, std::vector<std::string>& dim_names, std::vector<int>& dim_lens);
 
   //! Get the variable names and other info defined for this file
   ErrorCode get_variables();
@@ -159,15 +159,15 @@ private:
   //! File numbers assigned by netcdf
   int fileId;
 
-  //! Dimensions
+  //! Dimension names
   std::vector<std::string> dimNames;
 
+  //! Dimension lengths
+  std::vector<int> dimLens;
+
   //! These should be taken out when we fix the dummy var info things
   std::set<std::string> dummyVarNames;
 
-  //! Dimension values
-  std::vector<int> dimVals;
-
   //! Global attribs
   std::map<std::string, AttData> globalAtts;
 

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 4977f91..20fc5da 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -250,7 +250,7 @@ namespace moab {
       if (tag < MB_MESG_REMOTEH_ACK) myDebug->print(3, ", recv_ent_reqs=");
       else if (tag < MB_MESG_TAGS_ACK) myDebug->print(3, ", recv_remoteh_reqs=");
       else myDebug->print(3, ", recv_tag_reqs=");
-      for (unsigned int i = 0; i < reqs.size(); i++) myDebug->printf(3, " %x", reqs[i]);
+      for (unsigned int i = 0; i < reqs.size(); i++) myDebug->printf(3, " %p", (void*)reqs[i]);
       myDebug->print(3, "\n");
     }
   }
@@ -409,7 +409,6 @@ namespace moab {
                                              const bool owned_only) 
   {
     Range entities[4];
-    int local_num_elements[4];
     ErrorCode result;
     std::vector<unsigned char> pstatus;
     for (int dim = 0; dim <= dimension; dim++) {
@@ -430,7 +429,23 @@ namespace moab {
         if (pstatus[i] & PSTATUS_NOT_OWNED)
           dum_range.insert(*rit);
       entities[dim] = subtract( entities[dim], dum_range);
+    }
+
+    return assign_global_ids(entities, dimension, start_id, parallel, owned_only);
+  }
     
+  //! assign a global id space, for largest-dimension or all entities (and
+  //! in either case for vertices too)
+  ErrorCode ParallelComm::assign_global_ids( Range entities[],
+                                             const int dimension, 
+                                             const int start_id,
+                                             const bool parallel,
+                                             const bool owned_only) 
+  {
+    int local_num_elements[4];
+    ErrorCode result;
+    std::vector<unsigned char> pstatus;
+    for (int dim = 0; dim <= dimension; dim++) {
       local_num_elements[dim] = entities[dim].size();
     }
   
@@ -3527,9 +3542,9 @@ ErrorCode ParallelComm::reduce_void(int tag_data_type, const MPI_Op mpi_op, int
 }
 
 ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
-                                              int resolve_dim,
-                                              int shared_dim,
-                                              const Tag* id_tag) 
+                                            int resolve_dim,
+                                            int shared_dim,
+                                            const Tag* id_tag) 
   {
     ErrorCode result;
     Range proc_ents;
@@ -3541,7 +3556,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
       result = scdi->tag_shared_vertices(this, this_set);
       if (MB_SUCCESS == result) {
         myDebug->tprintf(1, "Total number of shared entities = %lu.\n", (unsigned long)sharedEnts.size());
-        return result;
+        if (shared_dim == 0) return result;
       }
     }
   
@@ -3572,13 +3587,14 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
   
     // must call even if we don't have any entities, to make sure
     // collective comm'n works
-    return resolve_shared_ents(this_set, proc_ents, resolve_dim, shared_dim, id_tag);
+    return resolve_shared_ents(this_set, proc_ents, resolve_dim, shared_dim, NULL, id_tag);
   }
   
   ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                               Range &proc_ents,
                                               int resolve_dim,
                                               int shared_dim,
+                                              Range *skin_ents,
                                               const Tag* id_tag) 
   {
 #ifdef USE_MPE
@@ -3591,12 +3607,13 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     ErrorCode result;
     myDebug->tprintf(1, "Resolving shared entities.\n");
 
+    if (resolve_dim < shared_dim) {
+      result = MB_FAILURE;
+      RRA("MOAB does not support vertex-based partitions, only element-based ones.");
+    }
+    
     if (-1 == shared_dim) {
-      if (0 == resolve_dim) {
-        result = mbImpl->get_dimension(shared_dim); 
-        RRA("Couldn't get dimension.");
-      }
-      else if (!proc_ents.empty())
+      if (!proc_ents.empty())
         shared_dim = mbImpl->dimension_from_handle(*proc_ents.begin())-1;
       else if (resolve_dim == 3)
         shared_dim = 2;
@@ -3605,60 +3622,37 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
         return MB_FAILURE;
       }
     }
-    assert(shared_dim >= 0 && resolve_dim >= 0);
+    assert(shared_dim >= 0 && resolve_dim >= shared_dim);
   
     // get the skin entities by dimension
-    Range skin_ents[4];
-    std::vector<int> gid_data;
+    Range tmp_skin_ents[4];
     std::vector<EntityHandle> handle_vec;
     int skin_dim;
 
-    // get the entities to be skinned
-    if (resolve_dim < shared_dim) {
-      // for vertex-based partition, it's the elements adj to the vertices
-      result = mbImpl->get_adjacencies(proc_ents, shared_dim,
-                                       false, skin_ents[resolve_dim],
-                                       Interface::UNION);
-      RRA("Failed getting skinned entities.");
-      skin_dim = shared_dim-1;
-    }
-    else {
-      // for element-based partition, it's just the elements
+    if (!skin_ents) {
+        // need to compute the skin here
+      skin_ents = tmp_skin_ents;
+      
+        // get the entities to be skinned
       skin_ents[resolve_dim] = proc_ents;
       skin_dim = resolve_dim-1;
-    }
-
-    // find the skin
-    Skinner skinner(mbImpl);
-    result = skinner.find_skin(this_set, skin_ents[skin_dim+1], false, skin_ents[skin_dim],
-                               NULL, true, true, true);
-    RRA("Failed to find skin.");
-    myDebug->tprintf(1, "Found skin, now resolving.\n");
 
-    // get entities adjacent to skin ents from shared_dim down to zero
-    for (int this_dim = skin_dim-1; this_dim >= 0; this_dim--) {
-      result = mbImpl->get_adjacencies(skin_ents[skin_dim], this_dim,
-                                       true, skin_ents[this_dim],
-                                       Interface::UNION);
-      RRA("Failed getting skin adjacencies.");
+        // find the skin
+      Skinner skinner(mbImpl);
+      result = skinner.find_skin(this_set, skin_ents[resolve_dim], false, skin_ents[skin_dim],
+                                 NULL, true, true, true);
+      RRA("Failed to find skin.");
+      myDebug->tprintf(1, "Found skin, now resolving.\n");
+
+        // get entities adjacent to skin ents from shared_dim down to zero
+      for (int this_dim = skin_dim-1; this_dim >= 0; this_dim--) {
+        result = mbImpl->get_adjacencies(skin_ents[skin_dim], this_dim,
+                                         true, skin_ents[this_dim],
+                                         Interface::UNION);
+        RRA("Failed getting skin adjacencies.");
+      }
     }
-
-    return resolve_shared_ents(this_set, proc_ents, skin_ents,
-                               resolve_dim, shared_dim, id_tag);
-  }
-
-  ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
-                                              Range &proc_ents,
-                                              Range skin_ents[],
-                                              int resolve_dim,
-                                              int shared_dim,
-                                              const Tag* id_tag)
-  { // resolve shared vertices first
-    ErrorCode result;
-    std::vector<int> gid_data;
-    std::vector<EntityHandle> handle_vec;
-    int skin_dim = resolve_dim-1;
-
+    
     // global id tag
     Tag gid_tag; int def_val = -1;
     if (id_tag)
@@ -3672,25 +3666,17 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
       else if (tag_created) {
         // just created it, so we need global ids
-        result = assign_global_ids(this_set, skin_dim+1,true,true,true);
+        Range tmp_ents[4];
+        tmp_ents[resolve_dim] = proc_ents.subset_by_dimension(resolve_dim);
+        result = mbImpl->get_adjacencies(tmp_ents[resolve_dim], 0, false, tmp_ents[0]);
+        RRA("Failed to get adjacent vertices.");
+        result = assign_global_ids(tmp_ents, resolve_dim, 1, true, true);
         RRA("Failed assigning global ids.");
       }
     }
   
-    // store index in temp tag; reuse gid_data 
-    gid_data.resize(2*skin_ents[0].size());
-    int idx = 0;
-    for (Range::iterator rit = skin_ents[0].begin(); 
-         rit != skin_ents[0].end(); rit++) 
-      gid_data[idx] = idx, idx++;
-    Tag idx_tag;
-    result = mbImpl->tag_get_handle("__idx_tag", 1, MB_TYPE_INTEGER,
-                                    idx_tag, MB_TAG_DENSE|MB_TAG_CREAT, &def_val ); 
-    if (MB_SUCCESS != result) return result;
-    result = mbImpl->tag_set_data(idx_tag, skin_ents[0], &gid_data[0]);
-    RRA("Couldn't assign index tag.");
-
     // get gids for skin ents in a vector, to pass to gs
+    std::vector<int> gid_data(skin_ents[0].size());
     result = mbImpl->tag_get_data(gid_tag, skin_ents[0], &gid_data[0]);
     RRA("Couldn't get gid tag for skin vertices.");
 
@@ -3707,7 +3693,6 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     // get a crystal router
     gs_data::crystal_data *cd = procConfig.crystal_router();
 
-
     /*  
     // get total number of entities; will overshoot highest global id, but
     // that's ok
@@ -3779,8 +3764,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                      Interface::UNION);
     RRA("Couldn't get proc_verts.");
   
-    result = tag_shared_verts(shared_verts, skin_ents,
-                              proc_nvecs, proc_verts);
+    result = tag_shared_verts(shared_verts, skin_ents, proc_nvecs, proc_verts);
     RRA("Trouble tagging shared verts.");
 
 #ifdef USE_MPE
@@ -3790,8 +3774,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 #endif
 
     // get entities shared by 1 or n procs
-    result = tag_shared_ents(resolve_dim, shared_dim, skin_ents,
-                             proc_nvecs);
+    result = get_proc_nvecs(resolve_dim, shared_dim, skin_ents, proc_nvecs);
     RRA("Trouble tagging shared entities.");
 
     shared_verts.reset();
@@ -3809,7 +3792,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     // create the sets for each interface; store them as tags on
     // the interface instance
     Range iface_sets;
-    result = create_interface_sets(proc_nvecs, resolve_dim, shared_dim);
+    result = create_interface_sets(proc_nvecs);
     RRA("Trouble creating iface sets.");
 
     // establish comm procs and buffers for them
@@ -3822,7 +3805,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     RRA("Shared handle check failed after iface vertex exchange.");
 #endif  
 
-    // resolve shared entity remote handles; implemented in ghost cell exchange
+    // resolve shared non-vertex remote handles; implemented in ghost cell exchange
     // code because it's so similar
     result = exchange_ghost_cells(-1, -1, 0, 0, true, true);
     RRA("Trouble resolving shared entity remote handles.");
@@ -4368,15 +4351,12 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
       RRA("");
     }
 
-    result = tag_shared_ents(resolve_dim, shared_dim, skin_ents,
-                             proc_nvecs);
+    result = get_proc_nvecs(resolve_dim, shared_dim, skin_ents, proc_nvecs);
     
-    return create_interface_sets(proc_nvecs, resolve_dim, shared_dim);
+    return create_interface_sets(proc_nvecs);
   }
   
-  ErrorCode ParallelComm::create_interface_sets(std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs,
-                                                int /*resolve_dim*/, 
-                                                int /*shared_dim*/) 
+  ErrorCode ParallelComm::create_interface_sets(std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs) 
   {
     if (proc_nvecs.empty()) return MB_SUCCESS;
   
@@ -4530,10 +4510,10 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     return MB_SUCCESS;
   }
 
-  ErrorCode ParallelComm::tag_shared_ents(int resolve_dim,
-                                          int shared_dim,
-                                          Range *skin_ents,
-                                          std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs) 
+  ErrorCode ParallelComm::get_proc_nvecs(int resolve_dim,
+                                         int shared_dim,
+                                         Range *skin_ents,
+                                         std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs) 
   {
     // set sharing procs tags on other skin ents
     ErrorCode result;
@@ -6247,7 +6227,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     }
 
     // create interface sets from shared entities
-    result = create_interface_sets(proc_nvecs, 3, 2);
+    result = create_interface_sets(proc_nvecs);
     RRA("Trouble creating iface sets.");
 
     return MB_SUCCESS;

diff --git a/src/parallel/ParallelMergeMesh.cpp b/src/parallel/ParallelMergeMesh.cpp
index f0b99c6..138e32c 100644
--- a/src/parallel/ParallelMergeMesh.cpp
+++ b/src/parallel/ParallelMergeMesh.cpp
@@ -559,7 +559,7 @@ namespace moab{
     }
     
     // get entities shared by 1 or n procs
-    rval = myPcomm->tag_shared_ents(dim,dim-1, &mySkinEnts[0],proc_nranges);
+    rval = myPcomm->get_proc_nvecs(dim,dim-1, &mySkinEnts[0],proc_nranges);
     if(rval != MB_SUCCESS){
       return rval;
     }
@@ -567,7 +567,7 @@ namespace moab{
     // create the sets for each interface; store them as tags on
     // the interface instance
     Range iface_sets;
-    rval = myPcomm->create_interface_sets(proc_nranges, dim, dim-1);
+    rval = myPcomm->create_interface_sets(proc_nranges);
     if(rval != MB_SUCCESS){
       return rval;
     }

diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index 90cbad6..5468de1 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -96,17 +96,47 @@ namespace moab {
     // \section GLOBAL IDS
     // ==================================
 
-    //! assign a global id space, for largest-dimension or all entities (and
-    //! in either case for vertices too)
-    //!\param owned_only If true, do not get global IDs for non-owned entities
-    //!                  from remote processors.
+    /* \brief Assign a global id space for entities
+     *
+     * Spaces are separate (and overlapping) for each dimension (i.e. global id space
+     * is not unique over all dimension entities)
+     *
+     * \param this_set Assign ids for entities in this set
+     * \param max_dim Assign for entities up to max_dim
+     * \param start_id Starting id for entities, defaults to 1
+     * \param largest_dim_only Assign only for max_dim and vertices, otherwise for edges/faces too
+     * \param parallel If true, use MPI_Scan-like function to properly assign over all processors, 
+     *        otherwise gids are assigned locally only
+     * \param owned_only If false, exchanged gids with sharing processors so gids are valid for 
+     *        non-owned entities too
+     */
     ErrorCode assign_global_ids(EntityHandle this_set,
-                                const int dimension,
+                                const int max_dim,
                                 const int start_id = 1,
                                 const bool largest_dim_only = true,
                                 const bool parallel = true,
                                 const bool owned_only = false);
 
+    /* \brief Assign a global id space for entities
+     *
+     * Same as set-based variant of this function, except entity Range vectors are input directly
+     * (by dimension, so entities[0] contains vertices, etc.)
+     *
+     * \param entities Assign ids for entities in the vector by dimension
+     * \param max_dim Assign for entities up to max_dim
+     * \param start_id Starting id for entities, defaults to 1
+     * \param largest_dim_only Assign only for max_dim and vertices, otherwise for edges/faces too
+     * \param parallel If true, use MPI_Scan-like function to properly assign over all processors, 
+     *        otherwise gids are assigned locally only
+     * \param owned_only If false, exchanged gids with sharing processors so gids are valid for 
+     *        non-owned entities too
+     */
+  ErrorCode assign_global_ids( Range entities[],
+                               const int dimension, 
+                               const int start_id,
+                               const bool parallel = true,
+                               const bool owned_only = true);
+    
     //! check for global ids; based only on tag handle being there or not;
     //! if it's not there, create them for the specified dimensions
     //!\param owned_only If true, do not get global IDs for non-owned entities
@@ -396,54 +426,51 @@ namespace moab {
      *
      * Resolve shared entities between processors for entities in proc_ents,
      * by comparing global id tag values on vertices on skin of elements in
-     * proc_ents.  Shared entities are assigned a tag that's either
-     * PARALLEL_SHARED_PROC_TAG_NAME, which is 1 integer in length, or 
-     * PARALLEL_SHARED_PROCS_TAG_NAME, whose length depends on the maximum
-     * number of sharing processors.  Values in these tags denote the ranks
-     * of sharing processors, and the list ends with the value -1.
-     *
-     * If shared_dim is input as -1 or not input, a value one less than the
-     * maximum dimension of entities in proc_ents is used.
+     * proc_ents.
      *
+     * \param this_set Set from which entities for proc_ents are taken
      * \param proc_ents Entities for which to resolve shared entities
-     * \param shared_dim Maximum dimension of shared entities to look for
+     * \param resolve_dim Dimension of entities in part/partition
+     * \param shared_dim Maximum dimension of shared entities to look for; if -1, 
+     *        resolve_dim-1 is used
+     * \param id_tag If non-NULL, use this tag to get global id on which vertex resolution
+     *        is based
      */
     ErrorCode resolve_shared_ents(EntityHandle this_set,
-                                  Range &proc_ents, 
-                                  int resolve_dim = -1,
+                                  int resolve_dim = 3, 
                                   int shared_dim = -1,
                                   const Tag* id_tag = 0);
-  
+
     /** \brief Resolve shared entities between processors
      *
-     * Same as resolve_shared_ents(Range&), except works for
-     * all entities in instance of dimension dim.  
+     * Same as resolve_shared_ents with entity set as first argument, except instead
+     * a range is input containing entities in the part/partition.
      *
-     * If shared_dim is input as -1 or not input, a value one less than the
-     * maximum dimension of entities is used.
-
-     * \param dim Dimension of entities in the partition
-     * \param shared_dim Maximum dimension of shared entities to look for
+     * \param this_set In this function variant, set is used to speed up skinning
+     * \param proc_ents Entities for which to resolve shared entities
+     * \param resolve_dim Dimension of entities in part/partition
+     * \param shared_dim Maximum dimension of shared entities to look for; if -1, 
+     *        resolve_dim-1 is used
+     * \param id_tag If non-NULL, use this tag to get global id on which vertex resolution
+     *        is based
      */
     ErrorCode resolve_shared_ents(EntityHandle this_set,
-                                  int resolve_dim = 3, 
+                                  Range &proc_ents, 
+                                  int resolve_dim = -1,
                                   int shared_dim = -1,
+                                  Range *skin_ents = NULL,
                                   const Tag* id_tag = 0);
-
+  
     /** \brief Resolve shared entities between processors
      *
-     * Entity skin array is offered by user not by skinner
-     * It is used by other resolve_shared_ents functions above 
-
-     * \param skin_ents[] entity skin array by user
+     * This version can be used statically, with messages exchanged via direct calls to buffer
+     * pack/unpack functions instead of MPI
+     *
+     * \param pc Array of ParallelComm instances
+     * \param np Number of ParallelComm objects in previous argument
+     * \param this_set Set of entities in parts/partition
+     * \param to_dim Maximum dimension of shared entities to look for
      */
-    ErrorCode resolve_shared_ents(EntityHandle this_set,
-                                  Range &proc_ents,
-				  Range skin_ents[],
-				  int resolve_dim = 3,
-				  int shared_dim = -1,
-				  const Tag* id_tag = 0);
-    
     static ErrorCode resolve_shared_ents(ParallelComm **pc, 
                                          const unsigned int np, 
                                          EntityHandle this_set,
@@ -863,8 +890,7 @@ namespace moab {
     // and tags the set with the procs sharing it; interface sets are optionally
     // returned; NOTE: a subsequent step is used to verify entities on the interface
     // and remove them if they're not shared
-    ErrorCode create_interface_sets(std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs,
-                                    int resolve_dim, int shared_dim);
+    ErrorCode create_interface_sets(std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs);
 
     // do the same but working straight from sharedEnts
     ErrorCode create_interface_sets(EntityHandle this_set, int resolve_dim, int shared_dim);
@@ -1230,10 +1256,10 @@ namespace moab {
                                std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs,
                                Range &proc_verts);
   
-    ErrorCode tag_shared_ents(int resolve_dim,
-                              int shared_dim,
-                              Range *skin_ents,
-                              std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs);
+    ErrorCode get_proc_nvecs(int resolve_dim,
+                             int shared_dim,
+                             Range *skin_ents,
+                             std::map<std::vector<int>, std::vector<EntityHandle> > &proc_nvecs);
 
     // after verifying shared entities, now parent/child links between sets can be established
     ErrorCode create_iface_pc_links();

diff --git a/test/parallel/parallel_hdf5_test.cc b/test/parallel/parallel_hdf5_test.cc
index 2b2a1c8..355e99e 100644
--- a/test/parallel/parallel_hdf5_test.cc
+++ b/test/parallel/parallel_hdf5_test.cc
@@ -1491,7 +1491,7 @@ void test_write_unbalanced()
   ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
   if (0 == pcomm)
     pcomm = new ParallelComm( &mb, MPI_COMM_WORLD );
-  rval = pcomm->resolve_shared_ents( 0, entities, 2, 0, &idtag );
+  rval = pcomm->resolve_shared_ents( 0, entities, 2, 0, NULL, &idtag );
   CHECK_ERR(rval);
   rval = pcomm->resolve_shared_sets( sets, idtag );
   CHECK_ERR(rval);

diff --git a/test/scdseq_test.cpp b/test/scdseq_test.cpp
index b241bb1..6393ddc 100644
--- a/test/scdseq_test.cpp
+++ b/test/scdseq_test.cpp
@@ -584,7 +584,7 @@ ErrorCode eseq_test2d(ScdInterface *scdi)
     // tri-valent shared edge between the three blocks
 
     // interval settings: only 3 of them
-  int int1 = 100, int2 = 100, int3 = 100, int4 = 100;
+  int int1 = 10, int2 = 10, int3 = 10, int4 = 10;
   ScdBox *ebox[3], *vbox[3];
   ErrorCode result = create_3dtri_3_sequences(scdi, int1, int2, int3, int4, vbox, ebox);
   CHECK_ERR(result);


https://bitbucket.org/fathomteam/moab/commits/825a2fe0670e/
Changeset:   825a2fe0670e
Branch:      None
User:        iulian07
Date:        2013-09-04 20:07:14
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  6 files

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index 5413e3e..6382871 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -5,6 +5,7 @@
 #include "StructuredElementSeq.hpp"
 #include "VertexSequence.hpp"
 #include "ScdVertexData.hpp"
+#include "MBTagConventions.hpp"
 #ifdef USE_MPI
 #  include "moab/ParallelComm.hpp"
 #  include "moab/TupleList.hpp"
@@ -23,7 +24,7 @@ namespace moab
 
 const char *ScdParData::PartitionMethodNames[] = {"alljorkori", "alljkbal", "sqij", "sqjk", "sqijk", "trivial", "nopart"};
 
-ScdInterface::ScdInterface(Core *imp, bool boxes) 
+ScdInterface::ScdInterface(Interface *imp, bool boxes) 
         : mbImpl(imp), 
           searchedBoxes(false),
           boxPeriodicTag(0),
@@ -102,7 +103,8 @@ ScdBox *ScdInterface::get_scd_box(EntityHandle eh)
 }
 
 ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double * const coords, unsigned int num_coords,
-                                      ScdBox *& new_box, int * const lperiodic, ScdParData *par_data)
+                                      ScdBox *& new_box, int * const lperiodic, ScdParData *par_data,
+                                      bool assign_gids)
 {
     // create a rectangular structured mesh block
   ErrorCode rval;
@@ -137,7 +139,8 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
   }
 
     // create element sequence
-  SequenceManager *seq_mgr = mbImpl->sequence_manager();
+  Core *mbcore = dynamic_cast<Core*>(mbImpl);
+  SequenceManager *seq_mgr = mbcore->sequence_manager();
 
   EntitySequence *tmp_seq;
   EntityHandle start_ent;
@@ -172,9 +175,45 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
 
   if (par_data) new_box->par_data(*par_data);
   
+
+  if (assign_gids) {
+    rval = assign_global_ids(new_box);
+    ERRORR(rval, "Trouble assigning global ids");
+  }
+
   return MB_SUCCESS;
 }
 
+ErrorCode ScdInterface::assign_global_ids(ScdBox *box)
+{
+  // Get a ptr to global id memory
+  void* data;
+  int count = 0;
+  Tag gid_tag;
+  ErrorCode rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, gid_tag, 
+                                          MB_TAG_CREAT & MB_TAG_DENSE, &count);
+  ERRORR(rval, "Trouble getting global id tag handle.");
+  Range tmp_range(box->start_vertex(), box->start_vertex() + box->num_vertices());
+  rval = mbImpl->tag_iterate(gid_tag, tmp_range.begin(), tmp_range.end(), count, data);
+  ERRORR(rval, "Failed to get tag iterator.");
+  assert(count == box->num_vertices());
+  int* gid_data = (int*) data;
+  int di = box->par_data().gDims[3] - box->par_data().gDims[0] + 1;
+  int dj = box->par_data().gDims[4] - box->par_data().gDims[1] + 1;
+
+  for (int kl = box->box_dims()[2]; kl <= box->box_dims()[5]; kl++) {
+    for (int jl = box->box_dims()[1]; jl <= box->box_dims()[4]; jl++) {
+      for (int il = box->box_dims()[0]; il <= box->box_dims()[3]; il++) {
+        int itmp = (!box->locally_periodic()[0] && box->par_data().gPeriodic[0] && il == box->par_data().gDims[3] ? 
+                    box->par_data().gDims[0] : il);
+        *gid_data = (-1 != kl ? kl * di * dj : 0) + jl * di + itmp + 1;
+        gid_data++;
+      }
+    }
+  }
+
+  return MB_SUCCESS;
+}
 
 ErrorCode ScdInterface::create_scd_sequence(HomCoord low, HomCoord high, EntityType tp,
                                             int starting_id, ScdBox *&new_box,
@@ -186,7 +225,8 @@ ErrorCode ScdInterface::create_scd_sequence(HomCoord low, HomCoord high, EntityT
       (tp == MBEDGE && 1 >= tmp_size[0]))
     return MB_TYPE_OUT_OF_RANGE;
 
-  SequenceManager *seq_mgr = mbImpl->sequence_manager();
+  Core *mbcore = dynamic_cast<Core*>(mbImpl);
+  SequenceManager *seq_mgr = mbcore->sequence_manager();
 
   EntitySequence *tmp_seq;
   EntityHandle start_ent, scd_set;
@@ -551,32 +591,18 @@ ErrorCode ScdBox::get_adj_edge_or_face(int dim, int i, int j, int k, int dir, En
 }
     
 #ifndef USE_MPI
-ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *, EntityHandle ) 
+ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *, ScdBox *) 
 {
   return MB_FAILURE;
 #else
-ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, EntityHandle seth) 
+ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, ScdBox *box) 
 {
-    // first, look for box data on the set
-  ScdBox *box = get_scd_box(seth);
-  Range tmp_range;
-  ErrorCode rval;
-  if (!box) {
-      // look for contained boxes
-    rval = mbImpl->get_entities_by_type(seth, MBENTITYSET, tmp_range);
-    if (MB_SUCCESS != rval) return rval;
-    for (Range::iterator rit = tmp_range.begin(); rit != tmp_range.end(); rit++) {
-      box = get_scd_box(*rit);
-      if (box) break;
-    }
-  }
-  
-  if (!box) return MB_FAILURE;
+  EntityHandle seth = box->box_set();
 
     // check the # ents in the box against the num in the set, to make sure it's only 1 box;
     // reuse tmp_range
-  tmp_range.clear();
-  rval = mbImpl->get_entities_by_dimension(seth, box->box_dimension(), tmp_range);
+  Range tmp_range;
+  ErrorCode rval = mbImpl->get_entities_by_dimension(seth, box->box_dimension(), tmp_range);
   if (MB_SUCCESS != rval) return rval;
   if (box->num_elements() != (int)tmp_range.size()) return MB_FAILURE;
     
@@ -670,7 +696,6 @@ ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, EntityHandle se
     pcomm->get_buffers(*pit);
 
 
-  shared_data.reset();  
 #ifndef NDEBUG
   rval = pcomm->check_all_shared_handles();
   if (MB_SUCCESS != rval) return rval;

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index f4fd618..0ad7e19 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -820,48 +820,44 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
   Range tmp_range;
   ScdBox *scd_box;
 
-  ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1), NULL,
-      0, scd_box, locallyPeriodic, &parData);
+  ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1), 
+                                       NULL, 0, scd_box, locallyPeriodic, &parData, true);
   ERRORR(rval, "Trouble creating scd vertex sequence.");
 
-  // Add box set and new vertices, elements to the file set
+    // add verts to tmp_range first, so we can duplicate global ids in vertex ids
   tmp_range.insert(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
-  tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
-  tmp_range.insert(scd_box->box_set());
-  rval = mbImpl->add_entities(_fileSet, tmp_range);
-  ERRORR(rval, "Couldn't add new vertices to file set.");
 
-  dbgOut.tprintf(1, "scdbox %d quads, %d vertices\n", scd_box->num_elements(), scd_box->num_vertices());
-
-  // Get a ptr to global id memory
-  void* data;
-  int count;
-  const Range::iterator topv = tmp_range.upper_bound(tmp_range.begin(), tmp_range.end(), scd_box->start_vertex()
-      + scd_box->num_vertices());
-  rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), topv, count, data);
-  ERRORR(rval, "Failed to get tag iterator.");
-  assert(count == scd_box->num_vertices());
-  int* gid_data = (int*) data;
-
-  // Duplicate global id data, which will be used to resolve sharing
-  int* fid_data;
   if (mpFileIdTag) {
+    Range::iterator topv = tmp_range.end();
+    int count;
+    void *data;
     rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), topv, count, data);
     ERRORR(rval, "Failed to get tag iterator on file id tag.");
     assert(count == scd_box->num_vertices());
-    fid_data = (int*) data;
+    int *fid_data = (int*) data;
+    rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), topv, count, data);
+    ERRORR(rval, "Failed to get tag iterator on file id tag.");
+    assert(count == scd_box->num_vertices());
+    int *gid_data = (int*) data;
+    for (int i = 0; i < count; i++) fid_data[i] = gid_data[i];
   }
 
+    // Then add box set and elements to the range, then to the file set
+  tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
+  tmp_range.insert(scd_box->box_set());
+  rval = mbImpl->add_entities(_fileSet, tmp_range);
+  ERRORR(rval, "Couldn't add new vertices to file set.");
+
+  dbgOut.tprintf(1, "scdbox %d quads, %d vertices\n", scd_box->num_elements(), scd_box->num_vertices());
+
   // Set the vertex coordinates
   double *xc, *yc, *zc;
   rval = scd_box->get_coordinate_arrays(xc, yc, zc);
   ERRORR(rval, "Couldn't get vertex coordinate arrays.");
 
-  int i, j, k, il, jl, kl, itmp, id;
+  int i, j, k, il, jl, kl;
   int dil = lDims[3] - lDims[0] + 1;
   int djl = lDims[4] - lDims[1] + 1;
-  int di = gDims[3] - gDims[0] + 1;
-  int dj = gDims[4] - gDims[1] + 1;
   assert(dil == (int)ilVals.size() && djl == (int)jlVals.size() &&
       (-1 == lDims[2] || lDims[5]-lDims[2] + 1 == (int)levVals.size()));
 #define INDEX(i, j, k) ()
@@ -875,14 +871,6 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
         xc[pos] = ilVals[i];
         yc[pos] = jlVals[j];
         zc[pos] = (-1 == lDims[2] ? 0.0 : levVals[k]);
-        itmp = (!locallyPeriodic[0] && globallyPeriodic[0] && il == gDims[3] ? gDims[0] : il);
-        id = (-1 != kl ? kl * di * dj : 0) + jl * di + itmp + 1;
-        *gid_data = id;
-        gid_data++;
-        if (mpFileIdTag) {
-          *fid_data = id;
-          fid_data++;
-        }
       }
     }
   }

diff --git a/src/moab/HomXform.hpp b/src/moab/HomXform.hpp
index 8110afa..8f3a1a7 100644
--- a/src/moab/HomXform.hpp
+++ b/src/moab/HomXform.hpp
@@ -31,6 +31,7 @@
 #define XFORM_INDEX(a,b) 4*a+b
 
 #include <math.h>
+#include <ostream>
 
 namespace moab {
 
@@ -473,6 +474,12 @@ inline int &HomCoord::operator[](const int &param)
   return homCoord[param];
 }
 
+inline std::ostream &operator<<(std::ostream &str, const HomCoord &hc)
+{
+  str << "(" << hc.i() << "," << hc.j() << "," << hc.k() << ")";
+  return str;
+}
+
 inline HomXform::HomXform(const int matrix[16]) 
 {
   for (int i = 0; i < 16; i++)

diff --git a/src/moab/ScdInterface.hpp b/src/moab/ScdInterface.hpp
index f8a4df8..bb24835 100644
--- a/src/moab/ScdInterface.hpp
+++ b/src/moab/ScdInterface.hpp
@@ -17,7 +17,6 @@ class EntitySequence;
 class ScdVertexData;
 class EntitySequence;
 class ScdBox;
-class Core;
 class ParallelComm;
 
 /** \class ScdInterface ScdInterface.hpp "moab/ScdInterface.hpp"
@@ -145,7 +144,7 @@ public:
      * \param impl MOAB instance
      * \param find_boxes If true, search all the entity sets, caching the structured mesh blocks
      */
-  ScdInterface(Core *impl, bool find_boxes = false);
+  ScdInterface(Interface *impl, bool find_boxes = false);
   
     // Destructor
   ~ScdInterface();
@@ -168,10 +167,12 @@ public:
      * \param lperiodic[2] 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
      *                 about global parallel nature of ScdBox across procs
+     * \param assign_global_ids If true, assigns 1-based global ids to vertices using GLOBAL_ID_TAG_NAME
      */
   ErrorCode construct_box(HomCoord low, HomCoord high, const double * const coords, unsigned int num_coords,
                           ScdBox *& new_box, int * const lperiodic = NULL, 
-                          ScdParData * const par_data = NULL);
+                          ScdParData * const par_data = NULL,
+                          bool assign_global_ids = false);
 
     //! Create a structured sequence of vertices, quads, or hexes
     /** Starting handle for the sequence is available from the returned ScdBox.  
@@ -281,6 +282,11 @@ public:
      */
   ErrorCode tag_shared_vertices(ParallelComm *pcomm, EntityHandle seth);
   
+    //! Tag vertices with sharing data for parallel representations
+    /** Given the ParallelComm object to use, tag the vertices shared with other processors
+     */
+  ErrorCode tag_shared_vertices(ParallelComm *pcomm, ScdBox *box);
+  
 protected:
     //! Remove the box from the list on ScdInterface
   ErrorCode remove_box(ScdBox *box);
@@ -372,8 +378,11 @@ private:
   
   static int gtol(const int *gijk, int i, int j, int k);
 
+    //! assign global ids to vertices in this box
+  ErrorCode assign_global_ids(ScdBox *box);
+  
   //! interface instance
-  Core *mbImpl;
+  Interface *mbImpl;
 
     //! whether we've searched the database for boxes yet
   bool searchedBoxes;
@@ -619,12 +628,18 @@ public:
      */
   bool locally_periodic_k() const;
   
-    //! Return whether box is locally periodic in i and j
-    /** Return whether box is locally periodic in i and j
-     * \param lperiodic Non-zero if locally periodic in i [0] or j [1]
-     */
-  void locally_periodic(bool lperiodic[3]) const;
+    //! Set local periodicity
+    /** 
+     * \param lperiodic Vector of ijk periodicities to set this box to
+      */
+  void locally_periodic(bool lperiodic[3]);
 
+    //! Get local periodicity
+    /** 
+     * \return Vector of ijk periodicities for this box
+     */
+  const int *locally_periodic() const;
+ 
     //! Return parallel data 
     /** Return parallel data, if there is any
      * \return par_data Parallel data set on this box 
@@ -1214,6 +1229,25 @@ inline ErrorCode ScdInterface::get_neighbor(int np, int pfrom, const ScdParData
   return MB_FAILURE;
 }
 
+inline ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, EntityHandle seth) 
+{
+  ScdBox *box = get_scd_box(seth);
+  if (!box) {
+      // look for contained boxes
+    Range tmp_range;
+    ErrorCode rval = mbImpl->get_entities_by_type(seth, MBENTITYSET, tmp_range);
+    if (MB_SUCCESS != rval) return rval;
+    for (Range::iterator rit = tmp_range.begin(); rit != tmp_range.end(); rit++) {
+      box = get_scd_box(*rit);
+      if (box) break;
+    }
+  }
+  
+  if (!box) return MB_FAILURE;
+
+  return tag_shared_vertices(pcomm, box);
+}
+
 inline ScdInterface *ScdBox::sc_impl() const 
 {
   return scImpl;
@@ -1382,12 +1416,17 @@ inline bool ScdBox::locally_periodic_k() const
   return locallyPeriodic[2];
 }
 
-inline void ScdBox::locally_periodic(bool lperiodic[3]) const 
+inline void ScdBox::locally_periodic(bool lperiodic[3])
 {
-  for (int i = 0; i < 3; i++) 
-    lperiodic[i] = locallyPeriodic[i];
+   for (int i = 0; i < 3; i++) 
+    locallyPeriodic[i] = lperiodic[i];
 }
 
+inline const int *ScdBox::locally_periodic() const
+{
+  return locallyPeriodic;
+}
+ 
 inline std::ostream &operator<<(std::ostream &str, const ScdParData &pd) 
 {
   static const char *PartitionMethodNames[] = {"NOPART", "ALLJORKORI", "ALLJKBAL", "SQIJ", "SQJK", "SQIJK"};

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 20fc5da..aecc6f2 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -430,7 +430,7 @@ namespace moab {
           dum_range.insert(*rit);
       entities[dim] = subtract( entities[dim], dum_range);
     }
-
+    
     return assign_global_ids(entities, dimension, start_id, parallel, owned_only);
   }
     
@@ -3542,9 +3542,9 @@ ErrorCode ParallelComm::reduce_void(int tag_data_type, const MPI_Op mpi_op, int
 }
 
 ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
-                                            int resolve_dim,
-                                            int shared_dim,
-                                            const Tag* id_tag) 
+                                              int resolve_dim,
+                                              int shared_dim,
+                                              const Tag* id_tag) 
   {
     ErrorCode result;
     Range proc_ents;
@@ -3556,7 +3556,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
       result = scdi->tag_shared_vertices(this, this_set);
       if (MB_SUCCESS == result) {
         myDebug->tprintf(1, "Total number of shared entities = %lu.\n", (unsigned long)sharedEnts.size());
-        if (shared_dim == 0) return result;
+        return result;
       }
     }
   
@@ -3617,29 +3617,24 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
         shared_dim = mbImpl->dimension_from_handle(*proc_ents.begin())-1;
       else if (resolve_dim == 3)
         shared_dim = 2;
-      else {
-        assert(false && "Unable to guess shared_dim.");
-        return MB_FAILURE;
-      }
     }
-    assert(shared_dim >= 0 && resolve_dim >= shared_dim);
+    
+    if (shared_dim < 0 || resolve_dim < 0) {
+      result = MB_FAILURE;
+      RRA("Unable to guess shared_dim or resolve_dim.");
+    }
   
     // get the skin entities by dimension
     Range tmp_skin_ents[4];
-    std::vector<EntityHandle> handle_vec;
-    int skin_dim;
 
+    // get the entities to be skinned
+    // find the skin
+    int skin_dim = resolve_dim-1;
     if (!skin_ents) {
-        // need to compute the skin here
       skin_ents = tmp_skin_ents;
-      
-        // get the entities to be skinned
       skin_ents[resolve_dim] = proc_ents;
-      skin_dim = resolve_dim-1;
-
-        // find the skin
       Skinner skinner(mbImpl);
-      result = skinner.find_skin(this_set, skin_ents[resolve_dim], false, skin_ents[skin_dim],
+      result = skinner.find_skin(this_set, skin_ents[skin_dim+1], false, skin_ents[skin_dim],
                                  NULL, true, true, true);
       RRA("Failed to find skin.");
       myDebug->tprintf(1, "Found skin, now resolving.\n");
@@ -3652,13 +3647,15 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
         RRA("Failed getting skin adjacencies.");
       }
     }
+    else if (skin_ents[resolve_dim].empty()) skin_ents[resolve_dim] = proc_ents;
     
     // global id tag
-    Tag gid_tag; int def_val = -1;
+    Tag gid_tag; 
     if (id_tag)
       gid_tag = *id_tag;
     else {
       bool tag_created = false;
+      int def_val = -1;
       result = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER,
                                       gid_tag, MB_TAG_DENSE|MB_TAG_CREAT, 
                                       &def_val, &tag_created );
@@ -3666,11 +3663,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
 
       else if (tag_created) {
         // just created it, so we need global ids
-        Range tmp_ents[4];
-        tmp_ents[resolve_dim] = proc_ents.subset_by_dimension(resolve_dim);
-        result = mbImpl->get_adjacencies(tmp_ents[resolve_dim], 0, false, tmp_ents[0]);
-        RRA("Failed to get adjacent vertices.");
-        result = assign_global_ids(tmp_ents, resolve_dim, 1, true, true);
+        result = assign_global_ids(this_set, skin_dim+1,true,true,true);
         RRA("Failed assigning global ids.");
       }
     }
@@ -3681,6 +3674,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     RRA("Couldn't get gid tag for skin vertices.");
 
     // put handles in vector for passing to gs setup
+    std::vector<EntityHandle> handle_vec;
     std::copy(skin_ents[0].begin(), skin_ents[0].end(), 
               std::back_inserter(handle_vec));
 
@@ -3764,7 +3758,8 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                      Interface::UNION);
     RRA("Couldn't get proc_verts.");
   
-    result = tag_shared_verts(shared_verts, skin_ents, proc_nvecs, proc_verts);
+    result = tag_shared_verts(shared_verts, skin_ents,
+                              proc_nvecs, proc_verts);
     RRA("Trouble tagging shared verts.");
 
 #ifdef USE_MPE
@@ -3805,7 +3800,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     RRA("Shared handle check failed after iface vertex exchange.");
 #endif  
 
-    // resolve shared non-vertex remote handles; implemented in ghost cell exchange
+    // resolve shared entity remote handles; implemented in ghost cell exchange
     // code because it's so similar
     result = exchange_ghost_cells(-1, -1, 0, 0, true, true);
     RRA("Trouble resolving shared entity remote handles.");
@@ -4534,7 +4529,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
  
         int op = (resolve_dim < shared_dim ? Interface::UNION : Interface::INTERSECT);      
         result = get_sharing_data(connect, num_connect, sharing_procs, op);
-        RRA("Failed to get sharing data in tag_shared_ents");
+        RRA("Failed to get sharing data in get_proc_nvecs");
         if (sharing_procs.empty() ||
             (sharing_procs.size() == 1 && *sharing_procs.begin() == (int)procConfig.proc_rank())) continue;
 

diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index 5468de1..93dc716 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -96,46 +96,24 @@ namespace moab {
     // \section GLOBAL IDS
     // ==================================
 
-    /* \brief Assign a global id space for entities
-     *
-     * Spaces are separate (and overlapping) for each dimension (i.e. global id space
-     * is not unique over all dimension entities)
-     *
-     * \param this_set Assign ids for entities in this set
-     * \param max_dim Assign for entities up to max_dim
-     * \param start_id Starting id for entities, defaults to 1
-     * \param largest_dim_only Assign only for max_dim and vertices, otherwise for edges/faces too
-     * \param parallel If true, use MPI_Scan-like function to properly assign over all processors, 
-     *        otherwise gids are assigned locally only
-     * \param owned_only If false, exchanged gids with sharing processors so gids are valid for 
-     *        non-owned entities too
-     */
+    //! assign a global id space, for largest-dimension or all entities (and
+    //! in either case for vertices too)
+    //!\param owned_only If true, do not get global IDs for non-owned entities
+    //!                  from remote processors.
     ErrorCode assign_global_ids(EntityHandle this_set,
-                                const int max_dim,
+                                const int dimension,
                                 const int start_id = 1,
                                 const bool largest_dim_only = true,
                                 const bool parallel = true,
                                 const bool owned_only = false);
 
-    /* \brief Assign a global id space for entities
-     *
-     * Same as set-based variant of this function, except entity Range vectors are input directly
-     * (by dimension, so entities[0] contains vertices, etc.)
-     *
-     * \param entities Assign ids for entities in the vector by dimension
-     * \param max_dim Assign for entities up to max_dim
-     * \param start_id Starting id for entities, defaults to 1
-     * \param largest_dim_only Assign only for max_dim and vertices, otherwise for edges/faces too
-     * \param parallel If true, use MPI_Scan-like function to properly assign over all processors, 
-     *        otherwise gids are assigned locally only
-     * \param owned_only If false, exchanged gids with sharing processors so gids are valid for 
-     *        non-owned entities too
-     */
+  //! assign a global id space, for largest-dimension or all entities (and
+  //! in either case for vertices too)
   ErrorCode assign_global_ids( Range entities[],
                                const int dimension, 
                                const int start_id,
-                               const bool parallel = true,
-                               const bool owned_only = true);
+                               const bool parallel,
+                               const bool owned_only);
     
     //! check for global ids; based only on tag handle being there or not;
     //! if it's not there, create them for the specified dimensions
@@ -426,33 +404,17 @@ namespace moab {
      *
      * Resolve shared entities between processors for entities in proc_ents,
      * by comparing global id tag values on vertices on skin of elements in
-     * proc_ents.
-     *
-     * \param this_set Set from which entities for proc_ents are taken
-     * \param proc_ents Entities for which to resolve shared entities
-     * \param resolve_dim Dimension of entities in part/partition
-     * \param shared_dim Maximum dimension of shared entities to look for; if -1, 
-     *        resolve_dim-1 is used
-     * \param id_tag If non-NULL, use this tag to get global id on which vertex resolution
-     *        is based
-     */
-    ErrorCode resolve_shared_ents(EntityHandle this_set,
-                                  int resolve_dim = 3, 
-                                  int shared_dim = -1,
-                                  const Tag* id_tag = 0);
-
-    /** \brief Resolve shared entities between processors
+     * proc_ents.  Shared entities are assigned a tag that's either
+     * PARALLEL_SHARED_PROC_TAG_NAME, which is 1 integer in length, or 
+     * PARALLEL_SHARED_PROCS_TAG_NAME, whose length depends on the maximum
+     * number of sharing processors.  Values in these tags denote the ranks
+     * of sharing processors, and the list ends with the value -1.
      *
-     * Same as resolve_shared_ents with entity set as first argument, except instead
-     * a range is input containing entities in the part/partition.
+     * If shared_dim is input as -1 or not input, a value one less than the
+     * maximum dimension of entities in proc_ents is used.
      *
-     * \param this_set In this function variant, set is used to speed up skinning
      * \param proc_ents Entities for which to resolve shared entities
-     * \param resolve_dim Dimension of entities in part/partition
-     * \param shared_dim Maximum dimension of shared entities to look for; if -1, 
-     *        resolve_dim-1 is used
-     * \param id_tag If non-NULL, use this tag to get global id on which vertex resolution
-     *        is based
+     * \param shared_dim Maximum dimension of shared entities to look for
      */
     ErrorCode resolve_shared_ents(EntityHandle this_set,
                                   Range &proc_ents, 
@@ -463,14 +425,20 @@ namespace moab {
   
     /** \brief Resolve shared entities between processors
      *
-     * This version can be used statically, with messages exchanged via direct calls to buffer
-     * pack/unpack functions instead of MPI
+     * Same as resolve_shared_ents(Range&), except works for
+     * all entities in instance of dimension dim.  
      *
-     * \param pc Array of ParallelComm instances
-     * \param np Number of ParallelComm objects in previous argument
-     * \param this_set Set of entities in parts/partition
-     * \param to_dim Maximum dimension of shared entities to look for
+     * If shared_dim is input as -1 or not input, a value one less than the
+     * maximum dimension of entities is used.
+
+     * \param dim Dimension of entities in the partition
+     * \param shared_dim Maximum dimension of shared entities to look for
      */
+    ErrorCode resolve_shared_ents(EntityHandle this_set,
+                                  int resolve_dim = 3, 
+                                  int shared_dim = -1,
+                                  const Tag* id_tag = 0);
+
     static ErrorCode resolve_shared_ents(ParallelComm **pc, 
                                          const unsigned int np, 
                                          EntityHandle this_set,


https://bitbucket.org/fathomteam/moab/commits/6b3fa3448d11/
Changeset:   6b3fa3448d11
Branch:      None
User:        iulian07
Date:        2013-09-04 21:48:18
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  3 files

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index aecc6f2..68c10eb 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -250,7 +250,7 @@ namespace moab {
       if (tag < MB_MESG_REMOTEH_ACK) myDebug->print(3, ", recv_ent_reqs=");
       else if (tag < MB_MESG_TAGS_ACK) myDebug->print(3, ", recv_remoteh_reqs=");
       else myDebug->print(3, ", recv_tag_reqs=");
-      for (unsigned int i = 0; i < reqs.size(); i++) myDebug->printf(3, " %p", (void*)reqs[i]);
+      for (unsigned int i = 0; i < reqs.size(); i++) myDebug->printf(3, " %p", (void*)(intptr_t)reqs[i]);
       myDebug->print(3, "\n");
     }
   }
@@ -3730,11 +3730,11 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     shared_verts.enableWriteAccess();
 
     unsigned int i = 0, j = 0;
-    for (unsigned int p = 0; p < gsd->nlinfo->np; p++) 
-      for (unsigned int np = 0; np < gsd->nlinfo->nshared[p]; np++) {
-        shared_verts.vi_wr[i++] = gsd->nlinfo->sh_ind[j];
-        shared_verts.vi_wr[i++] = gsd->nlinfo->target[p];
-        shared_verts.vul_wr[j] = gsd->nlinfo->ulabels[j];
+    for (unsigned int p = 0; p < gsd->nlinfo->_np; p++)
+      for (unsigned int np = 0; np < gsd->nlinfo->_nshared[p]; np++) {
+        shared_verts.vi_wr[i++] = gsd->nlinfo->_sh_ind[j];
+        shared_verts.vi_wr[i++] = gsd->nlinfo->_target[p];
+        shared_verts.vul_wr[j] = gsd->nlinfo->_ulabels[j];
         j++;
         shared_verts.inc_n();
       }
@@ -4236,17 +4236,17 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
     // by idx and secondarily by rank (we want lists of procs for each
     // idx, not lists if indices for each proc).
     size_t ntuple = 0;
-    for (unsigned p = 0; p < gsd->nlinfo->np; p++) 
-      ntuple += gsd->nlinfo->nshared[p];
+    for (unsigned p = 0; p < gsd->nlinfo->_np; p++)
+      ntuple += gsd->nlinfo->_nshared[p];
     std::vector< set_tuple > tuples;
     tuples.reserve( ntuple );
     size_t j = 0;
-    for (unsigned p = 0; p < gsd->nlinfo->np; p++) {
-      for (unsigned np = 0; np < gsd->nlinfo->nshared[p]; np++) {
+    for (unsigned p = 0; p < gsd->nlinfo->_np; p++) {
+      for (unsigned np = 0; np < gsd->nlinfo->_nshared[p]; np++) {
         set_tuple t;
-        t.idx = gsd->nlinfo->sh_ind[j];
-        t.proc = gsd->nlinfo->target[p];
-        t.handle = gsd->nlinfo->ulabels[j];
+        t.idx = gsd->nlinfo->_sh_ind[j];
+        t.proc = gsd->nlinfo->_target[p];
+        t.handle = gsd->nlinfo->_ulabels[j];
         tuples.push_back( t );
         ++j;
       }

diff --git a/src/parallel/gs.cpp b/src/parallel/gs.cpp
index a69cab5..cc8de5d 100644
--- a/src/parallel/gs.cpp
+++ b/src/parallel/gs.cpp
@@ -169,54 +169,55 @@ namespace moab {
   void gs_data::nonlocal_info::initialize(uint np, uint count, 
 					  uint nlabels, uint nulabels, uint maxv)
   {
-    target = NULL;
-    nshared = NULL;
-    sh_ind = NULL;
-    slabels = NULL;
-    ulabels = NULL;
-    reqs = NULL;
-    buf = NULL;
-    this->np = np;
-    target = (uint*) malloc((2*np+count)*sizeof(uint));
-    nshared = target + np;
-    sh_ind = nshared + np;
+    _target = NULL;
+    _nshared = NULL;
+    _sh_ind = NULL;
+    _slabels = NULL;
+    _ulabels = NULL;
+    _reqs = NULL;
+    _buf = NULL;
+    _np = np;
+    _target = (uint*) malloc((2*np+count)*sizeof(uint));
+    _nshared = _target + np;
+    _sh_ind = _nshared + np;
     if (1 < nlabels)
-      slabels = (slong*) malloc(((nlabels-1)*count)*sizeof(slong));
-    else slabels = NULL;
-    ulabels = (ulong*) malloc((nulabels*count)*sizeof(ulong));
-    reqs = (MPI_Request*) malloc(2*np*sizeof(MPI_Request));
-    buf = (realType*) malloc((2*count*maxv)*sizeof(realType));
-    this->maxv = maxv;
+      _slabels = (slong*) malloc(((nlabels-1)*count)*sizeof(slong));
+    else
+      _slabels = NULL;
+    _ulabels = (ulong*) malloc((nulabels*count)*sizeof(ulong));
+    _reqs = (MPI_Request*) malloc(2*np*sizeof(MPI_Request));
+    _buf = (realType*) malloc((2*count*maxv)*sizeof(realType));
+    _maxv = maxv;
   }
 
   void gs_data::nonlocal_info::nlinfo_free()
   {
     //Free the ptrs
-    free(buf);
-    free(reqs);
-    free(target);
-    free(slabels);
-    free(ulabels);
+    free(_buf);
+    free(_reqs);
+    free(_target);
+    free(_slabels);
+    free(_ulabels);
     //Set to null
-    ulabels=NULL;
-    buf=NULL;
-    reqs=NULL;
-    target=NULL;
-    slabels=NULL;
-    nshared = NULL;
-    sh_ind = NULL;
+    _ulabels=NULL;
+    _buf=NULL;
+    _reqs=NULL;
+    _target=NULL;
+    _slabels=NULL;
+    _nshared = NULL;
+    _sh_ind = NULL;
   }
 
   void gs_data::nonlocal_info::nonlocal(realType *u, int op, MPI_Comm comm)
   {
     MPI_Status status;
-    uint np = this->np;
-    MPI_Request *reqs = this->reqs;
-    uint *targ = this->target;
-    uint *nshared = this->nshared;
-    uint *sh_ind = this->sh_ind;
+    uint np = this->_np;
+    MPI_Request *reqs = this->_reqs;
+    uint *targ = this->_target;
+    uint *nshared = this->_nshared;
+    uint *sh_ind = this->_sh_ind;
     uint id;
-    realType *buf = this->buf, *start;
+    realType *buf = this->_buf, *start;
     unsigned int i;
     { MPI_Comm_rank(comm,(int *)&i); id=i; }
     for (i=0; i<np; ++i) {
@@ -232,8 +233,8 @@ namespace moab {
 		targ[i],targ[i],comm,reqs++);
       start+=nshared[i];
     }
-    for (reqs=this->reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
-    sh_ind = this->sh_ind;
+    for (reqs=this->_reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
+    sh_ind = this->_sh_ind;
 # define LOOP(OP) do {							\
       for(i=0;i<np;++i) {						\
 	uint c;								\
@@ -254,13 +255,13 @@ namespace moab {
 					    int op, MPI_Comm comm)
   {
     MPI_Status status;
-    uint np = this->np;
-    MPI_Request *reqs = this->reqs;
-    uint *targ = this->target;
-    uint *nshared = this->nshared;
-    uint *sh_ind = this->sh_ind;
+    uint np = this->_np;
+    MPI_Request *reqs = this->_reqs;
+    uint *targ = this->_target;
+    uint *nshared = this->_nshared;
+    uint *sh_ind = this->_sh_ind;
     uint id;
-    realType *buf = this->buf, *start;
+    realType *buf = this->_buf, *start;
     uint size = n*sizeof(realType);
     unsigned int i;
     { MPI_Comm_rank(comm,(int *)&i); id=i; }
@@ -276,8 +277,8 @@ namespace moab {
       MPI_Irecv(start,nsn*size,MPI_UNSIGNED_CHAR,targ[i],targ[i],comm,reqs++);
       start+=nsn;
     }
-    for (reqs=this->reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
-    sh_ind = this->sh_ind;
+    for (reqs=this->_reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
+    sh_ind = this->_sh_ind;
 # define LOOP(OP) do {					\
       for(i=0;i<np;++i) {				\
 	uint c,j;					\
@@ -301,13 +302,13 @@ namespace moab {
 					     MPI_Comm comm)
   {
     MPI_Status status;
-    uint np = this->np;
-    MPI_Request *reqs = this->reqs;
-    uint *targ = this->target;
-    uint *nshared = this->nshared;
-    uint *sh_ind = this->sh_ind;
+    uint np = this->_np;
+    MPI_Request *reqs = this->_reqs;
+    uint *targ = this->_target;
+    uint *nshared = this->_nshared;
+    uint *sh_ind = this->_sh_ind;
     uint id;
-    realType *buf = this->buf, *start;
+    realType *buf = this->_buf, *start;
     unsigned int i;
     { MPI_Comm_rank(comm,(int *)&i); id=i; }
     for (i=0; i<np; ++i) {
@@ -324,8 +325,8 @@ namespace moab {
 		targ[i],targ[i],comm,reqs++);
       start+=nsn;
     }
-    for (reqs=this->reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
-    sh_ind = this->sh_ind;
+    for (reqs=this->_reqs,i=np*2;i;--i) MPI_Wait(reqs++,&status);
+    sh_ind = this->_sh_ind;
 # define LOOP(OP) do {						\
       for(i=0;i<np;++i) {					\
 	uint c,j,ns=nshared[i];					\
@@ -362,9 +363,9 @@ namespace moab {
     all=&buffers[0];
     keep=&buffers[1];
     send=&buffers[2];
-    memcpy(&(this->comm),&comm,sizeof(MPI_Comm));
-    MPI_Comm_rank(comm,&id ); this->id =id ;
-    MPI_Comm_size(comm,&num); this->num=num;
+    memcpy(&(this->_comm),&comm,sizeof(MPI_Comm));
+    MPI_Comm_rank(comm,&id ); this->_id =id ;
+    MPI_Comm_size(comm,&num); this->_num=num;
   }
 
   void gs_data::crystal_data::reset()
@@ -408,10 +409,10 @@ namespace moab {
 
     VALGRIND_CHECK_MEM_IS_DEFINED( &send->n, sizeof(uint) );
     MPI_Isend(&send->n,sizeof(uint),MPI_UNSIGNED_CHAR,
-	      target  ,id   ,comm,&req[  0]);
+	      target  ,_id   ,_comm,&req[  0]);
     for (i=0; i<recvn; ++i)
       MPI_Irecv(&count[i]  ,sizeof(uint),MPI_UNSIGNED_CHAR,
-		target+i,target+i,comm,&req[i+1]);
+		target+i,target+i,_comm,&req[i+1]);
     MPI_Waitall(recvn+1,req,status);
     sum = keep->n;
     for (i=0; i<recvn; ++i) sum+=count[i];
@@ -423,13 +424,13 @@ namespace moab {
 
     VALGRIND_CHECK_MEM_IS_DEFINED( send->buf.ptr,send->n*sizeof(uint) );
     MPI_Isend(send->buf.ptr,send->n*sizeof(uint),
-	      MPI_UNSIGNED_CHAR,target,id,comm,&req[0]);
+	      MPI_UNSIGNED_CHAR,target,_id,_comm,&req[0]);
     if (recvn) {
       MPI_Irecv(recv[0],count[0]*sizeof(uint),MPI_UNSIGNED_CHAR,
-		target,target,comm,&req[1]);
+		target,target,_comm,&req[1]);
       if (recvn==2)
 	MPI_Irecv(recv[1],count[1]*sizeof(uint),MPI_UNSIGNED_CHAR,
-		  target+1,target+1,comm,&req[2]);
+		  target+1,target+1,_comm,&req[2]);
     }
     MPI_Waitall(recvn+1,req,status);
 
@@ -438,18 +439,18 @@ namespace moab {
 
   void gs_data::crystal_data::crystal_router()
   {
-    uint bl=0, bh, n=num, nl, target;
+    uint bl=0, bh, n=_num, nl, target;
     int recvn;
     crystal_buf *lo, *hi;
     while (n>1) {
       nl = n/2, bh = bl+nl;
-      if (id < bh)
-	target=id+nl,recvn=(n&1 && id==bh-1)?2:1   ,lo=keep,hi=send;
+      if (_id < bh)
+	target=_id+nl,recvn=(n&1 && _id==bh-1)?2:1   ,lo=keep,hi=send;
       else
-	target=id-nl,recvn=(target==bh)?(--target,0):1,hi=keep,lo=send;
+	target=_id-nl,recvn=(target==bh)?(--target,0):1,hi=keep,lo=send;
       partition(bh,lo,hi);
       send_(target,recvn);
-      if(id<bh) n=nl; else n-=nl,bl=bh;
+      if(_id<bh) n=nl; else n-=nl,bl=bh;
     }
   }
 
@@ -493,7 +494,7 @@ namespace moab {
       if (p!=lp) {
 	lp = p;
 	*buf++ = p;           /* target */
-	*buf++ = id; /* source */
+	*buf++ = _id; /* source */
 	len = buf++; *len=0;  /* length */
 	all->n += 3;
       }
@@ -556,7 +557,7 @@ namespace moab {
   {
     local_condense(u,op,this->local_cm);
 #ifdef USE_MPI
-    this->nlinfo->nonlocal(u,op,comm);
+    this->nlinfo->nonlocal(u,op,_comm);
 #endif
     local_uncondense(u,local_cm);
   }
@@ -564,13 +565,13 @@ namespace moab {
   void gs_data::gs_data_op_vec(realType *u, uint n, int op)
   {
 #ifdef USE_MPI
-    if (n>nlinfo->maxv)
+    if (n>nlinfo->_maxv)
       moab::fail("%s: initialized with max vec size = %d,"
-		 " but called with vec size = %d\n",__FILE__,nlinfo->maxv,n);
+		 " but called with vec size = %d\n",__FILE__,nlinfo->_maxv,n);
 #endif
     local_condense_vec(u,n,op,local_cm);
 #ifdef USE_MPI
-    this->nlinfo->nonlocal_vec(u,n,op,comm);
+    this->nlinfo->nonlocal_vec(u,n,op,_comm);
 #endif
     local_uncondense_vec(u,n,local_cm);
   }
@@ -579,9 +580,9 @@ namespace moab {
   {
     uint i;
 #ifdef USE_MPI
-    if (n>nlinfo->maxv)
+    if (n>nlinfo->_maxv)
       moab::fail("%s: initialized with max vec size = %d,"
-		 " but called with vec size = %d\n",__FILE__,nlinfo->maxv,n);
+		 " but called with vec size = %d\n",__FILE__,nlinfo->_maxv,n);
 #endif
     for (i=0; i<n; ++i) local_condense(u[i],op,local_cm);
 
@@ -590,7 +591,7 @@ namespace moab {
 	       " but called with vec size = %d\n",__FILE__,6,n);
 
 #ifdef USE_MPI
-    this->nlinfo->nonlocal_many(u,n,op,comm);
+    this->nlinfo->nonlocal_many(u,n,op,_comm);
 #endif
     for (i=0; i<n; ++i) local_uncondense(u[i],local_cm);
   }
@@ -616,7 +617,7 @@ namespace moab {
     VALGRIND_CHECK_MEM_IS_DEFINED(  label, nlabels * sizeof( long) );
     VALGRIND_CHECK_MEM_IS_DEFINED( ulabel, nlabels * sizeof(ulong) );
 #ifdef USE_MPI
-    MPI_Comm_dup(crystal->comm,&this->comm);
+    MPI_Comm_dup(crystal->_comm,&this->_comm);
 #else
     buf.buffer_init(1024);
 #endif
@@ -711,7 +712,7 @@ namespace moab {
     {
       uint i; sint *pi=primary.vi_wr; slong *pl=primary.vl_wr;
       for (i=primary.get_n(); i; --i,pi+=3,pl+=nlabels)
-	pi[0]=pl[0]%crystal->num;
+	pi[0]=pl[0]%crystal->_num;
     }
     rval = crystal->gs_transfer(1,primary,0); /* transfer to work procs */
     if (rval != MB_SUCCESS)
@@ -783,11 +784,11 @@ namespace moab {
       uint i; sint proc=-1,*si=shared.vi_wr;
       slong *sl = shared.vl_wr;
       ulong *ul = shared.vul_wr;
-      uint *target  = this->nlinfo->target;
-      uint *nshared = this->nlinfo->nshared;
-      uint *sh_ind  = this->nlinfo->sh_ind;
-      slong *slabels = this->nlinfo->slabels;
-      ulong *ulabels = this->nlinfo->ulabels;
+      uint *target  = this->nlinfo->_target;
+      uint *nshared = this->nlinfo->_nshared;
+      uint *sh_ind  = this->nlinfo->_sh_ind;
+      slong *slabels = this->nlinfo->_slabels;
+      ulong *ulabels = this->nlinfo->_ulabels;
       for (i=shared.get_n(); i; --i,si+=3) {
 	if (si[1]!=proc){
 	  proc=si[1], *target++ = proc;
@@ -815,7 +816,7 @@ namespace moab {
     if(nlinfo != NULL){
       nlinfo->nlinfo_free();
       delete this->nlinfo;
-      MPI_Comm_free(&comm);
+      MPI_Comm_free(&_comm);
       nlinfo = NULL;
     }
 #endif

diff --git a/src/parallel/moab/gs.hpp b/src/parallel/moab/gs.hpp
index b616ef2..8630a22 100644
--- a/src/parallel/moab/gs.hpp
+++ b/src/parallel/moab/gs.hpp
@@ -18,15 +18,15 @@ namespace moab {
     class nonlocal_info
     {
     public:
-      uint np;           /* number of processors to communicate with          */
-      uint *target;      /* int target[np]: array of processor ids to comm w/ */
-      uint *nshared;     /* nshared[i] = number of points shared w/ target[i] */
-      uint *sh_ind;      /* list of shared point indices                      */
-      slong *slabels;    /* list of signed long labels (not including gid)    */
-      ulong *ulabels;    /* list of unsigned long labels                      */
-      MPI_Request *reqs; /* pre-allocated for MPI calls                       */
-      realType *buf;         /* pre-allocated buffer to receive data              */
-      uint maxv;         /* maximum vector size                               */
+      uint _np;           /* number of processors to communicate with          */
+      uint *_target;      /* int target[np]: array of processor ids to comm w/ */
+      uint *_nshared;     /* nshared[i] = number of points shared w/ target[i] */
+      uint *_sh_ind;      /* list of shared point indices                      */
+      slong *_slabels;    /* list of signed long labels (not including gid)    */
+      ulong *_ulabels;    /* list of unsigned long labels                      */
+      MPI_Request *_reqs; /* pre-allocated for MPI calls                       */
+      realType *_buf;         /* pre-allocated buffer to receive data              */
+      uint _maxv;         /* maximum vector size                               */
     
       /**Constructor for nonlocal_info; takes all arguments and initializes 
        * nonlocal_info
@@ -110,8 +110,8 @@ namespace moab {
       crystal_buf buffers[3];
       //crystal_buf provides buffer space for communications
       crystal_buf *all, *keep, *send;
-      MPI_Comm comm;
-      uint num, id;
+      MPI_Comm _comm;
+      uint _num, _id;
 
       /**Default constructor (Note:  moab_crystal_data must be initialized
        * before use!)
@@ -167,7 +167,7 @@ namespace moab {
     sint *local_cm; /* local condense map */
 #ifdef USE_MPI
     nonlocal_info *nlinfo;
-    MPI_Comm comm;
+    MPI_Comm _comm;
 #endif
 
     /**Constructor for moab_gs_data:  takes all arguments and initializes


https://bitbucket.org/fathomteam/moab/commits/774ddbf00e0d/
Changeset:   774ddbf00e0d
Branch:      None
User:        iulian07
Date:        2013-09-06 01:26:02
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  10 files

diff --git a/src/moab/point_locater/element_maps/linear_hex_map.hpp b/src/moab/point_locater/element_maps/linear_hex_map.hpp
index 069d4c8..829addb 100644
--- a/src/moab/point_locater/element_maps/linear_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/linear_hex_map.hpp
@@ -36,7 +36,10 @@ class Linear_hex_map {
     //Constructor
     Linear_hex_map() {}
     //Copy constructor
-    Linear_hex_map( const Self & f ) {}
+    Linear_hex_map( const Self & f ) {
+      // Remove the warning about unused parameter
+      if (NULL != &f) {}
+    }
 
  public:
     //Natural coordinates
@@ -46,19 +49,23 @@ class Linear_hex_map {
 					const Entity_handle & h, 
 					const Points & v, 
 					const Point & p, 
-					const double tol=1.e-6) const{
-	Point result(3, 0.0);
-	solve_inverse( p, result, v);
-	bool point_found = solve_inverse( p, result, v, tol) && 
-						is_contained( result, tol);
-	return std::make_pair( point_found, result);
+					const double tol = 1.e-6) const {
+      // Remove the warnings about unused parameters
+      if (NULL != &moab) {}
+      if (NULL != &h) {}
+
+      Point result(3, 0.0);
+      solve_inverse( p, result, v);
+      bool point_found = solve_inverse( p, result, v, tol) &&
+                is_contained( result, tol);
+      return std::make_pair( point_found, result);
     }
 
   private:
     //This is a hack to avoid a .cpp file and C++11
     //reference_points(i,j) will be a 1 or -1;
     //This should unroll..
-    inline const double reference_points( const std::size_t& i, 
+    inline double reference_points( const std::size_t& i,
           				  const std::size_t& j) const{
     const double rpts[8][3] = { { -1, -1, -1 },
                                 {  1, -1, -1 },

diff --git a/src/moab/point_locater/element_maps/linear_tet_map.hpp b/src/moab/point_locater/element_maps/linear_tet_map.hpp
index d48c63b..dedb8ed 100644
--- a/src/moab/point_locater/element_maps/linear_tet_map.hpp
+++ b/src/moab/point_locater/element_maps/linear_tet_map.hpp
@@ -18,14 +18,17 @@ class Linear_tet_map {
     //Natural coordinates
     template< typename Moab, typename Points, typename Point>
     std::pair< bool, Point> operator()( const Moab & moab,
-					const Entity_handle eh, 
+					const Entity_handle _eh,
 				        const Points & v, 
 					const Point & p, 
 					const double tol=1e-6) {
-	set_tet( eh, v); 
-	//TODO: Make sure this is correct
-	Point result = Tinv*p;
-	return std::make_pair( is_contained( result, tol), result);
+      // Remove the warning about unused parameter
+      if (NULL != &moab) {}
+
+      set_tet( _eh, v);
+      //TODO: Make sure this is correct
+      Point result = Tinv*p;
+      return std::make_pair( is_contained( result, tol), result);
     }
   
     private:

diff --git a/src/moab/point_locater/element_maps/quadratic_hex_map.hpp b/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
index 1f8b84d..92ea3ed 100644
--- a/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
@@ -57,18 +57,22 @@ class Quadratic_hex_map {
 					const Entity_handle & h, 
 					const Points & v, 
 					const Point & p, 
-					const double tol=1.e-6) const{
-	Point result(3, 0.0);
-	bool point_found = solve_inverse( p, result, v, tol) && 
-						is_contained( result, tol);
-	return std::make_pair( point_found, result);
+					const double tol = 1.e-6) const {
+      // Remove the warnings about unused parameters
+      if (NULL != &moab) {}
+      if (NULL != &h) {}
+
+      Point result(3, 0.0);
+      bool point_found = solve_inverse( p, result, v, tol) &&
+                is_contained( result, tol);
+      return std::make_pair( point_found, result);
     }
 
   private:
     //This is a hack to avoid a .cpp file and C++11
     //reference_points(i,j) will be a 1 or -1;
     //This should unroll..
-    inline const double reference_points( const std::size_t& i, 
+    inline double reference_points( const std::size_t& i,
           				  const std::size_t& j) const{
     const double rpts[27][3] = {
     	{ -1, -1, -1 },
@@ -196,24 +200,27 @@ class Quadratic_hex_map {
     }
 
     template< typename Point, typename Points>
-    Matrix& jacobian( const Point & p, const Points & points, Matrix & J) const{
-	J = Matrix(0.0);
-	for (int i=0; i<27; i++){
- 		  const double  sh[3] = {  SH(reference_points(i,0), p[0]),
+    Matrix& jacobian( const Point & p, const Points & points, Matrix & J) const {
+    // Remove the warning about unused parameter
+    if (NULL != &points) {}
+
+    J = Matrix(0.0);
+    for (int i = 0; i < 27; i++) {
+      const double sh[3] = { SH(reference_points(i,0), p[0]),
                        		           SH(reference_points(i,1), p[1]),
                        		           SH(reference_points(i,2), p[2]) };
-  		  const double dsh[3] = { DSH(reference_points(i,0), p[0]),
+ 	    const double dsh[3] = { DSH(reference_points(i,0), p[0]),
                         		  DSH(reference_points(i,1), p[1]),
                         	   	  DSH(reference_points(i,2), p[2]) };
-  	    for (int j=0; j<3; j++) {
-		// dxj/dr first column
-    		J(j,0)+=dsh[0]*sh[1]*sh[2]*reference_points(i,j); 
-    		J(j,1)+= sh[0]*dsh[1]*sh[2]*reference_points(i,j); // dxj/ds
-    		J(j,2)+= sh[0]*sh[1]*dsh[2]*reference_points(i,j); // dxj/dt
-  	    }
-	}
-	return J;
-   }
+      for (int j = 0; j < 3; j++) {
+        // dxj/dr first column
+        J(j, 0) += dsh[0]*sh[1]*sh[2]*reference_points(i, j);
+        J(j, 1) += sh[0]*dsh[1]*sh[2]*reference_points(i, j); // dxj/ds
+        J(j, 2) += sh[0]*sh[1]*dsh[2]*reference_points(i, j); // dxj/dt
+      }
+    }
+    return J;
+  }
   private:
 }; //Class Quadratic_hex_map
 

diff --git a/src/moab/point_locater/element_maps/spectral_hex_map.hpp b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
index 1b01dca..c255545 100644
--- a/src/moab/point_locater/element_maps/spectral_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
@@ -66,15 +66,19 @@ class Spectral_hex_map {
 					const Points & v, 
 					const Point & p, 
 					const double tol=1.e-6) {
-	Point result(3, 0.0);
-	/*
-      	moab.tag_get_by_ptr(_xm1Tag, &eh, 1,(const void **) &_xyz[ 0] );
-      	moab.tag_get_by_ptr(_ym1Tag, &eh, 1,(const void **) &_xyz[ 1] );
-      	moab.tag_get_by_ptr(_zm1Tag, &eh, 1,(const void **) &_xyz[ 2] );
-	*/
-	bool point_found = solve_inverse( p, result, v, tol) && 
-						is_contained( result, tol);
-	return std::make_pair( point_found, result);
+        // Remove the warnings about unused parameters
+        if (NULL != &moab) {}
+        if (NULL != &h) {}
+
+        Point result(3, 0.0);
+        /*
+        moab.tag_get_by_ptr(_xm1Tag, &eh, 1,(const void **) &_xyz[ 0] );
+        moab.tag_get_by_ptr(_ym1Tag, &eh, 1,(const void **) &_xyz[ 1] );
+        moab.tag_get_by_ptr(_zm1Tag, &eh, 1,(const void **) &_xyz[ 2] );
+        */
+        bool point_found = solve_inverse( p, result, v, tol) &&
+                  is_contained( result, tol);
+        return std::make_pair( point_found, result);
     }
 
   private:
@@ -143,16 +147,19 @@ class Spectral_hex_map {
 
     template< typename Point, typename Points>
     Point& evaluate( const Point & p, const Points & points, Point & f) {
-    	for(int d = 0; d < 3; ++d){ lagrange_0(&_ld[ d], p[ 0]); }
-	for( int d = 0; d < 3; ++d){
-		f[ d] = tensor_i3( _ld[ 0].J, _ld[ 0].n,
-			_ld[1].J, _ld[1].n,
-			_ld[2].J, _ld[2].n,
-			_xyz[ d],
-			_odwork);
-	}
-    	return f;
-   }
+      // Remove the warning about unused parameter
+      if (NULL != &points) {}
+
+      for (int d = 0; d < 3; ++d) { lagrange_0(&_ld[ d], p[ 0]); }
+      for (int d = 0; d < 3; ++d) {
+        f[ d] = tensor_i3( _ld[ 0].J, _ld[ 0].n,
+        _ld[1].J, _ld[1].n,
+        _ld[2].J, _ld[2].n,
+        _xyz[ d],
+        _odwork);
+      }
+      return f;
+    }
 
    template< typename Point, typename Field>
    double   evaluate_scalar_field(const Point & p, const Field & field) const {
@@ -190,7 +197,8 @@ class Spectral_hex_map {
          double wj= _ld[1].J[j];
          double wi= _ld[0].J[i];
          Matrix3 J(0.);
-	 for(int i = 0; i < 8; ++i){ J(i/3, i%3) = _data.jac[ i];}
+         for (int n = 0; n < 8; n++)
+           J(n/3, n%3) = _data.jac[n];
          double bm = wk*wj*wi* J.determinant();
          integral+= bm*field[index++];
          //volume +=bm;
@@ -201,23 +209,27 @@ class Spectral_hex_map {
    return integral;
  }
 
-   template< typename Point, typename Points>
-   Matrix& jacobian( const Point & p, const Points & points, Matrix & J) {
+  template< typename Point, typename Points>
+  Matrix& jacobian( const Point & p, const Points & points, Matrix & J) {
+    // Remove the warnings about unused parameters
+    if (NULL != &p) {}
+    if (NULL != &points) {}
+
    	real x[ 3];
-       for(int i = 0; i < 3; ++i){ _data.elx[ i] = _xyz[ i]; }
-       opt_vol_set_intp_3(& _data,x);
-       for(int i = 0; i < 9; ++i){ J(i%3, i/3) = _data.jac[ i]; }
-       return J;
-   }
-    
+    for (int i = 0; i < 3; ++i) { _data.elx[ i] = _xyz[ i]; }
+    opt_vol_set_intp_3(& _data, x);
+    for (int i = 0; i < 9; ++i) { J(i%3, i/3) = _data.jac[ i]; }
+    return J;
+  }
+
   private:
-	bool _init;
-	int _n;
-	real * _z[ 3];
-	lagrange_data _ld[ 3];
-	opt_data_3 _data;
-	real * _odwork;
-	real * _xyz[ 3];
+  bool _init;
+  int _n;
+  real * _z[ 3];
+  lagrange_data _ld[ 3];
+  opt_data_3 _data;
+  real * _odwork;
+  real * _xyz[ 3];
 }; //Class Spectral_hex_map
 
 }// namespace element_utility

diff --git a/src/moab/point_locater/tree/bvh_tree.hpp b/src/moab/point_locater/tree/bvh_tree.hpp
index f050242..2f92b19 100644
--- a/src/moab/point_locater/tree/bvh_tree.hpp
+++ b/src/moab/point_locater/tree/bvh_tree.hpp
@@ -162,7 +162,7 @@ Bvh_tree( Entity_handles & _entities,
 	  Parametrizer & _entity_contains): entity_handles_( _entities), 
 				tree_(), moab( _moab), 
 				bounding_box( _bounding_box),
-				entity_contains( entity_contains){
+				entity_contains( _entity_contains){
 	typedef typename Entity_handles::iterator Entity_handle_iterator;
 	typedef  ct::_Element_data< const _Box, double > Element_data;
 	typedef typename std::tr1::unordered_map< Entity_handle, 
@@ -503,7 +503,7 @@ void find_split(const Iterator & begin,
 		const Iterator & end, Split_data & data) const{
 	typedef typename Iterator::value_type Map_iterator;
 	typedef typename Map_iterator::value_type::second_type Box_data;
-	typedef typename Box_data::first_type Bounding_box;
+	typedef typename Box_data::first_type _Bounding_box; // Note, not global typedef moab::common_tree::Box< double> Bounding_box;
 	typedef typename std::vector< Split_data> Split_list;
 	typedef typename std::vector< Split_list> Splits;
 	typedef typename Splits::iterator Split_iterator;
@@ -512,7 +512,7 @@ void find_split(const Iterator & begin,
 	Buckets buckets( NUM_DIM, Bucket_list( NUM_BUCKETS) );
 	Splits splits( NUM_DIM, Split_list( NUM_SPLITS, data));
 	
-	const Bounding_box interval = data.bounding_box;
+	const _Bounding_box interval = data.bounding_box;
 	establish_buckets( begin, end, interval, buckets);
 	initialize_splits( splits, buckets, data);
 	choose_best_split( splits, data);

diff --git a/src/moab/point_locater/tree/element_tree.hpp b/src/moab/point_locater/tree/element_tree.hpp
index 2b0b86c..261c4a5 100644
--- a/src/moab/point_locater/tree/element_tree.hpp
+++ b/src/moab/point_locater/tree/element_tree.hpp
@@ -45,7 +45,7 @@ bool operator()(const Value & a, const Value & b){
 template< typename Data>
 struct Split_comparator {
   //we minimizes ||left| - |right|| + |middle|^2 
-  const double split_objective( const Data & a) const {
+  double split_objective( const Data & a) const {
 	if (a.second.sizes[ 2]==0 || a.second.sizes[ 0] == 0){
 		return std::numeric_limits< std::size_t>::max();
 	}

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 68c10eb..ab680aa 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -2429,10 +2429,155 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
   }
   
   ErrorCode ParallelComm::update_remote_data(const EntityHandle new_h,
-                                             const int *ps,
-                                             const EntityHandle *hs,
-                                             const int num_ps,
-                                             const unsigned char add_pstat) 
+                                                 const int *ps,
+                                                 const EntityHandle *hs,
+                                                 const int num_ps,
+                                                 const unsigned char add_pstat
+// the following lines left in for future debugging, at least until I trust this function; tjt, 10/4/2013
+//                                             ,int *new_ps,
+//                                             EntityHandle *new_hs,
+//                                             int &new_numps,
+//                                             unsigned char &new_pstat
+                                             ) 
+  {
+      // get initial sharing data; tag_ps and tag_hs get terminated with -1 and 0
+      // in this function, so no need to initialize; sharing data does not include
+      // this proc if shared with only one other
+
+      // following variables declared here to avoid compiler errors
+    int new_numps;
+    unsigned char new_pstat;
+    std::vector<int> new_ps(MAX_SHARING_PROCS, -1);
+    std::vector<EntityHandle> new_hs(MAX_SHARING_PROCS, 0);
+    
+    new_numps = 0;
+    ErrorCode result = get_sharing_data(new_h, &new_ps[0], &new_hs[0], new_pstat, new_numps);
+    RRA("update_remote_data");
+    int num_exist = new_numps;
+
+      // add new pstat info to the flag
+    new_pstat |= add_pstat;
+    
+/*
+#define plist(str, lst, siz)                                          \
+    std::cout << str << "(";                                          \
+    for (int i = 0; i < (int)siz; i++) std::cout << lst[i] << " ";    \
+    std::cout << ") ";                                                \
+    
+    std::cout << "update_remote_data: rank = " << rank() << ", new_h = " << new_h << std::endl;
+    std::string ostr;
+    plist("ps", ps, num_ps);
+    plist("hs", hs, num_ps);
+    print_pstatus(add_pstat, ostr);
+    std::cout << ", add_pstat = " << ostr.c_str() << std::endl;
+    plist("tag_ps", new_ps, new_numps);
+    plist("tag_hs", new_hs, new_numps);
+    assert(new_numps <= size());
+    print_pstatus(new_pstat, ostr);
+    std::cout << ", tag_pstat=" << ostr.c_str() << std::endl;
+*/
+
+#ifndef NDEBUG
+    {
+        // check for duplicates in proc list
+      std::set<unsigned int> dumprocs;
+      unsigned int dp = 0;
+      for (; (int) dp < num_ps && -1 != ps[dp]; dp++)
+        dumprocs.insert(ps[dp]);
+      assert(dp == dumprocs.size());
+    }
+#endif      
+
+      // if only one sharer and I'm the owner, insert myself in the list;
+      // otherwise, my data is checked at the end
+    if (1 == new_numps && !(new_pstat & PSTATUS_NOT_OWNED)) {
+      new_hs[1] = new_hs[0];
+      new_ps[1] = new_ps[0];
+      new_hs[0] = new_h;
+      new_ps[0] = rank();
+      new_numps = 2;
+    }
+    
+      // now put passed-in data onto lists
+    int idx;
+    for (int i = 0; i < num_ps; i++) {
+      idx = std::find(&new_ps[0], &new_ps[0] + new_numps, ps[i]) - &new_ps[0];
+      if (idx < new_numps) {
+        if (!new_hs[idx] && hs[i])
+            // h on list is 0 and passed-in h is non-zero, replace it
+          new_hs[idx] = hs[i];
+        else
+          assert(!hs[i] || new_hs[idx] == hs[i]);
+      }
+      else {
+        if (new_numps+1 == MAX_SHARING_PROCS) {
+          result = MB_FAILURE;
+          std::ostringstream str;
+          str << "Exceeded MAX_SHARING_PROCS for " << CN::EntityTypeName( TYPE_FROM_HANDLE(new_h) )
+              << ' ' << ID_FROM_HANDLE(new_h) << " in process " << rank() << std::endl;
+          RRA(str.str().c_str());
+        }
+        new_ps[new_numps] = ps[i];
+        new_hs[new_numps] = hs[i];
+        new_numps++;
+      }
+    }
+
+      // add myself, if it isn't there already
+    if (new_ps[0] != (int)rank()) {
+      idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
+      if (idx == new_numps) {
+        new_ps[new_numps] = rank();
+        new_hs[new_numps] = new_h;
+        new_numps++;
+      }
+      else if (!new_hs[idx] && new_numps > 2)
+        new_hs[idx] = new_h;
+
+      assert(new_hs[idx] == new_h || new_numps <= 2);
+    }
+    
+      // adjust for interface layer if necessary
+    if (add_pstat & PSTATUS_INTERFACE) {
+      idx = std::min_element(&new_ps[0], &new_ps[0]+new_numps) - &new_ps[0];
+      if (idx) {
+        int tag_proc = new_ps[idx];
+        new_ps[idx] = new_ps[0];
+        new_ps[0] = tag_proc;
+        EntityHandle tag_h = new_hs[idx];
+        new_hs[idx] = new_hs[0];
+        new_hs[0] = tag_h;
+        if (new_ps[0] != (int)rank()) new_pstat |= PSTATUS_NOT_OWNED;
+      }
+    }
+
+      // update for shared, multishared
+    if (new_numps > 1) {
+      if (new_numps > 2) new_pstat |= PSTATUS_MULTISHARED;
+      new_pstat |= PSTATUS_SHARED;
+    }
+    
+/*    
+    plist("new_ps", new_ps, new_numps);
+    plist("new_hs", new_hs, new_numps);
+    print_pstatus(new_pstat, ostr);
+    std::cout << ", new_pstat=" << ostr.c_str() << std::endl;
+    std::cout << std::endl;
+*/
+  
+    result = set_sharing_data(new_h, new_pstat, num_exist, new_numps, &new_ps[0], &new_hs[0]);
+    RRA("update_remote_data: setting sharing data");
+
+    if (new_pstat & PSTATUS_SHARED) sharedEnts.push_back(new_h);
+
+    return MB_SUCCESS;
+  }
+
+ErrorCode ParallelComm::update_remote_data_old(const EntityHandle new_h,
+                                               const int *ps,
+                                               const EntityHandle *hs,
+                                               const int num_ps,
+                                               const unsigned char add_pstat) 
   {
     EntityHandle tag_hs[MAX_SHARING_PROCS];
     int tag_ps[MAX_SHARING_PROCS];
@@ -2547,6 +2692,17 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
     int tag_p;
     EntityHandle tag_h;
 
+    // update pstat
+    pstat |= add_pstat;
+
+    if (num_exist > 2) 
+      pstat |= (PSTATUS_MULTISHARED | PSTATUS_SHARED);
+    else if (num_exist > 0)
+      pstat |= PSTATUS_SHARED;
+
+//    compare_remote_data(new_h, num_ps, hs, ps, add_pstat,
+//                        num_exist, tag_hs, tag_ps, pstat);
+    
     // reset single shared proc/handle if was shared and moving to multi-shared
     if (num_exist > 2 && !(pstat & PSTATUS_MULTISHARED) &&
         (pstat & PSTATUS_SHARED)) {
@@ -2559,9 +2715,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       RRA("Couldn't set sharedh tag.");
     }
 
-    // update pstat
-    pstat |= add_pstat;
-  
     // set sharing tags
     if (num_exist > 2) {
       std::fill(tag_ps+num_exist, tag_ps+MAX_SHARING_PROCS, -1);
@@ -2570,7 +2723,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       RRA("Couldn't set sharedps tag.");
       result = mbImpl->tag_set_data(sharedhs_tag(), &new_h, 1, tag_hs);
       RRA("Couldn't set sharedhs tag.");
-      pstat |= (PSTATUS_MULTISHARED | PSTATUS_SHARED);
 
 #ifndef NDEBUG
       {
@@ -2594,7 +2746,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       RRA("Couldn't set sharedp tag.");
       result = mbImpl->tag_set_data(sharedh_tag(), &new_h, 1, tag_hs);
       RRA("Couldn't set sharedh tag.");
-      pstat |= PSTATUS_SHARED;
     }
 
     // now set new pstatus
@@ -2689,8 +2840,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       num_ps = 0;
     }
 
-    // num_ps is unsigned, so comparison with zero is pointless
-    //assert(0 <= num_ps && MAX_SHARING_PROCS >= num_ps);
     assert(MAX_SHARING_PROCS >= num_ps);
   
     return MB_SUCCESS;
@@ -5765,9 +5914,6 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
                                            int old_nump, int new_nump,
                                            int *ps, EntityHandle *hs) 
   {
-    assert("Should call this function only when reducing sharing procs." &&
-           new_nump < old_nump);
-
     // set sharing data to what's passed in; may have to clean up existing sharing tags
     // if things changed too much
   
@@ -5804,7 +5950,16 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
           dumprocs.insert(ps[dp]);
         assert(dp == (int)dumprocs.size());
       }
-#endif      
+#endif
+      if (old_nump < 3) {
+          // reset sharedp and sharedh tags
+        int tmp_p = -1;
+        EntityHandle tmp_h = 0;
+        result = mbImpl->tag_set_data(sharedp_tag(), &ent, 1, &tmp_p);
+        RRA("");
+        result = mbImpl->tag_set_data(sharedh_tag(), &ent, 1, &tmp_h);
+        RRA("");
+      }
     }
     else {
       unsigned int j = (ps[0] == (int)procConfig.proc_rank() ? 1 : 0);
@@ -8586,8 +8741,9 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
    *   so on average, the message size is num_edges *( sizeof(eh) + sizeof(int) + 1*3*sizeof(double) )
    *          = num_edges * (8+4+24)
    */
+
 ErrorCode ParallelComm::settle_intersection_points(Range & edges, Range & shared_edges_owned,
-          std::vector<std::vector<EntityHandle> *> & extraNodesVec, double tolerance)
+                                                   std::vector<std::vector<EntityHandle> *> & extraNodesVec, double tolerance)
 {
   // the index of an edge in the edges Range will give the index for extraNodesVec
   // the strategy of this follows exchange tags strategy:
@@ -8812,5 +8968,19 @@ ErrorCode ParallelComm::settle_intersection_points(Range & edges, Range & shared
   // end copy
   }
 
+void ParallelComm::print_pstatus(unsigned char pstat, std::string &ostr) 
+{
+  std::ostringstream str;
+  int num = 0;
+#define ppstat(a, b) {if (pstat & a) {if (num) str << ", "; str << b; num++;};}
+    
+  ppstat(PSTATUS_NOT_OWNED, "NOT_OWNED");
+  ppstat(PSTATUS_SHARED, "SHARED");
+  ppstat(PSTATUS_MULTISHARED, "MULTISHARED");
+  ppstat(PSTATUS_INTERFACE, "INTERFACE");
+  ppstat(PSTATUS_GHOST, "GHOST");
+
+  ostr = str.str();
+}
 
 } // namespace moab

diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index 93dc716..f0f1a2b 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -657,6 +657,13 @@ namespace moab {
     Tag part_tag() { return partition_tag(); }
 
     // ==================================
+    // \section DEBUGGING AIDS
+    // ==================================
+
+    //! print contents of pstatus value in human-readable form
+    void print_pstatus(unsigned char pstat, std::string &ostr);
+
+    // ==================================
     // \section IMESHP-RELATED FUNCTIONS
     // ==================================
 
@@ -1320,6 +1327,12 @@ namespace moab {
                                  const int num_ps,
                                  const unsigned char add_pstat);
   
+    ErrorCode update_remote_data_old(const EntityHandle new_h,
+                                     const int *ps,
+                                     const EntityHandle *hs,
+                                     const int num_ps,
+                                     const unsigned char add_pstat);
+    
     /** \brief Set pstatus tag interface bit on entities in sets passed in
      */
     ErrorCode tag_iface_entities();

diff --git a/tools/mbzoltan/MBZoltan.cpp b/tools/mbzoltan/MBZoltan.cpp
index e72c97e..299e3c4 100644
--- a/tools/mbzoltan/MBZoltan.cpp
+++ b/tools/mbzoltan/MBZoltan.cpp
@@ -211,7 +211,7 @@ ErrorCode MBZoltan::balance_mesh(const char *zmethod,
                    exportProcs, &assignment);
 
   if (mbpc->proc_config().proc_rank() == 0) {
-    ErrorCode result = write_partition(mbpc->proc_config().proc_size(), elems, assignment,
+    result = write_partition(mbpc->proc_config().proc_size(), elems, assignment,
                                        write_as_sets, write_as_tags);
 
     if (MB_SUCCESS != result) return result;
@@ -579,8 +579,7 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
     adjs.clear();
     result = mtu.get_bridge_adjacencies(*rit, (dimension > 0 ? dimension-1 : 3), 
                                         dimension, adjs); RR;
-    
-    
+
       // get the graph vertex ids of those
     if (!adjs.empty()) {
       assert(adjs.size() < 5*MAX_SUB_ENTITIES);
@@ -634,6 +633,10 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
                                    const double part_geom_mesh_size,
                                    const int n_part) 
 {
+  // To remove the warnings about unused variables
+  if (dimension > 0) {}
+  if (coords.size() > 0) {}
+
   // get body vertex weights
   DLIList<RefEntity*> body_list;
   gti->ref_entity_list("body", body_list, CUBIT_FALSE);
@@ -696,7 +699,6 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
     shared_surfs.reset();
     for (int k = 0; k < n_shared; k++) { // add adjacencies
       RefFace *face = shared_surfs.get_and_step();
-      int temp_index;
       std::map<int, int>::iterator iter = surf_vertex_map.find(face->id());
       if (iter != surf_vertex_map.end()) {
 	temp_index = (*iter).second;
@@ -760,8 +762,8 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
     }
   }
 
-  for (int i = 0; i < obj_weights.size(); i++) if (obj_weights[i] < 1.) obj_weights[i] = 1.;
-  for (int i = 0; i < edge_weights.size(); i++) if (edge_weights[i] < 1.) edge_weights[i] = 1.;
+  for (size_t i = 0; i < obj_weights.size(); i++) if (obj_weights[i] < 1.) obj_weights[i] = 1.;
+  for (size_t i = 0; i < edge_weights.size(); i++) if (edge_weights[i] < 1.) edge_weights[i] = 1.;
   
   return MB_SUCCESS;
 }
@@ -783,6 +785,8 @@ double MBZoltan::estimate_face_mesh_load(RefEntity* face, const double h)
 	   type == TORUS_SURFACE_TYPE) {
     return 2.352511671418708e-4*n_logn;
   }
+
+  return 0.0;
 }
 
 double MBZoltan::estimate_face_comm_load(RefEntity* face, const double h)
@@ -843,9 +847,9 @@ ErrorCode MBZoltan::write_partition(const int nparts,
       int n_vol = volumes.size();
       volumes.reset();
       for (int j = 0; j < n_vol; j++) {
-	RefEntity *vol = volumes.get_and_step();
-	td_par = (TDParallel *) vol->get_TD(&TDParallel::is_parallel);
-	if (td_par == NULL) td_par = new TDParallel(vol, NULL, &shared_procs);
+        RefEntity *vol = volumes.get_and_step();
+        td_par = (TDParallel *) vol->get_TD(&TDParallel::is_parallel);
+        if (td_par == NULL) td_par = new TDParallel(vol, NULL, &shared_procs);
       }
     }
   }
@@ -867,7 +871,7 @@ ErrorCode MBZoltan::write_partition(const int nparts,
       }
       shared_procs.append(proc); // local proc
       parents.reset();
-      for (int i = 0 ; i < 2; i++) {
+      for (int j = 0 ; j < 2; j++) {
         RefEntity *parent = parents.get_and_step();
         TDParallel *parent_td = (TDParallel *) parent->get_TD(&TDParallel::is_parallel);
         
@@ -887,8 +891,8 @@ ErrorCode MBZoltan::write_partition(const int nparts,
         
         if (debug) {
           std::cout << "surf" << entity->id() << "_is_partitioned_to_p";
-          for (int i = 0; i < shared_procs.size(); i++) {
-            std::cout << "," << shared_procs[i];
+          for (int j = 0; j < shared_procs.size(); j++) {
+            std::cout << "," << shared_procs[j];
           }
           std::cout << std::endl;
         }
@@ -1035,7 +1039,7 @@ ErrorCode MBZoltan::partition_surface(const int nparts,
 
 ErrorCode MBZoltan::partition_round_robin(const int n_part)
 {
-  int i, j;
+  int i, j, k;
   double* loads = new double[n_part]; // estimated loads for each processor
   double* ve_loads = new double[n_part]; // estimated loads for each processor
   for (i = 0; i < n_part; i++) {
@@ -1055,13 +1059,14 @@ ErrorCode MBZoltan::partition_round_robin(const int n_part)
   for (i = 0; i < n_entity; i++) {
     if (i == i_entity_proc) {
       proc++;
-      if (proc < n_part) i_entity_proc += n_entity_proc;
+      if (proc < n_part)
+        i_entity_proc += n_entity_proc;
       else {
         proc %= n_part;
         i_entity_proc++;
       }
     }
-    
+
     // assign to bodies
     entity = body_entity_list.get_and_step();
     DLIList<int> shared_procs;
@@ -1069,7 +1074,7 @@ ErrorCode MBZoltan::partition_round_robin(const int n_part)
     TDParallel *td_par = (TDParallel *) entity->get_TD(&TDParallel::is_parallel);
     if (td_par == NULL) td_par = new TDParallel(entity, NULL, &shared_procs);
     loads[proc] += entity->measure();
-    
+
     // assign to volumes, it should be removed in future
     DLIList<RefVolume*> volumes;
     (dynamic_cast<TopologyEntity*> (entity))->ref_volumes(volumes);
@@ -1080,7 +1085,7 @@ ErrorCode MBZoltan::partition_round_robin(const int n_part)
       td_par = (TDParallel *) vol->get_TD(&TDParallel::is_parallel);
       if (td_par == NULL) td_par = new TDParallel(vol, NULL, &shared_procs);
     }
-    
+
     // add local surface load
     DLIList<RefFace*> faces;
     (dynamic_cast<TopologyEntity*> (entity))->ref_faces(faces);
@@ -1089,78 +1094,74 @@ ErrorCode MBZoltan::partition_round_robin(const int n_part)
     for (j = 0; j < n_face; j++) {
       RefFace* face = faces.get_and_step();
       TopologyEntity *te = CAST_TO(face, TopologyEntity);
-      if (te->bridge_manager()->number_of_bridges() < 2) {
+      if (te->bridge_manager()->number_of_bridges() < 2)
         loads[proc] = loads[proc] + face->measure();
-      }
     }
 
     // Get all child entities
     DLIList<RefEntity*> child_list;
     RefEntity::get_all_child_ref_entities(body_entity_list, child_list);
     int n_child = child_list.size();
-    
+
     // assign processors to interface entities
     child_list.reset();
-    for (i = 0; i < n_child; i++) {
+    for (j = 0; j < n_child; j++) {
       entity = child_list.get_and_step();
       TopologyEntity *te = CAST_TO(entity, TopologyEntity);
       
       if (te->bridge_manager()->number_of_bridges() > 1) {
         DLIList<Body*> parent_bodies;
-	DLIList<int> shared_procs;
-	(dynamic_cast<TopologyEntity*> (entity))->bodies(parent_bodies);
-	int n_parent = parent_bodies.size();
+        DLIList<int> child_shared_procs; // Shared processors of each child entity
+        (dynamic_cast<TopologyEntity*> (entity))->bodies(parent_bodies);
+        int n_parent = parent_bodies.size();
 	
-	for (j = 0; j < n_parent; j++) {
-	  RefEntity *parent_vol = CAST_TO(parent_bodies.get_and_step(), RefEntity);
-	  TDParallel *parent_td = (TDParallel *) parent_vol->get_TD(&TDParallel::is_parallel);
-	  
-	  if (parent_td == NULL) {
-	    PRINT_ERROR("parent Volume has to be partitioned.");
-	    return MB_FAILURE;
-	  }
-	  shared_procs.append_unique(parent_td->get_charge_proc());
-	}
-        
-	if (shared_procs.size() > 1) { // if it is interface
-	  TDParallel *td_par = (TDParallel *) entity->get_TD(&TDParallel::is_parallel);
-	  if (td_par == NULL) {
+        for (k = 0; k < n_parent; k++) {
+          RefEntity *parent_vol = CAST_TO(parent_bodies.get_and_step(), RefEntity);
+          TDParallel *parent_td = (TDParallel *) parent_vol->get_TD(&TDParallel::is_parallel);
+
+          if (parent_td == NULL) {
+            PRINT_ERROR("parent Volume has to be partitioned.");
+            return MB_FAILURE;
+          }
+          child_shared_procs.append_unique(parent_td->get_charge_proc());
+        }
+
+        if (child_shared_procs.size() > 1) { // if it is interface
+          td_par = (TDParallel *) entity->get_TD(&TDParallel::is_parallel);
+          if (td_par == NULL) {
             int merge_id = TDUniqueId::get_unique_id(entity);
-	    if (entity->entity_type_info() == typeid(RefFace)) { // face
-	      if (shared_procs.size() != 2) {
-		PRINT_ERROR("Error: # of shared processors of interface surface should be 2.");
-		return MB_FAILURE;
-	      }
-
-	      // balance interface surface loads
-              if (loads[shared_procs[0]] > loads[shared_procs[1]]) {
-                shared_procs.reverse();
-	      }
-              loads[shared_procs[0]] = loads[shared_procs[0]] + entity->measure();
-	      td_par = new TDParallel(entity, NULL, &shared_procs, NULL,
-                                      merge_id, 1);
-	    }
-	    else if (entity->entity_type_info() == typeid(RefEdge) ||
-		     entity->entity_type_info() == typeid(RefVertex)) {
+            if (entity->entity_type_info() == typeid(RefFace)) { // face
+              if (child_shared_procs.size() != 2) {
+                PRINT_ERROR("Error: # of shared processors of interface surface should be 2.");
+                return MB_FAILURE;
+              }
+
               // balance interface surface loads
-              int min_p = shared_procs[0];
-              int n_shared_proc = shared_procs.size();
-              for (int i = 1; i < n_shared_proc; i++) {
-                if (ve_loads[shared_procs[i]] < ve_loads[min_p]) {
-                  min_p = shared_procs[i];
-                }
+              if (loads[child_shared_procs[0]] > loads[child_shared_procs[1]])
+                child_shared_procs.reverse();
+
+              loads[child_shared_procs[0]] = loads[child_shared_procs[0]] + entity->measure();
+              td_par = new TDParallel(entity, NULL, &child_shared_procs, NULL, merge_id, 1);
+            } // face
+            else if (entity->entity_type_info() == typeid(RefEdge) ||
+                entity->entity_type_info() == typeid(RefVertex)) { // edge or vertex
+              // balance interface surface loads
+              int min_p = child_shared_procs[0];
+              int n_shared_proc = child_shared_procs.size();
+              for (k = 1; k < n_shared_proc; k++) {
+                if (ve_loads[child_shared_procs[k]] < ve_loads[min_p])
+                  min_p = child_shared_procs[k];
               }
               ve_loads[min_p] = ve_loads[min_p] + entity->measure();
-              shared_procs.remove(min_p);
-              shared_procs.insert_first(min_p);
-	      td_par = new TDParallel(entity, NULL, &shared_procs, NULL,
-                                      merge_id, 1);
-	    }
-	  }
-	}
-      }
-    }
-  }
+              child_shared_procs.remove(min_p);
+              child_shared_procs.insert_first(min_p);
+              td_par = new TDParallel(entity, NULL, &child_shared_procs, NULL, merge_id, 1);
+            } // edge or vertex
+          } // if (td_par == NULL)
+        } // if it is interface
+      } // if (te->bridge_manager()->number_of_bridges() > 1)
+    } // for (j = 0; j < n_child; j++)
+  } // for (i = 0; i < n_entity; i++)
 
   return MB_SUCCESS;
 }
@@ -1357,14 +1358,14 @@ ErrorCode MBZoltan::write_partition(const int nparts,
 
       // check for empty sets, warn if there are any
     Range empty_sets;
-    for (Range::iterator rit = partSets.begin(); rit != partSets.end(); rit++) {
+    for (rit = partSets.begin(); rit != partSets.end(); rit++) {
       int num_ents = 0;
       result = mbImpl->get_number_entities_by_handle(*rit, num_ents);
       if (MB_SUCCESS != result || !num_ents) empty_sets.insert(*rit);
     }
     if (!empty_sets.empty()) {
       std::cout << "WARNING: " << empty_sets.size() << " empty sets in partition: ";
-      for (Range::iterator rit = empty_sets.begin(); rit != empty_sets.end(); rit++)
+      for (rit = empty_sets.begin(); rit != empty_sets.end(); rit++)
         std::cout << *rit << " ";
       std::cout << std::endl;
     }
@@ -1476,16 +1477,14 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
   int *sendNborId;
   int *sendProcs;
 
-  if (mbpc->proc_config().proc_rank() == 0)
-  {
+  if (mbpc->proc_config().proc_rank() == 0) {
       /* divide pts to start */
 
     numPts = (int *)malloc(sizeof(int) * mbpc->proc_config().proc_size());
     ptsPerProc = npts / mbpc->proc_config().proc_size();
     ptsAssigned = 0;
 
-    for (i=0; i < mbpc->proc_config().proc_size()-1; i++)
-    {
+    for (i = 0; i < mbpc->proc_config().proc_size() - 1; i++) {
       numPts[i] = ptsPerProc;
       ptsAssigned += ptsPerProc;
     }
@@ -1498,37 +1497,36 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
     sendEdges = length + numPts[0];
     sum = 0;
 
-    for (j=0; j<numPts[0]; j++)
+    for (j = 0; j < numPts[0]; j++)
       sum += length[j];
 
     sendNborId = adjs + sum;
 
-    for (j=numPts[0]; j<npts; j++)
+    for (j = numPts[0]; j < npts; j++)
       sum += length[j];
 
     nborProcs = (int *)malloc(sizeof(int) * sum);
 
-    for (j=0; j<sum; j++)
-      if ((i = adjs[j]/ptsPerProc) < mbpc->proc_config().proc_size())
+    for (j = 0; j < sum; j++)
+      if ((i = adjs[j] / ptsPerProc) < mbpc->proc_config().proc_size())
         nborProcs[j] = i;
       else
         nborProcs[j] = mbpc->proc_config().proc_size() - 1;
 
     sendProcs = nborProcs + (sendNborId - adjs);
 
-    for (i=1; i<mbpc->proc_config().proc_size(); i++)
-    {
-      MPI_Send(&numPts[i], 1, MPI_INT, i, 0x00,MPI_COMM_WORLD);
-      MPI_Send(sendPts, 3 * numPts[i], MPI_DOUBLE, i, 0x01,MPI_COMM_WORLD);
-      MPI_Send(sendIds, numPts[i], MPI_INT, i, 0x03,MPI_COMM_WORLD);
-      MPI_Send(sendEdges, numPts[i], MPI_INT, i, 0x06,MPI_COMM_WORLD);
+    for (i = 1; i < mbpc->proc_config().proc_size(); i++) {
+      MPI_Send(&numPts[i], 1, MPI_INT, i, 0x00, MPI_COMM_WORLD);
+      MPI_Send(sendPts, 3 * numPts[i], MPI_DOUBLE, i, 0x01, MPI_COMM_WORLD);
+      MPI_Send(sendIds, numPts[i], MPI_INT, i, 0x03, MPI_COMM_WORLD);
+      MPI_Send(sendEdges, numPts[i], MPI_INT, i, 0x06, MPI_COMM_WORLD);
       sum = 0;
 
-      for (j=0; j<numPts[i]; j++)
+      for (j = 0; j < numPts[i]; j++)
         sum += sendEdges[j];
 
-      MPI_Send(sendNborId, sum, MPI_INT, i, 0x07,MPI_COMM_WORLD);
-      MPI_Send(sendProcs, sum, MPI_INT, i, 0x08,MPI_COMM_WORLD);
+      MPI_Send(sendNborId, sum, MPI_INT, i, 0x07, MPI_COMM_WORLD);
+      MPI_Send(sendProcs, sum, MPI_INT, i, 0x08, MPI_COMM_WORLD);
       sendPts += (3 * numPts[i]);
       sendIds += numPts[i];
       sendEdges += numPts[i];
@@ -1538,8 +1536,7 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
 
     free(numPts);
   }
-  else
-  {
+  else {
     MPI_Recv(&mySize, 1, MPI_INT, 0, 0x00, MPI_COMM_WORLD, &stat);
     pts = (double *)malloc(sizeof(double) * 3 * mySize);
     ids = (int *)malloc(sizeof(int) * mySize);
@@ -1550,7 +1547,7 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
     MPI_Recv(length, mySize, MPI_INT, 0, 0x06, MPI_COMM_WORLD, &stat);
     sum = 0;
 
-    for (j=0; j<mySize; j++)
+    for (j = 0; j < mySize; j++)
       sum += length[j];
 
     adjs = (int *)malloc(sizeof(int) * sum);
@@ -1559,7 +1556,7 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
     MPI_Recv(adjs, sum, MPI_INT, 0, 0x07, MPI_COMM_WORLD, &stat);
     MPI_Recv(nborProcs, sum, MPI_INT, 0, 0x08, MPI_COMM_WORLD, &stat);
   }     
-          
+
   Points = pts;
   GlobalIds = ids;  
   NumPoints = mySize;
@@ -1569,7 +1566,7 @@ int MBZoltan::mbInitializePoints(int npts, double *pts, int *ids,
   ObjWeights = obj_weights;
   EdgeWeights = edge_weights;
   Parts = parts;
-          
+
   return mySize;
 }     
 
@@ -1590,33 +1587,29 @@ void MBZoltan::mbFinalizePoints(int npts, int numExport,
   else
     MyAssignment = (int *)malloc(sizeof(int) * NumPoints);
 
-  for (i=0; i<NumPoints; i++)
+  for (i = 0; i < NumPoints; i++)
     MyAssignment[i] = mbpc->proc_config().proc_rank();
 
-  for (i=0; i<numExport; i++)
+  for (i = 0; i < numExport; i++)
     MyAssignment[exportLocalIDs[i]] = exportProcs[i];
 
-  if (mbpc->proc_config().proc_rank() == 0)
-    {
+  if (mbpc->proc_config().proc_rank() == 0) {
       /* collect pts */
-
       recvA = MyAssignment + NumPoints;
 
-      for (i=1; i< (int) mbpc->proc_config().proc_size(); i++)
-	{
-	  MPI_Recv(&numPts, 1, MPI_INT, i, 0x04, MPI_COMM_WORLD, &stat);
-	  MPI_Recv(recvA, numPts, MPI_INT, i, 0x05, MPI_COMM_WORLD, &stat);
-	  recvA += numPts;
-	}
-
-      *assignment = MyAssignment;
+    for (i = 1; i< (int) mbpc->proc_config().proc_size(); i++) {
+      MPI_Recv(&numPts, 1, MPI_INT, i, 0x04, MPI_COMM_WORLD, &stat);
+      MPI_Recv(recvA, numPts, MPI_INT, i, 0x05, MPI_COMM_WORLD, &stat);
+      recvA += numPts;
     }
-  else
-    {
-      MPI_Send(&NumPoints, 1, MPI_INT, 0, 0x04,MPI_COMM_WORLD);
-      MPI_Send(MyAssignment, NumPoints, MPI_INT, 0, 0x05,MPI_COMM_WORLD);
-      free(MyAssignment);
-    }     
+
+    *assignment = MyAssignment;
+  }
+  else {
+    MPI_Send(&NumPoints, 1, MPI_INT, 0, 0x04, MPI_COMM_WORLD);
+    MPI_Send(MyAssignment, NumPoints, MPI_INT, 0, 0x05, MPI_COMM_WORLD);
+    free(MyAssignment);
+  }
 }
 
 int MBZoltan::mbGlobalSuccess(int rc)
@@ -1627,8 +1620,8 @@ int MBZoltan::mbGlobalSuccess(int rc)
 
   MPI_Allgather(&rc, 1, MPI_INT, vals, 1, MPI_INT, MPI_COMM_WORLD);
 
-  for (i=0; i<mbpc->proc_config().proc_size(); i++){
-    if (vals[i] != ZOLTAN_OK){
+  for (i = 0; i<mbpc->proc_config().proc_size(); i++) {
+    if (vals[i] != ZOLTAN_OK) {
       if (0 == mbpc->proc_config().proc_rank()){
         mbShowError(vals[i], "Result on process ");
       }
@@ -1653,15 +1646,15 @@ void MBZoltan::mbPrintGlobalResult(const char *s,
   v1[2] = exp;
   v1[3] = change;
 
-  if (mbpc->proc_config().proc_rank() == 0){
+  if (mbpc->proc_config().proc_rank() == 0) {
     v2 = (int *)malloc(4 * mbpc->proc_config().proc_size() * sizeof(int));
   }
 
   MPI_Gather(v1, 4, MPI_INT, v2, 4, MPI_INT, 0, MPI_COMM_WORLD);
 
-  if (mbpc->proc_config().proc_rank() == 0){
-    fprintf(stdout,"======%s======\n",s);
-    for (i=0, v=v2; i<mbpc->proc_config().proc_size(); i++, v+=4){
+  if (mbpc->proc_config().proc_rank() == 0) {
+    fprintf(stdout, "======%s======\n", s);
+    for (i = 0, v = v2; i < mbpc->proc_config().proc_size(); i++, v += 4) {
       fprintf(stdout,"%d: originally had %d, import %d, exp %d, %s\n",
         i, v[0], v[1], v[2],
         v[3] ? "a change of partitioning" : "no change");
@@ -1678,11 +1671,9 @@ void MBZoltan::mbPrintGlobalResult(const char *s,
 void MBZoltan::mbShowError(int val, const char *s)
 {
   if (s)
-    {
-    printf("%s ",s);
-    }
-  switch (val)
-    {
+    printf("%s ", s);
+
+  switch (val) {
     case ZOLTAN_OK:
       printf("%d: SUCCESSFUL\n", mbpc->proc_config().proc_rank());
       break;
@@ -1699,7 +1690,6 @@ void MBZoltan::mbShowError(int val, const char *s)
       printf("%d: INVALID RETURN CODE\n", mbpc->proc_config().proc_rank());
       break;
     }
-  return;
 }
 
 /**********************
@@ -1708,6 +1698,9 @@ void MBZoltan::mbShowError(int val, const char *s)
 
 int mbGetNumberOfAssignedObjects(void *userDefinedData, int *err)
 {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+
   *err = 0;
   return NumPoints;
 }
@@ -1716,56 +1709,64 @@ void mbGetObjectList(void *userDefinedData, int numGlobalIds, int numLids,
   ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int wgt_dim, float *obj_wgts,
   int *err)
 {
-  int i;
-    
-  for (i=0; i<NumPoints; i++)
-    {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+  if (numGlobalIds > 0){}
+  if (numLids > 0) {}
+  if (gids) {}
+  if (lids) {}
+
+  for (int i = 0; i < NumPoints; i++) {
     gids[i] = GlobalIds[i];
     lids[i] = i;
-    if (wgt_dim>0) obj_wgts[i] = ObjWeights[i];
-    }
-    
-  
+    if (wgt_dim > 0)
+      obj_wgts[i] = ObjWeights[i];
+  }
 
   *err = 0;
-    
-  return;
 }
 
 int mbGetObjectSize(void *userDefinedData, int *err)
 {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+
   *err = 0; 
   return 3;
-} 
+}
 
 void mbGetObject(void *userDefinedData, int numGlobalIds, int numLids, int numObjs,
   ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int numDim, double *pts, int *err)
 { 
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+  if (numGlobalIds > 0) {}
+  if (numLids > 0) {}
+  if (gids) {}
+  if (lids) {}
+
   int i, id, id3;
   int next = 0;
-  
-  if (numDim != 3)    
-    {
+
+  if (numDim != 3) {
     *err = 1;         
     return;
-    }
+  }
 
-  for (i=0; i<numObjs; i++)
-    {
+  for (i = 0; i < numObjs; i++) {
     id = lids[i];
-  
-    if ((id < 0) || (id >= NumPoints))
-      {
+
+    if ((id < 0) || (id >= NumPoints)) {
       *err = 1;
       return;
-      }
+    }
 
     id3 = lids[i] * 3;
 
     pts[next++] = Points[id3];
     pts[next++] = Points[id3 + 1];
     pts[next++] = Points[id3 + 2];
-    }
+  }
 } 
 
 void mbGetNumberOfEdges(void *userDefinedData, int numGlobalIds, int numLids,
@@ -1773,21 +1774,26 @@ void mbGetNumberOfEdges(void *userDefinedData, int numGlobalIds, int numLids,
 			ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,	int *numEdges,
 			int *err)
 {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+  if (numGlobalIds > 0) {}
+  if (numLids > 0) {}
+  if (gids) {}
+  if (lids) {}
+
   int i, id;
   int next = 0;
 
-  for (i=0; i<numObjs; i++)
-    {
-      id = lids[i];
-
-      if ((id < 0) || (id >= NumPoints))
-	{
-	  *err = 1;
-	  return;
-	}
+  for (i = 0; i < numObjs; i++) {
+    id = lids[i];
 
-      numEdges[next++] = NumEdges[id];
+    if ((id < 0) || (id >= NumPoints)) {
+      *err = 1;
+      return;
     }
+
+    numEdges[next++] = NumEdges[id];
+  }
 }
 
 void mbGetEdgeList(void *userDefinedData, int numGlobalIds, int numLids,
@@ -1796,50 +1802,62 @@ void mbGetEdgeList(void *userDefinedData, int numGlobalIds, int numLids,
 		   ZOLTAN_ID_PTR nborGlobalIds, int *nborProcs, int wgt_dim,
 		   float *edge_wgts, int *err)
 {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+  if (numGlobalIds > 0) {}
+  if (numLids > 0) {}
+  if (gids) {}
+  if (lids) {}
+  if (numEdges) {}
+
   int i, id, idSum, j;
   int next = 0;
 
-  for (i=0; i<numObjs; i++)
-    {
-      id = lids[i];
-
-      if ((id < 0) || (id >= NumPoints))
-	{
-	  *err = 1;
-	  return;
-	}
-
-      idSum = 0;
-
-      for (j=0; j<id; j++)
-	  idSum += NumEdges[j];
-
-      for (j=0; j<NumEdges[id]; j++)
-	{
-	  nborGlobalIds[next] = NborGlobalId[idSum];
-	  nborProcs[next] = NborProcs[idSum];
-          if (wgt_dim > 0) edge_wgts[next] = EdgeWeights[idSum];
-          next++;
-          idSum++;
-	}
+  for (i = 0; i < numObjs; i++) {
+    id = lids[i];
+
+    if ((id < 0) || (id >= NumPoints)) {
+	    *err = 1;
+      return;
+	  }
+
+    idSum = 0;
+
+    for (j = 0; j < id; j++)
+      idSum += NumEdges[j];
+
+    for (j = 0; j < NumEdges[id]; j++) {
+      nborGlobalIds[next] = NborGlobalId[idSum];
+      nborProcs[next] = NborProcs[idSum];
+      if (wgt_dim > 0) edge_wgts[next] = EdgeWeights[idSum];
+        next++;
+        idSum++;
     }
+  }
 }
 
 void mbGetPart(void *userDefinedData, int numGlobalIds, int numLids,
                int numObjs, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
                int *part, int *err)
 {
+  // To remove the warnings about unused variables
+  if (userDefinedData) {}
+  if (numGlobalIds > 0) {}
+  if (numLids > 0) {}
+  if (gids) {}
+  if (lids) {}
+
   int i, id;
   int next = 0;
 
   for (i = 0; i < numObjs; i++) {
     id = lids[i];
-    
+
     if ((id < 0) || (id >= NumPoints)) {
       *err = 1;
       return;
     }
-    
+
     part[next++] = Parts[id];
   }
 }

diff --git a/tools/mbzoltan/MBZoltan.hpp b/tools/mbzoltan/MBZoltan.hpp
index 92585e7..e36ec13 100644
--- a/tools/mbzoltan/MBZoltan.hpp
+++ b/tools/mbzoltan/MBZoltan.hpp
@@ -201,8 +201,6 @@ using namespace moab;
 #ifdef CGM
     std::map<int, int> body_vertex_map, surf_vertex_map;
 
-    std::vector<double> obj_weights;
-
     ErrorCode assemble_graph(const int dimension, 
                              std::vector<double> &coords,
                              std::vector<int> &moab_ids,


https://bitbucket.org/fathomteam/moab/commits/6e6600f01f0a/
Changeset:   6e6600f01f0a
Branch:      None
User:        iulian07
Date:        2013-09-06 23:08:52
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Conflicts:
	tools/mbcslam/process_arm.cpp

Affected #:  2 files

diff --git a/itaps/imesh/MOAB_iMeshP_unit_tests.cpp b/itaps/imesh/MOAB_iMeshP_unit_tests.cpp
index 29f88a8..96d659d 100644
--- a/itaps/imesh/MOAB_iMeshP_unit_tests.cpp
+++ b/itaps/imesh/MOAB_iMeshP_unit_tests.cpp
@@ -32,11 +32,12 @@ const char* const FILENAME = "iMeshP_test_file";
 
 #define PCHECK do { ierr = is_any_proc_error(ierr); CHKERR; } while(false)
 
+// Use my_rank instead of rank to avoid shadowed declaration
 #define ASSERT(A) do { \
   if (is_any_proc_error(!(A))) { \
-    int rank = 0; \
-    MPI_Comm_rank( MPI_COMM_WORLD, &rank ); \
-    if (!rank) std::cerr << "Failed assertion: " #A << std::endl \
+    int my_rank = 0; \
+    MPI_Comm_rank( MPI_COMM_WORLD, &my_rank ); \
+    if (0 == my_rank) std::cerr << "Failed assertion: " #A << std::endl \
                          << "  at " __FILE__ ":" << __LINE__ << std::endl; \
     return 1; \
   } } while (false)
@@ -1684,7 +1685,7 @@ int test_part_boundary_iter( iMesh_Instance imesh, iMeshP_PartitionHandle prtn,
  * Test:
  * - iMeshP_getAdjEntities
  */
-int test_get_adjacencies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& )
+int test_get_adjacencies( iMesh_Instance /* imesh */, iMeshP_PartitionHandle /* prtn */, const PartMap& )
 {
   return iBase_SUCCESS;
 }
@@ -1695,7 +1696,7 @@ int test_get_adjacencies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, con
  * - iMeshP_initEntIter
  * - iMeshP_initEntArrIter
  */
-int test_entity_iterator( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& )
+int test_entity_iterator( iMesh_Instance /*imesh */, iMeshP_PartitionHandle /*prtn*/, const PartMap& )
 {
   return iBase_SUCCESS;
 }
@@ -1708,7 +1709,7 @@ int test_entity_iterator( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, con
  * - iMeshP_isEntOwner
  * - iMeshP_isEntOwnerArr
  */
-int test_entity_owner( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& map )
+int test_entity_owner( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& /* map */ )
 {
   int ierr, rank, size;
   MPI_Comm_rank( MPI_COMM_WORLD, &rank );
@@ -1840,8 +1841,8 @@ int test_entity_owner( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const
     assert( junk1 == (int)is_owner_list.size() );
     assert( junk3 == (int)all_entities.size() );
     invalid_count = 0;
-    for (size_t i = 0; i < all_entities.size(); ++i) {
-      if (!(is_owner_list[i]) == (local_ids[0] == all_owners[i]))
+    for (size_t j = 0; j < all_entities.size(); ++j) {
+      if (!(is_owner_list[j]) == (local_ids[0] == all_owners[j]))
         ++invalid_count;
     }
   }
@@ -2166,7 +2167,7 @@ struct VtxCopyData {
  * - iMeshP_getCopyOnPart
  * - iMeshP_getOwnerCopy
  */
-int test_entity_copies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& map )
+int test_entity_copies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& /* map */ )
 {
   int ierr, rank, size;
   MPI_Comm_rank( MPI_COMM_WORLD, &rank );
@@ -2269,11 +2270,12 @@ int test_entity_copies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const
   int num_error = 0, num_incorrect = 0, junk4;
   for (size_t i = 0; i < local_vertices.size(); ++i) {
     int num_copies = -1;
-    iMeshP_Part* part_ids = 0;
+    //iMeshP_Part* part_ids = 0;
+    iMeshP_Part* ptr_part_ids = 0; // Use ptr_part_ids to avoid shadowing std::vector<iMeshP_Part> part_ids
     iBase_EntityHandle* copies = 0;
     junk2 = junk3 = junk4 = 0;
     iMeshP_getCopies( imesh, prtn, local_vertices[i],
-                      &part_ids, &junk2, &num_copies, 
+                      &ptr_part_ids, &junk2, &num_copies,
                       &copies, &junk3, &junk4, &ierr );
     if (iBase_SUCCESS != ierr) {
       ++num_error;
@@ -2285,13 +2287,13 @@ int test_entity_copies( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const
     if (num_copies != (int)expected.parts.size())
       ++num_incorrect;
     else for (size_t j = 0; j < expected.parts.size(); ++j) {
-      int idx = std::find( part_ids, part_ids+num_copies, expected.parts[j] ) - part_ids;
+      int idx = std::find( ptr_part_ids, ptr_part_ids + num_copies, expected.parts[j] ) - ptr_part_ids;
       if (idx == num_copies || copies[idx] != expected.handles[j]) {
         ++num_incorrect;
         break;
       }
     }
-    free(part_ids);
+    free(ptr_part_ids);
     free(copies);
   }
   ASSERT( 0 == num_error );
@@ -2461,7 +2463,7 @@ int get_num_adj_all( iMesh_Instance imesh,
  * Test:
  * - iMeshP_createGhostEntsAll
  */
-int test_create_ghost_ents( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& map )
+int test_create_ghost_ents( iMesh_Instance imesh, iMeshP_PartitionHandle prtn, const PartMap& /* map */)
 {
   int ierr;
   

diff --git a/tools/mbcslam/process_arm.cpp b/tools/mbcslam/process_arm.cpp
new file mode 100644
index 0000000..06472a9
--- /dev/null
+++ b/tools/mbcslam/process_arm.cpp
@@ -0,0 +1,406 @@
+/*
+ * process_arm.cpp
+ *
+ *  Created on: April 18, 2013
+ */
+
+// process the files from Mark; also, link against netcdf directly, because we will use
+// netcdf calls to read data, the same as in ReadNC and ReadNCDF
+//
+//
+#include <iostream>
+#include <sstream>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "moab/Core.hpp"
+#include "moab/Interface.hpp"
+#include "moab/ReadUtilIface.hpp"
+#include "moab/AdaptiveKDTree.hpp"
+
+#include "CslamUtils.hpp"
+
+#include "netcdf.h"
+
+#include <algorithm>
+#include <string>
+#include <assert.h>
+
+#include <cmath>
+
+
+using namespace moab;
+
+#define INS_ID(stringvar, prefix, id) \
+          sprintf(stringvar, prefix, id)
+
+#define GET_DIM(ncdim, name, val)\
+    {                            \
+    int gdfail = nc_inq_dimid(ncFile, name, &ncdim);          \
+    if (NC_NOERR == gdfail) {                                             \
+      size_t tmp_val;                                                   \
+      gdfail = nc_inq_dimlen(ncFile, ncdim, &tmp_val);                        \
+      if (NC_NOERR != gdfail) {                                           \
+        std::cout<<"couldn't get dimension length for" << name<< " \n"; \
+        return 1;                                              \
+      }                                                                 \
+      else val = tmp_val;                                               \
+    } else val = 0;}
+
+#define GET_DIMB(ncdim, name, varname, id, val) \
+          INS_ID(name, varname, id); \
+          GET_DIM(ncdim, name, val);
+
+#define GET_VAR(name, id, dims) \
+    {                           \
+    id = -1;\
+    int gvfail = nc_inq_varid(ncFile, name, &id);   \
+    if (NC_NOERR == gvfail) {       \
+    int ndims;\
+    gvfail = nc_inq_varndims(ncFile, id, &ndims);\
+    if (NC_NOERR == gvfail) {\
+    dims.resize(ndims);    \
+    gvfail = nc_inq_vardimid(ncFile, id, &dims[0]);}}}
+
+#define GET_1D_INT_VAR(name, id, vals) \
+    {GET_VAR(name, id, vals);  \
+  if (-1 != id) {\
+    size_t ntmp;\
+    int ivfail = nc_inq_dimlen(ncFile, vals[0], &ntmp);\
+    vals.resize(ntmp);\
+    size_t ntmp1 = 0;                                                           \
+    ivfail = nc_get_vara_int(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
+    if (NC_NOERR != ivfail) {\
+      std::cout<<"ReadNCDF:: Problem getting variable " <<name <<"\n";\
+      return 1;}}}
+
+
+#define GET_1D_DBL_VAR(name, id, vals) \
+    {std::vector<int> dum_dims;        \
+  GET_VAR(name, id, dum_dims);\
+  if (-1 != id) {\
+    size_t ntmp;\
+    int dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp);\
+    vals.resize(ntmp);\
+    size_t ntmp1 = 0;                                                           \
+    dvfail = nc_get_vara_double(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
+    if (NC_NOERR != dvfail) {\
+      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
+      return 1;}}}
+
+/*
+int get_2d_flt_var(int ncFile, const char * name, int index, std::vector<float> & vals)
+{
+  int id;
+  std::vector<int> dum_dims;
+  GET_VAR(name, id, dum_dims);
+  if (-1 != id) {
+    size_t ntmp;
+  int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);
+  vals.resize(ntmp);
+  size_t ntmp1[2] = {index, 0};
+
+  int ntimes;
+  dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntimes);
+  if (index>=ntimes) {
+    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
+    return 1;
+  }
+  size_t count[2] ={1, ntmp};
+  dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);
+  if (NC_NOERR != dvfail) {
+    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
+    return 1;
+  }
+  return 0;
+}
+*/
+/* get the variable along an index */
+#define GET_2D_FLT_VAR(name, id, index, vals) \
+    {std::vector<int> dum_dims;        \
+  GET_VAR(name, id, dum_dims);\
+  if (-1 != id) {\
+    size_t ntmp, ntmp2;\
+    int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);\
+    dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp2);\
+    vals.resize(ntmp);\
+    size_t ntmp1[2] = {index, 0}; \
+    if (index>=ntmp2) { \
+      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n"; \
+      return 1; \
+    } \
+    size_t count[2] ={1, ntmp}; \
+    dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);\
+    if (NC_NOERR != dvfail) {\
+      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
+      return 1;}}}
+
+int main(int argc, char ** argv)
+{
+
+  int num_el = 50000;
+  if (argc>1)
+  {
+    num_el = atoi(argv[1]);
+  }
+  std::cout << "num_el=" << num_el << "\n";
+
+  Core moab;
+  Interface & mb = moab;
+  ErrorCode rval;
+
+  int ncFile, temp_dim;        // netcdf/exodus file
+
+  // now, open the data file and read the lat, lon and U850 and V850
+  const char *data_file = "fc5_arm12.cam2.h2.0004-12-12-00000.nc";
+
+  int fail = nc_open(data_file, 0, &ncFile);
+  if (NC_NOWRITE != fail) {
+    std::cout<<"ReadNCDF:: problem opening Netcdf/Exodus II "<<data_file <<"\n";
+    return 1;
+  }
+  int ncol;
+  GET_DIM(temp_dim, "ncol", ncol);
+  std::cout << "ncol:" << ncol << "\n";
+
+  std::vector<double> lat;
+  std::vector<double> lon;
+  GET_1D_DBL_VAR("lat", temp_dim, lat);
+
+  GET_1D_DBL_VAR("lon", temp_dim, lon);
+
+  std::cout<< " lat, lon 0" << lat[0] << " " << lon[0] << "\n";
+  std::cout<< " lat, lon 1" << lat[1] << " " << lon[1] << "\n";
+  std::cout << " size: " << lat.size() << "\n";
+
+  // see if the mesh from metadata makes sense
+  // create quads with the connectivity from conn array
+
+  ReadUtilIface* readMeshIface;
+  mb.query_interface( readMeshIface );
+  if (NULL==readMeshIface)
+    return 1;
+  EntityHandle node_handle = 0;
+  std::vector<double*> arrays;
+  rval = readMeshIface->get_node_coords(3, ncol,
+      1, node_handle, arrays);
+  if (MB_SUCCESS!= rval)
+    return 1;
+
+  SphereCoords  sp;
+  sp.R = 1.;
+  Tag gid;
+  rval = mb.tag_get_handle("GLOBAL_ID", 1, MB_TYPE_INTEGER,
+      gid, MB_TAG_SPARSE|MB_TAG_CREAT);
+  if (MB_SUCCESS!= rval)
+      return 1;
+  std::vector<int> gids(ncol);
+
+  double conversion_factor = M_PI/180.;
+  for (int k=0; k<ncol; k++)
+  {
+    sp.lat=lat[k]*conversion_factor;
+    sp.lon=lon[k]*conversion_factor;
+    CartVect pos=spherical_to_cart (sp);
+    arrays[0][k]=pos[0];
+    arrays[1][k]=pos[1];
+    arrays[2][k]=pos[2];
+    gids[k]=k+1;
+  }
+
+  Range nodes(node_handle, node_handle+ncol-1);
+  rval = mb.tag_set_data(gid, nodes, &gids[0]);
+  if (MB_SUCCESS!= rval)
+       return 1;
+
+  EntityHandle newSet;
+  rval = mb.create_meshset(MESHSET_SET, newSet);
+  if (MB_SUCCESS != rval)
+    return 1;
+
+  // so the nodes will be part
+  mb.add_entities(newSet, nodes);
+
+  // build a kd tree with the vertices
+  EntityHandle tree_root;
+  AdaptiveKDTree kd(&mb, true);
+  rval = kd.build_tree(nodes, tree_root);
+  if (MB_SUCCESS != rval)
+    return 1;
+
+  unsigned int  min_depth, max_depth;
+  rval = kd.depth(tree_root, min_depth, max_depth);
+  if (MB_SUCCESS != rval)
+     return 1;
+  std::cout << "min_depth, max_depth " << min_depth << " " << max_depth << "\n";
+  // now, read the conn file created using spectral visu, and see how they fit
+  // this can be directly imported to moab
+  const char *myconn_file = "spec.R2.vtk";
+  EntityHandle euler_set;
+  rval = mb.create_meshset(MESHSET_SET, euler_set);
+  if (MB_SUCCESS != rval)
+    return 1;
+
+  rval = mb.load_file(myconn_file, &euler_set);
+
+  if (MB_SUCCESS != rval)
+    return 1;
+
+  mb.list_entities(&euler_set, 1);
+
+  Range specQuads;
+  rval = mb.get_entities_by_dimension(euler_set, 2, specQuads );
+  if (MB_SUCCESS != rval)
+     return 1;
+
+  Range vertices;
+  rval = mb.get_connectivity(specQuads, vertices);
+  if (MB_SUCCESS != rval)
+     return 1;
+
+  // do a mapping, from position of vertices to the vertices in the kd tree.
+  // find the closest vertex to each of this
+  std::vector<EntityHandle> mappedTo(vertices.size());
+  std::vector<double> mycoords(vertices.size()*3);
+  rval = mb.get_coords(vertices, &mycoords[0]);
+  double * ptr = &mycoords[0];
+  size_t num_verts=vertices.size();
+  for (size_t i=0; i<num_verts; i++, ptr+=3)
+  {
+    CartVect pos(ptr); // take 3 coordinates
+    std::vector<EntityHandle> leaves;
+    rval = kd.leaves_within_distance( tree_root,
+                                          ptr,
+                                          0.001,
+                                        leaves);
+    if (MB_SUCCESS != rval)
+      return 1;
+    Range closeVerts;
+    for (std::vector<EntityHandle>::iterator vit = leaves.begin(); vit != leaves.end(); vit++)
+    {
+      rval= mb.get_entities_by_handle(*vit, closeVerts, Interface::UNION);
+      if (moab::MB_SUCCESS != rval)
+        return 1;
+    }
+    if (closeVerts.size()<1)
+    {
+      std::cout << "increase tolerance, no points close to " << pos << "\n";
+      return 1;
+    }
+    std::vector<CartVect> coordsTarget(closeVerts.size());
+    rval = mb.get_coords(closeVerts, &(coordsTarget[0][0]));
+    if (MB_SUCCESS != rval)
+      return 1;
+    double minDist2=(pos-coordsTarget[0]).length_squared();
+    EntityHandle closestVertex=closeVerts[0];
+    for (unsigned int j=1; j<closeVerts.size(); j++)
+    {
+      double dist2=(pos-coordsTarget[j]).length_squared();
+      if (minDist2>dist2)
+      {
+        closestVertex = closeVerts[j];
+        minDist2=dist2;
+      }
+    }
+    if (minDist2 > 0.00001)
+    {
+      std::cout << " problem with node " << vertices[i] << "  min dist2:" << minDist2 << "\n";
+      return 1;
+    }
+    mappedTo [i] = closestVertex;
+  }
+
+  num_el = (int)specQuads.size();
+  // tmp_ptr is of type int* and points at the same place as conn
+  EntityHandle * conn = 0;
+
+  EntityHandle elh;
+
+  readMeshIface->get_element_connect(
+          num_el,
+          4,
+          MBQUAD,
+          1,
+          elh,
+          conn);
+
+  EntityHandle firstVertMyMesh=vertices[0];
+  for (int k=0; k<num_el; k++)
+  {
+    const EntityHandle * myconn=0;
+    EntityHandle specElem = specQuads[k];
+    int num_nodes=0;
+    rval = mb.get_connectivity(specElem, myconn, num_nodes);
+    if (MB_SUCCESS != rval || num_nodes !=4)
+      return 1;
+
+    int start_el = k*4;
+    for (int j=0; j<4; j++)
+       conn[start_el+j] = mappedTo[myconn[j]-firstVertMyMesh];
+  }
+  std::cout << " conn:" << conn[0] << " " << conn[1] << " " << conn[3]<< "\n";
+  Range erange(elh, elh+num_el-1);
+
+  mb.add_entities(newSet, erange);
+  std::vector<int> gidels(num_el);
+  Tag gid2;
+  rval = mb.tag_get_handle("GLOBAL_ID_EL", 1, MB_TYPE_INTEGER,
+        gid2, MB_TAG_SPARSE|MB_TAG_CREAT);
+
+  if (MB_SUCCESS != rval)
+      return 1;
+  for (int k=0; k<num_el; k++)
+    gidels[k]=k+1;
+  mb.tag_set_data(gid2, erange, &gidels[0]);
+
+  // For now, comment out times to remove compile warning (variable ‘times’ set but not used)
+  //int times;
+  //GET_DIM(temp_dim, "time", times);
+
+  Tag velotag;
+  rval = mb.tag_get_handle("VELO", 3, MB_TYPE_DOUBLE,
+            velotag, MB_TAG_DENSE|MB_TAG_CREAT);
+  if (MB_SUCCESS!= rval)
+    return 1;
+
+  for (size_t tt=0; tt<56 /*(size_t)times*/; tt++)
+  {
+    // now, read velocities from file:
+    // read the U850 and V850 variables
+    std::vector<float> u850;
+    GET_2D_FLT_VAR("U850", temp_dim, tt, u850);
+    std::vector<float> v850;
+    GET_2D_FLT_VAR("V850", temp_dim, tt, v850);
+
+    std::cout << " U850:" << u850[0] << " " << u850[1] << " " << u850[5] << " "<< u850.size()<<"\n";
+    std::cout << " V850:" << v850[0] << " " << v850[1] << " " << v850[5] << " "<< u850.size()<<"\n";
+    // ok, use radius as 6371km; not needed
+
+    std::vector<CartVect> velo850(ncol);
+
+    std::stringstream fileName;
+    fileName << "VELO0" <<  tt << ".h5m";
+    std::cout << " read velocities at 850 for time:" << tt << "\n";
+
+
+    for (int k=0; k<ncol; k++)
+    {
+      double latRad=lat[k]*conversion_factor;
+      double lonRad=lon[k]*conversion_factor;
+      CartVect U(-sin(lonRad), cos(lonRad), 0.);
+      CartVect V(-sin(latRad)*cos(lonRad), -sin(latRad)*cos(lonRad), cos(latRad));
+      velo850[k]=U*u850[k] +V*v850[k];
+    }
+    rval = mb.tag_set_data(velotag, nodes, &(velo850[0][0]));
+    if (MB_SUCCESS!= rval)
+      return 1;
+    rval = mb.write_mesh(fileName.str().c_str(), &newSet, 1);
+    if (MB_SUCCESS!= rval)
+      return 1;
+  }
+
+
+
+  return 0;
+}


https://bitbucket.org/fathomteam/moab/commits/c573803f6e48/
Changeset:   c573803f6e48
Branch:      None
User:        iulian07
Date:        2013-09-06 23:09:58
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  9 files

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index 6382871..d344037 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -104,11 +104,39 @@ ScdBox *ScdInterface::get_scd_box(EntityHandle eh)
 
 ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double * const coords, unsigned int num_coords,
                                       ScdBox *& new_box, int * const lperiodic, ScdParData *par_data,
-                                      bool assign_gids)
+                                      bool assign_gids, int tag_shared_ents)
 {
     // create a rectangular structured mesh block
   ErrorCode rval;
 
+  int tmp_lper[3] = {0, 0, 0};
+  if (lperiodic) std::copy(lperiodic, lperiodic+3, tmp_lper);
+  
+#ifndef USE_MPI
+  if (-1 == tag_shared_ents) ERRORR(MB_FAILURE, "Parallel capability requested but MOAB not compiled parallel.");
+  if (-1 == tag_shared_verts && !assign_gids) assign_gids = true; // need to assign gids in order to tag shared verts
+#else
+  if (par_data && low == high && ScdParData::NOPART != par_data->partMethod) {
+      // requesting creation of parallel mesh, so need to compute partition
+    if (!par_data->pComm) {
+        // this is a really boneheaded way to have to create a PC
+      par_data->pComm = ParallelComm::get_pcomm(mbImpl, 0);
+      if (NULL == par_data->pComm) par_data->pComm = new ParallelComm(mbImpl, MPI_COMM_WORLD);
+    }
+    int ldims[6];
+    rval = compute_partition(par_data->pComm->size(), par_data->pComm->rank(), *par_data, 
+                             ldims, tmp_lper, par_data->pDims);
+    ERRORR(rval, "Error returned from compute_partition.");
+    low.set(ldims);
+    high.set(ldims+3);
+    if (par_data->pComm->get_debug_verbosity() > 0) {
+      std::cout << "Proc " << par_data->pComm->rank() << ": " << *par_data;
+      std::cout << "Proc " << par_data->pComm->rank() << " local dims: " 
+                << low << "-" << high << std::endl;
+    }
+  }
+#endif
+  
   HomCoord tmp_size = high - low + HomCoord(1, 1, 1, 0);
   if ((tmp_size[1] && num_coords && (int)num_coords < tmp_size[0]) ||
       (tmp_size[2] && num_coords && (int)num_coords < tmp_size[0]*tmp_size[1]))
@@ -150,7 +178,7 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
   if (1 >= tmp_size[2]) this_tp = MBQUAD;
   if (1 >= tmp_size[2] && 1 >= tmp_size[1]) this_tp = MBEDGE;
   rval = seq_mgr->create_scd_sequence(low, high, this_tp, 0, start_ent, tmp_seq, 
-                                      lperiodic);
+                                      tmp_lper);
   ERRORR(rval, "Trouble creating scd element sequence.");
 
   new_box->elem_seq(tmp_seq);
@@ -181,6 +209,12 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
     ERRORR(rval, "Trouble assigning global ids");
   }
 
+#ifdef USE_MPI
+  if (par_data && -1 != tag_shared_ents) {
+    rval = tag_shared_vertices(par_data->pComm, new_box);
+  }
+#endif
+  
   return MB_SUCCESS;
 }
 
@@ -695,6 +729,7 @@ ErrorCode ScdInterface::tag_shared_vertices(ParallelComm *pcomm, ScdBox *box)
   for (std::vector<int>::iterator pit = procs.begin(); pit != procs.end(); pit++)
     pcomm->get_buffers(*pit);
 
+  if (pcomm->get_debug_verbosity() > 1) pcomm->list_entities(NULL, 1);
 
 #ifndef NDEBUG
   rval = pcomm->check_all_shared_handles();

diff --git a/src/moab/ScdInterface.hpp b/src/moab/ScdInterface.hpp
index bb24835..31609f2 100644
--- a/src/moab/ScdInterface.hpp
+++ b/src/moab/ScdInterface.hpp
@@ -103,10 +103,10 @@ class ParallelComm;
       //! struct for keeping parallel data in one place
 class ScdParData {
 public:
-  ScdParData() : partMethod(NOPART) {
-    gDims[0] = gDims[1] = gDims[2] = gDims[3] = gDims[4] = gDims[5] = -1;
-    gPeriodic[0] = gPeriodic[1] = gPeriodic[2] = -1;
-    pDims[0] = pDims[1] = pDims[2] = -1;
+  ScdParData() : partMethod(NOPART), pComm(NULL) {
+    gDims[0] = gDims[1] = gDims[2] = gDims[3] = gDims[4] = gDims[5] = 0;
+    gPeriodic[0] = gPeriodic[1] = gPeriodic[2] = 0;
+    pDims[0] = pDims[1] = pDims[2] = 0;
   }
 
     //! Partition method enumeration; these strategies are described in comments for
@@ -129,6 +129,8 @@ public:
     //! number of procs in each direction
   int pDims[3];
 
+    //! parallel communicator object for this par scd mesh
+  ParallelComm *pComm;
 };
   
 class ScdInterface 
@@ -168,11 +170,12 @@ public:
      * \param par_data If non-NULL, this will get stored on the ScdBox once created, contains info
      *                 about global parallel nature of ScdBox across procs
      * \param assign_global_ids If true, assigns 1-based global ids to vertices using GLOBAL_ID_TAG_NAME
+     * \param resolve_shared_ents If != -1, resolves shared entities up to and including dimension equal to value
      */
   ErrorCode construct_box(HomCoord low, HomCoord high, const double * const coords, unsigned int num_coords,
                           ScdBox *& new_box, int * const lperiodic = NULL, 
                           ScdParData * const par_data = NULL,
-                          bool assign_global_ids = false);
+                          bool assign_global_ids = false, int resolve_shared_ents = -1);
 
     //! Create a structured sequence of vertices, quads, or hexes
     /** Starting handle for the sequence is available from the returned ScdBox.  
@@ -1135,7 +1138,8 @@ inline ErrorCode ScdInterface::compute_partition_sqijk(int np, int nr,
       }
     }
   }
-  if (perfa_best == -1 || perfb_best == -1) return MB_FAILURE;
+  if (perfa_best == -1 || perfb_best == -1) 
+    return MB_FAILURE;
 
     // VARIABLES DESCRIBING THE MESH:
     // pijk[i] = # procs in direction i
@@ -1429,11 +1433,10 @@ inline const int *ScdBox::locally_periodic() const
  
 inline std::ostream &operator<<(std::ostream &str, const ScdParData &pd) 
 {
-  static const char *PartitionMethodNames[] = {"NOPART", "ALLJORKORI", "ALLJKBAL", "SQIJ", "SQJK", "SQIJK"};
-  str << "Partition method = " << PartitionMethodNames[pd.partMethod] << ", gDims = (" 
+  str << "Partition method = " << ScdParData::PartitionMethodNames[pd.partMethod] << ", gDims = (" 
       << pd.gDims[0] << "," << pd.gDims[1] << "," << pd.gDims[2] << ")-(" 
       << pd.gDims[3] << "," << pd.gDims[4] << "," << pd.gDims[5] << "), gPeriodic = (" 
-      << pd.gPeriodic[0] << ", " << pd.gPeriodic[1] << "," << pd.gPeriodic[2] << "), pDims = ("
+      << pd.gPeriodic[0] << "," << pd.gPeriodic[1] << "," << pd.gPeriodic[2] << "), pDims = ("
       << pd.pDims[0] << "," << pd.pDims[1] << "," << pd.pDims[2] << ")" << std::endl;
   return str;
 }

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index ab680aa..2d9e61c 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -2060,13 +2060,6 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
           // should have a new handle now
           assert(new_h);
         
-          // if a new multi-shared entity, save owner for subsequent lookup in L2 lists
-          if (store_remote_handles && !is_iface && num_ps > 2) {
-            L2hrem.push_back(hs[0]);
-            L2hloc.push_back(new_h);
-            L2p.push_back(ps[0]);
-          }
-
           created_here = true;
         }
 
@@ -2084,14 +2077,24 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
         if (created_here) new_ents.push_back(new_h);
 
         if (new_h && store_remote_handles) {
+          unsigned char new_pstat = 0x0;
+          if (is_iface) new_pstat = PSTATUS_INTERFACE;
+          else if (created_here) {
+            if (created_iface) new_pstat = PSTATUS_NOT_OWNED;
+            else new_pstat = PSTATUS_GHOST | PSTATUS_NOT_OWNED;
+          }
         
           // update sharing data and pstatus, adjusting order if iface
-          result = update_remote_data(new_h, &ps[0], &hs[0], num_ps, 
-                                      (is_iface ? PSTATUS_INTERFACE :
-                                       (created_here ? (created_iface ? PSTATUS_NOT_OWNED:
-                                                        PSTATUS_GHOST | PSTATUS_NOT_OWNED) : 0)));
-          RRA("");
+          result = update_remote_data(new_h, &ps[0], &hs[0], num_ps, new_pstat);
+          RRA("unpack_entities");
         
+          // if a new multi-shared entity, save owner for subsequent lookup in L2 lists
+          if (store_remote_handles && !is_iface && num_ps > 2) {
+            L2hrem.push_back(hs[0]);
+            L2hloc.push_back(new_h);
+            L2p.push_back(ps[0]);
+          }
+
           // need to send this new handle to all sharing procs
           if (!is_iface) {
             for (j = 0; j < num_ps; j++) {
@@ -2524,6 +2527,7 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
     }
 
       // add myself, if it isn't there already
+    idx = 0;
     if (new_ps[0] != (int)rank()) {
       idx = std::find(&new_ps[0], &new_ps[0] + new_numps, rank()) - &new_ps[0];
       if (idx == new_numps) {
@@ -2533,30 +2537,23 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
       }
       else if (!new_hs[idx] && new_numps > 2)
         new_hs[idx] = new_h;
-
-      assert(new_hs[idx] == new_h || new_numps <= 2);
-    }
-    
-      // adjust for interface layer if necessary
-    if (add_pstat & PSTATUS_INTERFACE) {
-      idx = std::min_element(&new_ps[0], &new_ps[0]+new_numps) - &new_ps[0];
-      if (idx) {
-        int tag_proc = new_ps[idx];
-        new_ps[idx] = new_ps[0];
-        new_ps[0] = tag_proc;
-        EntityHandle tag_h = new_hs[idx];
-        new_hs[idx] = new_hs[0];
-        new_hs[0] = tag_h;
-        if (new_ps[0] != (int)rank()) new_pstat |= PSTATUS_NOT_OWNED;
-      }
     }
 
-      // update for shared, multishared
+      // proc list is complete; update for shared, multishared
     if (new_numps > 1) {
       if (new_numps > 2) new_pstat |= PSTATUS_MULTISHARED;
       new_pstat |= PSTATUS_SHARED;
     }
-    
+
+      // if multishared, not ghost or interface, and not not_owned, I'm owned, and should be the first proc
+    assert(new_ps[idx] == (int)rank());
+    if ((new_numps > 2 && !(new_pstat&(PSTATUS_INTERFACE|PSTATUS_GHOST|PSTATUS_NOT_OWNED))) ||
+        (new_pstat&PSTATUS_INTERFACE && !(new_pstat&PSTATUS_NOT_OWNED))
+        ) {
+      std::swap(new_ps[0], new_ps[idx]);
+      std::swap(new_hs[0], new_hs[idx]);
+    }
+      
 /*    
     plist("new_ps", new_ps, new_numps);
     plist("new_hs", new_hs, new_numps);
@@ -2564,7 +2561,7 @@ ErrorCode ParallelComm::recv_entities(std::set<unsigned int>& recv_procs,
     std::cout << ", new_pstat=" << ostr.c_str() << std::endl;
     std::cout << std::endl;
 */
-  
+
     result = set_sharing_data(new_h, new_pstat, num_exist, new_numps, &new_ps[0], &new_hs[0]);
     RRA("update_remote_data: setting sharing data");
 
@@ -4073,7 +4070,7 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
       for (v = 0; v < procs.size(); v++) {
         rval = pc[procs[v]]->update_remote_data(handles[v], 
                                                 &procs[0], &handles[0], procs.size(),
-                                                PSTATUS_INTERFACE);
+                                                (procs[0] == (int)pc[procs[v]]->rank() ? PSTATUS_INTERFACE : (PSTATUS_NOT_OWNED|PSTATUS_INTERFACE)));
         if (MB_SUCCESS != rval) return rval;
       }
     }
@@ -5916,31 +5913,16 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
   {
     // set sharing data to what's passed in; may have to clean up existing sharing tags
     // if things changed too much
-  
-    ErrorCode result;
-    if (pstatus & PSTATUS_MULTISHARED && new_nump < 3) {
-      // need to remove multishared tags
-      result = mbImpl->tag_delete_data(sharedps_tag(), &ent, 1);
-      RRA("");
-      result = mbImpl->tag_delete_data(sharedhs_tag(), &ent, 1);
-      RRA("");
-      pstatus ^= PSTATUS_MULTISHARED;
-      if (new_nump < 2) 
-        pstatus = 0x0;
-      else if (ps[0] != (int)proc_config().proc_rank())
-        pstatus |= PSTATUS_NOT_OWNED;
-    }
-    else if (pstatus & PSTATUS_SHARED && new_nump < 2) {
-      hs[0] = 0;
-      ps[0] = -1;
-      pstatus = 0x0;
-    }
-
-    if (new_nump > 2) {
-      result = mbImpl->tag_set_data(sharedps_tag(), &ent, 1, ps);
-      RRA("");
-      result = mbImpl->tag_set_data(sharedhs_tag(), &ent, 1, hs);
-      RRA("");
+    
+    // check for consistency in input data
+    assert(new_nump > 1 &&
+           ((new_nump == 2 && pstatus&PSTATUS_SHARED && !(pstatus&PSTATUS_MULTISHARED)) || // if <= 2 must not be multishared
+            (new_nump > 2 && pstatus&PSTATUS_SHARED && pstatus&PSTATUS_MULTISHARED)) && // if > 2 procs, must be multishared
+           (!(pstatus&PSTATUS_GHOST) || pstatus&PSTATUS_SHARED) && // if ghost, it must also be shared
+           (new_nump < 3 || (pstatus&PSTATUS_NOT_OWNED && ps[0] != (int)rank()) || // I'm not owner and first proc not me
+            (!(pstatus&PSTATUS_NOT_OWNED) && ps[0] == (int)rank())) // I'm owner and first proc is me
+           );
+    
 #ifndef NDEBUG
       {
         // check for duplicates in proc list
@@ -5951,27 +5933,56 @@ ErrorCode ParallelComm::resolve_shared_ents(EntityHandle this_set,
         assert(dp == (int)dumprocs.size());
       }
 #endif
-      if (old_nump < 3) {
-          // reset sharedp and sharedh tags
-        int tmp_p = -1;
-        EntityHandle tmp_h = 0;
-        result = mbImpl->tag_set_data(sharedp_tag(), &ent, 1, &tmp_p);
-        RRA("");
-        result = mbImpl->tag_set_data(sharedh_tag(), &ent, 1, &tmp_h);
-        RRA("");
-      }
+
+    ErrorCode result;
+      // reset any old data that needs to be
+    if (old_nump > 2 && new_nump < 3) {
+      // need to remove multishared tags
+      result = mbImpl->tag_delete_data(sharedps_tag(), &ent, 1);
+      RRA("set_sharing_data:1");
+      result = mbImpl->tag_delete_data(sharedhs_tag(), &ent, 1);
+      RRA("set_sharing_data:2");
+//      if (new_nump < 2) 
+//        pstatus = 0x0;
+//      else if (ps[0] != (int)proc_config().proc_rank())
+//        pstatus |= PSTATUS_NOT_OWNED;
+    }
+    else if ((old_nump < 3 && new_nump > 2) || (old_nump > 1 && new_nump == 1)) {
+        // reset sharedp and sharedh tags
+      int tmp_p = -1;
+      EntityHandle tmp_h = 0;
+      result = mbImpl->tag_set_data(sharedp_tag(), &ent, 1, &tmp_p);
+      RRA("set_sharing_data:3");
+      result = mbImpl->tag_set_data(sharedh_tag(), &ent, 1, &tmp_h);
+      RRA("set_sharing_data:4");
+    }
+
+    assert("check for multishared/owner I'm first proc" &&
+           (!(pstatus & PSTATUS_MULTISHARED) || (pstatus & (PSTATUS_NOT_OWNED|PSTATUS_GHOST)) || (ps[0] == (int)rank())) &&
+           "interface entities should have > 1 proc" &&
+           (!(pstatus & PSTATUS_INTERFACE) || new_nump > 1) &&
+           "ghost entities should have > 1 proc" &&
+           (!(pstatus & PSTATUS_GHOST) || new_nump > 1)
+           );
+
+      // now set new data
+    if (new_nump > 2) {
+      result = mbImpl->tag_set_data(sharedps_tag(), &ent, 1, ps);
+      RRA("set_sharing_data:5");
+      result = mbImpl->tag_set_data(sharedhs_tag(), &ent, 1, hs);
+      RRA("set_sharing_data:6");
     }
     else {
       unsigned int j = (ps[0] == (int)procConfig.proc_rank() ? 1 : 0);
       assert(-1 != ps[j]);
       result = mbImpl->tag_set_data(sharedp_tag(), &ent, 1, ps+j);
-      RRA("");
+      RRA("set_sharing_data:7");
       result = mbImpl->tag_set_data(sharedh_tag(), &ent, 1, hs+j);
-      RRA("");
+      RRA("set_sharing_data:8");
     }
   
     result = mbImpl->tag_set_data(pstatus_tag(), &ent, 1, &pstatus);
-    RRA("");
+    RRA("set_sharing_data:9");
 
     if (old_nump > 1 && new_nump < 2) 
       sharedEnts.erase(std::find(sharedEnts.begin(), sharedEnts.end(), ent));
@@ -6835,6 +6846,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
                                               unsigned int /*to_proc*/,
                                               Buffer *buff) 
   {
+    assert(std::find(L1hloc.begin(), L1hloc.end(), (EntityHandle)0) == L1hloc.end());
+    
     // 2 vectors of handles plus ints
     buff->check_space(((L1p.size()+1)*sizeof(int) + 
                        (L1hloc.size()+1)*sizeof(EntityHandle) + 
@@ -6843,6 +6856,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     // should be in pairs of handles
     PACK_INT(buff->buff_ptr, L1hloc.size());
     PACK_INTS(buff->buff_ptr, &L1p[0], L1p.size());
+      // pack handles in reverse order, (remote, local), so on destination they
+      // are ordered (local, remote)
     PACK_EH(buff->buff_ptr, &L1hrem[0], L1hrem.size());
     PACK_EH(buff->buff_ptr, &L1hloc[0], L1hloc.size());
   
@@ -6865,19 +6880,22 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     buff_ptr += num_eh * sizeof(int);
     unsigned char *buff_rem = buff_ptr + num_eh * sizeof(EntityHandle);
     ErrorCode result;
-    EntityHandle hpair[2], dum_h;
+    EntityHandle hpair[2], new_h;
     int proc;
     for (int i = 0; i < num_eh; i++) {
       UNPACK_INT(buff_proc, proc);
+        // handles packed (local, remote), though here local is either on this
+        // proc or owner proc, depending on value of proc (-1 = here, otherwise owner);
+        // this is decoded in find_existing_entity
       UNPACK_EH(buff_ptr, hpair, 1);
       UNPACK_EH(buff_rem, hpair+1, 1);
 
       if (-1 != proc) {
         result = find_existing_entity(false, proc, hpair[0], 3, NULL, 0,
                                       mbImpl->type_from_handle(hpair[1]),
-                                      L2hloc, L2hrem, L2p, dum_h);
+                                      L2hloc, L2hrem, L2p, new_h);
         RRA("Didn't get existing entity.");
-        if (dum_h) hpair[0] = dum_h;
+        if (new_h) hpair[0] = new_h;
         else hpair[0] = 0;
       }
       if (!(hpair[0] && hpair[1])) return MB_FAILURE;
@@ -8644,6 +8662,11 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     myDebug->set_verbosity(verb);
   }
 
+  int ParallelComm::get_debug_verbosity() 
+  {
+    return myDebug->get_verbosity();
+  }
+
   ErrorCode ParallelComm::get_entityset_procs( EntityHandle set,
                                                std::vector<unsigned>& ranks ) const
   {
@@ -8983,4 +9006,11 @@ void ParallelComm::print_pstatus(unsigned char pstat, std::string &ostr)
   ostr = str.str();
 }
 
+void ParallelComm::print_pstatus(unsigned char pstat) 
+{
+  std::string str;
+  print_pstatus(pstat, str);
+  std::cout << str.c_str() << std::endl;
+}
+
 } // namespace moab

diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index f0f1a2b..e02d4b3 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -500,7 +500,8 @@ namespace moab {
 
     /** \brief Get the shared processors/handles for an entity
      * Get the shared processors/handles for an entity.  Arrays must
-     * be large enough to receive data for all sharing procs.
+     * be large enough to receive data for all sharing procs.  Does *not* include
+     * this proc if only shared with one other proc.
      * \param entity Entity being queried
      * \param ps Pointer to sharing proc data
      * \param hs Pointer to shared proc handle data
@@ -663,6 +664,9 @@ namespace moab {
     //! print contents of pstatus value in human-readable form
     void print_pstatus(unsigned char pstat, std::string &ostr);
 
+    //! print contents of pstatus value in human-readable form to std::cut
+    void print_pstatus(unsigned char pstat);
+    
     // ==================================
     // \section IMESHP-RELATED FUNCTIONS
     // ==================================
@@ -892,6 +896,9 @@ namespace moab {
     //! set the verbosity level of output from this pcomm
     void set_debug_verbosity(int verb);
 
+    //! get the verbosity level of output from this pcomm
+    int get_debug_verbosity();
+
     /* \brief Gather tag value from entities down to root proc
      * This function gathers data from a domain-decomposed mesh onto a global mesh
      * represented on the root processor.  On the root, this gather mesh is distinct from

diff --git a/test/io/read_cgm_test.cpp b/test/io/read_cgm_test.cpp
index c7fa27d..5377220 100644
--- a/test/io/read_cgm_test.cpp
+++ b/test/io/read_cgm_test.cpp
@@ -41,7 +41,7 @@ void read_multiple_test()
 
 }
   
-int main(int argc, char* argv[])
+int main(int /* argc */, char** /* argv */)
 {
   int result = RUN_TEST( read_multiple_test );
 

diff --git a/test/parallel/parallel_hdf5_test.cc b/test/parallel/parallel_hdf5_test.cc
index 355e99e..11224f2 100644
--- a/test/parallel/parallel_hdf5_test.cc
+++ b/test/parallel/parallel_hdf5_test.cc
@@ -724,21 +724,21 @@ void test_var_length_parallel()
     const void* ptrarr[1] = { 0 };
     rval = mb.tag_get_by_ptr( vartag, &h, 1, ptrarr, &size );
     CHECK_ERR( rval );
-    const int* data = reinterpret_cast<const int*>(ptrarr[0]);
+    const int* tag_data = reinterpret_cast<const int*>(ptrarr[0]);
     CHECK( size >= 2 );
-    CHECK( NULL != data );
-    CHECK_EQUAL( size-1, data[0] );
-    CHECK( data[1] >= 0 && data[1] < numproc );
-    ++vtx_counts[data[1]];
-    for (int j = 1; j < size-1; ++j)
-      CHECK_EQUAL( data[1]+j, data[1+j] );
+    CHECK( NULL != tag_data );
+    CHECK_EQUAL( size - 1, tag_data[0] );
+    CHECK( tag_data[1] >= 0 && tag_data[1] < numproc );
+    ++vtx_counts[tag_data[1]];
+    for (int j = 1; j < size - 1; ++j)
+      CHECK_EQUAL( tag_data[1] + j, tag_data[1 + j] );
   }
   
   // Check number of vertices for each rank
   for (int j = 0; j < numproc; ++j) {
     // Only root should have data for other processors.
     if (rank == 0 || rank == j) 
-      CHECK_EQUAL( j+1, vtx_counts[j] );
+      CHECK_EQUAL( j + 1, vtx_counts[j] );
     else 
       CHECK_EQUAL( 0, vtx_counts[j] );
   }
@@ -900,7 +900,7 @@ void create_input_file( const char* file_name,
   CHECK_ERR(rval);
 }
 
-void test_read_elements_common( bool by_rank, int intervals, bool print_time,
+void test_read_elements_common( bool by_rank, int intervals, bool /* print_time */,
                                 const char* extra_opts )
 {
   const char *file_name = by_rank ? "test_read_rank.h5m" : "test_read.h5m";
@@ -1204,7 +1204,7 @@ void test_read_sets_common( const char* extra_opts )
 
 void test_read_bc_sets()
 {
-  const char tag_name[] = "test_tag_s";
+  //const char tag_name[] = "test_tag_s";
   const char file_name[] = "test_read_sets.h5m";
   int numproc, rank;
   MPI_Comm_size( MPI_COMM_WORLD, &numproc );
@@ -1417,23 +1417,23 @@ void test_write_polygons()
   std::vector<EntityHandle> poly( numproc, 0 );
   CHECK_EQUAL( numproc, (int)range.size() );
   for (Range::iterator it = range.begin(); it != range.end(); ++it) {
-    const EntityHandle* conn;
+    const EntityHandle* conn_arr;
     int len;
-    rval = mb.get_connectivity( *it, conn, len );
+    rval = mb.get_connectivity( *it, conn_arr, len );
     CHECK_ERR(rval);
     double coords[3];
-    rval = mb.get_coords( conn, 1, coords );
+    rval = mb.get_coords( conn_arr, 1, coords );
     CHECK_ERR(rval);
-    int r = (int)(coords[2]);
-    CHECK_EQUAL( (EntityHandle)0, poly[r] );
-    poly[r] = *it;
+    int proc = (int)(coords[2]);
+    CHECK_EQUAL( (EntityHandle)0, poly[proc] );
+    poly[proc] = *it;
   }
   
     // check that each poly has the expected number of vertices
   for (int i = 0; i < numproc; ++i) {
-    const EntityHandle* conn;
+    const EntityHandle* conn_arr;
     int len;
-    rval = mb.get_connectivity( poly[i], conn, len );
+    rval = mb.get_connectivity( poly[i], conn_arr, len );
     CHECK_ERR(rval);
     CHECK_EQUAL( i % 4 + 5, len );
   }

diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 7d47a4c..864ebae 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1407,15 +1407,15 @@ ErrorCode test_shared_sets( const char* )
       continue;
     }
     
-    Range expected;
+    Range expected_range;
     for (size_t j = 0; j < 3; ++j)
       if (set_owners[j] == i)
-        expected.insert( set_arr[j] );
+        expected_range.insert( set_arr[j] );
     
-    if (expected != sets) {
+    if (expected_range != sets) {
       std::cerr << __FILE__ << ":" << __LINE__ << " rank " << rank 
                 << " has incorrect shared set list for sets owned by rank " 
-                << set_owners[i] << std::endl << "Expected: " << expected << std::endl
+                << set_owners[i] << std::endl << "Expected: " << expected_range << std::endl
                 << "Actual: " << sets << std::endl;
       ok = MB_FAILURE;
     }

diff --git a/test/parallel/parmerge.cpp b/test/parallel/parmerge.cpp
index f29445d..452acfc 100644
--- a/test/parallel/parmerge.cpp
+++ b/test/parallel/parmerge.cpp
@@ -144,7 +144,7 @@ int main(int argc, char * argv[])
 //This function doesn't normally get called, but is here for debugging
 //and verifying that merge is working.  
 void print_output(moab::ParallelComm *pc, moab::Core *mb,
-                  int myID, int numprocs, bool perform){
+                  int myID, int /* numprocs */, bool perform){
   moab::Range ents, skin;
   int o_ct=0, no_ct=0, tmp=0, o_tot=0, no_tot=0;
   if(perform){

diff --git a/test/parallel/structured3.cpp b/test/parallel/structured3.cpp
index 3ac5e9c..17ad177 100644
--- a/test/parallel/structured3.cpp
+++ b/test/parallel/structured3.cpp
@@ -1,242 +1,119 @@
+#include "moab/Core.hpp"
+#include "moab/ParallelComm.hpp"
+#include "moab/ScdInterface.hpp"
+#include "moab/HomXform.hpp"
+#include "moab/ProgOptions.hpp"
+#include "MBTagConventions.hpp"
+#include "TestUtil.hpp"
 #include <string>
 #include <iomanip>
 #include <iostream>
 #include <cassert>
-
-#include <moab/Core.hpp>
-#include <moab/Interface.hpp>
-#include <moab/ParallelComm.hpp>
-#include <moab/HomXform.hpp>
-#include <MBParallelConventions.h>
-#include <MBTagConventions.hpp>
-
-using namespace std;
+ 
 using namespace moab;
-
-// Number of cells in each direction:
-const int NC = 20;
+ 
+  // Number of cells in each direction:
+int NC;
 const int ITERS = 50;
-
-// Number of processes:
-const int NPROCS = 4;
-
-// Domain size:
-const double DSIZE = 10.0;
-
-// MOAB objects:
-Interface *mbint = NULL;
-ParallelComm *mbpc = NULL;
-
-// Local domain starting and ending hex indexes:
-int is, js, ks;
-int ie, je, ke;
-
-// Obvious:
-int rank;
-int size;
-
-Range all_verts;
-
-void set_local_domain_bounds();
-void create_hexes_and_verts();
-void resolve_and_exchange();
-void error(ErrorCode err);
-void tag_get_set(Tag tag);
-
+ 
+void create_parallel_mesh();
+ 
 int main(int argc, char *argv[]) 
 {
-  
-
   MPI_Init(&argc, &argv);
-  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-  MPI_Comm_size(MPI_COMM_WORLD, &size);
-  if(size != 4 && size != 2) {
-    cerr << "Run this with 2 or 4 processes\n";
-    exit(1);
-  }
-
-  mbint = new Core();
-  mbpc  = new ParallelComm(mbint, MPI_COMM_WORLD);
-
-  set_local_domain_bounds();
-  create_hexes_and_verts();
-  resolve_and_exchange();
-
-  error(mbint->get_entities_by_type(0, MBVERTEX, all_verts));
-
-
-// Create a tag
-  Tag tag;
-  error(mbint->tag_get_handle("test_tag", 1, MB_TYPE_DOUBLE, tag, MB_TAG_DENSE|MB_TAG_EXCL));
-
-  Range empty_range;
-  tag_get_set(tag);
-
-  int i;
-  for(i = 0; i < ITERS; i++) {
-    std::cout << i << endl;
-    mbpc->exchange_tags(tag, empty_range);
-  }
-
-  delete mbpc;
-  delete mbint;
 
+  ProgOptions po;
+  po.addOpt<int>( "int,i", "Number of intervals on a side" );
+  po.parseCommandLine( argc, argv );
+  if(!po.getOpt( "int", &NC )) NC = 4;
+  
+  int err = RUN_TEST(create_parallel_mesh);
+ 
   MPI_Finalize();
-  return 0;
+  return err;
 }
-
-void set_local_domain_bounds() 
+ 
+void create_parallel_mesh() 
 {
-  switch(rank) {
-    case 0:
-       
-        switch (size) {
-          case 2:
-              is = 0; ie = NC/2;
-              js = 0; je = NC;
-              ks = 0; ke = NC;
-              break;
-       
-          case 4:
-              is = 0; ie = NC/2;
-              js = 0; je = NC/2;
-              ks = 0; ke = NC;
-              break;
-        }
-        break;
-	
-    case 1:
-	
-        switch(size) {
-          case 2:
-              is = NC/2; ie = NC;
-              js = 0; je = NC;
-              ks = 0; ke = NC;
-              break;
-	
-          case 4:
-              is = NC/2; ie = NC;
-              js = 0; je = NC/2;
-              ks = 0; ke = NC;
-              break;
-        }
-        break;
-	
-    case 2:
-        is = 0; ie = NC/2;
-        js = NC/2; je = NC;
-        ks = 0; ke = NC;
-        break;
-	
-    case 3:
-        is = NC/2; ie = NC;
-        js = NC/2; je = NC;
-        ks = 0; ke = NC;
-        break;
-	
-    default:
-        cerr << "Run this with 4 processes\n";
-        exit(1);
+  Core mbint;
+  ParallelComm pc(&mbint, MPI_COMM_WORLD);
+  ScdInterface *scdi;
+  ErrorCode rval = mbint.query_interface(scdi);
+  CHECK_ERR(rval);
+    //pc.set_debug_verbosity(2);
+  
+    // create a structured mesh in parallel
+  ScdBox *new_box;
+  ScdParData par_data;
+  par_data.pComm = &pc;
+  par_data.gDims[0] = par_data.gDims[1] = par_data.gDims[2] = 0;
+  par_data.gDims[3] = par_data.gDims[4] = par_data.gDims[5] = NC;
+  if ((par_data.gDims[3]-par_data.gDims[0])*(par_data.gDims[3]-par_data.gDims[0])*(par_data.gDims[3]-par_data.gDims[0]) < (int)pc.size()) {
+    std::cerr << "Too few processors for this number of elements." << std::endl;
+    CHECK_ERR(MB_FAILURE);
   }
-}
-	
-	
-void create_hexes_and_verts()
-{
-  Core *mbcore = dynamic_cast<Core*>(mbint);
-  HomCoord coord_min(0,0,0);
-  HomCoord coord_max(NC/2, NC, NC);
-  EntitySequence* vertex_seq = NULL;
-  EntitySequence* cell_seq = NULL;
-  EntityHandle vs, cs;
-	
-  error(mbcore->create_scd_sequence(coord_min, coord_max, MBVERTEX, 1, vs, vertex_seq));
-  error(mbcore->create_scd_sequence(coord_min, coord_max, MBHEX, 1, cs, cell_seq));
-	
-  HomCoord p1(0,0,0);
-  HomCoord p2(NC/2,0,0);
-  HomCoord p3(0,NC/2,0);
-	
-  error(mbcore->add_vsequence(vertex_seq, cell_seq, p1, p1, p2, p2, p3, p3));
-	
-    // Set global id's:
-  int gid;
-  Tag global_id_tag;
-  error(mbint->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, global_id_tag));
-  EntityHandle handle = vs;
-  int i,j,k;
-	
-  ErrorCode err;
-	
-  for(i = is; i < ie + 1; i++) 
-    for(j = js; j < je + 1; j++)
-      for(k = ks; k < ke + 1; k++) {   
-        gid = k + j*(NC+1) + i*(NC+1)*(NC+1) + 1;
-        err = mbint->tag_set_data(global_id_tag, &handle, 1, &gid);
-        if(err != MB_SUCCESS) {
-          exit(1);
-        }
-        handle++;
-      }
-	
-  handle = cs;
-  for(i = is; i < ie; i++) 
-    for(j = js; j < je; j++)
-      for(k = ks; k < ke; k++) {       
-        gid = k + j*NC + i*NC*NC + 1;
-        error(mbint->tag_set_data(global_id_tag, &handle, 1, &gid));
-        handle++;
-      }
-}
-	
-	
-void resolve_and_exchange()
-{
-  EntityHandle entity_set;
-	
-    // Create the entity set:
-  error(mbint->create_meshset(MESHSET_SET, entity_set));
-	
-    // Get a list of hexes:
-  Range range;
-  error(mbint->get_entities_by_type(0, MBHEX, range));
-	
-    // Add entities to the entity set:
-  error(mbint->add_entities(entity_set, range));
-	
-    // Add the MATERIAL_SET tag to the entity set:
+    
+  par_data.partMethod = ScdParData::SQIJK;
+
+    // timing data
+  double times[5]; // tstart, tvert, tnonvert, tghost, titer;
+  times[0] = MPI_Wtime();
+  rval = scdi->construct_box(HomCoord(), HomCoord(), NULL, 0, // no vertex positions
+                             new_box, NULL, // not locally periodic
+                             &par_data, true, false); // assign global ids & resolve shared verts
+  CHECK_ERR(rval);
+
+    // get global id tag
   Tag tag;
-  error(mbint->tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, tag));
-  error(mbint->tag_set_data(tag, &entity_set, 1, &rank));
-	
-    // Set up partition sets. This is where MOAB is actually told what
-    // entities each process owns:
-  error(mbint->get_entities_by_type_and_tag(0, MBENTITYSET,
-                                            &tag, NULL, 1,
-                                            mbpc->partition_sets()));
-	
-    // Finally, determine which entites are shared and exchange the
-    // ghosted entities:
-  error(mbpc->resolve_shared_ents(0, -1, -1));
-  error(mbpc->exchange_ghost_cells(-1, 0, 1, 0, true));
-}
-	
-void error(ErrorCode err)
-{
-  if(err != MB_SUCCESS) {
-    cerr << "Error: MOAB function failed\n";
-    assert(0);
+  rval = mbint.tag_get_handle(GLOBAL_ID_TAG_NAME, tag);
+  CHECK_ERR(rval);
+  
+    // resolve shared verts
+  rval = pc.resolve_shared_ents(new_box->box_set(), -1, 0, &tag);
+  CHECK_ERR(rval);
+  times[1] = MPI_Wtime();
+  
+  rval = pc.exchange_ghost_cells(-1, -1, 0, 0, true, true);
+  CHECK_ERR(rval);
+  times[2] = MPI_Wtime();
+
+//  pc.list_entities(0,-1);
+  
+  rval = pc.exchange_ghost_cells(-1, 0, 1, 0, true);
+  if (MB_SUCCESS != rval) {
+    std::string err;
+    mbint.get_last_error(err);
+    std::cerr << "Error: proc " << pc.rank() << ": " << err << std::endl;
   }
-}
-	
-void tag_get_set(Tag tag)
-{
-  Range::iterator iter;
-  double data;
-	
-  for(iter = all_verts.begin(); iter != all_verts.end(); iter++) {
-    data = 1.0;
-    mbint->tag_set_data(tag, &(*iter), 1, &data);
-    mbint->tag_get_data(tag, &(*iter), 1, &data);
+  CHECK_ERR(rval);
+  times[3] = MPI_Wtime();
+
+//  pc.list_entities(0,-1);
+  
+    // Create a tag, used in exchange_tags
+  int def_val = 1.0;
+  rval = mbint.tag_get_handle("test_tag", 1, MB_TYPE_DOUBLE, tag, MB_TAG_DENSE|MB_TAG_EXCL, &def_val);
+  CHECK_ERR(rval);
+
+  Range empty_range;
+  if (!pc.rank()) std::cout << "Exchanging tags: ";
+  for(int i = 0; i < ITERS; i++) {
+    if (!pc.rank()) std::cout << i << ";";
+    pc.exchange_tags(tag, empty_range);
+    CHECK_ERR(rval);
   }
+  if (!pc.rank()) std::cout << std::endl;
+  times[4] = MPI_Wtime();
+
+  for (int i = 4; i >= 1; i--) times[i] -= times[i-1];
+
+  double tottimes[5];
+  MPI_Reduce(times+1, tottimes+1, 4, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
+  
+  if (!pc.rank()) 
+    std::cout << "Times:             " << std::endl
+              << "Create:            " << times[1] << std::endl
+              << "Resolve verts:     " << times[2] << std::endl
+              << "Resolve non-verts: " << times[3] << std::endl
+              << "Exchange ghosts:   " << times[4] << std::endl;
 }


https://bitbucket.org/fathomteam/moab/commits/eb2039342f9e/
Changeset:   eb2039342f9e
Branch:      None
User:        iulian07
Date:        2013-09-06 23:11:58
Summary:     delete again process_arm

Affected #:  1 file

diff --git a/tools/mbcslam/process_arm.cpp b/tools/mbcslam/process_arm.cpp
deleted file mode 100644
index 06472a9..0000000
--- a/tools/mbcslam/process_arm.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * process_arm.cpp
- *
- *  Created on: April 18, 2013
- */
-
-// process the files from Mark; also, link against netcdf directly, because we will use
-// netcdf calls to read data, the same as in ReadNC and ReadNCDF
-//
-//
-#include <iostream>
-#include <sstream>
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "moab/Core.hpp"
-#include "moab/Interface.hpp"
-#include "moab/ReadUtilIface.hpp"
-#include "moab/AdaptiveKDTree.hpp"
-
-#include "CslamUtils.hpp"
-
-#include "netcdf.h"
-
-#include <algorithm>
-#include <string>
-#include <assert.h>
-
-#include <cmath>
-
-
-using namespace moab;
-
-#define INS_ID(stringvar, prefix, id) \
-          sprintf(stringvar, prefix, id)
-
-#define GET_DIM(ncdim, name, val)\
-    {                            \
-    int gdfail = nc_inq_dimid(ncFile, name, &ncdim);          \
-    if (NC_NOERR == gdfail) {                                             \
-      size_t tmp_val;                                                   \
-      gdfail = nc_inq_dimlen(ncFile, ncdim, &tmp_val);                        \
-      if (NC_NOERR != gdfail) {                                           \
-        std::cout<<"couldn't get dimension length for" << name<< " \n"; \
-        return 1;                                              \
-      }                                                                 \
-      else val = tmp_val;                                               \
-    } else val = 0;}
-
-#define GET_DIMB(ncdim, name, varname, id, val) \
-          INS_ID(name, varname, id); \
-          GET_DIM(ncdim, name, val);
-
-#define GET_VAR(name, id, dims) \
-    {                           \
-    id = -1;\
-    int gvfail = nc_inq_varid(ncFile, name, &id);   \
-    if (NC_NOERR == gvfail) {       \
-    int ndims;\
-    gvfail = nc_inq_varndims(ncFile, id, &ndims);\
-    if (NC_NOERR == gvfail) {\
-    dims.resize(ndims);    \
-    gvfail = nc_inq_vardimid(ncFile, id, &dims[0]);}}}
-
-#define GET_1D_INT_VAR(name, id, vals) \
-    {GET_VAR(name, id, vals);  \
-  if (-1 != id) {\
-    size_t ntmp;\
-    int ivfail = nc_inq_dimlen(ncFile, vals[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    ivfail = nc_get_vara_int(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != ivfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable " <<name <<"\n";\
-      return 1;}}}
-
-
-#define GET_1D_DBL_VAR(name, id, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    dvfail = nc_get_vara_double(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-/*
-int get_2d_flt_var(int ncFile, const char * name, int index, std::vector<float> & vals)
-{
-  int id;
-  std::vector<int> dum_dims;
-  GET_VAR(name, id, dum_dims);
-  if (-1 != id) {
-    size_t ntmp;
-  int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);
-  vals.resize(ntmp);
-  size_t ntmp1[2] = {index, 0};
-
-  int ntimes;
-  dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntimes);
-  if (index>=ntimes) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  size_t count[2] ={1, ntmp};
-  dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);
-  if (NC_NOERR != dvfail) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  return 0;
-}
-*/
-/* get the variable along an index */
-#define GET_2D_FLT_VAR(name, id, index, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp, ntmp2;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);\
-    dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp2);\
-    vals.resize(ntmp);\
-    size_t ntmp1[2] = {index, 0}; \
-    if (index>=ntmp2) { \
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n"; \
-      return 1; \
-    } \
-    size_t count[2] ={1, ntmp}; \
-    dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-int main(int argc, char ** argv)
-{
-
-  int num_el = 50000;
-  if (argc>1)
-  {
-    num_el = atoi(argv[1]);
-  }
-  std::cout << "num_el=" << num_el << "\n";
-
-  Core moab;
-  Interface & mb = moab;
-  ErrorCode rval;
-
-  int ncFile, temp_dim;        // netcdf/exodus file
-
-  // now, open the data file and read the lat, lon and U850 and V850
-  const char *data_file = "fc5_arm12.cam2.h2.0004-12-12-00000.nc";
-
-  int fail = nc_open(data_file, 0, &ncFile);
-  if (NC_NOWRITE != fail) {
-    std::cout<<"ReadNCDF:: problem opening Netcdf/Exodus II "<<data_file <<"\n";
-    return 1;
-  }
-  int ncol;
-  GET_DIM(temp_dim, "ncol", ncol);
-  std::cout << "ncol:" << ncol << "\n";
-
-  std::vector<double> lat;
-  std::vector<double> lon;
-  GET_1D_DBL_VAR("lat", temp_dim, lat);
-
-  GET_1D_DBL_VAR("lon", temp_dim, lon);
-
-  std::cout<< " lat, lon 0" << lat[0] << " " << lon[0] << "\n";
-  std::cout<< " lat, lon 1" << lat[1] << " " << lon[1] << "\n";
-  std::cout << " size: " << lat.size() << "\n";
-
-  // see if the mesh from metadata makes sense
-  // create quads with the connectivity from conn array
-
-  ReadUtilIface* readMeshIface;
-  mb.query_interface( readMeshIface );
-  if (NULL==readMeshIface)
-    return 1;
-  EntityHandle node_handle = 0;
-  std::vector<double*> arrays;
-  rval = readMeshIface->get_node_coords(3, ncol,
-      1, node_handle, arrays);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  SphereCoords  sp;
-  sp.R = 1.;
-  Tag gid;
-  rval = mb.tag_get_handle("GLOBAL_ID", 1, MB_TYPE_INTEGER,
-      gid, MB_TAG_SPARSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-      return 1;
-  std::vector<int> gids(ncol);
-
-  double conversion_factor = M_PI/180.;
-  for (int k=0; k<ncol; k++)
-  {
-    sp.lat=lat[k]*conversion_factor;
-    sp.lon=lon[k]*conversion_factor;
-    CartVect pos=spherical_to_cart (sp);
-    arrays[0][k]=pos[0];
-    arrays[1][k]=pos[1];
-    arrays[2][k]=pos[2];
-    gids[k]=k+1;
-  }
-
-  Range nodes(node_handle, node_handle+ncol-1);
-  rval = mb.tag_set_data(gid, nodes, &gids[0]);
-  if (MB_SUCCESS!= rval)
-       return 1;
-
-  EntityHandle newSet;
-  rval = mb.create_meshset(MESHSET_SET, newSet);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  // so the nodes will be part
-  mb.add_entities(newSet, nodes);
-
-  // build a kd tree with the vertices
-  EntityHandle tree_root;
-  AdaptiveKDTree kd(&mb, true);
-  rval = kd.build_tree(nodes, tree_root);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  unsigned int  min_depth, max_depth;
-  rval = kd.depth(tree_root, min_depth, max_depth);
-  if (MB_SUCCESS != rval)
-     return 1;
-  std::cout << "min_depth, max_depth " << min_depth << " " << max_depth << "\n";
-  // now, read the conn file created using spectral visu, and see how they fit
-  // this can be directly imported to moab
-  const char *myconn_file = "spec.R2.vtk";
-  EntityHandle euler_set;
-  rval = mb.create_meshset(MESHSET_SET, euler_set);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  rval = mb.load_file(myconn_file, &euler_set);
-
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  mb.list_entities(&euler_set, 1);
-
-  Range specQuads;
-  rval = mb.get_entities_by_dimension(euler_set, 2, specQuads );
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  Range vertices;
-  rval = mb.get_connectivity(specQuads, vertices);
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  // do a mapping, from position of vertices to the vertices in the kd tree.
-  // find the closest vertex to each of this
-  std::vector<EntityHandle> mappedTo(vertices.size());
-  std::vector<double> mycoords(vertices.size()*3);
-  rval = mb.get_coords(vertices, &mycoords[0]);
-  double * ptr = &mycoords[0];
-  size_t num_verts=vertices.size();
-  for (size_t i=0; i<num_verts; i++, ptr+=3)
-  {
-    CartVect pos(ptr); // take 3 coordinates
-    std::vector<EntityHandle> leaves;
-    rval = kd.leaves_within_distance( tree_root,
-                                          ptr,
-                                          0.001,
-                                        leaves);
-    if (MB_SUCCESS != rval)
-      return 1;
-    Range closeVerts;
-    for (std::vector<EntityHandle>::iterator vit = leaves.begin(); vit != leaves.end(); vit++)
-    {
-      rval= mb.get_entities_by_handle(*vit, closeVerts, Interface::UNION);
-      if (moab::MB_SUCCESS != rval)
-        return 1;
-    }
-    if (closeVerts.size()<1)
-    {
-      std::cout << "increase tolerance, no points close to " << pos << "\n";
-      return 1;
-    }
-    std::vector<CartVect> coordsTarget(closeVerts.size());
-    rval = mb.get_coords(closeVerts, &(coordsTarget[0][0]));
-    if (MB_SUCCESS != rval)
-      return 1;
-    double minDist2=(pos-coordsTarget[0]).length_squared();
-    EntityHandle closestVertex=closeVerts[0];
-    for (unsigned int j=1; j<closeVerts.size(); j++)
-    {
-      double dist2=(pos-coordsTarget[j]).length_squared();
-      if (minDist2>dist2)
-      {
-        closestVertex = closeVerts[j];
-        minDist2=dist2;
-      }
-    }
-    if (minDist2 > 0.00001)
-    {
-      std::cout << " problem with node " << vertices[i] << "  min dist2:" << minDist2 << "\n";
-      return 1;
-    }
-    mappedTo [i] = closestVertex;
-  }
-
-  num_el = (int)specQuads.size();
-  // tmp_ptr is of type int* and points at the same place as conn
-  EntityHandle * conn = 0;
-
-  EntityHandle elh;
-
-  readMeshIface->get_element_connect(
-          num_el,
-          4,
-          MBQUAD,
-          1,
-          elh,
-          conn);
-
-  EntityHandle firstVertMyMesh=vertices[0];
-  for (int k=0; k<num_el; k++)
-  {
-    const EntityHandle * myconn=0;
-    EntityHandle specElem = specQuads[k];
-    int num_nodes=0;
-    rval = mb.get_connectivity(specElem, myconn, num_nodes);
-    if (MB_SUCCESS != rval || num_nodes !=4)
-      return 1;
-
-    int start_el = k*4;
-    for (int j=0; j<4; j++)
-       conn[start_el+j] = mappedTo[myconn[j]-firstVertMyMesh];
-  }
-  std::cout << " conn:" << conn[0] << " " << conn[1] << " " << conn[3]<< "\n";
-  Range erange(elh, elh+num_el-1);
-
-  mb.add_entities(newSet, erange);
-  std::vector<int> gidels(num_el);
-  Tag gid2;
-  rval = mb.tag_get_handle("GLOBAL_ID_EL", 1, MB_TYPE_INTEGER,
-        gid2, MB_TAG_SPARSE|MB_TAG_CREAT);
-
-  if (MB_SUCCESS != rval)
-      return 1;
-  for (int k=0; k<num_el; k++)
-    gidels[k]=k+1;
-  mb.tag_set_data(gid2, erange, &gidels[0]);
-
-  // For now, comment out times to remove compile warning (variable ‘times’ set but not used)
-  //int times;
-  //GET_DIM(temp_dim, "time", times);
-
-  Tag velotag;
-  rval = mb.tag_get_handle("VELO", 3, MB_TYPE_DOUBLE,
-            velotag, MB_TAG_DENSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  for (size_t tt=0; tt<56 /*(size_t)times*/; tt++)
-  {
-    // now, read velocities from file:
-    // read the U850 and V850 variables
-    std::vector<float> u850;
-    GET_2D_FLT_VAR("U850", temp_dim, tt, u850);
-    std::vector<float> v850;
-    GET_2D_FLT_VAR("V850", temp_dim, tt, v850);
-
-    std::cout << " U850:" << u850[0] << " " << u850[1] << " " << u850[5] << " "<< u850.size()<<"\n";
-    std::cout << " V850:" << v850[0] << " " << v850[1] << " " << v850[5] << " "<< u850.size()<<"\n";
-    // ok, use radius as 6371km; not needed
-
-    std::vector<CartVect> velo850(ncol);
-
-    std::stringstream fileName;
-    fileName << "VELO0" <<  tt << ".h5m";
-    std::cout << " read velocities at 850 for time:" << tt << "\n";
-
-
-    for (int k=0; k<ncol; k++)
-    {
-      double latRad=lat[k]*conversion_factor;
-      double lonRad=lon[k]*conversion_factor;
-      CartVect U(-sin(lonRad), cos(lonRad), 0.);
-      CartVect V(-sin(latRad)*cos(lonRad), -sin(latRad)*cos(lonRad), cos(latRad));
-      velo850[k]=U*u850[k] +V*v850[k];
-    }
-    rval = mb.tag_set_data(velotag, nodes, &(velo850[0][0]));
-    if (MB_SUCCESS!= rval)
-      return 1;
-    rval = mb.write_mesh(fileName.str().c_str(), &newSet, 1);
-    if (MB_SUCCESS!= rval)
-      return 1;
-  }
-
-
-
-  return 0;
-}


https://bitbucket.org/fathomteam/moab/commits/95566b9a0ad7/
Changeset:   95566b9a0ad7
Branch:      None
User:        iulian07
Date:        2013-09-06 23:32:36
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  4 files

diff --git a/src/moab/point_locater/element_maps/linear_hex_map.hpp b/src/moab/point_locater/element_maps/linear_hex_map.hpp
index 829addb..4b9cb77 100644
--- a/src/moab/point_locater/element_maps/linear_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/linear_hex_map.hpp
@@ -36,24 +36,17 @@ class Linear_hex_map {
     //Constructor
     Linear_hex_map() {}
     //Copy constructor
-    Linear_hex_map( const Self & f ) {
-      // Remove the warning about unused parameter
-      if (NULL != &f) {}
-    }
+    Linear_hex_map( const Self & /* f */ ) {}
 
  public:
     //Natural coordinates
     template< typename Moab, typename Entity_handle, 
 	      typename Points, typename Point>
-    std::pair< bool, Point> operator()( const Moab & moab,
-					const Entity_handle & h, 
+    std::pair< bool, Point> operator()( const Moab & /* moab */,
+					const Entity_handle & /* h */,
 					const Points & v, 
 					const Point & p, 
 					const double tol = 1.e-6) const {
-      // Remove the warnings about unused parameters
-      if (NULL != &moab) {}
-      if (NULL != &h) {}
-
       Point result(3, 0.0);
       solve_inverse( p, result, v);
       bool point_found = solve_inverse( p, result, v, tol) &&

diff --git a/src/moab/point_locater/element_maps/quadratic_hex_map.hpp b/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
index 92ea3ed..905b65c 100644
--- a/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/quadratic_hex_map.hpp
@@ -53,15 +53,11 @@ class Quadratic_hex_map {
     //Natural coordinates
     template< typename Moab, typename Entity_handle, 
 	      typename Points, typename Point>
-    std::pair< bool, Point> operator()( const Moab & moab,
-					const Entity_handle & h, 
+    std::pair< bool, Point> operator()( const Moab & /* moab */,
+					const Entity_handle & /* h */,
 					const Points & v, 
 					const Point & p, 
 					const double tol = 1.e-6) const {
-      // Remove the warnings about unused parameters
-      if (NULL != &moab) {}
-      if (NULL != &h) {}
-
       Point result(3, 0.0);
       bool point_found = solve_inverse( p, result, v, tol) &&
                 is_contained( result, tol);
@@ -200,10 +196,7 @@ class Quadratic_hex_map {
     }
 
     template< typename Point, typename Points>
-    Matrix& jacobian( const Point & p, const Points & points, Matrix & J) const {
-    // Remove the warning about unused parameter
-    if (NULL != &points) {}
-
+    Matrix& jacobian( const Point & p, const Points & /* points */, Matrix & J) const {
     J = Matrix(0.0);
     for (int i = 0; i < 27; i++) {
       const double sh[3] = { SH(reference_points(i,0), p[0]),

diff --git a/src/moab/point_locater/element_maps/spectral_hex_map.hpp b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
index c255545..11bd573 100644
--- a/src/moab/point_locater/element_maps/spectral_hex_map.hpp
+++ b/src/moab/point_locater/element_maps/spectral_hex_map.hpp
@@ -61,15 +61,11 @@ class Spectral_hex_map {
     //Natural coordinates
     template< typename Moab, typename Entity_handle, 
 	      typename Points, typename Point>
-    std::pair< bool, Point> operator()( const Moab & moab,
-					const Entity_handle & h, 
+    std::pair< bool, Point> operator()( const Moab & /* moab */,
+					const Entity_handle & /* h */,
 					const Points & v, 
 					const Point & p, 
-					const double tol=1.e-6) {
-        // Remove the warnings about unused parameters
-        if (NULL != &moab) {}
-        if (NULL != &h) {}
-
+					const double tol = 1.e-6) {
         Point result(3, 0.0);
         /*
         moab.tag_get_by_ptr(_xm1Tag, &eh, 1,(const void **) &_xyz[ 0] );
@@ -146,10 +142,7 @@ class Spectral_hex_map {
     }
 
     template< typename Point, typename Points>
-    Point& evaluate( const Point & p, const Points & points, Point & f) {
-      // Remove the warning about unused parameter
-      if (NULL != &points) {}
-
+    Point& evaluate( const Point & p, const Points & /* points */, Point & f) {
       for (int d = 0; d < 3; ++d) { lagrange_0(&_ld[ d], p[ 0]); }
       for (int d = 0; d < 3; ++d) {
         f[ d] = tensor_i3( _ld[ 0].J, _ld[ 0].n,
@@ -210,11 +203,7 @@ class Spectral_hex_map {
  }
 
   template< typename Point, typename Points>
-  Matrix& jacobian( const Point & p, const Points & points, Matrix & J) {
-    // Remove the warnings about unused parameters
-    if (NULL != &p) {}
-    if (NULL != &points) {}
-
+  Matrix& jacobian( const Point & /* p */, const Points & /* points */, Matrix & J) {
    	real x[ 3];
     for (int i = 0; i < 3; ++i) { _data.elx[ i] = _xyz[ i]; }
     opt_vol_set_intp_3(& _data, x);

diff --git a/tools/mbzoltan/MBZoltan.cpp b/tools/mbzoltan/MBZoltan.cpp
index 299e3c4..f1b712c 100644
--- a/tools/mbzoltan/MBZoltan.cpp
+++ b/tools/mbzoltan/MBZoltan.cpp
@@ -621,8 +621,8 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
 }
 
 #ifdef CGM
-ErrorCode MBZoltan::assemble_graph(const int dimension,
-                                   std::vector<double> &coords,
+ErrorCode MBZoltan::assemble_graph(const int /* dimension */,
+                                   std::vector<double> & /* coords */,
                                    std::vector<int> &moab_ids,
                                    std::vector<int> &adjacencies, 
                                    std::vector<int> &length,
@@ -633,10 +633,6 @@ ErrorCode MBZoltan::assemble_graph(const int dimension,
                                    const double part_geom_mesh_size,
                                    const int n_part) 
 {
-  // To remove the warnings about unused variables
-  if (dimension > 0) {}
-  if (coords.size() > 0) {}
-
   // get body vertex weights
   DLIList<RefEntity*> body_list;
   gti->ref_entity_list("body", body_list, CUBIT_FALSE);
@@ -1696,26 +1692,16 @@ void MBZoltan::mbShowError(int val, const char *s)
 ** call backs
 **********************/
 
-int mbGetNumberOfAssignedObjects(void *userDefinedData, int *err)
+int mbGetNumberOfAssignedObjects(void * /* userDefinedData */, int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-
   *err = 0;
   return NumPoints;
 }
 
-void mbGetObjectList(void *userDefinedData, int numGlobalIds, int numLids,
+void mbGetObjectList(void * /* userDefinedData */, int /* numGlobalIds */, int /* numLids */,
   ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int wgt_dim, float *obj_wgts,
   int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-  if (numGlobalIds > 0){}
-  if (numLids > 0) {}
-  if (gids) {}
-  if (lids) {}
-
   for (int i = 0; i < NumPoints; i++) {
     gids[i] = GlobalIds[i];
     lids[i] = i;
@@ -1726,25 +1712,15 @@ void mbGetObjectList(void *userDefinedData, int numGlobalIds, int numLids,
   *err = 0;
 }
 
-int mbGetObjectSize(void *userDefinedData, int *err)
+int mbGetObjectSize(void * /* userDefinedData */, int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-
   *err = 0; 
   return 3;
 }
 
-void mbGetObject(void *userDefinedData, int numGlobalIds, int numLids, int numObjs,
-  ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int numDim, double *pts, int *err)
+void mbGetObject(void * /* userDefinedData */, int /* numGlobalIds */, int /* numLids */, int numObjs,
+  ZOLTAN_ID_PTR /* gids */, ZOLTAN_ID_PTR lids, int numDim, double *pts, int *err)
 { 
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-  if (numGlobalIds > 0) {}
-  if (numLids > 0) {}
-  if (gids) {}
-  if (lids) {}
-
   int i, id, id3;
   int next = 0;
 
@@ -1769,18 +1745,11 @@ void mbGetObject(void *userDefinedData, int numGlobalIds, int numLids, int numOb
   }
 } 
 
-void mbGetNumberOfEdges(void *userDefinedData, int numGlobalIds, int numLids,
+void mbGetNumberOfEdges(void * /* userDefinedData */, int /* numGlobalIds */, int /* numLids */,
 			int numObjs, 
-			ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,	int *numEdges,
+			ZOLTAN_ID_PTR /* gids */, ZOLTAN_ID_PTR lids,	int *numEdges,
 			int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-  if (numGlobalIds > 0) {}
-  if (numLids > 0) {}
-  if (gids) {}
-  if (lids) {}
-
   int i, id;
   int next = 0;
 
@@ -1796,20 +1765,12 @@ void mbGetNumberOfEdges(void *userDefinedData, int numGlobalIds, int numLids,
   }
 }
 
-void mbGetEdgeList(void *userDefinedData, int numGlobalIds, int numLids,
+void mbGetEdgeList(void * /* userDefinedData */, int /* numGlobalIds */, int /* numLids */,
 		   int numObjs,
-		   ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int *numEdges,
+		   ZOLTAN_ID_PTR /* gids */, ZOLTAN_ID_PTR lids, int * /* numEdges */,
 		   ZOLTAN_ID_PTR nborGlobalIds, int *nborProcs, int wgt_dim,
 		   float *edge_wgts, int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-  if (numGlobalIds > 0) {}
-  if (numLids > 0) {}
-  if (gids) {}
-  if (lids) {}
-  if (numEdges) {}
-
   int i, id, idSum, j;
   int next = 0;
 
@@ -1836,17 +1797,10 @@ void mbGetEdgeList(void *userDefinedData, int numGlobalIds, int numLids,
   }
 }
 
-void mbGetPart(void *userDefinedData, int numGlobalIds, int numLids,
-               int numObjs, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
+void mbGetPart(void * /* userDefinedData */, int /* numGlobalIds */, int /* numLids */,
+               int numObjs, ZOLTAN_ID_PTR /* gids */, ZOLTAN_ID_PTR lids,
                int *part, int *err)
 {
-  // To remove the warnings about unused variables
-  if (userDefinedData) {}
-  if (numGlobalIds > 0) {}
-  if (numLids > 0) {}
-  if (gids) {}
-  if (lids) {}
-
   int i, id;
   int next = 0;
 


https://bitbucket.org/fathomteam/moab/commits/53ccd1d3fb0c/
Changeset:   53ccd1d3fb0c
Branch:      None
User:        iulian07
Date:        2013-09-08 02:05:08
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Conflicts:
	tools/mbcslam/Makefile.am

Affected #:  3 files

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index d344037..a61c8d2 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -113,8 +113,8 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
   if (lperiodic) std::copy(lperiodic, lperiodic+3, tmp_lper);
   
 #ifndef USE_MPI
-  if (-1 == tag_shared_ents) ERRORR(MB_FAILURE, "Parallel capability requested but MOAB not compiled parallel.");
-  if (-1 == tag_shared_verts && !assign_gids) assign_gids = true; // need to assign gids in order to tag shared verts
+  if (-1 != tag_shared_ents) ERRORR(MB_FAILURE, "Parallel capability requested but MOAB not compiled parallel.");
+  if (-1 == tag_shared_ents && !assign_gids) assign_gids = true; // need to assign gids in order to tag shared verts
 #else
   if (par_data && low == high && ScdParData::NOPART != par_data->partMethod) {
       // requesting creation of parallel mesh, so need to compute partition

diff --git a/test/parallel/Makefile.am b/test/parallel/Makefile.am
index e1098c5..130bfe8 100644
--- a/test/parallel/Makefile.am
+++ b/test/parallel/Makefile.am
@@ -76,6 +76,7 @@ check_PROGRAMS = $(TESTS) mbparallelcomm_test partcheck structured3 parmerge
 pcomm_unit_SOURCES = pcomm_unit.cpp
 parallel_hdf5_test_SOURCES = parallel_hdf5_test.cc
 mhdf_parallel_SOURCES = mhdf_parallel.c
+mhdf_parallel_LDADD = $(LDADD) $(HDF5_LIBS)
 parallel_unit_tests_SOURCES = parallel_unit_tests.cpp
 parallel_write_test_SOURCES = parallel_write_test.cc
 uber_parallel_test_SOURCES = uber_parallel_test.cpp
@@ -92,7 +93,8 @@ mpastrvpart_SOURCES = mpastrvpart.cpp
 
 if ENABLE_mbcoupler
   par_coupler_test_SOURCES = par_coupler_test.cpp
-  par_coupler_test_LDADD = $(LDADD) ../../tools/mbcoupler/libmbcoupler.la
+  par_coupler_test_LDADD = $(LDADD) $(top_builddir)/tools/mbcoupler/libmbcoupler.la \
+          $(top_builddir)/itaps/imesh/libiMesh.la
 endif
 
 if ENABLE_mbcslam

diff --git a/tools/mbcslam/Makefile.am b/tools/mbcslam/Makefile.am
index bf5ae85..ebf5040 100644
--- a/tools/mbcslam/Makefile.am
+++ b/tools/mbcslam/Makefile.am
@@ -21,7 +21,7 @@ lib_LTLIBRARIES = libmbcslam.la
 libmbcslam_la_LIBADD = $(top_builddir)/src/libMOAB.la $(top_builddir)/itaps/imesh/libiMesh.la \
          $(top_builddir)/tools/mbcoupler/libmbcoupler.la
          
-LDADD = libmbcslam.la $(top_builddir)/tools/mbcoupler/libmbcoupler.la
+LDADD = $(top_builddir)/src/libMOAB.la libmbcslam.la $(top_builddir)/tools/mbcoupler/libmbcoupler.la
 
 libmbcslam_la_SOURCES = \
    Intx2Mesh.cpp Intx2Mesh.hpp Intx2MeshOnSphere.cpp Intx2MeshOnSphere.hpp \
@@ -41,6 +41,10 @@ cfgdir = $(libdir)
 TESTS = intx_on_sphere_test  intx_in_plane_test  spec_visu_test spherical_area_test \
          case1_test  intx_mpas
 noinst_PROGRAMS =  cslam_par_test diffusion 
+if NETCDF_FILE
+  noinst_PROGRAMS += process_arm
+  process_arm_LDADD = $(LDADD) $(NETCDF_LIBS)
+endif
 
 check_PROGRAMS = $(TESTS) 
 intx_on_sphere_test_SOURCES = intx_on_sphere_test.cpp
@@ -51,7 +55,7 @@ spherical_area_test_SOURCES = spherical_area_test.cpp
 case1_test_SOURCES = case1_test.cpp
 intx_mpas_SOURCES = intx_mpas.cpp
 cslam_par_test_SOURCES = cslam_par_test.cpp
-cslam_par_test_LDADD = $(LDADD) $(top_builddir)/tools/mbcoupler/libmbcoupler.la 
+
 EXTRA_DIST  = lagrangeHomme.vtk  \
               eulerHomme.vtk \
               m1.vtk \


https://bitbucket.org/fathomteam/moab/commits/64cca916f266/
Changeset:   64cca916f266
Branch:      None
User:        iulian07
Date:        2013-09-13 16:29:03
Summary:     add a projection utility
also, add a time step as an input parameter for the diffusion utility

Affected #:  3 files

diff --git a/tools/mbcslam/Makefile.am b/tools/mbcslam/Makefile.am
index ebf5040..440384c 100644
--- a/tools/mbcslam/Makefile.am
+++ b/tools/mbcslam/Makefile.am
@@ -40,11 +40,7 @@ cfgdir = $(libdir)
 
 TESTS = intx_on_sphere_test  intx_in_plane_test  spec_visu_test spherical_area_test \
          case1_test  intx_mpas
-noinst_PROGRAMS =  cslam_par_test diffusion 
-if NETCDF_FILE
-  noinst_PROGRAMS += process_arm
-  process_arm_LDADD = $(LDADD) $(NETCDF_LIBS)
-endif
+noinst_PROGRAMS =  cslam_par_test diffusion proj1
 
 check_PROGRAMS = $(TESTS) 
 intx_on_sphere_test_SOURCES = intx_on_sphere_test.cpp
@@ -55,6 +51,7 @@ spherical_area_test_SOURCES = spherical_area_test.cpp
 case1_test_SOURCES = case1_test.cpp
 intx_mpas_SOURCES = intx_mpas.cpp
 cslam_par_test_SOURCES = cslam_par_test.cpp
+proj1_SOURCES = proj1.cpp
 
 EXTRA_DIST  = lagrangeHomme.vtk  \
               eulerHomme.vtk \

diff --git a/tools/mbcslam/diffusion.cpp b/tools/mbcslam/diffusion.cpp
index 70d1b6f..3980c2f 100644
--- a/tools/mbcslam/diffusion.cpp
+++ b/tools/mbcslam/diffusion.cpp
@@ -385,11 +385,15 @@ int main(int argc, char **argv)
       {
         field_type = atoi(argv[++index]);
       }
+      if (!strcmp(argv[index], "-ns"))
+      {
+        numSteps = atoi(argv[++index]);
+      }
 
       if (!strcmp(argv[index], "-h"))
       {
         std::cout << "usage: -gtol <tol> -input <file> -O <extra_read_opts> \n   "
-        <<    "-f <field_type> -h (this help)\n";
+        <<    "-f <field_type> -h (this help) -ns <numSteps> \n";
         std::cout << " filed type: 1: quasi-smooth; 2: smooth; 3: slotted cylinders (non-smooth)\n";
         return 0;
       }
@@ -418,7 +422,8 @@ int main(int argc, char **argv)
 
   if (0==rank)
     std::cout << " case 1: use -gtol " << gtol <<
-        " -R " << radius << " -input " << filename_mesh1 <<  " -f " << field_type << "\n";
+        " -R " << radius << " -input " << filename_mesh1 <<  " -f " << field_type <<
+        " numSteps: " << numSteps << "\n";
 
   Tag tagTracer = 0;
   std::string tag_name("Tracer");

diff --git a/tools/mbcslam/proj1.cpp b/tools/mbcslam/proj1.cpp
new file mode 100644
index 0000000..e78ef79
--- /dev/null
+++ b/tools/mbcslam/proj1.cpp
@@ -0,0 +1,83 @@
+/*
+ * proj1.cpp
+ *
+ *  project on a sphere of radius R
+ */
+
+#include "moab/Core.hpp"
+#include "moab/Interface.hpp"
+#include <iostream>
+#include <math.h>
+
+#include "CslamUtils.hpp"
+#include <assert.h>
+using namespace moab;
+
+double radius = 1.;// in m:  6371220.
+
+int main(int argc, char **argv)
+{
+
+  std::string extra_read_opts;
+  // read a file and project on a sphere
+
+  if (argc < 3)
+    return 1;
+
+  int index = 1;
+  char * input_mesh1 = argv[1];
+  char * output = argv[2];
+  while (index < argc)
+  {
+    if (!strcmp(argv[index], "-R")) // this is for geometry tolerance
+    {
+      radius = atof(argv[++index]);
+    }
+
+    index++;
+  }
+
+  Core moab;
+  Interface & mb = moab;
+
+  ErrorCode rval;
+
+  rval = mb.load_mesh(input_mesh1);
+
+  std::cout  << " -R " << radius << " input: " << input_mesh1 <<
+      "  output: " << output << "\n";
+
+  Range verts;
+  rval = mb.get_entities_by_dimension(0, 0, verts);
+  if (MB_SUCCESS != rval)
+    return 1;
+
+  double *x_ptr, *y_ptr, *z_ptr;
+  int count;
+  rval = mb.coords_iterate(verts.begin(), verts.end(), x_ptr, y_ptr, z_ptr, count);
+  if (MB_SUCCESS != rval)
+      return 1;
+  assert(count == (int) verts.size()); // should end up with just one contiguous chunk of vertices
+
+  for (int v = 0; v < count; v++) {
+     //EntityHandle v = verts[v];
+     CartVect pos( x_ptr[v], y_ptr[v] , z_ptr[v]);
+     pos = pos/pos.length();
+     pos = radius*pos;
+     x_ptr[v] = pos[0];
+     y_ptr[v] = pos[1];
+     z_ptr[v] = pos[2];
+  }
+
+  Range edges;
+  rval = mb.get_entities_by_dimension(0, 1, edges);
+  if (MB_SUCCESS != rval)
+    return 1;
+  mb.delete_entities(edges);
+  mb.write_file(output);
+
+  // remove all edges
+
+
+  return 0;
+}


https://bitbucket.org/fathomteam/moab/commits/e55713bbc0f7/
Changeset:   e55713bbc0f7
Branch:      None
User:        iulian07
Date:        2013-09-13 16:31:22
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  87 files

diff --git a/.gitignore b/.gitignore
index 967aaa7..d3721c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,99 +1,132 @@
-MOABConfig.cmake
-moab.files
-config/test-driver
-moab.config
-moab.includes
-moab.creator*
-*.ccm
-*.cub
+*~
+*.a
 aclocal.m4
 autom4te.cache/
-config.h
-config.h.in
-config.log
-config.lt
-config.status
+bin
+bin/*
+*.ccm
 config/config.guess
 config/config.sub
 config/depcomp
+config.h
+config.h.in
 config/install-sh
 config/libtool.m4
+config.log
+config.lt
 config/ltmain.sh
+config/lt~obsolete.m4
 config/ltoptions.m4
 config/ltsugar.m4
 config/ltversion.m4
-config/lt~obsolete.m4
 config/missing
+config.status
+config/test-driver
 configure
+.cproject
+*.cub
+.deps
 doc/config.tex
 doc/dev.dox
-doc/user.dox
 doc/user/*
+doc/user.dox
 examples/examples.make
+examples/FileRead
+examples/GeomSetHierarchy
+examples/GetEntities
+examples/*.h5m
+examples/HelloMoabPar
+examples/itaps/FindConnectF
+examples/itaps/ListSetsNTagsCXX
+examples/itaps/ListSetsNTagsF90
+examples/itaps/TagIterateC
+examples/itaps/TagIterateF
+examples/KDTree
+examples/ObbTree
+examples/ReduceExchangeTags
+examples/SetsNTags
+examples/SkinMesh
+examples/SurfArea
+examples/TestExodusII
+include
+include/*
 itaps/iBase_f.h
 itaps/igeom/FBiGeom-Defs.inc
+itaps/igeom/FBiGeom_protos.h
+itaps/igeom/testgeom
+itaps/igeom/testSmooth2
+itaps/igeom/testSmoothGeom
+itaps/imesh/FindAdjacencyF90
 itaps/imesh/iMesh-Defs.inc
+itaps/imesh/iMesh_extensions_protos.h
 itaps/imesh/iMeshP_extensions_protos.h
 itaps/imesh/iMeshP_protos.h
-itaps/imesh/iMesh_extensions_protos.h
 itaps/imesh/iMesh_protos.h
+itaps/imesh/MOAB_iMesh_extensions_tests
+itaps/imesh/MOAB_iMeshP_unit_tests
+itaps/imesh/MOAB_iMesh_unit_tests
+itaps/imesh/partest
+itaps/imesh/ScdMeshF77
+itaps/imesh/ScdMeshF90
+itaps/imesh/testc_cbind
+*.la
+*.la
+*.lai
+lib
+lib/*
+.libs
 libtool
+*.lo
+*.log
+makefile
+Makefile
+*/Makefile
+*/**/Makefile
+*/**/Makefile.in
+*/Makefile.in
+Makefile.in
+moab.config
+MOABConfig.cmake
+moab.creator*
+moab.files
+moab.includes
 moab.make
+*.o
+.project
+*.rej
+share/*
+share/doc/moab
+share/man/man1
+*.so
 src/FCDefs.h
+src/io/mhdf/h5minfo
+src/io/mhdf/h5mvalidate
 src/MBCN_protos.h
-src/MOAB_FCDefs.h
 src/moab/EntityHandle.hpp
-src/moab/Version.h
+src/MOAB_FCDefs.h
 src/moab/stamp-h2
 src/moab/stamp-h3
+src/moab/Version.h
 src/parallel/moab_mpi_config.h
 src/parallel/stamp-h4
 src/stamp-h5
 stamp-h1
-tools/mbcoupler/tests/
-tools/mbzoltan/Config.moab
-tools/vtkMOABReader/CMakeLists.txt
-tools/vtkMOABReaderNew/CMakeLists.txt
-.deps
-Makefile.in
-Makefile
-*/Makefile.in
-*/Makefile
-*/**/Makefile.in
-*/**/Makefile
-.libs
-*.o
-*.log
-*.lo
-*.la
-*.a
-*.so
-include/*
-lib/*
-share/*
-bin/*
-*~
-examples/HelloMoabPar
-examples/TestExodusII
-itaps/igeom/FBiGeom_protos.h
-itaps/igeom/testSmooth2
-itaps/igeom/testSmoothGeom
-itaps/igeom/testgeom
-itaps/imesh/FindAdjacencyF90
-itaps/imesh/MOAB_iMeshP_unit_tests
-itaps/imesh/ScdMeshF77
-itaps/imesh/ScdMeshF90
-itaps/imesh/partest
 test/adaptive_kd_tree_tests
 test/bsp_tree_poly_test
 test/bsp_tree_test
-test/*.gen
+test/CMakeLists.txt
 test/coords_connect_iterate
 test/cropvol_test
 test/dual/dual_test
+test/elem_eval_test
 test/file_options_test
+test/*.g
+test/*.g
+test/*.gen
+test/*.gen
 test/geom_util_test
 test/gttool_test
+test/gttool_test
 test/h5file/dump_sets
 test/h5file/h5legacy
 test/h5file/h5partial
@@ -102,13 +135,14 @@ test/h5file/h5regression
 test/h5file/h5sets_test
 test/h5file/h5test
 test/h5file/h5varlen
-test/*.g
 test/homxform_test
+test/io/*.ccmg
+test/io/ccmio_test
 test/io/cub_file_test
 test/io/exodus_test
+test/io/*.g
 test/io/gmsh_test
 test/io/ideas_test
-test/io/*.g
 test/io/nastran_test
 test/io/read_cgm_test
 test/io/read_nc
@@ -133,7 +167,6 @@ test/obb_test
 test/oldinc/test_oldinc
 test/read_mpas_nc
 test/parallel/*.h5m
-test/parallel/*.vtk
 test/parallel/mbparallelcomm_test
 test/parallel/mhdf_parallel
 test/parallel/mpastrvpart
@@ -142,6 +175,8 @@ test/parallel/par_intx_sph
 test/parallel/parallel_hdf5_test
 test/parallel/parallel_unit_tests
 test/parallel/parallel_write_test
+test/parallel/par_coupler_test
+test/parallel/par_intx_sph
 test/parallel/parmerge
 test/parallel/partcheck
 test/parallel/pcomm_serial
@@ -152,39 +187,68 @@ test/parallel/scdtest
 test/parallel/structured3
 test/parallel/uber_parallel_test
 test/parallel/ucdtrvpart
+test/parallel/*.vtk
 test/perf/adj_time
 test/perf/perf
 test/perf/perftool
+test/perf/point_in_elem
+test/perf/runtest
 test/perf/seqperf
 test/perf/tstt_perf_binding
+test/perf/point_location/elem_eval_time
+test/perf/point_location/point_location
 test/range_test
 test/reorder_test
 test/scdseq_test
 test/scd_test_partn
 test/seq_man_test
+test/spatial_locator_test
+test/test_boundbox
 test/tag_test
 test/test_adj
 test/test_prog_opt
+test/TestRunner.hpp
 test/var_len_test
 test/var_len_test_no_template
 test/xform_test
+tools/dagmc/dagmc_preproc
 tools/dagmc/pt_vol_test
+tools/dagmc/quads_to_tris
 tools/dagmc/ray_fire_test
 tools/dagmc/test_geom
 tools/dagmc/update_coords
+tools/hexmodops
+tools/mbconvert
 tools/mbcoupler/*.h5m
+tools/mbcoupler/*.g
+tools/mbcoupler/tests/
 tools/mbcslam/case1_test
 tools/mbcslam/intersect1.h5m
-tools/mbcslam/intx.vtk
 tools/mbcslam/intx1.vtk
 tools/mbcslam/intx_in_plane_test
 tools/mbcslam/intx_on_sphere_test
+tools/mbcslam/intx.vtk
 tools/mbcslam/lagr.h5m
-tools/mbcslam/spec_visu_test
 tools/mbcslam/spectral.vtk
+tools/mbcslam/spec_visu_test
 tools/mbcslam/spherical_area_test
-.project
-.cproject
-examples/*.h5m
-examples/ReduceExchangeTags
-
+tools/mbdepth
+tools/mbgsets
+tools/mbmem
+tools/mbsize
+tools/mbskin
+tools/mbsurfplot
+tools/mbtagprop
+tools/mbzoltan/Config.moab
+tools/spheredecomp
+tools/vtkMOABReader/CMakeLists.txt
+tools/vtkMOABReaderNew/CMakeLists.txt
+tools/vtkMOABReaderNew/CMakeCache.txt
+tools/vtkMOABReaderNew/CMakeFiles/*
+tools/vtkMOABReaderNew/cmake_install.cmake
+tools/vtkMOABReaderNew/vtkMoabReaderPlugin.qrc
+tools/vtkMOABReaderNew/vtkMoabReaderPluginInit.cxx
+tools/vtkMOABReaderNew/vtkMoabReaderPlugin_Plugin.cxx
+tools/vtkMOABReaderNew/vtkMoabReaderPlugin_Plugin.h
+tools/vtkMOABReaderNew/vtkSMvtkMoabReaderPluginInstantiator.cxx
+tools/vtkMOABReaderNew/vtkSMvtkMoabReaderPluginInstantiator.h

diff --git a/README b/README
index 6bcf434..563265c 100644
--- a/README
+++ b/README
@@ -82,4 +82,3 @@ Implementation:
 2.00 (11/1/06): LOTS of bug fixes & improvements
 1.00 (2/1/04): Initial release
 
-

diff --git a/doc/MOAB-UG.doc b/doc/MOAB-UG.doc
index 5cf591c..b7668b8 100644
Binary files a/doc/MOAB-UG.doc and b/doc/MOAB-UG.doc differ

diff --git a/doc/UG/moabUG.h b/doc/UG/moabUG.h
index a6a6f4a..8f4a6be 100644
--- a/doc/UG/moabUG.h
+++ b/doc/UG/moabUG.h
@@ -895,7 +895,7 @@ Note that using the iMesh interface from Fortran-based applications requires a c
 
   \section representation 8.Structured Mesh Representation
 
-A structured mesh is defined as a D-dimensional mesh whose interior vertices have 2D connected edges.   Structured mesh can be stored without connectivity, if certain information is kept about the parametric space of each structured block of mesh.  MOAB can represent structured mesh with implicit connectivity, saving approximately 57% of the storage cost compared to an unstructured representation<sup>7</sup>.  Since connectivity must be computed on the fly, these queries execute a bit slower than those for unstructured mesh.  More information on the theory behind MOAB's structured mesh representation can be found in 
+A structured mesh is defined as a D-dimensional mesh whose interior vertices have 2D connected edges.   Structured mesh can be stored without connectivity, if certain information is kept about the parametric space of each structured block of mesh.  MOAB can represent structured mesh with implicit connectivity, saving approximately 57% of the storage cost compared to an unstructured representation<sup>7</sup>.  Since connectivity must be computed on the fly, these queries execute a bit slower than those for unstructured mesh.  More information on the theory behind MOAB's structured mesh representation can be found in “MOAB-SD: Integrated structured and unstructured mesh representation”[17].
 
 Currently, MOAB's structured mesh representation can only be used by creating structured mesh at runtime; that is, structured mesh is saved/restored in an unstructured format in MOAB's HDF5-based native save format.  For more details on how to use MOAB's structured mesh representation, see the scdseq_test.cpp source file in the test/ directory.
 

diff --git a/itaps/igeom/FBiGeom_MOAB.cpp b/itaps/igeom/FBiGeom_MOAB.cpp
index cb889bd..7fcd2b1 100644
--- a/itaps/igeom/FBiGeom_MOAB.cpp
+++ b/itaps/igeom/FBiGeom_MOAB.cpp
@@ -4,7 +4,7 @@
 #include "moab/GeomTopoTool.hpp"
 #include "moab/OrientedBoxTreeTool.hpp"
 #include "moab/CartVect.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "MBTagConventions.hpp"
 #include <stdlib.h>
 #include <cstring>

diff --git a/itaps/imesh/iMeshP_MOAB.cpp b/itaps/imesh/iMeshP_MOAB.cpp
index e554fba..51254ca 100644
--- a/itaps/imesh/iMeshP_MOAB.cpp
+++ b/itaps/imesh/iMeshP_MOAB.cpp
@@ -4,7 +4,7 @@
 #include "moab/Range.hpp"
 #include "moab/CN.hpp"
 #include "moab/MeshTopoUtil.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/ParallelComm.hpp"
 #include "MBParallelConventions.h"
 #include "MBIter.hpp"

diff --git a/itaps/imesh/iMesh_MOAB.cpp b/itaps/imesh/iMesh_MOAB.cpp
index d09fec1..68c0b72 100644
--- a/itaps/imesh/iMesh_MOAB.cpp
+++ b/itaps/imesh/iMesh_MOAB.cpp
@@ -4,7 +4,7 @@
 #include "moab/CN.hpp"
 #include "moab/MeshTopoUtil.hpp"
 #include "moab/ScdInterface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "iMesh_MOAB.hpp"
 #include "MBIter.hpp"
 #include "MBTagConventions.hpp"
@@ -3303,7 +3303,7 @@ void iMesh_createStructuredMesh(iMesh_Instance instance,
   ScdBox *scd_box;
   rval = scdi->construct_box(HomCoord(local_dims[0], local_dims[1], (-1 != local_dims[2] ? local_dims[2] : 0), 1),
                              HomCoord(local_dims[3], local_dims[4], (-1 != local_dims[5] ? local_dims[5] : 0), 1),
-                             NULL, 0, scd_box);
+                             NULL, 0, scd_box, NULL, NULL, (vert_gids ? true : false));
   CHKERR(rval, "Trouble creating scd vertex sequence.");
 
     // set the global box parameters

diff --git a/src/BoundBox.cpp b/src/BoundBox.cpp
new file mode 100644
index 0000000..cb34330
--- /dev/null
+++ b/src/BoundBox.cpp
@@ -0,0 +1,78 @@
+#include "moab/Interface.hpp"
+#include "moab/BoundBox.hpp"
+
+namespace moab 
+{
+    ErrorCode BoundBox::update(Interface &iface, const Range& elems)
+    {
+      ErrorCode rval;
+      bMin = CartVect(HUGE_VAL);
+      bMax = CartVect(-HUGE_VAL);
+      
+      CartVect coords;
+      EntityHandle const *conn, *conn2;
+      int len, len2;
+      Range::const_iterator i;
+  
+        // vertices
+      const Range::const_iterator elem_begin = elems.lower_bound( MBEDGE );
+      for (i = elems.begin(); i != elem_begin; ++i) {
+        rval = iface.get_coords( &*i, 1, coords.array() );
+        if (MB_SUCCESS != rval)
+          return rval;
+        update_min(coords.array());
+        update_max(coords.array());
+      }
+
+        // elements with vertex-handle connectivity list
+      const Range::const_iterator poly_begin = elems.lower_bound( MBPOLYHEDRON, elem_begin );
+      std::vector<EntityHandle> dum_vector;
+      for (i = elem_begin; i != poly_begin; ++i) {
+        rval = iface.get_connectivity( *i, conn, len, true, &dum_vector);
+        if (MB_SUCCESS != rval)
+          return rval;
+
+        for (int j = 0; j < len; ++j) {
+          rval = iface.get_coords( conn+j, 1, coords.array() );
+          if (MB_SUCCESS != rval)
+            return rval;
+          update_min(coords.array());
+          update_max(coords.array());
+        }
+      }
+  
+        // polyhedra
+      const Range::const_iterator set_begin  = elems.lower_bound( MBENTITYSET, poly_begin );
+      for (i = poly_begin; i != set_begin; ++i) {
+        rval = iface.get_connectivity( *i, conn, len, true );
+        if (MB_SUCCESS != rval)
+          return rval;
+
+        for (int j = 0; j < len; ++j) {
+          rval = iface.get_connectivity( conn[j], conn2, len2 );
+          for (int k = 0; k < len2; ++k) {
+            rval = iface.get_coords( conn2+k, 1, coords.array() );
+            if (MB_SUCCESS != rval)
+              return rval;
+            update_min(coords.array());
+            update_max(coords.array());
+          }
+        }
+      }
+  
+        // sets
+      BoundBox box;
+      for (i = set_begin; i != elems.end(); ++i) {
+        Range tmp_elems;
+        rval = iface.get_entities_by_handle(*i, tmp_elems);
+        if (MB_SUCCESS != rval) return rval;
+        rval = box.update(iface, tmp_elems);
+        if (MB_SUCCESS != rval) return rval;
+
+        update(box);
+      }
+  
+      return MB_SUCCESS;
+    }
+
+}

diff --git a/src/Core.cpp b/src/Core.cpp
index 57ff342..476fdca 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -83,7 +83,7 @@
 #include "MBTagConventions.hpp"
 #include "ExoIIUtil.hpp"
 #include "EntitySequence.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #ifdef LINUX
 # include <dlfcn.h>
 # include <dirent.h>
@@ -1153,11 +1153,11 @@ ErrorCode Core::get_connectivity_by_type(const EntityType type,
 ErrorCode  Core::get_connectivity(const EntityHandle *entity_handles,
                                       const int num_handles,
                                       Range &connectivity,
-                                      bool topological_connectivity) const
+                                      bool corners_only) const
 {
   std::vector<EntityHandle> tmp_connect;
   ErrorCode result = get_connectivity(entity_handles, num_handles, tmp_connect,
-                                        topological_connectivity);
+                                        corners_only);
   if (MB_SUCCESS != result) return result;
 
   std::sort( tmp_connect.begin(), tmp_connect.end() );
@@ -1169,7 +1169,7 @@ ErrorCode  Core::get_connectivity(const EntityHandle *entity_handles,
 ErrorCode  Core::get_connectivity(const EntityHandle *entity_handles,
                                   const int num_handles,
                                   std::vector<EntityHandle> &connectivity,
-                                  bool topological_connectivity,
+                                  bool corners_only,
                                   std::vector<int> *offsets) const
 {
   connectivity.clear(); // this seems wrong as compared to other API functions,
@@ -1182,7 +1182,7 @@ ErrorCode  Core::get_connectivity(const EntityHandle *entity_handles,
   int len;
   if (offsets) offsets->push_back(0);
   for (int i = 0; i < num_handles; ++i) {
-    rval = get_connectivity( entity_handles[i], conn, len, topological_connectivity, &tmp_storage );
+    rval = get_connectivity( entity_handles[i], conn, len, corners_only, &tmp_storage );
     if (MB_SUCCESS != rval)
       return rval;
     connectivity.insert( connectivity.end(), conn, conn + len );
@@ -1195,7 +1195,7 @@ ErrorCode  Core::get_connectivity(const EntityHandle *entity_handles,
 ErrorCode Core::get_connectivity(const EntityHandle entity_handle,
                                      const EntityHandle*& connectivity,
                                      int& number_nodes,
-                                     bool topological_connectivity,
+                                     bool corners_only,
                                      std::vector<EntityHandle>* storage) const
 {
   ErrorCode status;
@@ -1222,7 +1222,7 @@ ErrorCode Core::get_connectivity(const EntityHandle entity_handle,
   return static_cast<const ElementSequence*>(seq)->get_connectivity(entity_handle,
                                                               connectivity,
                                                               number_nodes,
-                                                              topological_connectivity,
+                                                              corners_only,
                                                               storage);
 }
 
@@ -2896,9 +2896,11 @@ ErrorCode Core::list_entity(const EntityHandle entity) const
   if (multiple != 0)
     std::cout << "   (MULTIPLE = " << multiple << ")" << std::endl;
 
+  result = print_entity_tags(std::string(), entity, MB_TAG_DENSE);  
+
   std::cout << std::endl;
 
-  return MB_SUCCESS;
+  return result;
 }
 
 ErrorCode Core::convert_entities( const EntityHandle meshset,
@@ -3598,16 +3600,21 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
   }
 
     // print all sparse tags
+  print_entity_tags(indent_prefix, ms_handle, MB_TAG_SPARSE);
+}
+
+ErrorCode Core::print_entity_tags(std::string indent_prefix, const EntityHandle handle, TagType tp) const 
+{
   std::vector<Tag> set_tags;
-  ErrorCode result = this->tag_get_tags_on_entity(ms_handle, set_tags);
-  std::cout << indent_prefix << "Sparse tags:" << std::endl;
+  ErrorCode result = this->tag_get_tags_on_entity(handle, set_tags);
+  std::cout << indent_prefix << (tp == MB_TAG_SPARSE ? "Sparse tags:" : "Dense tags:") << std::endl;
   indent_prefix += "  ";
 
   for (std::vector<Tag>::iterator vit = set_tags.begin();
        vit != set_tags.end(); vit++) {
     TagType this_type;
     result = this->tag_get_type(*vit, this_type);
-    if (MB_SUCCESS != result || MB_TAG_SPARSE != this_type) continue;
+    if (MB_SUCCESS != result || tp != this_type) continue;
     DataType this_data_type;
     result = this->tag_get_data_type(*vit, this_data_type);
     int this_size;
@@ -3622,7 +3629,7 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
     if (MB_SUCCESS != result) continue;
     switch (this_data_type) {
       case MB_TYPE_INTEGER:
-        result = this->tag_get_data(*vit, &ms_handle, 1, &int_vals[0]);
+        result = this->tag_get_data(*vit, &handle, 1, &int_vals[0]);
         if (MB_SUCCESS != result) continue;
         std::cout << indent_prefix << tag_name << " = ";
         if (this_size < 10)
@@ -3631,7 +3638,7 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
         std::cout << std::endl;
         break;
       case MB_TYPE_DOUBLE:
-        result = this->tag_get_data(*vit, &ms_handle, 1, &dbl_vals[0]);
+        result = this->tag_get_data(*vit, &handle, 1, &dbl_vals[0]);
         if (MB_SUCCESS != result) continue;
         std::cout << indent_prefix << tag_name << " = ";
         if (this_size < 10)
@@ -3640,7 +3647,7 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
         std::cout << std::endl;
         break;
       case MB_TYPE_HANDLE:
-        result = this->tag_get_data(*vit, &ms_handle, 1, &hdl_vals[0]);
+        result = this->tag_get_data(*vit, &handle, 1, &hdl_vals[0]);
         if (MB_SUCCESS != result) continue;
         std::cout << indent_prefix << tag_name << " = ";
         if (this_size < 10)
@@ -3651,7 +3658,7 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
       case MB_TYPE_OPAQUE:
         if (NAME_TAG_SIZE == this_size) {
           char dum_tag[NAME_TAG_SIZE];
-          result = this->tag_get_data(*vit, &ms_handle, 1, &dum_tag);
+          result = this->tag_get_data(*vit, &handle, 1, &dum_tag);
           if (MB_SUCCESS != result) continue;
             // insert NULL just in case there isn't one
           dum_tag[NAME_TAG_SIZE-1] = '\0';
@@ -3662,6 +3669,8 @@ void Core::print(const EntityHandle ms_handle, const char *prefix,
         break;
     }
   }
+
+  return MB_SUCCESS;
 }
 
 ErrorCode Core::check_adjacencies()

diff --git a/src/FileOptions.cpp b/src/FileOptions.cpp
index f2a4477..380a491 100644
--- a/src/FileOptions.cpp
+++ b/src/FileOptions.cpp
@@ -18,7 +18,7 @@
  *\date 2007-08-21
  */
 
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include <ctype.h>
 #include <stdlib.h>

diff --git a/src/FileOptions.hpp b/src/FileOptions.hpp
deleted file mode 100644
index 85b3eef..0000000
--- a/src/FileOptions.hpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * MOAB, a Mesh-Oriented datABase, is a software component for creating,
- * storing and accessing finite element mesh data.
- * 
- * Copyright 2004 Sandia Corporation.  Under the terms of Contract
- * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
- * retains certain rights in this software.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- */
-
-/**\file FileOptions.hpp
- *\author Jason Kraftcheck (kraftche at cae.wisc.edu)
- *\date 2007-08-21
- */
-
-#ifndef FILE_OPTIONS_HPP
-#define FILE_OPTIONS_HPP
-
-#include <string>
-#include <vector>
-#include "moab/Types.hpp"
-
-namespace moab {
-
-/**\brief Parse options string passed to file IO routines
- *
- * This is a utility class used by file-IO-related code to 
- * parse the options string passed to Core::load_file and
- * Core::write_file
- */
-class FileOptions {
-public:
-
-  /*\param options_string The concatenation of a list of 
-   *          options, separated either by the default separator
-   *          (semicolon) with a custom separator specified at
-   *          the beginning of the string (semicolon followed by
-   *          destired separator character.)
-   */
-  FileOptions( const char* option_string );
-  
-  FileOptions( const FileOptions& copy );
-  FileOptions& operator=( const FileOptions& copy );
-  
-  ~FileOptions();
-  
-  /**\brief Check for option with no value 
-   *
-   * Check for an option w/out a value.
-   *\param name The option name
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but has value
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_null_option( const char* name ) const;
-  
-  
-  /**\brief Check for option with boolean (true/false, yes/no) value.
-   *
-   * Check for an option with a true/false value.  Allowable values
-   * are "true", "false", "yes", "no", "1", "0", "on", "off".
-   *\param name The option name
-   *\param default_value The value to return if the option is not specified.
-   *\param value The resulting value.  This argument is set to the passed
-   *            default value if the option is not found.
-   *\return - MB_TYPE_OUT_OF_RANGE if options is found, but has an invalid value
-   *        - MB_SUCCESS otherwise
-   */
-  ErrorCode get_toggle_option( const char* name, 
-                               bool default_value,
-                               bool& value ) const;
-   
-  /**\brief Check for option with an integer value.
-   *
-   * Check for an option with an integer value
-   *\param name The option name
-   *\param value Output. The value.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not have an integer value
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_int_option( const char* name, int& value ) const;
-  
-  /**\brief Check for option with an integer value.  Accept option with no value.
-   *
-   * Check for an option with an integer value.
-   * If the option is found but has no value specified, then
-   * pass back the user-specified default value.
-   *
-   *\NOTE:  This function will not pass back the default_val, but will instead
-   *        return MB_ENTITY_NOT_FOUND if the option is not specified at all.
-   *        The default value is returned only when the option is specified,
-   *        but is specified w/out a value.
-   *
-   *\param name The option name
-   *\param default_val The default value for the option.
-   *\param value Output. The value.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found but has a value that cannot be parsed as an int
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_int_option( const char* name, int default_val, int& value ) const;
-  
-  /**\brief Check for option with a double value.
-   *
-   * Check for an option with a double value
-   *\param name The option name
-   *\param value Output. The value.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not have a double value
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_real_option( const char* name, double& value ) const;
-  
-  /**\brief Check for option with any value.
-   *
-   * Check for an option with any value.
-   *\param name The option name
-   *\param value Output. The value.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not have a value
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_str_option( const char* name, std::string& value ) const;
-  
-  /**\brief Check for option 
-   *
-   * Check for an option
-   *\param name The option name
-   *\param value The option value, or an empty string if no value.
-   *\return MB_SUCCESS or MB_ENTITY_NOT_FOUND
-   */
-  ErrorCode get_option( const char* name, std::string& value ) const;
-  
-  /**\brief Check the string value of an option
-   *
-   * Check which of a list of possible values a string option contains.
-   *\param name The option name
-   *\param values A NULL-terminated array of C-style strings enumerating
-   *              the possible option values.
-   *\param index  Output: The index into <code>values</code> for the
-   *              option value.
-   *\return MB_SUCCESS if matched name and value.
-   *        MB_ENTITY_NOT_FOUND if the option was not specified
-   *        MB_FAILURE if the option value is not in the input <code>values</code> array.
-   */
-  ErrorCode match_option( const char* name, const char* const* values, int& index ) const;
-  
-  /**\brief Check if an option matches a string value
-   *
-   * Check if the value for an option is the passed string.
-   *\param name The option name
-   *\param value The expected value.
-   *\return MB_SUCCESS if matched name and value.
-   *        MB_ENTITY_NOT_FOUND if the option was not specified
-   *        MB_FAILURE if the option value doesn't match the passed string/
-   */
-  ErrorCode match_option( const char* name, const char* value) const;
-  
-  /**\brief Check for option for which the value is a list of ints
-   *
-   * Check for an option which is an int list.  The value is expected to
-   * be a comma-separated list of int ranges, where an int range can be 
-   * either a single integer value or a range of integer values separated
-   * by a dash ('-').
-   *
-   *\param name The option name
-   *\param values Output. The list of integer values.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not contain an ID list
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_ints_option( const char* name, std::vector<int>& values) const;
-  
-  /**\brief Check for option for which the value is a list of doubles
-   *
-   * Check for an option which is a double list.  The value is expected to
-   * be a comma-separated list of double values
-   *
-   *\param name The option name
-   *\param values Output. The list of double values.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not contain an ID list
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_reals_option( const char* name, std::vector<double>& values) const;
-  
-  /**\brief Check for option for which the value is a list of strings
-   *
-   * Check for an option which is a string list.  The value is expected to
-   * be a comma-separated list of string values, with no embedded spaces or commas.
-   *
-   *\param name The option name
-   *\param values Output. The list of string values.
-   *\return - MB_SUCCESS if option is found
-   *        - MB_TYPE_OUT_OF_RANGE if options is found, but does not contain a string list
-   *        - MB_ENTITY_NOT_FOUND if option is not found.
-   */
-  ErrorCode get_strs_option( const char* name, std::vector<std::string>& values) const;
-  
-  /** number of options */
-  inline unsigned size() const 
-    { return mOptions.size(); }
-  
-  /** true if no options */
-  inline bool empty() const 
-    { return mOptions.empty(); }
-  
-  /** Get list of options */
-  void get_options( std::vector<std::string>& list ) const;
-  
-  /** Check if all options have been looked at */
-  bool all_seen() const;
-  
-  /** Mark all options as seen.  USed for non-root procs during bcast-delete read */
-  void mark_all_seen() const;
-  
-  /** Get first unseen option */
-  ErrorCode get_unseen_option( std::string& value ) const;
-  
-private:
-  
-  /**\brief Check for option 
-   *
-   * Check for an option
-   *\param name The option name
-   *\param value The option value, or an empty string if no value.
-   *\return MB_SUCCESS or MB_ENTITY_NOT_FOUND
-   */
-  ErrorCode get_option( const char* name, const char*& value) const;
-
-  char* mData;
-  std::vector<const char*> mOptions;
-  mutable std::vector<bool> mSeen;
-
-    /** Case-insensitive compare of name with option value. */
-  static bool compare( const char* name, const char* option );
-};
-  
-} // namespace moab
-
-#endif
-

diff --git a/src/Makefile.am b/src/Makefile.am
index 7cebb7c..de77a06 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,6 +41,7 @@ libMOAB_la_SOURCES = \
   BitPage.hpp \
   BitTag.cpp \
   BitTag.hpp \
+  BoundBox.cpp \
   BSPTree.cpp \
   BSPTreePoly.cpp \
   CN.cpp \
@@ -57,7 +58,6 @@ libMOAB_la_SOURCES = \
   Factory.cpp \
   FBEngine.cpp \
   FileOptions.cpp \
-  FileOptions.hpp \
   GeomUtil.cpp \
   GeomTopoTool.cpp \
   HigherOrderFactory.cpp \
@@ -75,16 +75,10 @@ libMOAB_la_SOURCES = \
   OrientedBox.cpp \
   OrientedBox.hpp \
   OrientedBoxTreeTool.cpp \
-  moab/point_locater/lotte/minmax.h \
-  moab/point_locater/lotte/extrafindpt.h \
   lotte/poly.c \
-  moab/point_locater/lotte/poly.h \
   lotte/findpt.c \
-  moab/point_locater/lotte/findpt.h \
   lotte/errmem.c \
-  moab/point_locater/lotte/errmem.h \
   lotte/tensor.c \
-  moab/point_locater/lotte/tensor.h \
   PolyElementSeq.cpp \
   PolyElementSeq.hpp \
   ProgOptions.cpp \
@@ -146,12 +140,14 @@ libMOAB_la_SOURCES = \
 # The list of header files which are to be installed
 nobase_libMOAB_la_include_HEADERS = \
   moab/AdaptiveKDTree.hpp \
+  moab/BoundBox.hpp \
   moab/BSPTree.hpp \
   moab/BSPTreePoly.hpp \
   moab/CN.hpp \
   moab/CartVect.hpp \
   moab/Compiler.hpp \
   moab/Core.hpp \
+  moab/CpuTimer.hpp \
   moab/DualTool.hpp \
   moab/Error.hpp \
   moab/GeomTopoTool.hpp \
@@ -160,6 +156,8 @@ nobase_libMOAB_la_include_HEADERS = \
   moab/EntityType.hpp \
   moab/EntityHandle.hpp \
   moab/FBEngine.hpp \
+  moab/FileOptions.hpp \
+  moab/FindPtFuncs.h \
   moab/Forward.hpp \
   moab/GeomUtil.hpp \
   moab/Interface.hpp \
@@ -172,10 +170,6 @@ nobase_libMOAB_la_include_HEADERS = \
   moab/point_locater/element_maps/linear_tet_map.hpp  \
   moab/point_locater/element_maps/spectral_hex_map.hpp  \
   moab/point_locater/element_maps/quadratic_hex_map.hpp  \
-  moab/point_locater/lotte/types.h  \
-  moab/point_locater/lotte/errmem.h  \
-  moab/point_locater/lotte/findpt.h  \
-  moab/point_locater/lotte/poly.h  \
   moab/point_locater/point_locater.hpp \
   moab/point_locater/parametrizer.hpp \
   moab/Matrix3.hpp \

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index a61c8d2..4dd7c5b 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -145,11 +145,13 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
   rval = create_scd_sequence(low, high, MBVERTEX, 0, new_box);
   ERRORR(rval, "Trouble creating scd vertex sequence.");
 
-  if (num_coords && coords) {
-      // set the vertex coordinates
-    double *xc, *yc, *zc;
-    rval = new_box->get_coordinate_arrays(xc, yc, zc);
-    ERRORR(rval, "Couldn't get vertex coordinate arrays.");
+    // set the vertex coordinates
+  double *xc, *yc, *zc;
+
+  rval = new_box->get_coordinate_arrays(xc, yc, zc);
+  ERRORR(rval, "Couldn't get vertex coordinate arrays.");
+
+  if (coords && num_coords) {
 
     unsigned int i = 0;
     for (int kl = low[2]; kl <= high[2]; kl++) {
@@ -165,6 +167,23 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
       }
     }
   }
+  else {
+    unsigned int i = 0;
+    for (int kl = low[2]; kl <= high[2]; kl++) {
+      for (int jl = low[1]; jl <= high[1]; jl++) {
+        for (int il = low[0]; il <= high[0]; il++) {
+          xc[i] = (double) il;
+          if (new_box->box_size()[1])
+            yc[i] = (double) jl;
+          else yc[i] = 0.0;
+          if (new_box->box_size()[2])
+            zc[i] = (double) kl;
+          else zc[i] = 0.0;
+          i++;
+        }
+      }
+    }
+  }
 
     // create element sequence
   Core *mbcore = dynamic_cast<Core*>(mbImpl);
@@ -753,7 +772,7 @@ ErrorCode ScdInterface::get_neighbor_alljkbal(int np, int pfrom,
   pto = -1;
   across_bdy[0] = across_bdy[1] = across_bdy[2] = 0;
   
-  int ldims[6], pijk[3], lperiodic[2];
+  int ldims[6], pijk[3], lperiodic[3];
   ErrorCode rval = compute_partition_alljkbal(np, pfrom, gdims, gperiodic, 
                                               ldims, lperiodic, pijk);
   if (MB_SUCCESS != rval) return rval;
@@ -1150,7 +1169,7 @@ ErrorCode ScdInterface::get_neighbor_alljorkori(int np, int pfrom,
   pto = -1;
   if (np == 1) return MB_SUCCESS;
   
-  int pijk[3], lperiodic[2], ldims[6];
+  int pijk[3], lperiodic[3], ldims[6];
   rval = compute_partition_alljorkori(np, pfrom, gdims, gperiodic, ldims, lperiodic, pijk);
   if (MB_SUCCESS != rval) return rval;
 

diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index 6355141..4982b4c 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -164,10 +164,10 @@ protected:
   //! Center dimension numbers for i/j
   int iCDim, jCDim;
 
-  //! Whether mesh is locally periodic in i or j
+  //! Whether mesh is locally periodic in i or j or k
   int locallyPeriodic[3];
 
-  //! Whether mesh is globally periodic in i or j
+  //! Whether mesh is globally periodic in i or j or k
   int globallyPeriodic[3];
 };
 

diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index e5b3f08..ca86127 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -1,6 +1,6 @@
 #include "NCHelperEuler.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include <cmath>
 #include <sstream>

diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index dd555ff..a234450 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -1,6 +1,6 @@
 #include "NCHelperFV.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include <cmath>
 #include <sstream>

diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index f883bd7..4f2ac51 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -1,6 +1,6 @@
 #include "NCHelperHOMME.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/SpectralMeshTool.hpp"
 
 #include <cmath>

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 45d1b00..c0605e8 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -1,6 +1,6 @@
 #include "NCHelperMPAS.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/SpectralMeshTool.hpp"
 #include "MBTagConventions.hpp"
 

diff --git a/src/io/ReadABAQUS.cpp b/src/io/ReadABAQUS.cpp
index 1c44057..b3a37d0 100644
--- a/src/io/ReadABAQUS.cpp
+++ b/src/io/ReadABAQUS.cpp
@@ -36,7 +36,7 @@
 #include "moab/ReadUtilIface.hpp"
 #include "AffineXform.hpp"
 // #include "abaqus_order.h"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 namespace moab {
 

diff --git a/src/io/ReadCCMIO.cpp b/src/io/ReadCCMIO.cpp
index 3161425..ec53b6c 100644
--- a/src/io/ReadCCMIO.cpp
+++ b/src/io/ReadCCMIO.cpp
@@ -11,7 +11,7 @@
 #include "MBTagConventions.hpp"
 #include "Internals.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "ReadCCMIO.hpp"
 #include "moab/MeshTopoUtil.hpp"
 

diff --git a/src/io/ReadCGM.cpp b/src/io/ReadCGM.cpp
index 02f748e..a610d4a 100644
--- a/src/io/ReadCGM.cpp
+++ b/src/io/ReadCGM.cpp
@@ -37,7 +37,7 @@
 #include "moab/Interface.hpp"
 #include "moab/Range.hpp"
 #include "MBTagConventions.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include "moab/GeomTopoTool.hpp"
 

diff --git a/src/io/ReadDamsel.cpp b/src/io/ReadDamsel.cpp
index 8d1bcfe..f02f0ea 100644
--- a/src/io/ReadDamsel.cpp
+++ b/src/io/ReadDamsel.cpp
@@ -13,7 +13,7 @@
 #include "moab/Range.hpp"
 #include "moab/Error.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "MBTagConventions.hpp"
 #include "EntitySequence.hpp"
 #include "Internals.hpp"

diff --git a/src/io/ReadGCRM.cpp b/src/io/ReadGCRM.cpp
index 19d789e..0b86bd6 100644
--- a/src/io/ReadGCRM.cpp
+++ b/src/io/ReadGCRM.cpp
@@ -15,7 +15,7 @@
 #include "moab/ReaderIface.hpp"
 #include "moab/ReadUtilIface.hpp"
 #include "MBTagConventions.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #define ERRORR(rval, str) \
     if (MB_SUCCESS != rval) {readMeshIface->report_error("%s", str); return rval;}

diff --git a/src/io/ReadHDF5.cpp b/src/io/ReadHDF5.cpp
index 916b69a..c707380 100644
--- a/src/io/ReadHDF5.cpp
+++ b/src/io/ReadHDF5.cpp
@@ -38,7 +38,7 @@
 #include "MBTagConventions.hpp"
 #include "ReadHDF5.hpp"
 #include "moab/CN.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #ifdef HDF5_PARALLEL
 #  include <H5FDmpi.h>
 #  include <H5FDmpio.h>

diff --git a/src/io/ReadMCNP5.cpp b/src/io/ReadMCNP5.cpp
index c05ed41..b290f75 100644
--- a/src/io/ReadMCNP5.cpp
+++ b/src/io/ReadMCNP5.cpp
@@ -18,7 +18,7 @@
 #include "moab/ReadUtilIface.hpp"
 #include "Internals.hpp" // for MB_START_ID
 #include "moab/Range.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include <iostream>
 #include <sstream>

diff --git a/src/io/ReadNASTRAN.cpp b/src/io/ReadNASTRAN.cpp
index 6534417..47a8780 100644
--- a/src/io/ReadNASTRAN.cpp
+++ b/src/io/ReadNASTRAN.cpp
@@ -27,7 +27,7 @@
 #include "moab/ReadUtilIface.hpp"
 #include "Internals.hpp" // for MB_START_ID
 #include "moab/Range.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "FileTokenizer.hpp"
 #include "MBTagConventions.hpp"
 #include "moab/CN.hpp"

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 50225df..a27a89d 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -3,7 +3,7 @@
 
 #include "moab/ReadUtilIface.hpp"
 #include "MBTagConventions.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #define ERRORR(rval, str) \
   if (MB_SUCCESS != rval) { readMeshIface->report_error("%s", str); return rval; }

diff --git a/src/io/ReadNCDF.cpp b/src/io/ReadNCDF.cpp
index c69b3b5..01e98aa 100644
--- a/src/io/ReadNCDF.cpp
+++ b/src/io/ReadNCDF.cpp
@@ -38,7 +38,7 @@
 #include "Internals.hpp"
 #include "moab/ReadUtilIface.hpp"
 #include "exodus_order.h"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/AdaptiveKDTree.hpp"
 #include "moab/CartVect.hpp"
 

diff --git a/src/io/ReadSTL.cpp b/src/io/ReadSTL.cpp
index 4ba085d..59bd80b 100644
--- a/src/io/ReadSTL.cpp
+++ b/src/io/ReadSTL.cpp
@@ -25,7 +25,7 @@
 #include "moab/Interface.hpp"
 #include "moab/ReadUtilIface.hpp"
 #include "moab/Range.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "SysUtil.hpp"
 
 #include <errno.h>

diff --git a/src/io/ReadSmf.cpp b/src/io/ReadSmf.cpp
index 0970d71..eac232e 100644
--- a/src/io/ReadSmf.cpp
+++ b/src/io/ReadSmf.cpp
@@ -28,7 +28,7 @@
 #include "Internals.hpp"
 #include "moab/Interface.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "AffineXform.hpp"
 
 static inline int streq(const char *a,const char *b) { return strcmp(a,b)==0; }

diff --git a/src/io/ReadTemplate.cpp b/src/io/ReadTemplate.cpp
index 309a71e..97f70ce 100644
--- a/src/io/ReadTemplate.cpp
+++ b/src/io/ReadTemplate.cpp
@@ -8,7 +8,7 @@
 #include "moab/Interface.hpp"
 #include "moab/ReadUtilIface.hpp"
 #include "moab/Range.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 
 #include <cstdio>
 #include <assert.h>

diff --git a/src/io/ReadTetGen.cpp b/src/io/ReadTetGen.cpp
index 72197fb..1d6609a 100644
--- a/src/io/ReadTetGen.cpp
+++ b/src/io/ReadTetGen.cpp
@@ -2,7 +2,7 @@
 #include "moab/Interface.hpp"
 #include "moab/Range.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "MBTagConventions.hpp"
 #include <iostream>
 #include <fstream>

diff --git a/src/io/ReadVtk.cpp b/src/io/ReadVtk.cpp
index ac3b9e4..2936a85 100644
--- a/src/io/ReadVtk.cpp
+++ b/src/io/ReadVtk.cpp
@@ -28,7 +28,7 @@
 #include "Internals.hpp"
 #include "moab/Interface.hpp"
 #include "moab/ReadUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "FileTokenizer.hpp"
 #include "VtkUtil.hpp"
 

diff --git a/src/io/Tqdcfr.cpp b/src/io/Tqdcfr.cpp
index b930ab6..717f43a 100644
--- a/src/io/Tqdcfr.cpp
+++ b/src/io/Tqdcfr.cpp
@@ -16,7 +16,7 @@
 #include "Tqdcfr.hpp"
 #include "moab/Core.hpp"
 #include "moab/Range.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include <iostream>
 #include <string>
 

diff --git a/src/io/WriteDamsel.hpp b/src/io/WriteDamsel.hpp
index 8902f08..fff9e8b 100644
--- a/src/io/WriteDamsel.hpp
+++ b/src/io/WriteDamsel.hpp
@@ -26,7 +26,7 @@
 #include "moab/Range.hpp"
 #include "moab/WriterIface.hpp"
 #include "RangeSeqIntersectIter.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "DamselUtil.hpp"
 
 #include "damsel.h"

diff --git a/src/io/WriteGmsh.cpp b/src/io/WriteGmsh.cpp
index aac3d38..7d4e2f7 100644
--- a/src/io/WriteGmsh.cpp
+++ b/src/io/WriteGmsh.cpp
@@ -5,7 +5,7 @@
 #include "moab/Interface.hpp"
 #include "moab/Range.hpp"
 #include "moab/WriteUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "GmshUtil.hpp"
 
 #include <fstream>

diff --git a/src/io/WriteHDF5.cpp b/src/io/WriteHDF5.cpp
index 839c455..337cb96 100644
--- a/src/io/WriteHDF5.cpp
+++ b/src/io/WriteHDF5.cpp
@@ -48,17 +48,12 @@
 #include "Internals.hpp"
 #include "MBTagConventions.hpp"
 #include "moab/CN.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/Version.h"
+#include "moab/CpuTimer.hpp"
 #include "IODebugTrack.hpp"
 #include "mhdf.h"
 
-#ifdef USE_MPI
-#define RUNTIME MPI_Wtime()
-#else
-#define RUNTIME (clock()/(double)CLOCKS_PER_SEC)
-#endif
-
 /* Access HDF5 file handle for debugging
 #include <H5Fpublic.h>
 struct file { uint32_t magic; hid_t handle; };
@@ -100,15 +95,6 @@ struct file { uint32_t magic; hid_t handle; };
 
 namespace moab {
 
-class CpuTimer {
-private:
-  double atBirth, atLast;
-public:
-  CpuTimer() : atBirth(RUNTIME), atLast(atBirth) {}
-  double since_birth() { return (atLast = RUNTIME) - atBirth; };
-  double elapsed() { double tmp = atLast; return (atLast = RUNTIME) - tmp; }
-};
-
 template <typename T> inline 
 void VALGRIND_MAKE_VEC_UNDEFINED( std::vector<T>& v ) {
     VALGRIND_MAKE_MEM_UNDEFINED( &v[0], v.size() * sizeof(T) );
@@ -601,7 +587,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
   topState.end(result);
   CHK_MB_ERR_0(result);
   
-  times[GATHER_TIME] = timer.elapsed();
+  times[GATHER_TIME] = timer.time_elapsed();
   
   //if (nodeSet.range.size() == 0)
   //  return error(MB_ENTITY_NOT_FOUND);
@@ -650,7 +636,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
   if (MB_SUCCESS != result)
     return error(result);
 
-  times[CREATE_TIME] = timer.elapsed();
+  times[CREATE_TIME] = timer.time_elapsed();
 
   dbgOut.tprint(1,"Writing Nodes.\n");
     // Write node coordinates
@@ -662,7 +648,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
       return error(result);
   }
 
-  times[COORD_TIME] = timer.elapsed();
+  times[COORD_TIME] = timer.time_elapsed();
 
   dbgOut.tprint(1,"Writing connectivity.\n");
   
@@ -674,7 +660,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
     if (MB_SUCCESS != result)
       return error(result);
   }
-  times[CONN_TIME] = timer.elapsed();
+  times[CONN_TIME] = timer.time_elapsed();
 
   dbgOut.tprint(1,"Writing sets.\n");
   
@@ -684,7 +670,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
     return error(result);
   debug_barrier();
   
-  times[SET_TIME] = timer.elapsed();
+  times[SET_TIME] = timer.time_elapsed();
   dbgOut.tprint(1,"Writing adjacencies.\n");
   
     // Write adjacencies
@@ -701,7 +687,7 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
     if (MB_SUCCESS != result)
       return error(result);
   }
-  times[ADJ_TIME] = timer.elapsed();
+  times[ADJ_TIME] = timer.time_elapsed();
 
   dbgOut.tprint(1,"Writing tags.\n");
   
@@ -716,9 +702,9 @@ ErrorCode WriteHDF5::write_file_impl( const char* filename,
     if (MB_SUCCESS != result)
       return error(result);
   }
-  times[TAG_TIME] = timer.elapsed();
+  times[TAG_TIME] = timer.time_elapsed();
   
-  times[TOTAL_TIME] = timer.since_birth();
+  times[TOTAL_TIME] = timer.time_since_birth();
 
   if (cputime) {
     print_times( times );
@@ -1374,7 +1360,7 @@ ErrorCode WriteHDF5::write_sets( double* times )
     mhdf_closeData( filePtr, table, &status );
     CHK_MHDF_ERR_0(status);
    
-    times[SET_PARENT] = timer.elapsed();
+    times[SET_PARENT] = timer.time_elapsed();
     track.all_reduce();
   }
   
@@ -1393,7 +1379,7 @@ ErrorCode WriteHDF5::write_sets( double* times )
     mhdf_closeData( filePtr, table, &status );
     CHK_MHDF_ERR_0(status);
    
-    times[SET_CHILD] = timer.elapsed();
+    times[SET_CHILD] = timer.time_elapsed();
     track.all_reduce();
   }
   
@@ -1415,7 +1401,7 @@ ErrorCode WriteHDF5::write_sets( double* times )
     mhdf_closeData( filePtr, table, &status );
     CHK_MHDF_ERR_0(status);
    
-    times[SET_CONTENT] = timer.elapsed();
+    times[SET_CONTENT] = timer.time_elapsed();
     track.all_reduce();
   }
   assert( ranged_sets.size() + null_stripped_sets.size() == set_sizes.size() );
@@ -1544,7 +1530,7 @@ ErrorCode WriteHDF5::write_sets( double* times )
   mhdf_closeData( filePtr, table, &status );
   CHK_MHDF_ERR_0(status);
 
-  times[SET_META] = timer.elapsed();
+  times[SET_META] = timer.time_elapsed();
   track_meta.all_reduce();
 
   return MB_SUCCESS;
@@ -1881,7 +1867,7 @@ ErrorCode WriteHDF5::write_tag( const TagDesc& tag_data,
   if (array_len == MB_VARIABLE_LENGTH && tag_data.write_sparse) {
     dbgOut.printf( 2, "Writing sparse data for var-len tag: \"%s\"\n", name.c_str() );
     rval = write_var_len_tag( tag_data, name, moab_type, hdf5_type, elem_size );
-    times[VARLEN_TAG_TIME] += timer.elapsed();
+    times[VARLEN_TAG_TIME] += timer.time_elapsed();
   }
   else {
     int data_len = elem_size;
@@ -1890,7 +1876,7 @@ ErrorCode WriteHDF5::write_tag( const TagDesc& tag_data,
     if (tag_data.write_sparse) {
       dbgOut.printf( 2, "Writing sparse data for tag: \"%s\"\n", name.c_str() );
       rval = write_sparse_tag( tag_data, name, moab_type, hdf5_type, data_len );
-      times[SPARSE_TAG_TIME] += timer.elapsed();
+      times[SPARSE_TAG_TIME] += timer.time_elapsed();
     }
     for (size_t i = 0; MB_SUCCESS == rval && i < tag_data.dense_list.size(); ++i) {
       const ExportSet* set = find( tag_data.dense_list[i] );
@@ -1901,7 +1887,7 @@ ErrorCode WriteHDF5::write_tag( const TagDesc& tag_data,
       rval = write_dense_tag( tag_data, *set, name, moab_type, hdf5_type, data_len );
       subState.end(rval);
     }
-    times[DENSE_TAG_TIME] += timer.elapsed();
+    times[DENSE_TAG_TIME] += timer.time_elapsed();
   }
  
   H5Tclose( hdf5_type );

diff --git a/src/io/WriteSTL.cpp b/src/io/WriteSTL.cpp
index 62644a6..45718d8 100644
--- a/src/io/WriteSTL.cpp
+++ b/src/io/WriteSTL.cpp
@@ -25,7 +25,7 @@
 #include "moab/Interface.hpp"
 #include "moab/Range.hpp"
 #include "moab/WriteUtilIface.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "SysUtil.hpp"
 
 #include <stdio.h>

diff --git a/src/io/WriteSmf.cpp b/src/io/WriteSmf.cpp
index 0a09b8b..9d7f5f0 100644
--- a/src/io/WriteSmf.cpp
+++ b/src/io/WriteSmf.cpp
@@ -40,7 +40,7 @@
 #include "MBTagConventions.hpp"
 #include "moab/WriteUtilIface.hpp"
 #include "Internals.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/Version.h"
 
 namespace moab {

diff --git a/src/io/WriteVtk.cpp b/src/io/WriteVtk.cpp
index 03e95e4..bfda520 100644
--- a/src/io/WriteVtk.cpp
+++ b/src/io/WriteVtk.cpp
@@ -41,7 +41,7 @@
 #include "MBTagConventions.hpp"
 #include "moab/WriteUtilIface.hpp"
 #include "Internals.hpp"
-#include "FileOptions.hpp"
+#include "moab/FileOptions.hpp"
 #include "moab/Version.h"
 
 #define INS_ID(stringvar, prefix, id) \

diff --git a/src/lotte/errmem.c b/src/lotte/errmem.c
index 0196d83..b890bce 100644
--- a/src/lotte/errmem.c
+++ b/src/lotte/errmem.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include "moab/FindPtFuncs.h"
 
 void fail(const char *fmt, ...)
 {

diff --git a/src/lotte/findpt.c b/src/lotte/findpt.c
index 00fe8b7..160c7ab 100644
--- a/src/lotte/findpt.c
+++ b/src/lotte/findpt.c
@@ -5,12 +5,10 @@
 #include <float.h>
 #include <string.h>  /* for memcpy */
 
-#include "errmem.h"
-#include "types.h"
-#include "minmax.h"
-#include "poly.h"
-#include "tensor.h"
-#include "extrafindpt.h"
+#include "moab/FindPtFuncs.h"
+
+const unsigned opt_no_constraints_2 = 3+1;
+const unsigned opt_no_constraints_3 = 9+3+1;
 
 /*--------------------------------------------------------------------------
    Lobatto Polynomial Bounds
@@ -484,14 +482,6 @@ static void obbox_free_3(obbox_data_3 *p)
   free(p);
 }
 
-typedef struct {
-  real x[2], A[4], axis_bnd[4];
-} obbox_2;
-
-typedef struct {
-  real x[3], A[9], axis_bnd[6];
-} obbox_3;
-
 int obbox_axis_test_2(const obbox_2 *p, const real x[2])
 {
   return (x[0]<p->axis_bnd[0] || x[0]>p->axis_bnd[1] ||
@@ -767,34 +757,6 @@ void obbox_calc_3(const obbox_data_3 *p, real tol,
      
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  unsigned hash_n;
-  real bnd[4]; /* bounds for all elements */
-  real fac[2]; /* fac[i] = hash_n / (bnd[2*i+1]-bnd[2*i]) */
-  obbox_2 *obb; /* obb[nel] -- bounding box info for each element */
-  uint *offset; /* hash table -- for cell i,j:
-                         uint index = j*hash_n+i,
-                                  b = offset[index  ],
-                                  e = offset[index+1];
-                         elements in cell are
-                           offset[b], offset[b+1], ..., offset[e-1] */
-  unsigned max; /* maximum # of elements in any cell */
-} hash_data_2;
-
-typedef struct {
-  unsigned hash_n;
-  real bnd[6]; /* bounds for all elements */
-  real fac[3]; /* fac[i] = hash_n / (bnd[2*i+1]-bnd[2*i]) */
-  obbox_3 *obb; /* obb[nel] -- bounding box info for each element */
-  uint *offset; /* hash table -- for cell i,j,k:
-                         uint index = (k*hash_n+j)*hash_n+i,
-                                  b = offset[index  ],
-                                  e = offset[index+1];
-                         elements in cell are
-                           offset[b], offset[b+1], ..., offset[e-1] */
-  unsigned max; /* maximum # of elements in any cell */
-} hash_data_3;
-
 static int ifloor(real x)
 {
   /*
@@ -1885,12 +1847,6 @@ double opt_findpt_2(opt_data_2 *p, const real *const elx[2],
      
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  uint el;
-  real r[3];
-  real dist;
-} findpt_listel;
-
 /* heap sort on A[0:n-1] with key A[i]->dist
    precondition: n!=0 */
 static void findpt_list_sort(findpt_listel **A, unsigned n)
@@ -1925,34 +1881,6 @@ static void findpt_list_sort(findpt_listel **A, unsigned n)
   }
 }
 
-typedef struct {
-  const real *xw[2];   /* geometry data */
-  real *z[2];          /* lobatto nodes */
-  lagrange_data ld[2]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  hash_data_2 *hash;   /* geometric hashing data */
-  findpt_listel *list, **sorted, **end; /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  opt_data_2 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_2;
-
-typedef struct {
-  const real *xw[3];   /* geometry data */
-  real *z[3];          /* lobatto nodes */
-  lagrange_data ld[3]; /* interpolation, derivative weights & data */
-  unsigned nptel;      /* nodes per element */
-  hash_data_3 *hash;   /* geometric hashing data */
-  findpt_listel *list, **sorted, **end; /* pre-allocated list of elements to
-                                           check (found by hashing), and
-                                           pre-allocated list of pointers into
-                                           the first list for sorting */
-  opt_data_3 *od; /* data for the optimization algorithm */
-  real *od_work;
-} findpt_data_3;
-
 findpt_data_2 *findpt_setup_2(
           const real *const xw[2], const unsigned n[2], uint nel,
           uint max_hash_size, real bbox_tol)

diff --git a/src/lotte/poly.c b/src/lotte/poly.c
index 6b5cba6..b8a93b7 100644
--- a/src/lotte/poly.c
+++ b/src/lotte/poly.c
@@ -5,8 +5,7 @@
 #include <string.h>  /* for memcpy */
 #include <float.h>
 
-#include "errmem.h"
-#include "types.h"
+#include "moab/FindPtFuncs.h"
 
 /* 
   For brevity's sake, some names have been shortened
@@ -354,15 +353,6 @@ void lagrange_weights_deriv(const real *z, unsigned n,
      lagrange_free(&p);  // deallocate memory allocated by setup
   --------------------------------------------------------------------------*/
 
-typedef struct {
-  unsigned n;                /* number of Lagrange nodes            */
-  const real *z;             /* Lagrange nodes (user-supplied)      */
-  real *J, *D, *D2;          /* weights for 0th,1st,2nd derivatives */
-  real *J_z0, *D_z0, *D2_z0; /* ditto at z[0]   (computed at setup) */
-  real *J_zn, *D_zn, *D2_zn; /* ditto at z[n-1] (computed at setup) */
-  real *w, *d, *u0, *v0, *u1, *v1, *u2, *v2; /* work data            */
-} lagrange_data;
-
 void lagrange_0(lagrange_data *p, real x)
 {
   unsigned i, n=p->n;

diff --git a/src/lotte/tensor.c b/src/lotte/tensor.c
index 19e54b7..510dc38 100644
--- a/src/lotte/tensor.c
+++ b/src/lotte/tensor.c
@@ -1,4 +1,4 @@
-#include "types.h"
+#include "moab/FindPtFuncs.h"
 
 /*--------------------------------------------------------------------------
    Matrix-Matrix Multiplication

diff --git a/src/moab/BoundBox.hpp b/src/moab/BoundBox.hpp
new file mode 100644
index 0000000..9400944
--- /dev/null
+++ b/src/moab/BoundBox.hpp
@@ -0,0 +1,177 @@
+#ifndef BOUND_BOX_HPP
+#define BOUND_BOX_HPP
+
+#include "moab/Interface.hpp"
+#include "moab/CartVect.hpp"
+
+#include <cfloat>
+
+namespace moab {
+
+    class BoundBox {
+  public:
+      BoundBox() : bMin(DBL_MAX), bMax(-DBL_MAX) {}
+      BoundBox(const CartVect &min, const CartVect &max) : 
+              bMin(min), bMax(max) {}
+      BoundBox(const double *corners);
+      ~BoundBox() {}
+
+      bool contains_point(const double *point, const double tol = 0.0) const;
+      bool contains_box(const BoundBox &b, const double tol = 0.0) const;
+      void compute_center(CartVect &center);
+      void update(const BoundBox &other_box);
+      void update(const double *coords);
+      ErrorCode update(Interface &iface, const Range& elems);
+      ErrorCode update(Interface &iface, const EntityHandle ent);
+      void update_min(const BoundBox &other_box);
+      void update_min(const double *coords);
+      void update_max(const BoundBox &other_box);
+      void update_max(const double *coords);
+
+        /** \brief Return the diagonal length of this box
+         */
+      double diagonal_length() const;
+      
+        /** \brief Return the square of the diagonal length of this box
+         */
+      double diagonal_squared() const;
+      
+        /** \brief Return square of distance from box, or zero if inside 
+         * \param from_point Point from which you want distance_sq
+         */
+      double distance_squared(const double *from_point) const;
+
+        /** \brief Return distance from box, or zero if inside 
+         * \param from_point Point from which you want distance
+         */
+      double distance(const double *from_point) const;
+      
+      BoundBox &operator=(const BoundBox &from) {
+        bMin = from.bMin;
+        bMax = from.bMax;
+        return *this;
+      }
+      inline bool operator==(const BoundBox &box) const {
+        return (bMin == box.bMin && bMax == box.bMax);
+      }
+
+      CartVect bMin, bMax;
+    };
+    
+    inline BoundBox::BoundBox(const double *corners) 
+    {
+        // relies on CartVect being Plain Old Data, no virtual table
+      double *arr = bMin.array();
+      for (int i = 0; i < 6; i++)
+        arr[i] = corners[i];
+    }
+
+    inline bool BoundBox::contains_point(const double *point, const double tol) const {
+      if (point[0] < bMin[0]-tol || point[0] > bMax[0]+tol ||
+          point[1] < bMin[1]-tol || point[1] > bMax[1]+tol ||
+          point[2] < bMin[2]-tol || point[2] > bMax[2]+tol)
+        return false;
+      else return true;
+    }
+
+    inline bool BoundBox::contains_box(const BoundBox &b, const double tol) const {
+      if (b.bMin[0] < bMin[0]-tol || b.bMax[0] > bMax[0]+tol ||
+          b.bMin[1] < bMin[1]-tol || b.bMax[1] > bMax[1]+tol ||
+          b.bMin[2] < bMin[2]-tol || b.bMax[2] > bMax[2]+tol) 
+        return false;
+
+      else return true;
+    }
+
+    inline void BoundBox::update(const BoundBox &other_box) 
+    {
+      update_min(other_box);
+      update_max(other_box);
+    }
+
+    inline void BoundBox::update(const double *coords) 
+    {
+      update_min(coords);
+      update_max(coords+3);
+    }
+
+    inline void BoundBox::update_min(const BoundBox &other_box) 
+    {
+      bMin[0] = std::min(bMin[0], other_box.bMin[0]);
+      bMin[1] = std::min(bMin[1], other_box.bMin[1]);
+      bMin[2] = std::min(bMin[2], other_box.bMin[2]);
+    }
+      
+    inline void BoundBox::update_min(const double *coords) 
+    {
+      bMin[0] = std::min(bMin[0], coords[0]);
+      bMin[1] = std::min(bMin[1], coords[1]);
+      bMin[2] = std::min(bMin[2], coords[2]);
+    }
+      
+    inline void BoundBox::update_max(const BoundBox &other_box)
+    {
+      bMax[0] = std::max(bMax[0], other_box.bMax[0]);
+      bMax[1] = std::max(bMax[1], other_box.bMax[1]);
+      bMax[2] = std::max(bMax[2], other_box.bMax[2]);
+    }
+
+    inline void BoundBox::update_max(const double *coords)
+    {
+      bMax[0] = std::max(bMax[0], coords[0]);
+      bMax[1] = std::max(bMax[1], coords[1]);
+      bMax[2] = std::max(bMax[2], coords[2]);
+    }
+
+    inline void BoundBox::compute_center(CartVect &center){
+      center = 0.5 * (bMin + bMax);
+    }
+
+    inline std::ostream &operator<<(std::ostream& out, const BoundBox &box) {
+      out << "Min: ";
+      out << box.bMin;
+      out << ", Max: ";
+      out << box.bMax;
+      return out;
+    }
+
+    inline ErrorCode BoundBox::update(Interface &iface, const EntityHandle ent) 
+    {
+      Range tmp_range(ent, ent);
+      return update(iface, tmp_range);
+    }
+
+    inline double BoundBox::distance_squared(const double *from_point) const
+    {
+      double dist_sq = 0.0;
+      for (int i = 0; i < 3; ++i) {
+        if (from_point[i] < bMin[i])
+          dist_sq += (bMin[i] - from_point[i]) * (bMin[i] - from_point[i]);
+        else if (from_point[i] > bMax[i]) 
+          dist_sq += (bMax[i] - from_point[i]) * (bMax[i] - from_point[i]);
+      }
+      return dist_sq;
+    }
+
+    inline double BoundBox::distance(const double *from_point) const
+    {
+      double dist_sq = distance_squared(from_point);
+      return sqrt(dist_sq);
+    }
+
+    inline double BoundBox::diagonal_length() const 
+    {
+      if (DBL_MAX == bMax[0] || DBL_MAX == bMax[1] || DBL_MAX == bMax[2] ||
+          DBL_MAX == bMin[0] || DBL_MAX == bMin[1] || DBL_MAX == bMin[2]) return DBL_MAX;
+      return (bMax - bMin).length();
+    }
+
+    inline double BoundBox::diagonal_squared() const 
+    {
+      if (DBL_MAX == bMax[0] || DBL_MAX == bMax[1] || DBL_MAX == bMax[2] ||
+          DBL_MAX == bMin[0] || DBL_MAX == bMin[1] || DBL_MAX == bMin[2]) return DBL_MAX;
+      return (bMax - bMin).length_squared();
+    }
+}
+
+#endif

diff --git a/src/moab/CartVect.hpp b/src/moab/CartVect.hpp
index 383f8e4..a249fef 100644
--- a/src/moab/CartVect.hpp
+++ b/src/moab/CartVect.hpp
@@ -1,18 +1,3 @@
-/**
- * MOAB, a Mesh-Oriented datABase, is a software component for creating,
- * storing and accessing finite element mesh data.
- *
- * Copyright 2004 Sandia Corporation.  Under the terms of Contract
- * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
- * retains certain rights in this software.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- */
-
 #ifndef MB_CART_VECT_HPP
 #define MB_CART_VECT_HPP
 
@@ -24,8 +9,6 @@ namespace moab {
 
 /**
  * \brief Cartesian Vector
- * \author Jason Kraftcheck
- * \date July, 2006
  */
 class CartVect
 {
@@ -67,6 +50,8 @@ class CartVect
       { d[0] *= s; d[1] *= s; d[2] *= s; return *this; }
     inline CartVect& operator/=( double s )
       { d[0] /= s; d[1] /= s; d[2] /= s; return *this; }
+  inline bool operator==(const CartVect& v ) const
+      { return d[0] == v[0] && d[1] == v[1] && d[2] == v[2]; }
 
     inline double length() const; //!< vector length
 

diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index efa17e3..4bb86c8 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -221,7 +221,7 @@ public:
           \param entity_handle EntityHandle to get connectivity of.
           \param connectivity Vector in which connectivity of <em>entity_handle</em> is returned.  
           Should contain MeshVertices.
-          \param topological_connectivity If true, higher order nodes are ignored. 
+          \param corners_only If true, higher order nodes are ignored. 
 
           Example: \code 
           std::vector<EntityHandle> conn;
@@ -229,7 +229,7 @@ public:
     virtual ErrorCode  get_connectivity(const EntityHandle *entity_handles, 
                                         const int num_handles,
                                         std::vector<EntityHandle> &connectivity, 
-                                        bool topological_connectivity = false,
+                                        bool corners_only = false,
                                         std::vector<int> *offsets = NULL) const;
  
     //! Gets the connectivity for a vector of elements
@@ -238,14 +238,14 @@ public:
   virtual ErrorCode  get_connectivity(const EntityHandle *entity_handles, 
                                         const int num_handles,
                                         Range &connectivity, 
-                                        bool topological_connectivity = false) const;
+                                        bool corners_only = false) const;
 
     //! Gets the connectivity for elements
     /** Same as vector-based version except range is returned (unordered!)
     */
   virtual ErrorCode get_connectivity( const Range& entity_handles, 
                                         Range &connectivity, 
-                                        bool topological_connectivity = false) const;
+                                        bool corners_only = false) const;
  
     //! Gets a pointer to constant connectivity data of <em>entity_handle</em> 
       /** Sets <em>number_nodes</em> equal to the number of nodes of the <em> 
@@ -273,7 +273,7 @@ public:
     virtual ErrorCode  get_connectivity( const EntityHandle entity_handle, 
                                            const EntityHandle *&connectivity, 
                                            int &num_nodes, 
-                                           bool topological_connectivity = false,
+                                           bool corners_only = false,
                                            std::vector<EntityHandle>* storage = 0
                                           ) const;
 
@@ -1134,6 +1134,8 @@ public:
   void print(const EntityHandle handle, const char *prefix,
              bool first_call = true) const;
 
+  ErrorCode print_entity_tags(std::string indent_prefix, const EntityHandle handle, TagType tp) const;
+  
   virtual ErrorCode get_last_error(std::string& info) const;
 
   virtual std::string get_error_string(const ErrorCode code) const;

This diff is so big that we needed to truncate the remainder.

https://bitbucket.org/fathomteam/moab/commits/5a570701269a/
Changeset:   5a570701269a
Branch:      None
User:        iulian07
Date:        2013-09-16 21:36:19
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  8 files

diff --git a/src/ScdInterface.cpp b/src/ScdInterface.cpp
index 4dd7c5b..1d42dde 100644
--- a/src/ScdInterface.cpp
+++ b/src/ScdInterface.cpp
@@ -147,12 +147,10 @@ ErrorCode ScdInterface::construct_box(HomCoord low, HomCoord high, const double
 
     // set the vertex coordinates
   double *xc, *yc, *zc;
-
   rval = new_box->get_coordinate_arrays(xc, yc, zc);
   ERRORR(rval, "Couldn't get vertex coordinate arrays.");
 
   if (coords && num_coords) {
-
     unsigned int i = 0;
     for (int kl = low[2]; kl <= high[2]; kl++) {
       for (int jl = low[1]; jl <= high[1]; jl++) {

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 0ad7e19..5f621d7 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -824,25 +824,25 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
                                        NULL, 0, scd_box, locallyPeriodic, &parData, true);
   ERRORR(rval, "Trouble creating scd vertex sequence.");
 
-    // add verts to tmp_range first, so we can duplicate global ids in vertex ids
+  // Add verts to tmp_range first, so we can duplicate global ids in vertex ids
   tmp_range.insert(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
 
   if (mpFileIdTag) {
-    Range::iterator topv = tmp_range.end();
     int count;
-    void *data;
-    rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), topv, count, data);
+    void* data;
+    rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), tmp_range.end(), count, data);
     ERRORR(rval, "Failed to get tag iterator on file id tag.");
     assert(count == scd_box->num_vertices());
-    int *fid_data = (int*) data;
-    rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), topv, count, data);
-    ERRORR(rval, "Failed to get tag iterator on file id tag.");
+    int* fid_data = (int*) data;
+    rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), tmp_range.end(), count, data);
+    ERRORR(rval, "Failed to get tag iterator on global id tag.");
     assert(count == scd_box->num_vertices());
-    int *gid_data = (int*) data;
-    for (int i = 0; i < count; i++) fid_data[i] = gid_data[i];
+    int* gid_data = (int*) data;
+    for (int i = 0; i < count; i++)
+      fid_data[i] = gid_data[i];
   }
 
-    // Then add box set and elements to the range, then to the file set
+  // Then add box set and elements to the range, then to the file set
   tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
   tmp_range.insert(scd_box->box_set());
   rval = mbImpl->add_entities(_fileSet, tmp_range);
@@ -859,8 +859,8 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
   int dil = lDims[3] - lDims[0] + 1;
   int djl = lDims[4] - lDims[1] + 1;
   assert(dil == (int)ilVals.size() && djl == (int)jlVals.size() &&
-      (-1 == lDims[2] || lDims[5]-lDims[2] + 1 == (int)levVals.size()));
-#define INDEX(i, j, k) ()
+      (-1 == lDims[2] || lDims[5] - lDims[2] + 1 == (int)levVals.size()));
+//#define INDEX(i, j, k) ()
   for (kl = lDims[2]; kl <= lDims[5]; kl++) {
     k = kl - lDims[2];
     for (jl = lDims[1]; jl <= lDims[4]; jl++) {
@@ -874,7 +874,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
       }
     }
   }
-#undef INDEX
+//#undef INDEX
 
 #ifndef NDEBUG
   int num_verts = (lDims[3] - lDims[0] + 1) * (lDims[4] - lDims[1] + 1) * (-1 == lDims[2] ? 1 : lDims[5] - lDims[2] + 1);

diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index 4bb86c8..aa7d9da 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -216,16 +216,17 @@ public:
   
       //! Gets the connectivity for an element EntityHandle. 
       /** For non-element handles (ie, MeshSets), 
-          returns an error. Connectivity data is copied from the database into the vector 
-          <em>connectivity</em>. The nodes in <em>connectivity</em> are properly ordered.
-          \param entity_handle EntityHandle to get connectivity of.
-          \param connectivity Vector in which connectivity of <em>entity_handle</em> is returned.  
-          Should contain MeshVertices.
-          \param corners_only If true, higher order nodes are ignored. 
-
-          Example: \code 
-          std::vector<EntityHandle> conn;
-          get_connectivity( entity_handle, conn ); \endcode */
+       * returns an error. Connectivity data is copied from the database into the vector 
+       *   <em>connectivity</em>. The nodes in <em>connectivity</em> are properly ordered.
+       *  \param entity_handle EntityHandle to get connectivity of.
+       *  \param connectivity Vector in which connectivity of <em>entity_handle</em> is returned.  
+       *   Should contain MeshVertices.
+       *  \param corners_only If true, returns only corner vertices, otherwise returns all of them (including any higher-order vertices)
+       *
+       *   Example: \code 
+       *   std::vector<EntityHandle> conn;
+       *   get_connectivity( entity_handle, conn ); \endcode 
+       */
     virtual ErrorCode  get_connectivity(const EntityHandle *entity_handles, 
                                         const int num_handles,
                                         std::vector<EntityHandle> &connectivity, 

diff --git a/src/moab/FileOptions.hpp b/src/moab/FileOptions.hpp
index 85b3eef..722c9fe 100644
--- a/src/moab/FileOptions.hpp
+++ b/src/moab/FileOptions.hpp
@@ -42,7 +42,7 @@ public:
    *          the beginning of the string (semicolon followed by
    *          destired separator character.)
    */
-  FileOptions( const char* option_string );
+  FileOptions( const char* option_string);
   
   FileOptions( const FileOptions& copy );
   FileOptions& operator=( const FileOptions& copy );

diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index b6bb3e5..09f4219 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -527,7 +527,7 @@ public:
         \param entity_handles Vector of element handles to get connectivity of.
         \param num_handles Number of entity handles in <em>entity_handles</em>
         \param connectivity Vector in which connectivity of <em>entity_handles</em> is returned.  
-        \param corners_only If true, higher order nodes are ignored. 
+        \param corners_only If true, returns only corner vertices, otherwise returns all of them (including any higher-order vertices)
         \param offsets If non-NULL, offsets->[i] stores the index of the start of entity i's connectivity,
                 with the last value in offsets one beyond the last entry
     */
@@ -561,8 +561,7 @@ public:
         \param entity_handle EntityHandle to get connectivity of.
         \param connectivity Array in which connectivity of <em>entity_handle</em> is returned.
         \param num_nodes Number of MeshVertices in array <em>connectivity</em>. 
-        \param corners_only If true, num_nodes will be set to number of corner vertices
-        for that element type.
+        \param corners_only If true, returns only corner vertices, otherwise returns all of them (including any higher-order vertices)
         \param storage Some elements (e.g. structured mesh) may not have an
                        explicit connectivity list.  This function will normally
                        return MB_NOT_IMPLEMENTED for such elements.  However,

diff --git a/test/scdtest2.cpp b/test/scdtest2.cpp
deleted file mode 100644
index e744746..0000000
--- a/test/scdtest2.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "moab/ScdInterface.hpp"
-#include "moab/Core.hpp"
-#include "TestUtil.hpp"
-
-#include <iostream>
-
-#ifdef USE_MPI
-#include "moab/ParallelComm.hpp"
-#endif
-
-using namespace moab;
-
-void test_john()
-{
-  Core moab;
-  ScdInterface *scd;
-  ErrorCode rval = moab.Interface::query_interface(scd);
-  CHECK_ERR(rval);
-  int gdims[] = {0, 0, 0, 48, 40, 0};
-  int ldims[6];
-
-  std::cout << "x dims are " << gdims[3] << "\n";
-  std::cout << "y dims are " << gdims[4] << "\n";
-  
-#ifdef USE_MPI
-  ParallelComm pcomm(&moab, MPI_COMM_WORLD);
-  int procs = pcomm.proc_config().proc_size(),
-      rank = pcomm.proc_config().proc_rank();
-  ScdParData pardata;
-  std::copy(gdims, gdims+6, pardata.gDims);
-  pardata.gPeriodic[0] = pardata.gPeriodic[1] = 0;
-  pardata.partMethod = ScdParData::SQIJ;
-  int pDims[2];
-  
-  rval = ScdInterface::compute_partition(procs, rank, pardata, ldims, NULL, pDims); CHECK_ERR(rval);
-  std::cout << "processors in x are " << pDims[0] << "\n";
-  std::cout << "processors in y are " << pDims[1] << "\n";
-#else
-  std::copy(gdims, gdims+6, ldims);
-#endif
-
-  std::cout << "local dims are " 
-            << ldims[0] << " " << ldims[1] << " " << ldims[2] << " " 
-            << ldims[3] << " " << ldims[4] << " " << ldims[5] << "\n";
-
-  ScdBox* box;
-
-#ifdef USE_MPI
-  rval = scd->construct_box(HomCoord(ldims, 3), HomCoord(ldims+3, 3), NULL, 0, box, NULL, &pardata); CHECK_ERR(rval);
-  rval = pcomm.resolve_shared_ents(0); CHECK_ERR(rval);
-#else
-  rval = scd->construct_box(HomCoord(ldims, 3), HomCoord(ldims+3, 3), NULL, 0, box); CHECK_ERR(rval);
-#endif
-
-  moab.list_entities(0,0);
-  std::vector<EntityHandle> conn;
-  Range quads, verts;
-  rval = moab.get_entities_by_type(0, MBQUAD, quads); CHECK_ERR(rval);
-  rval = moab.get_adjacencies(quads, 0, false, verts, Interface::UNION); CHECK_ERR(rval);
-  Tag gid_tag;
-  rval = moab.tag_get_handle("GLOBAL_ID", gid_tag); CHECK_ERR(rval);
-  int *qgids, *vgids, count;
-  rval = moab.tag_iterate(gid_tag, quads.begin(), quads.end(), count, (void*&)qgids); 
-  CHECK_ERR(rval); CHECK_EQUAL(count, (int)quads.size());
-  rval = moab.tag_iterate(gid_tag, verts.begin(), verts.end(), count, (void*&)vgids); 
-  CHECK_ERR(rval); CHECK_EQUAL(count, (int)verts.size());
-  for (Range::iterator rit = quads.begin(); rit != quads.end(); rit++) {
-    rval = moab.get_connectivity(&(*rit), 1, conn); CHECK_ERR(rval);
-    std::cout << "Connectivity array for quad " << qgids[*rit-*quads.begin()] << " is: ";
-    for (int i = 0; i < 4; i++) std::cout << vgids[conn[i]-*verts.begin()] << " ";
-    std::cout << std::endl;
-  }
-  
-}
-
-int main(int, char**) 
-{
-    // test partition methods
-  RUN_TEST(test_john);
-}

diff --git a/tools/mbcoupler/ElemUtil.cpp b/tools/mbcoupler/ElemUtil.cpp
index 873cc44..cfc36e0 100644
--- a/tools/mbcoupler/ElemUtil.cpp
+++ b/tools/mbcoupler/ElemUtil.cpp
@@ -419,18 +419,20 @@ bool integrate_trilinear_hex(const CartVect* hex_corners,
 
 namespace Element {
 
+    Map::~Map() 
+    {}
+    
+    inline const std::vector<CartVect>& Map::get_vertices() {
+        return this->vertex;
+      }
+        //
+      void Map::set_vertices(const std::vector<CartVect>& v) {
+        if(v.size() != this->vertex.size()) {
+          throw ArgError();
+        }
+        this->vertex = v;
+      }
 
-
-  inline const std::vector<CartVect>& Map::get_vertices() {
-    return this->vertex;
-  }
-  //
-  void Map::set_vertices(const std::vector<CartVect>& v) {
-    if(v.size() != this->vertex.size()) {
-      throw ArgError();
-    }
-    this->vertex = v;
-  }// Map::set_vertices()
   //
   CartVect Map::ievaluate(const CartVect& x, double tol, const CartVect& x0) const {
     // TODO: should differentiate between epsilons used for
@@ -458,7 +460,6 @@ namespace Element {
     return xi;
   }// Map::ievaluate()
 
-
 // filescope for static member data that is cached
   const double LinearEdge::corner[2][3] = {  { -1, 0, 0 },
                                          {  1, 0, 0 } };
@@ -538,6 +539,8 @@ namespace Element {
 
   }// LinearHex::LinearHex()
 
+    LinearHex::~LinearHex() 
+    {}
   /* For each point, its weight and location are stored as an array.
      Hence, the inner dimension is 2, the outer dimension is gauss_count.
      We use a one-point Gaussian quadrature, since it integrates linear functions exactly.
@@ -653,6 +656,8 @@ namespace Element {
   QuadraticHex::QuadraticHex():Map(0) {
   }
 
+    QuadraticHex::~QuadraticHex() 
+    {}
   double SH(const int i, const double xi)
   {
     switch (i)
@@ -749,6 +754,9 @@ namespace Element {
   }// LinearTet::LinearTet()
 
 
+    LinearTet::~LinearTet() 
+    {}
+
   void LinearTet::set_vertices(const std::vector<CartVect>& v) {
     this->Map::set_vertices(v);
     this->T = Matrix3(v[1][0]-v[0][0],v[2][0]-v[0][0],v[3][0]-v[0][0],
@@ -1002,6 +1010,9 @@ namespace Element {
 
   }// LinearQuad::LinearQuad()
 
+    LinearQuad::~LinearQuad() 
+    {}
+    
   /* For each point, its weight and location are stored as an array.
      Hence, the inner dimension is 2, the outer dimension is gauss_count.
      We use a one-point Gaussian quadrature, since it integrates linear functions exactly.

diff --git a/tools/mbcoupler/ElemUtil.hpp b/tools/mbcoupler/ElemUtil.hpp
index 9b4bf9a..1db4c9e 100644
--- a/tools/mbcoupler/ElemUtil.hpp
+++ b/tools/mbcoupler/ElemUtil.hpp
@@ -71,10 +71,11 @@ namespace ElemUtil {
       Map(const std::vector<CartVect>& v) {this->vertex.resize(v.size()); this->set_vertices(v);};
       /**\brief Construct a Map defined by n vertices. */
       Map(const unsigned int n) {this->vertex = std::vector<CartVect>(n);};
+      virtual ~Map();
       /**\brief Evaluate the map on \xi (calculate $\vec x = F($\vec \xi)$ )*/
       virtual CartVect evaluate( const CartVect& xi ) const = 0;
       /**\brief Evaluate the inverse map (calculate $\vec \xi = F^-1($\vec x)$ to given tolerance)*/
-      CartVect ievaluate( const CartVect& x, double tol, const CartVect& x0 = CartVect(0.0)) const ;
+      virtual CartVect ievaluate( const CartVect& x, double tol, const CartVect& x0 = CartVect(0.0)) const ;
       /**\brief decide if within the natural param space, with a tolerance*/
       virtual bool inside_nat_space(const CartVect & xi, double & tol) const = 0;
       /* FIX: should evaluate and ievaluate return both the value and the Jacobian (first jet)? */
@@ -98,7 +99,7 @@ namespace ElemUtil {
       /**\brief Size of the vertices vector. */
       unsigned int size() {return this->vertex.size();}
       /**\brief Retrieve vertices. */
-      inline const std::vector<CartVect>& get_vertices();
+      const std::vector<CartVect>& get_vertices();
       /**\brief Set vertices.      */
       virtual void set_vertices(const std::vector<CartVect>& v);
 
@@ -122,13 +123,15 @@ namespace ElemUtil {
     public:
       LinearHex(const std::vector<CartVect>& vertices) : Map(vertices){};
       LinearHex();
+      virtual ~LinearHex();
+      
       virtual CartVect evaluate( const CartVect& xi ) const;
       //virtual CartVect ievaluate(const CartVect& x, double tol) const ;
       virtual bool inside_nat_space(const CartVect & xi, double & tol) const;
 
       virtual Matrix3  jacobian(const CartVect& xi) const;
-      double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
-      double   integrate_scalar_field(const double *field_vertex_values) const;
+      virtual double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
+      virtual double   integrate_scalar_field(const double *field_vertex_values) const;
 
     protected:
       /* Preimages of the vertices -- "canonical vertices" -- are known as "corners". */
@@ -144,13 +147,14 @@ namespace ElemUtil {
     public:
       QuadraticHex(const std::vector<CartVect>& vertices) : Map(vertices){};
       QuadraticHex();
+      virtual ~QuadraticHex();
       virtual CartVect evaluate( const CartVect& xi ) const;
       //virtual CartVect ievaluate(const CartVect& x, double tol) const ;
       virtual bool inside_nat_space(const CartVect & xi, double & tol) const;
 
       virtual Matrix3  jacobian(const CartVect& xi) const;
-      double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
-      double   integrate_scalar_field(const double *field_vertex_values) const;
+      virtual double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
+      virtual double   integrate_scalar_field(const double *field_vertex_values) const;
 
     protected:
       /* Preimages of the vertices -- "canonical vertices" -- are known as "corners".
@@ -166,6 +170,7 @@ namespace ElemUtil {
     public:
       LinearTet(const std::vector<CartVect>& vertices) : Map(vertices){};
       LinearTet();
+      virtual ~LinearTet();
       /* Override the evaluation routines to take advantage of the properties of P1. */
       virtual CartVect evaluate(const CartVect& xi) const {return this->vertex[0] + this->T*xi;};
       virtual CartVect ievaluate(const CartVect& x) const {return this->T_inverse*(x-this->vertex[0]);};
@@ -174,12 +179,12 @@ namespace ElemUtil {
       virtual double   det_jacobian(const CartVect& )  const {return this->det_T;};
       virtual double   det_ijacobian(const CartVect& ) const {return this->det_T_inverse;};
       //
-      double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
-      double   integrate_scalar_field(const double *field_vertex_values) const;
+      virtual double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
+      virtual double   integrate_scalar_field(const double *field_vertex_values) const;
       //
       /* Override set_vertices so we can precompute the matrices effecting the mapping to and from the canonical simplex. */
-      void     set_vertices(const std::vector<CartVect>& v);
-      bool inside_nat_space(const CartVect & xi, double & tol) const;
+      virtual void     set_vertices(const std::vector<CartVect>& v);
+      virtual bool inside_nat_space(const CartVect & xi, double & tol) const;
     protected:
       static const double corner[4][3];
       Matrix3 T, T_inverse;
@@ -225,13 +230,14 @@ namespace ElemUtil {
     public:
       LinearQuad(const std::vector<CartVect>& vertices) : Map(vertices){};
       LinearQuad();
+      virtual ~LinearQuad();
       virtual CartVect evaluate( const CartVect& xi ) const;
       //virtual CartVect ievaluate(const CartVect& x, double tol) const ;
       virtual bool inside_nat_space(const CartVect & xi, double & tol) const;
 
       virtual Matrix3  jacobian(const CartVect& xi) const;
-      double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
-      double   integrate_scalar_field(const double *field_vertex_values) const;
+      virtual double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
+      virtual double   integrate_scalar_field(const double *field_vertex_values) const;
 
     protected:
       /* Preimages of the vertices -- "canonical vertices" -- are known as "corners". */
@@ -252,8 +258,8 @@ namespace ElemUtil {
       virtual bool inside_nat_space(const CartVect & xi, double & tol) const;
 
       virtual Matrix3  jacobian(const CartVect& xi) const;
-      double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
-      double   integrate_scalar_field(const double *field_vertex_values) const;
+      virtual double   evaluate_scalar_field(const CartVect& xi, const double *field_vertex_values) const;
+      virtual double   integrate_scalar_field(const double *field_vertex_values) const;
 
     protected:
       /* Preimages of the vertices -- "canonical vertices" -- are known as "corners". */


https://bitbucket.org/fathomteam/moab/commits/355f928f4bc6/
Changeset:   355f928f4bc6
Branch:      None
User:        iulian07
Date:        2013-09-17 18:40:46
Summary:     merge with master origin
Merge branch 'master' of bitbucket.org:fathomteam/moab

Conflicts:
	tools/mbcslam/process_arm.cpp

Affected #:  63 files

diff --git a/configure.ac b/configure.ac
index b08389a..cc1d3e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -623,7 +623,6 @@ AC_HELP_STRING([--disable-tools],[Disable all tools by default])],
                          [ENABLE_TOOLS=$enableval],[ENABLE_TOOLS=] )
   # Individual tools
 MB_OPTIONAL_TOOL([mbconvert],    [yes])
-MB_OPTIONAL_TOOL([pointsearch],  [no])
 MB_OPTIONAL_TOOL([hexmodops],    [yes])
 MB_OPTIONAL_TOOL([qvdual],       [no] )
 MB_OPTIONAL_TOOL([vtkMOABReader],[${VTKMOAB_DEFAULT}] )
@@ -1184,6 +1183,7 @@ AC_CONFIG_FILES([Makefile
                  src/Makefile
                  src/io/Makefile
                  src/io/mhdf/Makefile
+		 src/LocalDiscretization/Makefile
                  src/parallel/Makefile
                  src/oldinc/Makefile
                  test/Makefile
@@ -1191,6 +1191,7 @@ AC_CONFIG_FILES([Makefile
                  test/dual/Makefile
                  test/obb/Makefile
                  test/perf/Makefile
+                 test/perf/point_location/Makefile
                  test/io/Makefile
                  test/parallel/Makefile
                  test/oldinc/Makefile

diff --git a/examples/makefile b/examples/makefile
index 3b848d2..ff5876c 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -47,6 +47,9 @@ HelloParMOAB: HelloParMOAB.o
 TestExodusII: TestExodusII.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
+point_in_elem_search: point_in_elem_search.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
 clean:
 	rm -rf *.o ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES}
 

diff --git a/examples/old/Makefile.am b/examples/old/Makefile.am
index d0a33b9..21e6da3 100644
--- a/examples/old/Makefile.am
+++ b/examples/old/Makefile.am
@@ -7,7 +7,6 @@
 check_PROGRAMS = FileRead \
                  GeomSetHierarchy \
                  GetEntities \
-                 KDTree \
 		 ObbTree \
                  SetsNTags \
                  SkinMesh \
@@ -28,7 +27,6 @@ GetEntities_SOURCES = simple/GetEntities.cpp
 SetsNTags_SOURCES = SetsNTags.cpp
 SkinMesh_SOURCES = SkinMesh.cpp
 SurfArea_SOURCES = SurfArea.cpp
-KDTree_SOURCES = KDTree.cpp
 ObbTree_SOURCES = ObbTree.cpp
 
 exampledir = ${docdir}/examples
@@ -38,7 +36,6 @@ nobase_example_DATA = \
                GeomSetHierarchy.cpp \
                simple/GetEntities.cpp \
                simple/makefile \
-               KDTree.cpp \
 	       ObbTree.cpp \
                SetsNTags.cpp \
                SkinMesh.cpp \

diff --git a/examples/point_in_elem_search.cpp b/examples/point_in_elem_search.cpp
new file mode 100644
index 0000000..a917fa0
--- /dev/null
+++ b/examples/point_in_elem_search.cpp
@@ -0,0 +1,86 @@
+/** \brief This test shows how to perform local point-in-element searches with MOAB's new tree searching functionality.  
+ *
+ * MOAB's SpatialLocator functionality performs point-in-element searches over a local or parallel mesh.
+ * SpatialLocator is flexible as to what kind of tree is used and what kind of element basis functions are 
+ * used to localize elements and interpolate local fields.
+ */
+
+#include <iostream>
+#include <cstdlib>
+#include <cstdio>
+
+#include "moab/Core.hpp"
+#include "moab/Interface.hpp"
+#include "moab/Range.hpp"
+#include "moab/AdaptiveKDTree.hpp"
+#include "moab/ElemEvaluator.hpp"
+#include "moab/LinearHex.hpp"
+#include "moab/CN.hpp"
+#include "moab/SpatialLocator.hpp"
+
+using namespace moab;
+
+#define ERR(s) if (MB_SUCCESS != rval) \
+    {std::string str;mb.get_last_error(str); std::cerr << s << str << std::endl; return 1;}
+
+int main(int argc, char **argv) {
+
+  int num_queries = 1000000;
+  
+  if (argc == 1) {
+    std::cout << "Usage: " << argv[0] << "<filename> [num_queries]" << std::endl;
+    return 0;
+  }
+  else if (argc == 3) num_queries = atoi(argv[2]);
+
+    // instantiate & load a file
+  moab::Core mb;
+
+    // load the file
+  ErrorCode rval = mb.load_file(argv[argc-1]); ERR("Error loading file");
+  
+    // get all 3d elements in the file
+  Range elems;
+  rval = mb.get_entities_by_dimension(0, 3, elems); ERR("Error getting 3d elements");
+  
+    // create a tree to use for the location service
+  AdaptiveKDTree tree(&mb);
+
+    // specify an evaluator based on linear hexes
+  ElemEvaluator el_eval(&mb);
+
+    // build the SpatialLocator
+  SpatialLocator sl(&mb, elems, &tree);
+  
+    // get the box extents
+  BoundBox box;
+  CartVect box_extents, pos;
+  rval = sl.get_bounding_box(box); ERR("Problem getting tree bounding box");
+  box_extents = box.bMax - box.bMin;
+  
+    // query at random places in the tree
+  CartVect params;
+  bool is_inside;
+  int num_inside = 0;
+  EntityHandle elem;
+  for (int i = 0; i < num_queries; i++) {
+    pos = box.bMin + 
+        CartVect(box_extents[0]*.01*(rand()%100), box_extents[1]*.01*(rand()%100), box_extents[2]*.01*(rand()%100));
+    ErrorCode tmp_rval = sl.locate_point(pos.array(), elem, params.array(), 0.0, 0.0, &is_inside);
+    if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
+    if (is_inside) num_inside++;
+  }
+  
+  std::cout << "Mesh contains " << elems.size() << " elements of type " 
+            << CN::EntityTypeName(mb.type_from_handle(*elems.begin())) << std::endl;
+  std::cout << "Bounding box min-max = (" << box.bMin[0] << "," << box.bMin[1] << "," << box.bMin[2] << ")-("
+            << box.bMax[0] << "," << box.bMax[1] << "," << box.bMax[2] << ")" << std::endl;
+  std::cout << "Queries inside box = " << num_inside << "/" << num_queries << " = " 
+            << 100.0*((double)num_inside)/num_queries << "%" << std::endl;
+}
+
+    
+  
+  
+  
+

This diff is so big that we needed to truncate the remainder.

https://bitbucket.org/fathomteam/moab/commits/54a133a791ac/
Changeset:   54a133a791ac
Branch:      None
User:        iulian07
Date:        2013-09-17 18:42:17
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  1 file

diff --git a/tools/mcnpmit/main.cpp b/tools/mcnpmit/main.cpp
index 7eb0011..eca4b85 100644
--- a/tools/mcnpmit/main.cpp
+++ b/tools/mcnpmit/main.cpp
@@ -12,6 +12,7 @@
 #include "MBTagConventions.hpp"
 #include "moab/AdaptiveKDTree.hpp"
 #include "moab/GeomUtil.hpp"
+#include "moab/FileOptions.hpp"
 #include "../tools/mbcoupler/ElemUtil.hpp"
 
 #define MBI mb_instance()
@@ -61,8 +62,6 @@ int main(int argc, char **argv) {
   moab::ErrorCode                MBresult;
   moab::AdaptiveKDTree           kdtree(MBI);
   moab::EntityHandle             root;
-  moab::AdaptiveKDTree::Settings settings;
-  settings.candidatePlaneSet = moab::AdaptiveKDTree::SUBDIVISION;
 
   MBI->tag_get_handle("CoordTag", 1, moab::MB_TYPE_INTEGER, coord_tag, moab::MB_TAG_DENSE|moab::MB_TAG_CREAT);
   MBI->tag_get_handle("RotationTag", 16, moab::MB_TYPE_DOUBLE, rotation_tag, moab::MB_TAG_DENSE|moab::MB_TAG_CREAT );
@@ -89,8 +88,9 @@ int main(int argc, char **argv) {
     
   }
   else {
-    std::cout << "Building KD-Tree..." << std::endl;      
-    MBresult = kdtree.build_tree( MCNP -> elem_handles, root, &settings);
+    std::cout << "Building KD-Tree..." << std::endl;
+    moab::FileOptions opts("CANDIDATE_PLANE_SET=SUBDIVISION");
+    MBresult = kdtree.build_tree( MCNP -> elem_handles, &root, &opts);
     if (MBresult == moab::MB_SUCCESS) {
 
       MBI->tag_set_data(coord_tag, &root, 1, &(MCNP->coord_system));
@@ -178,9 +178,6 @@ int main(int argc, char **argv) {
 
   bool found = false;
 
-  moab::AdaptiveKDTreeIter    treeiter;
-  kdtree.get_tree_iterator( root, treeiter );
-
   // MBRange verts;
   std::vector<moab::EntityHandle> verts;
   moab::Range range;
@@ -198,8 +195,6 @@ int main(int argc, char **argv) {
 //  double davg = 0.0;
 //  unsigned int    nmax = 0, nmin = 1000000000 ;
 
-  int status_freq = int(num_pts/100);
-
   for (unsigned int i = 0; i < (unsigned int) num_pts; i++) {
 
     // if (i%status_freq == 0)
@@ -228,7 +223,8 @@ int main(int argc, char **argv) {
     testvc[2] = transformed_pt[2];
 
     // Find the leaf containing the point
-    MBresult = kdtree.leaf_containing_point( root, transformed_pt, treeiter);
+    moab::EntityHandle tree_node;
+    MBresult = kdtree.point_search(transformed_pt, tree_node);
     if (moab::MB_SUCCESS != MBresult) {
       double x, y, z;
       if (CARTESIAN == coord_sys) {
@@ -250,7 +246,7 @@ int main(int argc, char **argv) {
     }
 
     range.clear();
-    MBresult = MBI -> get_entities_by_type( treeiter.handle(), moab::MBHEX, range );
+    MBresult = MBI -> get_entities_by_type(tree_node, moab::MBHEX, range );
     assert(MBresult == moab::MB_SUCCESS);
 
     // davg += (double) range.size();


https://bitbucket.org/fathomteam/moab/commits/327c115d9a8c/
Changeset:   327c115d9a8c
Branch:      master
User:        iulian07
Date:        2013-09-17 18:52:38
Summary:     remove process_arm (again)

Affected #:  1 file

diff --git a/tools/mbcslam/process_arm.cpp b/tools/mbcslam/process_arm.cpp
deleted file mode 100644
index da4c284..0000000
--- a/tools/mbcslam/process_arm.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * process_arm.cpp
- *
- *  Created on: April 18, 2013
- */
-
-// process the files from Mark; also, link against netcdf directly, because we will use
-// netcdf calls to read data, the same as in ReadNC and ReadNCDF
-//
-//
-#include <iostream>
-#include <sstream>
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "moab/Core.hpp"
-#include "moab/Interface.hpp"
-#include "moab/ReadUtilIface.hpp"
-#include "moab/AdaptiveKDTree.hpp"
-
-#include "CslamUtils.hpp"
-
-#include "netcdf.h"
-
-#include <algorithm>
-#include <string>
-#include <assert.h>
-
-#include <cmath>
-
-
-using namespace moab;
-
-#define INS_ID(stringvar, prefix, id) \
-          sprintf(stringvar, prefix, id)
-
-#define GET_DIM(ncdim, name, val)\
-    {                            \
-    int gdfail = nc_inq_dimid(ncFile, name, &ncdim);          \
-    if (NC_NOERR == gdfail) {                                             \
-      size_t tmp_val;                                                   \
-      gdfail = nc_inq_dimlen(ncFile, ncdim, &tmp_val);                        \
-      if (NC_NOERR != gdfail) {                                           \
-        std::cout<<"couldn't get dimension length for" << name<< " \n"; \
-        return 1;                                              \
-      }                                                                 \
-      else val = tmp_val;                                               \
-    } else val = 0;}
-
-#define GET_DIMB(ncdim, name, varname, id, val) \
-          INS_ID(name, varname, id); \
-          GET_DIM(ncdim, name, val);
-
-#define GET_VAR(name, id, dims) \
-    {                           \
-    id = -1;\
-    int gvfail = nc_inq_varid(ncFile, name, &id);   \
-    if (NC_NOERR == gvfail) {       \
-    int ndims;\
-    gvfail = nc_inq_varndims(ncFile, id, &ndims);\
-    if (NC_NOERR == gvfail) {\
-    dims.resize(ndims);    \
-    gvfail = nc_inq_vardimid(ncFile, id, &dims[0]);}}}
-
-#define GET_1D_INT_VAR(name, id, vals) \
-    {GET_VAR(name, id, vals);  \
-  if (-1 != id) {\
-    size_t ntmp;\
-    int ivfail = nc_inq_dimlen(ncFile, vals[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    ivfail = nc_get_vara_int(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != ivfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable " <<name <<"\n";\
-      return 1;}}}
-
-
-#define GET_1D_DBL_VAR(name, id, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp);\
-    vals.resize(ntmp);\
-    size_t ntmp1 = 0;                                                           \
-    dvfail = nc_get_vara_double(ncFile, id, &ntmp1, &ntmp, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-/*
-int get_2d_flt_var(int ncFile, const char * name, int index, std::vector<float> & vals)
-{
-  int id;
-  std::vector<int> dum_dims;
-  GET_VAR(name, id, dum_dims);
-  if (-1 != id) {
-    size_t ntmp;
-  int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);
-  vals.resize(ntmp);
-  size_t ntmp1[2] = {index, 0};
-
-  int ntimes;
-  dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntimes);
-  if (index>=ntimes) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  size_t count[2] ={1, ntmp};
-  dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);
-  if (NC_NOERR != dvfail) {
-    std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";
-    return 1;
-  }
-  return 0;
-}
-*/
-/* get the variable along an index */
-#define GET_2D_FLT_VAR(name, id, index, vals) \
-    {std::vector<int> dum_dims;        \
-  GET_VAR(name, id, dum_dims);\
-  if (-1 != id) {\
-    size_t ntmp, ntmp2;\
-    int dvfail = nc_inq_dimlen(ncFile, dum_dims[1], &ntmp);\
-    dvfail = nc_inq_dimlen(ncFile, dum_dims[0], &ntmp2);\
-    vals.resize(ntmp);\
-    size_t ntmp1[2] = {index, 0}; \
-    if (index>=ntmp2) { \
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n"; \
-      return 1; \
-    } \
-    size_t count[2] ={1, ntmp}; \
-    dvfail = nc_get_vara_float(ncFile, id, ntmp1, count, &vals[0]);\
-    if (NC_NOERR != dvfail) {\
-      std::cout<<"ReadNCDF:: Problem getting variable "<< name<<"\n";\
-      return 1;}}}
-
-int main(int argc, char ** argv)
-{
-
-  int num_el = 50000;
-  if (argc>1)
-  {
-    num_el = atoi(argv[1]);
-  }
-  std::cout << "num_el=" << num_el << "\n";
-
-  Core moab;
-  Interface & mb = moab;
-  ErrorCode rval;
-
-  int ncFile, temp_dim;        // netcdf/exodus file
-
-  // now, open the data file and read the lat, lon and U850 and V850
-  const char *data_file = "fc5_arm12.cam2.h2.0004-12-12-00000.nc";
-
-  int fail = nc_open(data_file, 0, &ncFile);
-  if (NC_NOWRITE != fail) {
-    std::cout<<"ReadNCDF:: problem opening Netcdf/Exodus II "<<data_file <<"\n";
-    return 1;
-  }
-  int ncol;
-  GET_DIM(temp_dim, "ncol", ncol);
-  std::cout << "ncol:" << ncol << "\n";
-
-  std::vector<double> lat;
-  std::vector<double> lon;
-  GET_1D_DBL_VAR("lat", temp_dim, lat);
-
-  GET_1D_DBL_VAR("lon", temp_dim, lon);
-
-  std::cout<< " lat, lon 0" << lat[0] << " " << lon[0] << "\n";
-  std::cout<< " lat, lon 1" << lat[1] << " " << lon[1] << "\n";
-  std::cout << " size: " << lat.size() << "\n";
-
-  // see if the mesh from metadata makes sense
-  // create quads with the connectivity from conn array
-
-  ReadUtilIface* readMeshIface;
-  mb.query_interface( readMeshIface );
-  if (NULL==readMeshIface)
-    return 1;
-  EntityHandle node_handle = 0;
-  std::vector<double*> arrays;
-  rval = readMeshIface->get_node_coords(3, ncol,
-      1, node_handle, arrays);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  SphereCoords  sp;
-  sp.R = 1.;
-  Tag gid;
-  rval = mb.tag_get_handle("GLOBAL_ID", 1, MB_TYPE_INTEGER,
-      gid, MB_TAG_SPARSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-      return 1;
-  std::vector<int> gids(ncol);
-
-  double conversion_factor = M_PI/180.;
-  for (int k=0; k<ncol; k++)
-  {
-    sp.lat=lat[k]*conversion_factor;
-    sp.lon=lon[k]*conversion_factor;
-    CartVect pos=spherical_to_cart (sp);
-    arrays[0][k]=pos[0];
-    arrays[1][k]=pos[1];
-    arrays[2][k]=pos[2];
-    gids[k]=k+1;
-  }
-
-  Range nodes(node_handle, node_handle+ncol-1);
-  rval = mb.tag_set_data(gid, nodes, &gids[0]);
-  if (MB_SUCCESS!= rval)
-       return 1;
-
-  EntityHandle newSet;
-  rval = mb.create_meshset(MESHSET_SET, newSet);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  // so the nodes will be part
-  mb.add_entities(newSet, nodes);
-
-  // build a kd tree with the vertices
-  EntityHandle tree_root = 0;
-  AdaptiveKDTree kd(&mb);
-  rval = kd.build_tree(nodes, &tree_root);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  unsigned int  min_depth, max_depth;
-  rval = kd.compute_depth(tree_root, min_depth, max_depth);
-  if (MB_SUCCESS != rval)
-     return 1;
-  std::cout << "min_depth, max_depth " << min_depth << " " << max_depth << "\n";
-  // now, read the conn file created using spectral visu, and see how they fit
-  // this can be directly imported to moab
-  const char *myconn_file = "spec.R2.vtk";
-  EntityHandle euler_set;
-  rval = mb.create_meshset(MESHSET_SET, euler_set);
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  rval = mb.load_file(myconn_file, &euler_set);
-
-  if (MB_SUCCESS != rval)
-    return 1;
-
-  mb.list_entities(&euler_set, 1);
-
-  Range specQuads;
-  rval = mb.get_entities_by_dimension(euler_set, 2, specQuads );
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  Range vertices;
-  rval = mb.get_connectivity(specQuads, vertices);
-  if (MB_SUCCESS != rval)
-     return 1;
-
-  // do a mapping, from position of vertices to the vertices in the kd tree.
-  // find the closest vertex to each of this
-  std::vector<EntityHandle> mappedTo(vertices.size());
-  std::vector<double> mycoords(vertices.size()*3);
-  rval = mb.get_coords(vertices, &mycoords[0]);
-  double * ptr = &mycoords[0];
-  size_t num_verts=vertices.size();
-  for (size_t i=0; i<num_verts; i++, ptr+=3)
-  {
-    CartVect pos(ptr); // take 3 coordinates
-    std::vector<EntityHandle> leaves;
-    rval = kd.distance_search( ptr,
-                               0.001,
-                               leaves);
-    if (MB_SUCCESS != rval)
-      return 1;
-    Range closeVerts;
-    for (std::vector<EntityHandle>::iterator vit = leaves.begin(); vit != leaves.end(); vit++)
-    {
-      rval= mb.get_entities_by_handle(*vit, closeVerts, Interface::UNION);
-      if (moab::MB_SUCCESS != rval)
-        return 1;
-    }
-    if (closeVerts.size()<1)
-    {
-      std::cout << "increase tolerance, no points close to " << pos << "\n";
-      return 1;
-    }
-    std::vector<CartVect> coordsTarget(closeVerts.size());
-    rval = mb.get_coords(closeVerts, &(coordsTarget[0][0]));
-    if (MB_SUCCESS != rval)
-      return 1;
-    double minDist2=(pos-coordsTarget[0]).length_squared();
-    EntityHandle closestVertex=closeVerts[0];
-    for (unsigned int j=1; j<closeVerts.size(); j++)
-    {
-      double dist2=(pos-coordsTarget[j]).length_squared();
-      if (minDist2>dist2)
-      {
-        closestVertex = closeVerts[j];
-        minDist2=dist2;
-      }
-    }
-    if (minDist2 > 0.00001)
-    {
-      std::cout << " problem with node " << vertices[i] << "  min dist2:" << minDist2 << "\n";
-      return 1;
-    }
-    mappedTo [i] = closestVertex;
-  }
-
-  num_el = (int)specQuads.size();
-  // tmp_ptr is of type int* and points at the same place as conn
-  EntityHandle * conn = 0;
-
-  EntityHandle elh;
-
-  readMeshIface->get_element_connect(
-          num_el,
-          4,
-          MBQUAD,
-          1,
-          elh,
-          conn);
-
-  EntityHandle firstVertMyMesh=vertices[0];
-  for (int k=0; k<num_el; k++)
-  {
-    const EntityHandle * myconn=0;
-    EntityHandle specElem = specQuads[k];
-    int num_nodes=0;
-    rval = mb.get_connectivity(specElem, myconn, num_nodes);
-    if (MB_SUCCESS != rval || num_nodes !=4)
-      return 1;
-
-    int start_el = k*4;
-    for (int j=0; j<4; j++)
-       conn[start_el+j] = mappedTo[myconn[j]-firstVertMyMesh];
-  }
-  std::cout << " conn:" << conn[0] << " " << conn[1] << " " << conn[3]<< "\n";
-  Range erange(elh, elh+num_el-1);
-
-  mb.add_entities(newSet, erange);
-  std::vector<int> gidels(num_el);
-  Tag gid2;
-  rval = mb.tag_get_handle("GLOBAL_ID_EL", 1, MB_TYPE_INTEGER,
-        gid2, MB_TAG_SPARSE|MB_TAG_CREAT);
-
-  if (MB_SUCCESS != rval)
-      return 1;
-  for (int k=0; k<num_el; k++)
-    gidels[k]=k+1;
-  mb.tag_set_data(gid2, erange, &gidels[0]);
-
-  // For now, comment out times to remove compile warning (variable ‘times’ set but not used)
-  //int times;
-  //GET_DIM(temp_dim, "time", times);
-
-  Tag velotag;
-  rval = mb.tag_get_handle("VELO", 3, MB_TYPE_DOUBLE,
-            velotag, MB_TAG_DENSE|MB_TAG_CREAT);
-  if (MB_SUCCESS!= rval)
-    return 1;
-
-  for (size_t tt=0; tt<56 /*(size_t)times*/; tt++)
-  {
-    // now, read velocities from file:
-    // read the U850 and V850 variables
-    std::vector<float> u850;
-    GET_2D_FLT_VAR("U850", temp_dim, tt, u850);
-    std::vector<float> v850;
-    GET_2D_FLT_VAR("V850", temp_dim, tt, v850);
-
-    std::cout << " U850:" << u850[0] << " " << u850[1] << " " << u850[5] << " "<< u850.size()<<"\n";
-    std::cout << " V850:" << v850[0] << " " << v850[1] << " " << v850[5] << " "<< u850.size()<<"\n";
-    // ok, use radius as 6371km; not needed
-
-    std::vector<CartVect> velo850(ncol);
-
-    std::stringstream fileName;
-    fileName << "VELO0" <<  tt << ".h5m";
-    std::cout << " read velocities at 850 for time:" << tt << "\n";
-
-
-    for (int k=0; k<ncol; k++)
-    {
-      double latRad=lat[k]*conversion_factor;
-      double lonRad=lon[k]*conversion_factor;
-      CartVect U(-sin(lonRad), cos(lonRad), 0.);
-      CartVect V(-sin(latRad)*cos(lonRad), -sin(latRad)*cos(lonRad), cos(latRad));
-      velo850[k]=U*u850[k] +V*v850[k];
-    }
-    rval = mb.tag_set_data(velotag, nodes, &(velo850[0][0]));
-    if (MB_SUCCESS!= rval)
-      return 1;
-    rval = mb.write_mesh(fileName.str().c_str(), &newSet, 1);
-    if (MB_SUCCESS!= rval)
-      return 1;
-  }
-
-
-
-  return 0;
-}

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