[MOAB-dev] commit/MOAB: tautges: makefile: GetEntities: show how to get adjacencies and connectivity
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jul 27 14:04:42 CDT 2013
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/73cc7a794ed7/
Changeset: 73cc7a794ed7
Branch: master
User: tautges
Date: 2013-07-27 21:04:17
Summary: makefile: GetEntities: show how to get adjacencies and connectivity
HelloMOAB: correct usage syntax
Affected #: 3 files
diff --git a/examples/GetEntities.cpp b/examples/GetEntities.cpp
new file mode 100644
index 0000000..6c6a956
--- /dev/null
+++ b/examples/GetEntities.cpp
@@ -0,0 +1,60 @@
+/** @example GetEntities.cpp
+ * Description: Get entities and report non-vertex entity connectivity and vertex adjacencies.\n
+ * This example shows how to get connectivity and adjacencies.\n
+ *
+ * To run: ./GetEntities [meshfile]\n
+ * (default values can run if users don't specify a mesh file)
+ */
+
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/CN.hpp"
+#include <iostream>
+
+using namespace moab;
+using namespace std;
+
+#ifndef MESH_DIR
+#define MESH_DIR "."
+#endif
+
+string test_file_name = string(MESH_DIR) + string("/1hex.g");
+
+int main(int argc, char **argv) {
+
+ if (argc > 1){
+ //user has input a mesh file
+ test_file_name = argv[1];
+ }
+ // instantiate & load a mesh from a file
+ Core *mb = new Core();
+ ErrorCode rval = mb->load_mesh(test_file_name.c_str());
+ if (MB_SUCCESS != rval) return 1;
+
+ Range ents;
+
+ // get all entities in the database
+ rval = mb->get_entities_by_handle(0, ents);
+ if (MB_SUCCESS != rval) return 1;
+
+ for (Range::iterator it = ents.begin(); it != ents.end(); it++) {
+ if (MBVERTEX == mb->type_from_handle(*it)) {
+ Range adjs;
+ rval = mb->get_adjacencies(&(*it), 1, 3, false, adjs);
+ if (MB_SUCCESS != rval) return 1;
+ cout << "Vertex " << mb->id_from_handle(*it) << " adjacencies:" << endl;
+ adjs.print();
+ }
+ else if (mb->type_from_handle(*it) < MBENTITYSET) {
+ const EntityHandle *connect;
+ int num_connect;
+ rval = mb->get_connectivity(*it, connect, num_connect);
+ if (MB_SUCCESS != rval) return 1;
+ cout << CN::EntityTypeName(mb->type_from_handle(*it)) << " " << mb->id_from_handle(*it) << " vertex connectivity is: ";
+ for (int i = 0; i < num_connect; i++) cout << mb->id_from_handle(connect[i]) << " ";
+ cout << endl;
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/HelloMOAB.cpp b/examples/HelloMOAB.cpp
index 11bbc81..6129233 100644
--- a/examples/HelloMOAB.cpp
+++ b/examples/HelloMOAB.cpp
@@ -2,7 +2,7 @@
* 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
*
- * To run: ./HelloMOAB <meshfile>\n
+ * To run: ./HelloMOAB [meshfile]\n
* (default values can run if users don't specify a mesh file)
*/
diff --git a/examples/makefile b/examples/makefile
index 865b390..c9b0978 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -7,7 +7,7 @@ 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
+EXAMPLES = StructuredMeshSimple HelloMOAB DirectAccessWithHoles DirectAccessNoHoles GetEntities
PAREXAMPLES = HelloParMOAB ReduceExchangeTags
EXOIIEXAMPLES = TestExodusII
@@ -34,6 +34,9 @@ DirectAccessWithHoles: DirectAccessWithHoles.o
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}
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