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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Oct 4 17:04:08 CDT 2013


2 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/2d2c2a1df4c9/
Changeset:   2d2c2a1df4c9
Branch:      None
User:        iulian07
Date:        2013-10-05 00:00:34
Summary:     fix the skinner for padded polygons
check the next vertex when building side edges
assume that the last vertices could be repeating

Affected #:  1 file

diff --git a/src/Skinner.cpp b/src/Skinner.cpp
index c3c6b1b..02acf2c 100644
--- a/src/Skinner.cpp
+++ b/src/Skinner.cpp
@@ -424,6 +424,7 @@ ErrorCode Skinner::find_skin_noadj(const Range &source_entities,
   for(iter = source_entities.begin(); iter != end_iter; ++iter)
   {
     // get the connectivity of this entity
+    int actual_num_nodes_polygon=0;
     result = thisMB->get_connectivity(*iter, conn, num_nodes, false, &tmp_conn_vec);
     if (MB_SUCCESS != result)
       return result;
@@ -434,7 +435,13 @@ ErrorCode Skinner::find_skin_noadj(const Range &source_entities,
     // treat separately polygons (also, polyhedra will need special handling)
     if (MBPOLYGON == type)
     {
-      num_sides = num_nodes;
+      // treat padded polygons, if existing; count backwards, see how many of the last nodes are repeated
+      // assume connectivity is fine, otherwise we could be in trouble
+      actual_num_nodes_polygon = num_nodes;
+      while (actual_num_nodes_polygon >= 3 &&
+          conn[actual_num_nodes_polygon-1]==conn[actual_num_nodes_polygon-2])
+        actual_num_nodes_polygon--;
+      num_sides = actual_num_nodes_polygon;
       sub_type = MBEDGE;
       num_sub_nodes = 2;
     }
@@ -445,7 +452,9 @@ ErrorCode Skinner::find_skin_noadj(const Range &source_entities,
       if(MBPOLYGON==type)
       {
         sub_conn[0] = conn[i];
-        sub_conn[1] = conn[(i+1)%num_sides];
+        sub_conn[1] = conn[i+1];
+        if (i+1 == actual_num_nodes_polygon)
+          sub_conn[1]=conn[0];
       }
       else
       {
@@ -1431,8 +1440,17 @@ ErrorCode Skinner::create_side( EntityHandle elem,
     }
     if (len == i)
       return MB_FAILURE; // not found, big error
+    // now, what if the polygon is padded?
+    // the previous index is fine always. but the next one could be trouble :(
     int prevIndex = (i+len-1)%len;
     int nextIndex = (i+1)%len;
+    // if the next index actually point to the same node, as current, it means it is padded
+    if (conn[nextIndex]== conn[i])
+    {
+      // it really means we are at the end of proper nodes, the last nodes are repeated, so it should
+      // be the first node
+      nextIndex = 0; // this is the first node!
+    }
     EntityHandle conn2[2] = {side_conn[0], side_conn[1]};
     if (conn[prevIndex]==side_conn[1])
     {
@@ -1617,9 +1635,12 @@ ErrorCode Skinner::find_skin_vertices_2D( Tag tag,
         }
       }
 
-      const int prev_idx = (idx + len - 1)%len;
+      // so it must be a MBPOLYGON
+      const int prev_idx = (idx + len - 1)%len; // this should be fine, always, even for padded case
       prev = conn[prev_idx];
       next = conn[(idx+1)%len];
+      if (next == conn[idx]) // it must be the padded case, so roll to the beginning
+        next = conn[0];
       
         // Insert sides (edges) in our list of candidate skin sides
       adj_edges.insert( &prev, 1, *i, prev_idx );


https://bitbucket.org/fathomteam/moab/commits/96425776d048/
Changeset:   96425776d048
Branch:      master
User:        iulian07
Date:        2013-10-05 00:03:41
Summary:     Merge branch 'master' of https://bitbucket.org/fathomteam/moab

Affected #:  1 file

diff --git a/test/io/read_mpas_nc.cpp b/test/io/read_mpas_nc.cpp
index d442577..0bc2d5a 100644
--- a/test/io/read_mpas_nc.cpp
+++ b/test/io/read_mpas_nc.cpp
@@ -11,6 +11,7 @@ static const char example[] = "/io/mpasx1.642.t.2.nc";
 
 #ifdef USE_MPI
 #include "moab_mpi.h"
+#include "moab/ParallelComm.hpp"
 #endif
 
 void test_read_all();
@@ -18,6 +19,7 @@ void test_read_onevar();
 void test_read_onetimestep();
 void test_read_nomesh();
 void test_read_novars();
+void test_read_no_mixed_elements();
 
 ErrorCode get_options(std::string& opts);
 
@@ -30,7 +32,7 @@ int main(int argc, char* argv[])
   if (fail)
     return 1;
 #else
-  argv[0] = argv[argc-argc]; // To remove the warnings in serial mode about unused variables
+  argv[0] = argv[argc - argc]; // To remove the warnings in serial mode about unused variables
 #endif
 
   result += RUN_TEST(test_read_all);
@@ -38,6 +40,8 @@ int main(int argc, char* argv[])
   result += RUN_TEST(test_read_onetimestep);
   result += RUN_TEST(test_read_nomesh);
   result += RUN_TEST(test_read_novars);
+  // Test read option NO_MIXED_ELEMENTS
+  result += RUN_TEST(test_read_no_mixed_elements);
 
 #ifdef USE_MPI
   fail = MPI_Finalize();
@@ -69,74 +73,84 @@ void test_read_all()
   rval = mb.tag_get_handle("vorticity1", 1, MB_TYPE_DOUBLE, vorticity_tag1);
   CHECK_ERR(rval);
 
-  // Get vertices (1280 edges)
-  Range verts;
-  rval = mb.get_entities_by_type(0, MBVERTEX, verts);
-  assert(rval == MB_SUCCESS);
-  CHECK_EQUAL((size_t)1280, verts.size());
-  CHECK_EQUAL((size_t)1, verts.psize());
-
-  // Check vorticity tag values on first two vertices
-  EntityHandle vert_ents[] = {verts[0], verts[1]};
-  rval = mb.tag_get_data(vorticity_tag0, &vert_ents[0], 2, val);
-  CHECK_REAL_EQUAL(1.1, val[0], eps);
-  CHECK_REAL_EQUAL(1.2, val[1], eps);
-  rval = mb.tag_get_data(vorticity_tag1, &vert_ents[0], 2, val);
-  CHECK_REAL_EQUAL(2.1, val[0], eps);
-  CHECK_REAL_EQUAL(2.2, val[1], eps);
-
-  // Check tags for edge variable u
-  Tag u_tag0, u_tag1;
-  rval = mb.tag_get_handle("u0", 1, MB_TYPE_DOUBLE, u_tag0);
-  CHECK_ERR(rval);
-  rval = mb.tag_get_handle("u1", 1, MB_TYPE_DOUBLE, u_tag1);
-  CHECK_ERR(rval);
-
-  // Get edges (1920 edges)
-  Range edges;
-  rval = mb.get_entities_by_type(0, MBEDGE, edges);
-  assert(rval == MB_SUCCESS);
-  CHECK_EQUAL((size_t)1920, edges.size());
-  CHECK_EQUAL((size_t)1, edges.psize());
-
-  // Check u tag values on two specified edges
-  EntityHandle edge_ents[] = {edges[5], edges[6]};
-  rval = mb.tag_get_data(u_tag0, &edge_ents[0], 2, val);
-  CHECK_REAL_EQUAL(1.113138721544778, val[0], eps);
-  CHECK_REAL_EQUAL(-1.113138721930009, val[1], eps);
-  rval = mb.tag_get_data(u_tag1, &edge_ents[0], 2, val);
-  CHECK_REAL_EQUAL(2.113138721544778, val[0], eps);
-  CHECK_REAL_EQUAL(-2.113138721930009, val[1], eps);
-
-  // Check tags for cell variable ke
-  Tag ke_tag0, ke_tag1;
-  rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
-  CHECK_ERR(rval);
-  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
-  CHECK_ERR(rval);
+  // Check values of tag T0 at some strategically chosen places below
+  int procs = 1;
+#ifdef USE_MPI
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  procs = pcomm->proc_config().proc_size();
+#endif
 
-  // Get cells (12 pentagons and 630 hexagons)
-  Range cells;
-  rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
-  assert(rval == MB_SUCCESS);
-  CHECK_EQUAL((size_t)642, cells.size());
+  // Make check runs this test in one processor
+  if (1 == procs) {
+    // Get vertices (1280 edges)
+    Range verts;
+    rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+    assert(rval == MB_SUCCESS);
+    CHECK_EQUAL((size_t)1280, verts.size());
+    CHECK_EQUAL((size_t)1, verts.psize());
+
+    // Check vorticity tag values on first two vertices
+    EntityHandle vert_ents[] = {verts[0], verts[1]};
+    rval = mb.tag_get_data(vorticity_tag0, &vert_ents[0], 2, val);
+    CHECK_REAL_EQUAL(1.1, val[0], eps);
+    CHECK_REAL_EQUAL(1.2, val[1], eps);
+    rval = mb.tag_get_data(vorticity_tag1, &vert_ents[0], 2, val);
+    CHECK_REAL_EQUAL(2.1, val[0], eps);
+    CHECK_REAL_EQUAL(2.2, val[1], eps);
+
+    // Check tags for edge variable u
+    Tag u_tag0, u_tag1;
+    rval = mb.tag_get_handle("u0", 1, MB_TYPE_DOUBLE, u_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("u1", 1, MB_TYPE_DOUBLE, u_tag1);
+    CHECK_ERR(rval);
+
+    // Get edges (1920 edges)
+    Range edges;
+    rval = mb.get_entities_by_type(0, MBEDGE, edges);
+    assert(rval == MB_SUCCESS);
+    CHECK_EQUAL((size_t)1920, edges.size());
+    CHECK_EQUAL((size_t)1, edges.psize());
+
+    // Check u tag values on two specified edges
+    EntityHandle edge_ents[] = {edges[5], edges[6]};
+    rval = mb.tag_get_data(u_tag0, &edge_ents[0], 2, val);
+    CHECK_REAL_EQUAL(1.113138721544778, val[0], eps);
+    CHECK_REAL_EQUAL(-1.113138721930009, val[1], eps);
+    rval = mb.tag_get_data(u_tag1, &edge_ents[0], 2, val);
+    CHECK_REAL_EQUAL(2.113138721544778, val[0], eps);
+    CHECK_REAL_EQUAL(-2.113138721930009, val[1], eps);
+
+    // Check tags for cell variable ke
+    Tag ke_tag0, ke_tag1;
+    rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+    CHECK_ERR(rval);
+    rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+    CHECK_ERR(rval);
+
+    // Get cells (12 pentagons and 630 hexagons)
+    Range cells;
+    rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+    assert(rval == MB_SUCCESS);
+    CHECK_EQUAL((size_t)642, cells.size());
 #ifdef USE_MPI
-  // If MOAB is compiled parallel, sequence size requested are increased
-  // by a factor of 1.5, to allow for ghosts. This will introduce a gap
-  // between the two face sequences.
-  CHECK_EQUAL((size_t)2, cells.psize());
+    // If MOAB is compiled parallel, sequence size requested are increased
+    // by a factor of 1.5, to allow for ghosts. This will introduce a gap
+    // between the two face sequences.
+    CHECK_EQUAL((size_t)2, cells.psize());
 #else
   CHECK_EQUAL((size_t)1, cells.psize());
 #endif
 
-  // Check ke tag values on first pentagon and first hexagon
-  EntityHandle cell_ents[] = {cells[0], cells[12]};
-  rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
-  CHECK_REAL_EQUAL(1.5, val[0], eps);
-  CHECK_REAL_EQUAL(1.6, val[1], eps);
-  rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
-  CHECK_REAL_EQUAL(2.5, val[0], eps);
-  CHECK_REAL_EQUAL(2.6, val[1], eps);
+    // Check ke tag values on first pentagon and first hexagon
+    EntityHandle cell_ents[] = {cells[0], cells[12]};
+    rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(1.5, val[0], eps);
+    CHECK_REAL_EQUAL(1.6, val[1], eps);
+    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(2.5, val[0], eps);
+    CHECK_REAL_EQUAL(2.6, val[1], eps);
+  }
 }
 
 void test_read_onevar() 
@@ -261,6 +275,55 @@ void test_read_novars()
   CHECK_ERR(rval);
 }
 
+void test_read_no_mixed_elements()
+{
+  Core moab;
+  Interface& mb = moab;
+  std::string opts;
+  ErrorCode rval = get_options(opts);
+  CHECK_ERR(rval);
+
+  opts += std::string(";NO_MIXED_ELEMENTS;VARIABLE=ke");
+  rval = mb.load_file(example, NULL, opts.c_str());
+  CHECK_ERR(rval);
+
+  // Check for proper tags
+  Tag ke_tag0, ke_tag1;
+  rval = mb.tag_get_handle("ke0", 1, MB_TYPE_DOUBLE, ke_tag0);
+  CHECK_ERR(rval);
+  rval = mb.tag_get_handle("ke1", 1, MB_TYPE_DOUBLE, ke_tag1);
+  CHECK_ERR(rval);
+
+  int procs = 1;
+#ifdef USE_MPI
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  procs = pcomm->proc_config().proc_size();
+#endif
+
+  // Make check runs this test in one processor
+  if (1 == procs) {
+    // Get cells (12 pentagons and 630 hexagons)
+    Range cells;
+    rval = mb.get_entities_by_type(0, MBPOLYGON, cells);
+    assert(rval == MB_SUCCESS);
+    CHECK_EQUAL((size_t)642, cells.size());
+    // Only one group of cells (each cell is actually represented by a 10-vertex polygon)
+    CHECK_EQUAL((size_t)1, cells.psize());
+
+    const double eps = 1e-20;
+    double val[2];
+
+    // Check ke tag values on first pentagon and first hexagon
+    EntityHandle cell_ents[] = {cells[0], cells[12]};
+    rval = mb.tag_get_data(ke_tag0, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(1.5, val[0], eps);
+    CHECK_REAL_EQUAL(1.6, val[1], eps);
+    rval = mb.tag_get_data(ke_tag1, &cell_ents[0], 2, val);
+    CHECK_REAL_EQUAL(2.5, val[0], eps);
+    CHECK_REAL_EQUAL(2.6, val[1], eps);
+  }
+}
+
 ErrorCode get_options(std::string &opts) 
 {
 #ifdef USE_MPI

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