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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Jul 27 14:30:40 CDT 2013


2 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/723a5944e461/
Changeset:   723a5944e461
Branch:      None
User:        tautges
Date:        2013-07-27 21:12:56
Summary:     Move SetsNTags example.

Affected #:  2 files

diff --git a/examples/SetsNTags.cpp b/examples/SetsNTags.cpp
new file mode 100644
index 0000000..9930891
--- /dev/null
+++ b/examples/SetsNTags.cpp
@@ -0,0 +1,87 @@
+#include "moab/Core.hpp"
+#include "moab/Interface.hpp"
+#include "moab/Range.hpp"
+
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+#include <iostream>
+
+int main(int argc, char **argv) {
+    // 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;
+
+    // instantiate & load a file
+  moab::Interface *mb = new moab::Core();
+  const char *par_opt = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;SETS=SETS";
+
+  bool parallel = false;
+  if (argc > 2 && !strcmp(argv[1], "-p")) parallel = true;
+  else if (argc == 1) {
+    std::cout << "Usage: " << argv[0] << "[-p] <filename>" << std::endl;
+    return 0;
+  }
+
+  if (parallel) 
+    rval = mb->load_file(argv[argc-1], 0, par_opt);
+  else
+    rval = mb->load_file(argv[argc-1]);
+  if (moab::MB_SUCCESS != rval) return 1;
+
+    // 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;
+      set_ents.print("   ");
+      set_ents.clear();
+    }
+  }
+
+    // do the same for all sets
+  sets.clear();
+  rval = mb->get_entities_by_type(0, moab::MBENTITYSET, sets);
+  if (moab::MB_SUCCESS != rval) return 1;
+
+    // print the sets
+  rval = mb->list_entities(sets);
+  if (moab::MB_SUCCESS != rval) return 1;
+
+  rval = mb->list_entities(NULL, 1);
+  
+#ifdef USE_MPI
+  if (parallel) {
+    MPI_Barrier(MPI_COMM_WORLD);
+    std::cout << std::flush;
+    std::cerr << std::flush;
+  }
+#endif
+
+  delete mb;
+}

diff --git a/examples/old/SetsNTags.cpp b/examples/old/SetsNTags.cpp
deleted file mode 100644
index 9930891..0000000
--- a/examples/old/SetsNTags.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "moab/Core.hpp"
-#include "moab/Interface.hpp"
-#include "moab/Range.hpp"
-
-#ifdef USE_MPI
-#include "moab_mpi.h"
-#endif
-
-#include <iostream>
-
-int main(int argc, char **argv) {
-    // 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;
-
-    // instantiate & load a file
-  moab::Interface *mb = new moab::Core();
-  const char *par_opt = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;SETS=SETS";
-
-  bool parallel = false;
-  if (argc > 2 && !strcmp(argv[1], "-p")) parallel = true;
-  else if (argc == 1) {
-    std::cout << "Usage: " << argv[0] << "[-p] <filename>" << std::endl;
-    return 0;
-  }
-
-  if (parallel) 
-    rval = mb->load_file(argv[argc-1], 0, par_opt);
-  else
-    rval = mb->load_file(argv[argc-1]);
-  if (moab::MB_SUCCESS != rval) return 1;
-
-    // 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;
-      set_ents.print("   ");
-      set_ents.clear();
-    }
-  }
-
-    // do the same for all sets
-  sets.clear();
-  rval = mb->get_entities_by_type(0, moab::MBENTITYSET, sets);
-  if (moab::MB_SUCCESS != rval) return 1;
-
-    // print the sets
-  rval = mb->list_entities(sets);
-  if (moab::MB_SUCCESS != rval) return 1;
-
-  rval = mb->list_entities(NULL, 1);
-  
-#ifdef USE_MPI
-  if (parallel) {
-    MPI_Barrier(MPI_COMM_WORLD);
-    std::cout << std::flush;
-    std::cerr << std::flush;
-  }
-#endif
-
-  delete mb;
-}


https://bitbucket.org/fathomteam/moab/commits/9bc4354a5e8a/
Changeset:   9bc4354a5e8a
Branch:      master
User:        tautges
Date:        2013-07-27 21:30:33
Summary:     - adding SetsNTags example
- modifying a few mesh files to include dirichlet/neumann sets

Affected #:  5 files

diff --git a/MeshFiles/unittest/125hex.g b/MeshFiles/unittest/125hex.g
index 6cf0433..2042583 100644
Binary files a/MeshFiles/unittest/125hex.g and b/MeshFiles/unittest/125hex.g differ

diff --git a/MeshFiles/unittest/1hex.g b/MeshFiles/unittest/1hex.g
index 3dcd658..0affc6e 100644
Binary files a/MeshFiles/unittest/1hex.g and b/MeshFiles/unittest/1hex.g differ

diff --git a/MeshFiles/unittest/1khex.g b/MeshFiles/unittest/1khex.g
index e6c9417..6b0a8fc 100644
Binary files a/MeshFiles/unittest/1khex.g and b/MeshFiles/unittest/1khex.g differ

diff --git a/examples/SetsNTags.cpp b/examples/SetsNTags.cpp
index 9930891..83d7ace 100644
--- a/examples/SetsNTags.cpp
+++ b/examples/SetsNTags.cpp
@@ -1,87 +1,77 @@
+/** @example SetsNTags.cpp
+ * Description: Get the sets representing materials and Dirichlet/Neumann boundary conditions and list their contents.\n
+ * This example shows how to get entity sets, and tags on those sets.
+ *
+ * To run: ./SetsNTags [meshfile]\n
+ * (default values can run if users don't specify a mesh file)
+ */
+
 #include "moab/Core.hpp"
 #include "moab/Interface.hpp"
 #include "moab/Range.hpp"
+#include "MBTagConventions.hpp"
+
+#include <iostream>
 
-#ifdef USE_MPI
-#include "moab_mpi.h"
+using namespace moab;
+using namespace std;
+
+#ifndef MESH_DIR
+#define MESH_DIR "."
 #endif
 
-#include <iostream>
+string test_file_name = string(MESH_DIR) + string("/125hex.g");
+
+// tag names for these conventional tags come from MBTagConventions.hpp
+const char *tag_nms[] = {MATERIAL_SET_TAG_NAME, DIRICHLET_SET_TAG_NAME, NEUMANN_SET_TAG_NAME};
 
 int main(int argc, char **argv) {
     // 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;
+  Tag mtag;
+  ErrorCode rval;
+  Range sets, set_ents;
 
     // instantiate & load a file
-  moab::Interface *mb = new moab::Core();
-  const char *par_opt = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;SETS=SETS";
-
-  bool parallel = false;
-  if (argc > 2 && !strcmp(argv[1], "-p")) parallel = true;
-  else if (argc == 1) {
-    std::cout << "Usage: " << argv[0] << "[-p] <filename>" << std::endl;
-    return 0;
-  }
+  Interface *mb = new Core();
+
+    // need option handling here for input filename
+  if (argc > 1){
+    //user has input a mesh file
+    test_file_name = argv[1];
+  }  
 
-  if (parallel) 
-    rval = mb->load_file(argv[argc-1], 0, par_opt);
-  else
-    rval = mb->load_file(argv[argc-1]);
-  if (moab::MB_SUCCESS != rval) return 1;
+  rval = mb->load_file(test_file_name.c_str());
+  if (MB_SUCCESS != rval) return 1;
 
     // 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 the tag handle for this tag name; tag should already exist (it was created during file read)
+    rval = mb->tag_get_handle(tag_nms[i], 1, MB_TYPE_INTEGER, mtag);
+    if (MB_SUCCESS != rval) return 1;
 
-      // get all the sets of that type in the mesh
+      // get all the sets having that tag (with any value for that tag)
     sets.clear();
-    rval = mb->get_entities_by_type_and_tag(0, moab::MBENTITYSET, &mtag,
-                                            NULL, 1, sets);
-    if (moab::MB_SUCCESS != rval) return 1;
+    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &mtag, NULL, 1, sets);
+    if (MB_SUCCESS != rval) return 1;
 
-      // iterate over each set, getting entities
-    moab::Range::iterator set_it;
+      // iterate over each set, getting the entities and printing them
+    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;
+      rval = mb->tag_get_data(mtag, &(*set_it), 1, &set_id);
+      if (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;
+      rval = mb->get_entities_by_handle(*set_it, set_ents, true);
+      if (MB_SUCCESS != rval) return 1;
 
-      std::cout << tag_nms[i] << " " << set_id << " has " 
-                << set_ents.size() << " entities:" << std::endl;
+      cout << tag_nms[i] << " " << set_id << " has " 
+                << set_ents.size() << " entities:" << endl;
       set_ents.print("   ");
       set_ents.clear();
     }
   }
 
-    // do the same for all sets
-  sets.clear();
-  rval = mb->get_entities_by_type(0, moab::MBENTITYSET, sets);
-  if (moab::MB_SUCCESS != rval) return 1;
-
-    // print the sets
-  rval = mb->list_entities(sets);
-  if (moab::MB_SUCCESS != rval) return 1;
-
-  rval = mb->list_entities(NULL, 1);
-  
-#ifdef USE_MPI
-  if (parallel) {
-    MPI_Barrier(MPI_COMM_WORLD);
-    std::cout << std::flush;
-    std::cerr << std::flush;
-  }
-#endif
-
   delete mb;
 }

diff --git a/examples/makefile b/examples/makefile
index c9b0978..34b8c3c 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -7,39 +7,43 @@ include ${MOAB_DIR}/lib/iMesh-Defs.inc
 # MESH_DIR is the top-level MOAB source directory, used to locate mesh files that come with MOAB source
 MESH_DIR="../MeshFiles/unittest"
 
-EXAMPLES = StructuredMeshSimple HelloMOAB DirectAccessWithHoles DirectAccessNoHoles GetEntities
+EXAMPLES = HelloMOAB GetEntities SetsNTags StructuredMeshSimple DirectAccessWithHoles DirectAccessNoHoles 
 PAREXAMPLES = HelloParMOAB ReduceExchangeTags
+F90EXAMPLES = DirectAccessNoHolesF90
 EXOIIEXAMPLES = TestExodusII
 
 default: ${EXAMPLES}
 
-StructuredMeshSimple : StructuredMeshSimple.o
-	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
-
 HelloMOAB : HelloMOAB.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
-ReduceExchangeTags : ReduceExchangeTags.o
+GetEntities: GetEntities.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
-HelloMoabPar: HelloMoabPar.o
-	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
-
-TestExodusII: TestExodusII.o
+SetsNTags: SetsNTags.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
+StructuredMeshSimple : StructuredMeshSimple.o
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
+
 DirectAccessWithHoles: DirectAccessWithHoles.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
 DirectAccessNoHoles: DirectAccessNoHoles.o
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
-GetEntities: GetEntities.o
-	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
-
 DirectAccessNoHolesF90: DirectAccessNoHolesF90.o
 	${MOAB_CXX} -o $@ $< ${IMESH_LIBS}
 
+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}
+
 clean:
 	rm -rf *.o ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES}

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