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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Apr 15 18:48:19 CDT 2013


3 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/a0cd248833d4/
Changeset:   a0cd248833d4
Branch:      None
User:        tautges
Date:        2013-04-16 01:44:53
Summary:     Removing -E.

Affected #:  1 file

diff --git a/examples/makefile b/examples/makefile
index bf7bdb0..742cd01 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -8,4 +8,4 @@ StructuredMeshSimple : StructuredMeshSimple.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
 
 .cpp.o:
-	${MOAB_CXX} -c ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -E $<
+	${MOAB_CXX} -c ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" $<


https://bitbucket.org/fathomteam/moab/commits/7c6b603fb04e/
Changeset:   7c6b603fb04e
Branch:      None
User:        tautges
Date:        2013-04-16 01:45:16
Summary:     Renamed this example.

Affected #:  1 file

diff --git a/examples/StructuredMeshSimple.cpp b/examples/StructuredMeshSimple.cpp
new file mode 100644
index 0000000..d357951
--- /dev/null
+++ b/examples/StructuredMeshSimple.cpp
@@ -0,0 +1,110 @@
+/* \example StructuredMeshSimple StructuredMeshSimple.cpp
+ * \brief Show creation and query of structured mesh, serial or parallel, through MOAB's structured mesh interface.
+ * This is an example showing creation and query of a 3D structured mesh.  In serial, a single N*N*N block of elements
+ * is created; in parallel, each proc gets an N*N*N block, with blocks arranged in a 1d column, sharing vertices
+ * and faces at their interfaces (proc 0 has no left neighbor and proc P-1 no right neighbor).
+ * Each square block of hex elements is then referenced by its ijk parameterization.
+ * 1D and 2D examples could be made simply by changing the dimension parameter passed into the MOAB functions.
+ *
+ * This example:
+ * 0. Instantiate MOAB and get the structured mesh interface
+ * 1. Decide what the local parameters of the mesh will be, based on parallel/serial and rank.
+ * 2. Create a N^d structured mesh, which includes (N+1)^d vertices and N^d elements.
+ * 3. Get the vertices and elements from moab and check their numbers against (N+1)^d and N^d, resp.
+ * 4. Loop over elements in d nested loops over i, j, k; for each (i,j,k):
+ * 4a. Get the element corresponding to (i,j,k)
+ * 4b. Get the connectivity of the element
+ * 4c. Get the coordinates of the vertices comprising that element
+ * 5. Release the structured mesh interface and destroy the MOAB instance
+ *
+ * To run: ./structuredmesh [d [N] ]
+ * (default values so can run w/ no user interaction)
+ */
+
+#include "moab/Core.hpp"
+#include "moab/ScdInterface.hpp"
+#include "moab/ProgOptions.hpp"
+#include "moab/CN.hpp"
+#include <iostream>
+#include <vector>
+
+using namespace moab;
+
+int main(int argc, char **argv) 
+{
+  int N = 10, dim = 3;
+
+  ProgOptions opts;
+  opts.addOpt<int>(std::string("dim,d"), std::string("Dimension of mesh (default=3)"),
+                   &dim);
+  opts.addOpt<int>(std::string(",n"), std::string("Number of elements on a side (default=10)"),
+                   &N);
+  opts.parseCommandLine(argc, argv);
+  
+    // 0. Instantiate MOAB and get the structured mesh interface
+  Interface *mb = new Core();
+  ScdInterface *scdiface;
+  ErrorCode rval = mb->query_interface(scdiface); // get a ScdInterface object through moab instance
+  if (MB_SUCCESS != rval) return rval;
+
+    // 1. Decide what the local parameters of the mesh will be, based on parallel/serial and rank.
+  int ilow = 0, ihigh = N;
+  int rank = 0, nprocs = 1;
+#ifdef USE_MPI
+  MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  ilow = rank*N; ihigh = ilow + N;
+#endif  
+
+    // 2. Create a N^d structured mesh, which includes (N+1)^d vertices and N^d elements.
+  ScdBox *box;
+  rval = scdiface->construct_box(HomCoord(ilow, (dim>1?0:-1), (dim>2?0:-1)), // use in-line logical tests to handle dimensionality
+                                 HomCoord(ihigh, (dim>1?N:-1), (dim>2?N:-1)), 
+                                 NULL, 0, // NULL coords vector and 0 coords (don't specify coords for now)
+                                 box);    // box is the structured box object providing the parametric
+                                          // structured mesh interface for this rectangle of elements
+  if (MB_SUCCESS != rval) return rval;
+
+    // 3. Get the vertices and elements from moab and check their numbers against (N+1)^d and N^d, resp.
+  Range verts, elems;
+  rval = mb->get_entities_by_dimension(0, 0, verts); // first '0' specifies "root set", or entire MOAB instance, second the entity dimension being requested
+  if (MB_SUCCESS != rval) return rval;
+  rval = mb->get_entities_by_dimension(0, dim, elems);
+  if (MB_SUCCESS != rval) return rval;
+
+#define MYSTREAM(a) if (!rank) std::cout << a << std::endl
+  
+  if (pow(N,dim) == (int) elems.size() && pow(N+1,dim) == (int) verts.size()) { // expected #e and #v are N^d and (N+1)^d, resp.
+#ifdef USE_MPI
+    MYSTREAM("Proc 0: ");
+#endif
+    MYSTREAM("Created " << elems.size() << " " << CN::EntityTypeName(mb->type_from_handle(*elems.begin())) 
+             << " elements and " << verts.size() << " vertices." << std::endl);
+  }
+  else
+    std::cout << "Created the wrong number of vertices or hexes!" << std::endl;
+  
+    // 4. Loop over elements in 3 nested loops over i, j, k; for each (i,j,k):
+  std::vector<double> coords(3*pow(N+1,dim));
+  std::vector<EntityHandle> connect;
+  for (int k = 0; k < (dim>2?N:1); k++) {
+    for (int j = 0; j < (dim>1?N:1); j++) {
+      for (int i = 0; i < N-1; i++) {
+          // 4a. Get the element corresponding to (i,j,k)
+        EntityHandle ehandle = box->get_element(i, j, k);
+        if (0 == ehandle) return MB_FAILURE;
+          // 4b. Get the connectivity of the element
+        rval = mb->get_connectivity(&ehandle, 1, connect); // get the connectivity, in canonical order
+        if (MB_SUCCESS != rval) return rval;
+          // 4c. Get the coordinates of the vertices comprising that element
+        rval = mb->get_coords(connect.data(), connect.size(), coords.data()); // get the coordinates of those vertices
+        if (MB_SUCCESS != rval) return rval;
+      }
+    }
+  }
+
+    // 5. Release the structured mesh interface and destroy the MOAB instance
+  mb->release_interface(scdiface); // tell MOAB we're done with the ScdInterface
+  delete mb;
+  
+  return 0;
+}


https://bitbucket.org/fathomteam/moab/commits/a339cd2826af/
Changeset:   a339cd2826af
Branch:      master
User:        tautges
Date:        2013-04-16 01:46:58
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Conflicts:
	examples/makefile

Affected #:  9 files

diff --git a/.gitignore b/.gitignore
index fe08584..6d29b5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,11 @@
 MOABConfig.cmake
+moab.files
+config/test-driver
 moab.config
+moab.includes
+moab.creator*
+*.ccm
+*.cub
 aclocal.m4
 autom4te.cache/
 config.h
@@ -22,6 +28,7 @@ configure
 doc/config.tex
 doc/dev.dox
 doc/user.dox
+doc/user/*
 examples/examples.make
 itaps/iBase_f.h
 itaps/igeom/FBiGeom-Defs.inc
@@ -66,3 +73,115 @@ 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/coords_connect_iterate
+test/cropvol_test
+test/dual/dual_test
+test/file_options_test
+test/geom_util_test
+test/gttool_test
+test/h5file/dump_sets
+test/h5file/h5legacy
+test/h5file/h5partial
+test/h5file/h5portable
+test/h5file/h5regression
+test/h5file/h5sets_test
+test/h5file/h5test
+test/h5file/h5varlen
+test/*.g
+test/homxform_test
+test/io/cub_file_test
+test/io/exodus_test
+test/io/gmsh_test
+test/io/ideas_test
+test/io/*.g
+test/io/nastran_test
+test/io/read_cgm_test
+test/io/read_nc
+test/io/read_ucd_nc
+test/io/readutil_test
+test/io/smf_test
+test/io/stl_test
+test/io/tqdcfr
+test/io/vtk_test
+test/kd_tree_test
+test/kd_tree_time
+test/kd_tree_tool
+test/mbcn_test
+test/mbfacet_test
+test/mbground_test
+test/mesh_set_test
+test/moab_test
+test/obb/obb_test
+test/obb/obb_time
+test/obb/obb_tree_tool
+test/obb_test
+test/oldinc/test_oldinc
+test/parallel/*.h5m
+test/parallel/*.vtk
+test/parallel/mbparallelcomm_test
+test/parallel/mhdf_parallel
+test/parallel/par_coupler_test
+test/parallel/par_intx_sph
+test/parallel/parallel_hdf5_test
+test/parallel/parallel_unit_tests
+test/parallel/parallel_write_test
+test/parallel/parmerge
+test/parallel/partcheck
+test/parallel/pcomm_serial
+test/parallel/pcomm_unit
+test/parallel/read_nc_par
+test/parallel/scdpart
+test/parallel/scdtest
+test/parallel/structured3
+test/parallel/uber_parallel_test
+test/parallel/ucdtrvpart
+test/perf/adj_time
+test/perf/perf
+test/perf/perftool
+test/perf/seqperf
+test/perf/tstt_perf_binding
+test/range_test
+test/reorder_test
+test/scdseq_test
+test/seq_man_test
+test/tag_test
+test/test_adj
+test/test_prog_opt
+test/var_len_test
+test/var_len_test_no_template
+test/xform_test
+tools/dagmc/pt_vol_test
+tools/dagmc/ray_fire_test
+tools/dagmc/test_geom
+tools/dagmc/update_coords
+tools/mbcoupler/*.h5m
+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/lagr.h5m
+tools/mbcslam/spec_visu_test
+tools/mbcslam/spectral.vtk
+tools/mbcslam/spherical_area_test
+.project
+.cproject
+examples/*.h5m
+examples/ReduceExchangeTags
+

diff --git a/MeshFiles/unittest/disk.h5m b/MeshFiles/unittest/disk.h5m
new file mode 100644
index 0000000..ef19883
Binary files /dev/null and b/MeshFiles/unittest/disk.h5m differ

diff --git a/doc/user.dox.in b/doc/user.dox.in
index 98d4155..4fed19e 100644
--- a/doc/user.dox.in
+++ b/doc/user.dox.in
@@ -311,7 +311,7 @@ INPUT                  = @top_srcdir@/src @top_srcdir@/src/moab \
                          @top_srcdir@/src/MBEntityType.h \
                          @top_srcdir@/src/parallel/MBParallelConventions.h \
                          @top_srcdir@/tools/ @top_srcdir@/tools/mbcoupler @top_srcdir@/tools/dagmc/DagMC.hpp \
-                         @top_srcdir@/itaps @top_srcdir@/itaps/imesh
+			 @top_srcdir@/itaps @top_srcdir@/itaps/imesh @top_srcdir@/examples
 
 # If the value of the INPUT tag contains directories, you can use the 
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
@@ -339,11 +339,11 @@ EXCLUDE                =
 
 EXCLUDE_PATTERNS       = 
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# The EXAMPLE_PATH tag can be used to specify one or more files or
 # directories that contain example code fragments that are included (see 
 # the \include command).
 
-EXAMPLE_PATH           =  
+EXAMPLE_PATH           =  @top_srcdir@/examples/
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 

diff --git a/examples/HelloMOAB.cpp b/examples/HelloMOAB.cpp
index 9c44832..ee81de9 100644
--- a/examples/HelloMOAB.cpp
+++ b/examples/HelloMOAB.cpp
@@ -1,11 +1,8 @@
-/* \example HelloMOAB HelloMOAB.cpp
- * \Description: read a mesh, get the entities.
- * Prerequisite examples: none
- * better Doxygen-ized, standardized comment section
+/** @example HelloMOAB.cpp
+ * Description: read a mesh, get the entities.\n
+ * HelloMOAB is a simple test file which is used to read meshes from VTK file and test how many entities there are.\n
  *
- * general description: This is a simple file which is used to read meshes from VTK file and test how many entities there are.
- *
- * To run: ./HelloMOAB <mesh file>
+ * To run: ./HelloMOAB <meshfile>\n
  * (default values can run if users don't specify a mesh file)
  */
 
@@ -54,7 +51,7 @@ int main( int argc, char** argv[] )
   rval = iface->get_entities_by_type(0, MBHEX, hex);
   assert(rval == MB_SUCCESS);
 
-
+   //output the number of entities
   cout << "Number of vertices is " << verts.size() <<  endl;
   cout << "Number of edges is " << edges.size() <<  endl;
   cout << "Number of triangular faces is " << tri.size() <<  endl;

diff --git a/examples/HelloMoabPar.cpp b/examples/HelloMoabPar.cpp
new file mode 100644
index 0000000..a5a71aa
--- /dev/null
+++ b/examples/HelloMoabPar.cpp
@@ -0,0 +1,154 @@
+/** @example HelloMoabPar.cpp \n
+ * \brief Read mesh into MOAB in parallel \n
+ * This example shows the simplest way of telling MOAB to read in parallel.
+ *
+ *    -#  Initialize MPI and get the rank and number of processors \n
+ *    -#  Process arguments (file name and options for parallel read) \n
+ *    -#  Initialize MOAB \n
+ *    -#  Load a partitioned file in parallel; \n
+ *    -#  retrieve shared entities on each processor \n
+ *    -#  Filter owned entities among shared ones on each processor \n
+ *    -#  Exchange ghost layers, and repeat the reports \n
+ *
+ * <b>To compile</b>: \n
+ *    make HelloMoabPar MOAB_DIR=<installdir>  \n
+ * <b>To run</b>: mpiexec -np 4 HelloMoabPar \n
+ *  (depending on your configuration, LD_LIBRARY_PATH may need to contain <hdf5>/lib folder)
+ *
+ */
+
+#include "moab/ParallelComm.hpp"
+#include "MBParallelConventions.h"
+#include "moab/Core.hpp"
+#include <iostream>
+
+using namespace moab;
+
+int main(int argc, char **argv)
+{
+  MPI_Init(&argc, &argv);
+
+  int nprocs, rank;
+  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+  std::string filename;
+  std::string options;
+  if (3 != argc)
+  {
+    if (rank == 0)
+    {
+      std::cout << "Usage: " << argv[0] << " <filename><options (separated by;)>\n ";
+    }
+    /* this file has a partition with 4 parts */
+    filename = "../MeshFiles/unittest/disk.h5m";
+    /*  Options for reading
+     *  - read in parallel
+     *  - use PARALLEL_PARTITION tag
+     *  - resolve shared entities after reading
+    */
+    options = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS";
+  }
+  else
+  {
+    filename = argv[1];
+    options = argv[2];
+  }
+  if (rank == 0)
+    std::cout << "reading file " << filename << "\n  with options:" << options <<
+      "\n  on " << nprocs << " processors\n";
+
+  // get MOAB instance and read the file with the specified options
+  Interface *mbImpl = new Core;
+  if (NULL == mbImpl) return 1;
+  ErrorCode rval = mbImpl->load_file(filename.c_str(), 0, options.c_str());
+  if (rval != MB_SUCCESS) return 1;
+
+  // get the ParallelComm instance
+  ParallelComm* pcomm = ParallelComm::get_pcomm(mbImpl, 0);
+  MPI_Comm comm = pcomm->comm();
+  if (0 == pcomm) return 1;
+
+  // get all shared entities with other processors
+  Range shared_ents;
+  rval = pcomm->get_shared_entities(-1, // -1 means all other processors                                    Range &shared_ents,
+      shared_ents);
+  if (rval != MB_SUCCESS) return 1;
+  /* Among shared entities, get those owned by the current processor
+   * For this, use a filter operation;
+   * Each shared entity is owned by exactly one processor;
+   * An entity could be simply-shared (with exactly one other processor) or
+   *  multi-shared.
+   */
+  Range owned_entities;
+  rval = pcomm->filter_pstatus(shared_ents, // pass entities that we want to filter
+      PSTATUS_NOT_OWNED, // status we are looking for
+      PSTATUS_NOT, // operation applied ; so it will return owned entities (!not_owned = owned)
+      -1, // this means all processors
+      &owned_entities);
+  if (rval != MB_SUCCESS) return 1;
+  unsigned int nums[4]={0}; // to store the owned entities per dimension
+  for (int i=0; i<3; i++)
+  {
+    nums[i]=(int)owned_entities.num_of_dimension(i);
+  }
+  int * rbuf;
+  if (rank==0)
+    rbuf = (int *)malloc(nprocs*4*sizeof(int));
+  MPI_Gather( nums, 4, MPI_INT, rbuf, 4, MPI_INT, 0, comm);
+  // print the stats gathered:
+  if (rank == 0)
+  {
+    for (int i=0; i<nprocs; i++)
+    {
+      std::cout << " shared, owned entities on proc " << i << " :" << rbuf[4*i] << " verts, " <<
+          rbuf[4*i+1] << " edges, " << rbuf[4*i+2] << " faces\n";
+    }
+
+  }
+
+  /*
+   * Now exchange 1 layer of ghost elements, using vertices as bridge
+   *   we could have done this as part of reading process, by passing an extra read option
+   *    ";PARALLEL_GHOSTS=2.0.1.0"
+   */
+  rval = pcomm->exchange_ghost_cells(2, // int ghost_dim,
+                                     0, // int bridge_dim,
+                                     1, //int num_layers,
+                                     0, //int addl_ents,
+                                     true); // bool store_remote_handles);
+  if (rval != MB_SUCCESS) return 1;
+
+  // repeat the reports, after ghost exchange
+  shared_ents.clear();
+  owned_entities.clear();
+  rval = pcomm->get_shared_entities(-1, // -1 means all other processors                                    Range &shared_ents,
+        shared_ents);
+  if (rval != MB_SUCCESS) return 1;
+  rval = pcomm->filter_pstatus(shared_ents,
+        PSTATUS_NOT_OWNED,
+        PSTATUS_NOT,
+        -1,
+        &owned_entities);
+  if (rval != MB_SUCCESS)  return 1;
+
+  // find out how many shared entities of each dimension are owned on this processor
+  for (int i=0; i<3; i++)
+    nums[i]=(int)owned_entities.num_of_dimension(i);
+
+  // gather the statistics on processor 0
+  MPI_Gather( nums, 4, MPI_INT, rbuf, 4, MPI_INT, 0, comm);
+  if (rank == 0)
+  {
+    std::cout << " \n\n After exchanging one ghost layer: \n";
+    for (int i=0; i<nprocs; i++)
+    {
+      std::cout << " shared, owned entities on proc " << i << " :" << rbuf[4*i] << " verts, " <<
+          rbuf[4*i+1] << " edges, " << rbuf[4*i+2] << " faces\n";
+    }
+    free(rbuf);
+  }
+  MPI_Finalize();
+
+  return 0;
+}

diff --git a/examples/ReduceExchangeTags.cpp b/examples/ReduceExchangeTags.cpp
new file mode 100644
index 0000000..6c2e7de
--- /dev/null
+++ b/examples/ReduceExchangeTags.cpp
@@ -0,0 +1,228 @@
+/** @example ReduceExchangeTags.cpp
+ * \brief Example program that shows the use case for performing tag data exchange
+ * between parallel processors in order to sync data on shared entities. The reduction
+ * operation on tag data is also shown where the user can perform any of the actions supported
+ * by MPI_Op on data residing on shared entities. \n
+ *
+ * <b>This example </b>:
+ *    -# Initialize MPI and instantiate MOAB
+ *    -# Get user options: Input mesh file name, tag name (default: USERTAG), tag value (default: 1.0)
+ *    -# Create the root and partition sets
+ *    -# Instantiate ParallelComm and read the mesh file in parallel using appropriate options
+ *    -# Create two tags: USERTAG_EXC (exchange) and USERTAG_RED (reduction)
+ *    -# Set tag data and exchange shared entity information between processors
+ *      -# Get entities in all dimensions and set local (current rank, dimension) dependent data for
+ *     exchange tag (USERTAG_EXC)
+ *      -# Perform exchange of tag data so that data on shared entities are synced via ParallelCommunicator.
+ *    -#  Set tag data and reduce shared entity information between processors using MPI_SUM
+ *      -#  Get higher dimensional entities in the current partition and set local (current rank)
+ *     dependent data for reduce tag (USERTAG_EXC)
+ *      -#  Perform the reduction operation (MPI_SUM) on shared entities via ParallelCommunicator.
+ *    -#  Destroy the MOAB instance and finalize MPI
+ *
+ * <b>To run:</b> \n mpiexec -n 2 ./ReduceExchangeTags <mesh_file><tag_name><tag_value> \n
+ * <b>Example:</b> \n mpiexec -n 2 ./ReduceExchangeTags ../MeshFiles/unittest/64bricks_1khex.h5m USERTAG 100 \n
+ *
+ */
+
+#include "moab/ParallelComm.hpp"
+#include "MBParallelConventions.h"
+#include "moab/Core.hpp"
+#include <iostream>
+#include <string>
+#include <sstream>
+
+using namespace moab;
+
+// Error routines for use with MOAB API
+#define CHKERR(CODE, MSG)                                 \
+  do {                                                    \
+    if (MB_SUCCESS != (CODE)) {                           \
+      std::string errstr;  mbi->get_last_error(errstr);   \
+      std::cerr << errstr << std::endl;                   \
+      std::cerr << MSG << std::endl;                      \
+      MPI_Finalize();                                     \
+    }                                                     \
+  } while(false)
+
+// Error routines for use with MPI API
+#define MPICHKERR(CODE, MSG)                              \
+  do {                                                    \
+    if (0 != CODE) {                                      \
+      std::cerr << MSG << std::endl;                      \
+      MPI_Finalize();                                     \
+    }                                                     \
+  } while(false)
+
+#define dbgprint(MSG)                                \
+  do {                                              \
+      if (!rank) std::cerr << MSG << std::endl;     \
+  } while(false)
+
+#define dbgprintall(MSG)                                      \
+  do {                                                        \
+      std::cerr << "[" << rank << "]: " << MSG << std::endl;  \
+  } while(false)
+
+
+// Function to parse input parameters
+ErrorCode get_file_options(int argc, char **argv,
+                           std::string& filename,
+                           std::string& tagName,
+                           double&      tagValues)
+{
+  // get mesh filename
+  if (argc > 1) filename = std::string(argv[1]);
+  else filename = std::string(MESH_DIR) + std::string("/64bricks_1khex.h5m");
+
+  // get tag selection options
+  if (argc > 2) tagName = std::string(argv[2]);
+  else tagName = "USERTAG";
+
+  if (argc > 3)  tagValues = atof(argv[3]);
+  else tagValues = 1.0;
+
+  return MB_SUCCESS;
+}
+
+//
+// Start of main test program
+//
+int main(int argc, char **argv)
+{
+  ErrorCode err;
+  int ierr, rank;
+  std::string filename, tagName;
+  double tagValue;
+  MPI_Comm comm = MPI_COMM_WORLD;
+  /// Parallel Read options:
+  ///   PARALLEL = type {READ_PART}
+  ///   PARTITION = PARALLEL_PARTITION : Partition as you read
+  ///   PARALLEL_RESOLVE_SHARED_ENTS : Communicate to all processors to get the shared adjacencies consistently in parallel
+  ///   PARALLEL_GHOSTS : a.b.c
+  ///                   : a = 3 - highest dimension of entities
+  ///                   : b = 0 -
+  ///                   : c = 1 - number of layers
+  ///   PARALLEL_COMM = index
+  std::string read_options = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION_DISTRIBUTE;PARALLEL_GHOSTS=3.0.1;PARALLEL_COMM=0";
+
+  // Print usage if not enough arguments
+  if (argc < 1) {
+    std::cerr << "Usage: ";
+    std::cerr << argv[0] << " <file_name><tag_name><tag_value>" << std::endl;
+    std::cerr << "file_name    : mesh file name" << std::endl;
+    std::cerr << "tag_name     : name of tag to add to mesh" << std::endl;
+    std::cerr << "tag_value    : a double valued string to set for highest-dimensional entities in the mesh for the named tag" << std::endl;
+
+    ierr = MPI_Finalize();
+    MPICHKERR(ierr, "MPI_Finalize failed; Aborting");
+
+    return 1;
+  }
+
+  // Initialize MPI first
+  ierr = MPI_Init(&argc, &argv);
+  MPICHKERR(ierr, "MPI_Init failed");
+
+  ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  MPICHKERR(ierr, "MPI_Comm_rank failed");
+
+  dbgprint( "********** reduce_exchange_tags **********\n" );
+
+  // Create the moab instance
+  Interface *mbi = new Core();
+  CHKERR(NULL == mbi, "MOAB constructor failed");
+
+  // Get the input options
+  err = get_file_options(argc, argv, filename, tagName, tagValue);
+  CHKERR(err, "get_file_options failed");
+
+  // Print out the input parameters
+  dbgprint( " Input Parameters - " );
+  dbgprint( "   Filenames: " << filename );
+  dbgprint( "   Tag: Name=" << tagName << " Value=" << tagValue << std::endl );
+
+  // Create root sets for each mesh.  Then pass these
+  // to the load_file functions to be populated.
+  EntityHandle rootset, partnset;
+  err = mbi->create_meshset(MESHSET_SET, rootset);
+  CHKERR(err, "Creating root set failed");
+  err = mbi->create_meshset(MESHSET_SET, partnset);
+  CHKERR(err, "Creating partition set failed");
+
+  // Create the parallel communicator object with the partition handle associated with MOAB
+  ParallelComm *parallel_communicator = ParallelComm::get_pcomm( mbi, partnset, &comm );
+
+  // Load the file from disk with given options
+  err = mbi->load_file( filename.c_str(), &rootset, read_options.c_str() );
+  CHKERR(err, "MOAB::load_file failed");
+
+  // Create two tag handles: Exchange and Reduction operations
+  dbgprint( "-Creating tag handle " << tagName << "..." );
+  Tag tagReduce, tagExchange;
+  {
+    std::stringstream sstr;
+    // Create the exchange tag: default name = USERTAG_EXC
+    sstr << tagName << "_EXC";
+    err = mbi->tag_get_handle(sstr.str().c_str(), 1, MB_TYPE_INTEGER, tagExchange, MB_TAG_CREAT|MB_TAG_DENSE, &tagValue);
+    CHKERR(err, "Retrieving tag handles failed");
+
+    // Create the exchange tag: default name = USERTAG_RED
+    sstr.str(""); sstr << tagName << "_RED";
+    err = mbi->tag_get_handle(sstr.str().c_str(), 1, MB_TYPE_DOUBLE, tagReduce, MB_TAG_CREAT|MB_TAG_DENSE, &tagValue);
+    CHKERR(err, "Retrieving tag handles failed");
+  }
+
+  // Perform exchange tag data
+  dbgprint( "-Exchanging tags between processors " );
+  {
+    Range partEnts, dimEnts;
+    for (int dim = 0; dim <= 3; dim++) {
+      // Get all entities of dimension = dim
+      err = mbi->get_entities_by_dimension(rootset, dim, dimEnts, false);
+
+      std::vector<int> tagValues(dimEnts.size(), static_cast<int>(tagValue)*(rank+1)*(dim+1));
+      // Set local tag data for exchange
+      err = mbi->tag_set_data(tagExchange, dimEnts, &tagValues[0]);
+      CHKERR(err, "Setting local tag data failed during exchange phase");
+      // Merge entities into parent set
+      partEnts.merge(dimEnts);
+    }
+
+    // Exchange tags between processors
+    err = parallel_communicator->exchange_tags(tagExchange, partEnts);
+    CHKERR(err, "Exchanging tags between processors failed");
+  }
+
+  // Perform reduction of tag data
+  dbgprint( "-Reducing tags between processors " );
+  {
+    Range partEnts;
+    // Get all higher dimensional entities belonging to current partition
+    err = parallel_communicator->get_part_entities(partEnts);
+    CHKERR(err, "ParallelComm::get_part_entities failed");
+
+    // Output what is in current partition sets
+    dbgprintall( "Number of Partitioned entities: " <<  partEnts.size() );
+    MPI_Barrier(comm);
+
+    // Set local tag data for reduction
+    std::vector<double> tagValues(partEnts.size(), tagValue*(rank+1));
+    err = mbi->tag_set_data(tagReduce, partEnts, &tagValues[0]);
+    CHKERR(err, "Setting local tag data failed during reduce phase");
+
+    Range dummy;
+    // Reduce tag data using MPI_SUM on the interface between partitions
+    err = parallel_communicator->reduce_tags(tagReduce, MPI_SUM, dummy/*partEnts*/);
+    CHKERR(err, "Reducing tags between processors failed");
+  }
+  // Write out to output file to visualize reduction/exchange of tag data
+  mbi->write_file("test.h5m", "H5M", "PARALLEL=WRITE_PART");
+
+  // Done, cleanup
+  delete mbi;
+
+  dbgprint( "\n********** reduce_exchange_tags DONE! **********" );
+  MPI_Finalize();
+  return 0;
+}

diff --git a/examples/TestExodusII.cpp b/examples/TestExodusII.cpp
new file mode 100644
index 0000000..c425f66
--- /dev/null
+++ b/examples/TestExodusII.cpp
@@ -0,0 +1,89 @@
+/** @example TestExodusII.cpp
+ * This example demonstrates how to retrieve material, dirichlet and neumann sets
+ * from an ExodusII file. \n
+ * Sets in MOAB contain entities and have a tag on them to give meaning to the entities.
+ * Tag names: MATERIAL_SET", "DIRICHLET_SET" and "NEUMANN_SET" are reserved and
+ * are associated with their corresponding entity sets.
+ * Sets are traversed to find out the type number of entities contained in each set. \n
+ *
+ * <b>Steps in this example </b>:
+ *    -# Instantiate MOAB
+ *    -# Get input mesh file name and load it.
+ *    -# Loop over the three sets: material, dirichlet and neumann
+ *      -# Get TagHandle and EntitySet(corresponding to the TagHandle)
+ *      -# Loop thru all the EntitySet's
+ *        -# Get the set id and entities in this set
+ *    -# Destroy the MOAB instance
+ *
+ *
+ * <b> To compile: </b>
+ *    make TestExodusII MOAB_DIR=<installdir> \n
+ *
+ * <b> To run: </b>
+ *    -# TestExodusII <mesh-file> \n
+ *    -# TestExodusII (This uses the default <mesh-file>: <MOAB_SRC_DIR>/MeshFiles/unittest/mbtest2.g)
+ */
+#include <iostream>
+
+// Include header for MOAB instance and range
+#include "moab/Core.hpp"
+
+int main(int argc, char **argv) {
+
+  // instantiate & load a file
+  moab::Interface *mb = new moab::Core();
+
+  // If no input is specified load ../MeshFiles/unittest/mbtest2.g
+//  const char* test_file_name =  "../MeshFiles/unittest/mbtest2.g";
+
+  // get the material set tag handle
+  moab::Tag mtag;
+  moab::ErrorCode rval;
+  const char *tag_nms[] = {"MATERIAL_SET", "DIRICHLET_SET", "NEUMANN_SET"};
+  moab::Range sets, set_ents;
+
+  if (argc == 1) {
+      std::cout << "Running default case, loading ../MeshFiles/unittest/mbtest2.g" << std::endl;
+      std::cout << "Usage: " << argv[0] << " <filename>\n" << std::endl;
+      rval = mb->load_file("../MeshFiles/unittest/mbtest2.g");
+    }
+  else{
+      rval = mb->load_file(argv[argc-1]);
+      std::cout << "Loaded mesh file: " << argv[argc-1] << std::endl;
+    }
+
+  // loop over set types
+  for (int i = 0; i < 3; i++) {
+      rval = mb->tag_get_handle(tag_nms[i], 1, moab::MB_TYPE_INTEGER, mtag);
+      if (moab::MB_SUCCESS != rval) return 1;
+
+      // get all the sets of that type in the mesh
+      sets.clear();
+      rval = mb->get_entities_by_type_and_tag(0, moab::MBENTITYSET, &mtag,
+                                              NULL, 1, sets);
+      if (moab::MB_SUCCESS != rval) return 1;
+
+      // iterate over each set, getting entities
+      moab::Range::iterator set_it;
+      for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
+          moab::EntityHandle this_set = *set_it;
+
+          // get the id for this set
+          int set_id;
+          rval = mb->tag_get_data(mtag, &this_set, 1, &set_id);
+          if (moab::MB_SUCCESS != rval) return 1;
+
+          // get the entities in the set, recursively
+          rval = mb->get_entities_by_handle(this_set, set_ents, true);
+          if (moab::MB_SUCCESS != rval) return 1;
+
+          std::cout << tag_nms[i] << " " << set_id << " has "
+                    << set_ents.size() << " entities:" << std::endl;
+
+          // print the entities contained in this set
+          set_ents.print("   ");
+          set_ents.clear();
+        }
+    }
+  delete mb;
+}

diff --git a/examples/makefile b/examples/makefile
index 742cd01..4ec6154 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -1,11 +1,26 @@
 # MOAB_DIR points to top-level install dir, below which MOAB's lib/ and include/ are located
 include ${MOAB_DIR}/lib/moab.make
 
+.SUFFIXES: .o .cpp
+
 # MESH_DIR is the top-level MOAB source directory, used to locate mesh files that come with MOAB source
 MESH_DIR="../MeshFiles/unittest"
 
 StructuredMeshSimple : StructuredMeshSimple.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
 
-.cpp.o:
-	${MOAB_CXX} -c ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" $<
+HelloMOAB : HelloMOAB.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+ReduceExchangeTags : ReduceExchangeTags.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+HelloMoabPar: HelloMoabPar.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
+
+TestExodusII: TestExodusII.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+.cpp.o :
+	${MOAB_CXX} ${MOAB_CXXFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -c $<
+

diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 7189b76..030b9d1 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -1980,7 +1980,7 @@ public:
 //! predicate for STL algorithms.  Returns true if the entity handle is
 //! of the specified type.  For example, to remove all the tris out of a list
 //! of 2D entities retrieved using get_adjacencies you could do
-//! \example std::remove_if(list.begin(), list.end(), type_equals(gMB, MeshTri));
+//! std::remove_if(list.begin(), list.end(), type_equals(gMB, MeshTri));
 class type_equals : public std::unary_function<EntityHandle, bool>
 {
 public:
@@ -2003,7 +2003,7 @@ public:
 //! predicate for STL algorithms.  Returns true if the entity handle is not
 //! of the specified type.  For example, to remove all but the tris out of a list
 //! of 2D entities retrieved using get_adjacencies you could do
-//! \example std::remove_if(list.begin(), list.end(), type_not_equals(gMB, MeshTri));
+//! std::remove_if(list.begin(), list.end(), type_not_equals(gMB, MeshTri));
 class type_not_equals : public std::unary_function<EntityHandle, bool>
 {
 public:

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