[MOAB-dev] r1655 - MOAB/trunk/tools/iMesh

tautges at mcs.anl.gov tautges at mcs.anl.gov
Thu Mar 13 15:47:33 CDT 2008


Author: tautges
Date: 2008-03-13 15:47:33 -0500 (Thu, 13 Mar 2008)
New Revision: 1655

Added:
   MOAB/trunk/tools/iMesh/partest.cpp
Modified:
   MOAB/trunk/tools/iMesh/Makefile.am
   MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
Corrected parsing of string options in load_mesh implementation.  Adding a test which is conditionally compiled if compiling parallel.


Modified: MOAB/trunk/tools/iMesh/Makefile.am
===================================================================
--- MOAB/trunk/tools/iMesh/Makefile.am	2008-03-13 20:46:43 UTC (rev 1654)
+++ MOAB/trunk/tools/iMesh/Makefile.am	2008-03-13 20:47:33 UTC (rev 1655)
@@ -16,6 +16,12 @@
 check_PROGRAMS = testc_cbind
 testc_cbind_SOURCES = testc_cbind.c
 
+if PARALLEL
+  check_PROGRAMS += partest
+  partest_SOURCES = partest.cpp
+  partest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
+endif
+
 LDADD = libiMesh.la $(top_builddir)/libMOAB.la ${MOAB_CXX_LDFLAGS} ${MOAB_CXX_LIBS}
 testc_cbind_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la
 

Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-03-13 20:46:43 UTC (rev 1654)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-03-13 20:47:33 UTC (rev 1655)
@@ -258,18 +258,14 @@
                    const char *name, const char *options, 
                    int *err, int name_len, int options_len) 
 {
-    // get filename & attempt to NULL-terminate
-  char tmp_filename[1024];
-  std::fill(tmp_filename, tmp_filename+1024, '\0');
-  strncpy(tmp_filename, name, name_len);
-  tmp_filename[MIN(1023, name_len)] = '\0';
-  char *tmp_pos = strchr(tmp_filename, '.');
-  if (NULL != tmp_pos) {
-    tmp_pos = strchr(tmp_pos, ' ');
-    if (NULL != tmp_pos) *tmp_pos = '\0';
-  }
+    // get filename, option & null-terminate
+  std::string tmp_filename(name, name_len), 
+    tmp_options(options, options_len);
+
+  MBEntityHandle file_set;
   
-  MBErrorCode result = MBI->load_mesh(tmp_filename);
+  MBErrorCode result = MBI->load_file(tmp_filename.c_str(), file_set, 
+                                      tmp_options.c_str());
 
   if (MB_SUCCESS != result) {
     std::string msg("iMesh_load:ERROR loading a mesh, with error type: ");

Added: MOAB/trunk/tools/iMesh/partest.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/partest.cpp	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/partest.cpp	2008-03-13 20:47:33 UTC (rev 1655)
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <stdio.h>
+#include "mpi.h"
+#include "iMesh.h"
+
+
+#define IMESH_ASSERT(ierr) if (ierr!=0) printf("imesh asser\n");
+#define IMESH_NULL 0
+
+int main(int argc, char* argv[]){
+  MPI_Init(&argc, &argv);
+  printf("Hello\n");
+
+  iMesh_Instance imesh;
+  int ierr, num_sets;
+
+
+  imesh = IMESH_NULL;
+  iMesh_newMesh("", &imesh, &ierr, 0);
+  IMESH_ASSERT(ierr);
+
+
+  const char options[] = "PARALLEL=BCAST_DELETE;PARTITION=MATERIAL_SET;PARTITION_DISTRIBUTE;";
+  const char filename[] = "64bricks_1mhex.h5m";
+
+  iMesh_load(imesh,
+             IMESH_NULL,
+             filename,
+             options,
+             &ierr,
+             strlen(filename),
+             strlen(options));
+  IMESH_ASSERT(ierr);
+
+  
+  iMesh_getNumEntSets(imesh,
+                      IMESH_NULL,
+                      1,
+                      &num_sets,
+                      &ierr);
+  IMESH_ASSERT(ierr);
+  printf("There's %d entity sets here\n", num_sets);
+
+
+  printf("Done\n");
+  MPI_Finalize(); //probably the 4th time this is called.. no big deal
+
+}




More information about the moab-dev mailing list