moab-dev
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
July 2014
- 13 participants
- 72 discussions
14 Jul '14
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/6794c6023c0a/
Changeset: 6794c6023c0a
Branch: iulian07/pcomm_delete
User: iulian07
Date: 2014-07-14 23:00:35
Summary: add pcomm delete entities method
the method checks if the entities to be deleted are shared, then informs the
other processors about the change
after entities are deleted, each local list sharedEnds is updated
Affected #: 2 files
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 886ef77..f660c0a 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -8791,7 +8791,77 @@ ErrorCode ParallelComm::settle_intersection_points(Range & edges, Range & shared
return MB_SUCCESS;
// end copy
+}
+ErrorCode ParallelComm::delete_entities(Range & to_delete)
+{
+
+ // will not look at shared sets yet, but maybe we should
+ // first, see if any of the entities to delete is shared; then inform the other processors
+ // about their fate (to be deleted), using a crystal router transfer
+ ErrorCode rval=MB_SUCCESS;
+ unsigned char pstat;
+ EntityHandle tmp_handles[MAX_SHARING_PROCS];
+ int tmp_procs[MAX_SHARING_PROCS];
+ unsigned int num_ps;
+ TupleList ents_to_delete;
+ ents_to_delete.initialize(1, 0, 1, 0, to_delete.size() * (MAX_SHARING_PROCS+1) );// a little bit of overkill
+ ents_to_delete.enableWriteAccess();
+ unsigned int i = 0;
+ for (Range::iterator it=to_delete.begin(); it!=to_delete.end(); it++)
+ {
+ EntityHandle eh=*it; // entity to be deleted
+
+ rval = get_sharing_data(eh, tmp_procs, tmp_handles,
+ pstat, num_ps);
+ if (rval!=MB_SUCCESS || num_ps==0)
+ continue;
+ // add to the tuple list the information to be sent (to the remote procs)
+
+ for (unsigned int p = 0; p < num_ps; p++)
+ {
+ ents_to_delete.vi_wr[i] = tmp_procs[p];
+ ents_to_delete.vul_wr[i] = (unsigned long)tmp_handles[p];
+ i++;
+ ents_to_delete.inc_n();
+ }
+ }
+
+ gs_data::crystal_data *cd = this->procConfig.crystal_router();
+ // all communication happens here; no other mpi calls
+ // also, this is a collective call
+ rval = cd->gs_transfer(1,ents_to_delete,0);
+
+ if (MB_SUCCESS!= rval)
+ {
+ std::cout << "error in tuple transfer\n";
+ return rval;
}
+ // add to the range of ents to delete the new ones that were sent from other procs
+ unsigned int received = ents_to_delete.get_n();
+ for (i=0; i< received; i++)
+ {
+ //int from = ents_to_delete.vi_rd[i];
+ unsigned long valrec = ents_to_delete.vul_rd[i];
+ to_delete.insert((EntityHandle)valrec);
+ }
+ rval = mbImpl->delete_entities(to_delete);
+ if (MB_SUCCESS!= rval)
+ {
+ std::cout << "error in deleting actual entities\n";
+ return rval;
+ }
+ std::vector<EntityHandle> good_ents;
+ for (size_t j=0; j<sharedEnts.size(); j++)
+ {
+ int index=to_delete.index(sharedEnts[j]);
+ if (-1==index)
+ good_ents.push_back(sharedEnts[j]);
+ }
+ sharedEnts = good_ents;
+
+ // what about shared sets? who is updating them?
+ return MB_SUCCESS;
+}
void ParallelComm::print_pstatus(unsigned char pstat, std::string &ostr)
{
diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index 3424c51..976236e 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -932,6 +932,12 @@ namespace moab {
ErrorCode settle_intersection_points(Range & edges, Range & shared_edges_owned,
std::vector<std::vector<EntityHandle> *> & extraNodesVec, double tolerance);
+ /* \brief delete entities from moab database
+ * will check the shared ents array, and clean it if necessary
+ *
+ */
+ ErrorCode delete_entities(Range & to_delete);
+
private:
ErrorCode reduce_void(int tag_data_type, const MPI_Op mpi_op, int num_ents, void *old_vals, void *new_vals);
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.
1
0
commit/MOAB: iulian07: add a new method of merging with a tag
by commits-noreply@bitbucket.org 14 Jul '14
by commits-noreply@bitbucket.org 14 Jul '14
14 Jul '14
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/90aa282ddaf9/
Changeset: 90aa282ddaf9
Branch: iulian07/merge_with_tag
User: iulian07
Date: 2014-07-14 23:03:41
Summary: add a new method of merging with a tag
in the classic method of merging, the vertices on the skin are merged first, using
a kd tree
after vertices are identified to be in close proximity, they are merged.
In this new method, vertices are merged if a tag has the same values
It will be used in the example that generates large mesh
Affected #: 2 files
diff --git a/src/MergeMesh.cpp b/src/MergeMesh.cpp
index cb43b85..62b0022 100644
--- a/src/MergeMesh.cpp
+++ b/src/MergeMesh.cpp
@@ -139,7 +139,79 @@ ErrorCode MergeMesh::perform_merge(Tag merge_tag)
result = mbImpl->delete_entities(deadEnts);
return result;
}
+// merge vertices according to an input tag
+// merge them if the tags are equal
+struct handle_id
+{
+ EntityHandle eh;
+ int val;
+};
+
+// handle structure comparison function for qsort
+// if the id is the same , compare the handle.
+bool compare_handle_id(handle_id ia, handle_id ib) {
+
+ if(ia.val == ib.val) {
+ return ia.eh<ia.eh;
+ } else {
+ return ia.val<ib.val;
+ }
+}
+
+ErrorCode MergeMesh::merge_using_integer_tag(Range & verts, Tag user_tag, Tag merge_tag)
+{
+ ErrorCode rval;
+ DataType tag_type;
+ rval = mbImpl->tag_get_data_type(user_tag, tag_type);
+ if (rval!=MB_SUCCESS || tag_type!=MB_TYPE_INTEGER)
+ return MB_FAILURE;
+ std::vector<int> vals(verts.size());
+ rval = mbImpl->tag_get_data(user_tag, verts, &vals[0]);
+ if (rval!=MB_SUCCESS)
+ return rval;
+
+ if (0 == merge_tag)
+ {
+ EntityHandle def_val = 0;
+ rval = mbImpl->tag_get_handle("__merge_tag", 1, MB_TYPE_HANDLE, mbMergeTag,
+ MB_TAG_DENSE | MB_TAG_EXCL, &def_val);
+ if (MB_SUCCESS != rval)
+ return rval;
+ }
+ else
+ mbMergeTag = merge_tag;
+
+ std::vector<handle_id> handles(verts.size());
+ int i=0;
+ for (Range::iterator vit = verts.begin(); vit!= verts.end(); vit++ )
+ {
+ handles[i].eh=*vit;
+ handles[i].val = vals[i];
+ i++;
+ }
+ std::sort(handles.begin(), handles.end(), compare_handle_id);
+
+ i=0;
+ while (i<(int)verts.size()-1)
+ {
+ handle_id first = handles[i];
+ int j=i+1;
+ while (handles[j].val == first.val && j<(int)verts.size())
+ {
+ rval= mbImpl->tag_set_data(mbMergeTag, &(handles[j].eh), 1, &(first.eh));
+ if (rval!=MB_SUCCESS)
+ return rval;
+ deadEnts.insert(handles[j].eh);
+ j++;
+ }
+ i=j;
+ }
+
+ rval = perform_merge(mbMergeTag);
+
+ return rval;
+}
ErrorCode MergeMesh::find_merged_to(EntityHandle &tree_root,
AdaptiveKDTree &tree, Tag merge_tag)
{
diff --git a/src/moab/MergeMesh.hpp b/src/moab/MergeMesh.hpp
index 8eef9a8..8f4d5bc 100644
--- a/src/moab/MergeMesh.hpp
+++ b/src/moab/MergeMesh.hpp
@@ -32,6 +32,9 @@ public:
//Identify higher dimension to be merged
ErrorCode merge_higher_dimensions(Range &elems);
+ // merge vertices according to an input tag
+ ErrorCode merge_using_integer_tag(Range & verts, Tag user_tag, Tag merge_tag=0);
+
//- perform the actual merge
ErrorCode perform_merge(Tag merged_to);
private:
@@ -39,8 +42,6 @@ private:
double mergeTol, mergeTolSq;
- Tag mergeTag;
-
//- given a kdtree, set tag on vertices in leaf nodes with vertices
//- to which they should be merged
ErrorCode find_merged_to(EntityHandle &tree_root,
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.
1
0
4 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/77a70ae7a5bf/
Changeset: 77a70ae7a5bf
Branch: None
User: danwu
Date: 2014-07-14 17:30:24
Summary: Framework code for enhanced error handling.
Affected #: 6 files
diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp
new file mode 100644
index 0000000..9f0fdee
--- /dev/null
+++ b/src/ErrorHandler.cpp
@@ -0,0 +1,75 @@
+#include "moab/ErrorHandler.hpp"
+#include "ErrorOutput.hpp"
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+#include <stdlib.h>
+
+namespace moab {
+
+static ErrorOutput* errorOutput = NULL;
+
+void MBErrorHandler_Init()
+{
+ if (NULL == errorOutput) {
+ errorOutput = new ErrorOutput(stderr);
+ errorOutput->use_world_rank();
+ }
+}
+
+void MBErrorHandler_Finalize()
+{
+ if (NULL != errorOutput) {
+ delete errorOutput;
+ errorOutput = NULL;
+ }
+}
+
+bool MBErrorHandler_Initialized()
+{
+ return (NULL != errorOutput);
+}
+
+void MBTraceBackErrorHandler(int line, const char* func, const char* file, const char* dir, const char* err_msg, ErrorType err_type)
+{
+ // For a globally fatal error, get world rank of current processor, so that it is only printed from processor 0
+ // For a per-processor relevant error, set rank of current processor to 0, so that it is always printed
+ int rank = 0;
+ if (MB_ERROR_TYPE_NEW_GLOBAL == err_type && NULL != errorOutput && errorOutput->have_rank())
+ rank = errorOutput->get_rank();
+
+ if (0 == rank) {
+ // Print the error messages if it is a new error
+ if (MB_ERROR_TYPE_EXISTING != err_type && NULL != errorOutput && NULL != err_msg) {
+ errorOutput->print("--------------------- Error Message ------------------------------------\n");
+ errorOutput->printf("%s!\n", err_msg);
+ }
+
+ // Print a line of stack trace
+ if (NULL != errorOutput)
+ errorOutput->printf("%s() line %d in %s%s\n", func, line, dir, file);
+ }
+ else {
+ // Do not print the error messages, since processor 0 will print them
+ // Sleep 10 seconds before aborting so it will not accidently kill process 0
+ sleep(10);
+ abort();
+ }
+}
+
+ErrorCode MBError(int line, const char* func, const char* file, const char* dir, ErrorCode err_code, const char* err_msg, ErrorType err_type)
+{
+ MBTraceBackErrorHandler(line, func, file, dir, err_msg, err_type);
+
+#ifdef USE_MPI
+ // If this is called from the main() routine we call MPI_Abort() to allow
+ // the parallel program to be properly shutdown
+ if (strncmp(func, "main", 4) == 0)
+ MPI_Abort(MPI_COMM_WORLD, err_code);
+#endif
+
+ return err_code;
+}
+
+} // namespace moab
diff --git a/src/ErrorOutput.cpp b/src/ErrorOutput.cpp
new file mode 100644
index 0000000..e71e010
--- /dev/null
+++ b/src/ErrorOutput.cpp
@@ -0,0 +1,169 @@
+#include "ErrorOutput.hpp"
+
+#include <iostream>
+#include <string.h>
+#include <algorithm>
+#include <assert.h>
+
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+namespace moab {
+
+class FILEErrorStream : public ErrorOutputStream
+{
+private:
+ FILE* filePtr;
+
+public:
+ FILEErrorStream(FILE* filep) : filePtr(filep) {}
+ void println(int rank, const char* str);
+ void println(const char* str);
+};
+
+void FILEErrorStream::println(int rank, const char* str)
+{
+ fprintf(filePtr, "[%d]MOAB ERROR: %s\n", rank, str);
+ fflush(filePtr);
+}
+
+void FILEErrorStream::println(const char* str)
+{
+ fprintf(filePtr, "MOAB ERROR: %s\n", str);
+ fflush(filePtr);
+}
+
+class CxxErrorStream : public ErrorOutputStream
+{
+private:
+ std::ostream& outStr;
+
+public:
+ CxxErrorStream(std::ostream& str) : outStr(str) {}
+ void println(int rank, const char* str);
+ void println(const char* str);
+};
+
+void CxxErrorStream::println(int rank, const char* str)
+{
+ outStr << "[" << rank << "]MOAB ERROR: " << str << std::endl;
+ outStr.flush();
+}
+
+void CxxErrorStream::println(const char* str)
+{
+ outStr << "MOAB ERROR: " << str << std::endl;
+ outStr.flush();
+}
+
+ErrorOutput::ErrorOutput(FILE* impl)
+ : outputImpl(new FILEErrorStream(impl)),
+ mpiRank(-1)
+{
+ lineBuffer.reserve(1024);
+}
+
+ErrorOutput::ErrorOutput(std::ostream& str)
+ : outputImpl(new CxxErrorStream(str)),
+ mpiRank(-1)
+{
+ lineBuffer.reserve(1024);
+}
+
+ErrorOutput::~ErrorOutput()
+{
+ if (!lineBuffer.empty()) {
+ lineBuffer.push_back('\n');
+ process_line_buffer();
+ }
+
+ if (NULL != outputImpl) {
+ delete outputImpl;
+ outputImpl = NULL;
+ }
+}
+
+void ErrorOutput::use_world_rank()
+{
+#ifdef USE_MPI
+ int flag1;
+ MPI_Initialized(&flag1);
+ int flag2;
+ MPI_Finalized(&flag2);
+ if (flag1 && !flag2)
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
+#endif
+}
+
+void ErrorOutput::print_real(const char* buffer)
+{
+ lineBuffer.insert(lineBuffer.end(), buffer, buffer + strlen(buffer));
+ process_line_buffer();
+}
+
+void ErrorOutput::print_real(const std::string& str)
+{
+ lineBuffer.insert(lineBuffer.end(), str.begin(), str.end());
+ process_line_buffer();
+}
+
+void ErrorOutput::print_real(const char* fmt, va_list args1, va_list args2)
+{
+ size_t idx = lineBuffer.size();
+#ifdef HAVE_VSNPRINTF
+ // try once with remaining space in buffer
+ lineBuffer.resize(lineBuffer.capacity());
+ unsigned size = vsnprintf(&lineBuffer[idx], lineBuffer.size() - idx, fmt, args1);
+ ++size; // trailing null
+ // if necessary, increase buffer size and retry
+ if (size > (lineBuffer.size() - idx)) {
+ lineBuffer.resize(idx + size);
+ size = vsnprintf(&lineBuffer[idx], lineBuffer.size() - idx, fmt, args2);
+ ++size; // trailing null
+ }
+#else
+ // Guess how much space might be required.
+ // If every character is a format code then there are len/3 format codes.
+ // Guess a random large value of 81 characters per formatted argument.
+ unsigned exp_size = 27 * strlen(fmt);
+ lineBuffer.resize(idx + exp_size);
+ unsigned size = vsprintf(&lineBuffer[idx], fmt, args1);
+ ++size; // trailing null
+ // check if we overflowed the buffer
+ if (size > exp_size) {
+ // crap!
+ fprintf(stderr, "ERROR: Buffer overflow at %s:%d\n", __FILE__, __LINE__);
+ lineBuffer.resize(idx + exp_size);
+ size = vsprintf(&lineBuffer[idx], fmt, args2);
+ ++size; // trailing null
+ }
+#endif
+
+ // less one because we don't want the trailing '\0'
+ lineBuffer.resize(idx + size - 1);
+ process_line_buffer();
+}
+
+void ErrorOutput::process_line_buffer()
+{
+ size_t last_idx = 0;
+ std::vector<char>::iterator i;
+ for (i = std::find(lineBuffer.begin(), lineBuffer.end(), '\n');
+ i != lineBuffer.end(); i = std::find(i, lineBuffer.end(), '\n')) {
+ *i = '\0';
+ if (have_rank())
+ outputImpl->println(get_rank(), &lineBuffer[last_idx]);
+ else
+ outputImpl->println(&lineBuffer[last_idx]);
+ ++i;
+ last_idx = i - lineBuffer.begin();
+ }
+
+ if (last_idx) {
+ i = std::copy(lineBuffer.begin() + last_idx, lineBuffer.end(), lineBuffer.begin());
+ lineBuffer.erase(i, lineBuffer.end());
+ }
+}
+
+} // namespace moab
diff --git a/src/ErrorOutput.hpp b/src/ErrorOutput.hpp
new file mode 100644
index 0000000..cd9a03e
--- /dev/null
+++ b/src/ErrorOutput.hpp
@@ -0,0 +1,101 @@
+#ifndef moab_ERROR_OUTPUT_HPP
+#define moab_ERROR_OUTPUT_HPP
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <vector>
+#include <iosfwd>
+#include <string>
+
+#include "moab/Compiler.hpp"
+
+namespace moab {
+
+class ErrorOutputStream;
+
+/**\brief Utility class for printing error output
+ *
+ * This class implements line-oriented output. That is, it buffers
+ * output data until a newline is encountered, at which point it
+ * sends the output to the output stream followed by an explicit
+ * flush, and optionally prefixed with the MPI rank.
+ *
+ * \Note Any output not terminated with an newline character or
+ * followed by later output containing a newline character
+ * will not be flushed until the destructor is invoked.
+ */
+class ErrorOutput {
+public:
+ /**
+ *\param str Output stream to which to flush output
+ */
+ ErrorOutput(FILE* str);
+
+ /**
+ *\param str Output stream to which to flush output
+ */
+ ErrorOutput(std::ostream& str);
+
+ /**
+ * Destructor flushes any remaining output that wasn't followed
+ * by a newline character.
+ */
+ ~ErrorOutput();
+
+ //!\brief Check if MPI rank has been set.
+ bool have_rank() const { return mpiRank >= 0; }
+ //!\brief Get MPI rank.
+ int get_rank() const { return mpiRank; }
+ //!\brief Set MPI rank.
+ void set_rank(int rank) { mpiRank = rank; }
+ //!\brief Set MPI rank to the rank of this process in MPI_COMM_WORLD,
+ //! if MOAB is built with MPI and MPI_Init has been called
+ void use_world_rank();
+
+ //!\brief Output the specified string
+ void print(const char* str) { print_real(str); }
+
+ //!\brief Output the specified string
+ void print(const std::string& str) { print_real(str); }
+
+ //!\brief Output the specified printf-formatted output
+ void printf(const char* fmt, ...) MB_PRINTF(1);
+
+private:
+ ErrorOutputStream* outputImpl;
+ int mpiRank;
+
+ void print_real(const char* buffer);
+ void print_real(const std::string& str);
+
+ // Function must be passed to copies of the same va_list because
+ // a) it might have to call vs(n)printf twice, b) vs(n)printf modifies
+ // the va_list such that it cannot be reused, and c) va_copy is not
+ // (yet) portable (c99, no c++ standard).
+ void print_real(const char* buffer, va_list args1, va_list args2);
+ void process_line_buffer();
+
+ std::vector<char> lineBuffer;
+};
+
+inline void ErrorOutput::printf(const char* fmt, ...)
+{
+ va_list args1, args2;
+ va_start(args1, fmt);
+ va_start(args2, fmt);
+ print_real(fmt, args1, args2);
+ va_end(args2);
+ va_end(args1);
+}
+
+class ErrorOutputStream {
+public:
+ ErrorOutputStream() {}
+ virtual ~ErrorOutputStream() {}
+ virtual void println(const char* str) = 0;
+ virtual void println(int rank, const char* str) = 0;
+};
+
+} // namespace moab
+
+#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index a9adf0d..f55d82c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,9 @@ libMOAB_la_SOURCES = \
ElementSequence.hpp \
EntitySequence.cpp \
EntitySequence.hpp \
+ ErrorHandler.cpp \
+ ErrorOutput.cpp \
+ ErrorOutput.hpp \
Factory.cpp \
FBEngine.cpp \
FileOptions.cpp \
@@ -161,6 +164,7 @@ nobase_libMOAB_la_include_HEADERS = \
moab/HomXform.hpp \
moab/EntityType.hpp \
moab/EntityHandle.hpp \
+ moab/ErrorHandler.hpp \
moab/FBEngine.hpp \
moab/FileOptions.hpp \
moab/FindPtFuncs.h \
diff --git a/src/moab/ErrorHandler.hpp b/src/moab/ErrorHandler.hpp
new file mode 100644
index 0000000..ec91113
--- /dev/null
+++ b/src/moab/ErrorHandler.hpp
@@ -0,0 +1,144 @@
+#ifndef MOAB_ERROR_HANDLER_HPP
+#define MOAB_ERROR_HANDLER_HPP
+
+#include "moab/Types.hpp"
+
+#include <sstream>
+#include <string.h>
+
+namespace moab {
+
+//! ErrorType - passed to the error handling routines indicating if this is a new error (globally fatal
+//! or per-processor relevant) or an existing one
+enum ErrorType {MB_ERROR_TYPE_NEW_GLOBAL = 0, MB_ERROR_TYPE_NEW_LOCAL = 1, MB_ERROR_TYPE_EXISTING = 2};
+
+//! Initialize MOAB error handler (e.g. create a utility object for printing error output)
+void MBErrorHandler_Init();
+
+//! Finalize MOAB error handler (e.g. delete the utility object for printing error output)
+void MBErrorHandler_Finalize();
+
+//! Indicates whether MBErrorHandler_Init has been called
+bool MBErrorHandler_Initialized();
+
+//! Routine that is called when an error has been detected
+ErrorCode MBError(int line, const char* func, const char* file, const char* dir,
+ ErrorCode err_code, const char* err_msg, ErrorType err_type);
+
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+
+#define MBSTRINGIFY_(X) #X
+#define MBSTRINGIFY(X) MBSTRINGIFY_(X)
+
+#ifdef LOCDIR
+#define __SDIR__ MBSTRINGIFY(LOCDIR)
+#else
+#define __SDIR__ ""
+#endif
+
+//! Set a new error with passed error code and passed error message string
+#define SET_ERR(err_code, err_msg) \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, err_msg, MB_ERROR_TYPE_NEW_LOCAL)
+
+//! Set a new error with passed error code and passed error message string stream
+#define SET_ERR_STR(err_code, err_msg_str) \
+ do { \
+ std::ostringstream ostr; \
+ ostr << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_LOCAL); \
+ } while (false)
+
+//! Set a new global error with passed error code and passed error message string
+#define SET_GLB_ERR(err_code, err_msg) \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, err_msg, MB_ERROR_TYPE_NEW_GLOBAL)
+
+//! Set a new global error with passed error code and passed error message string stream
+#define SET_GLB_ERR_STR(err_code, err_msg_str) \
+ do { \
+ std::ostringstream ostr; \
+ ostr << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_GLOBAL); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+#define CHK_ERR(err_code) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, "", MB_ERROR_TYPE_EXISTING); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string
+#define CHK_ERR1(err_code, err_msg_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR(err_code, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string stream
+#define CHK_ERR1_STR(err_code, err_msg_str_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR_STR(err_code, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string
+#define CHK_ERR2(err_code, err_code_to_set, err_msg_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR(err_code_to_set, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_ERR2_STR(err_code, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and default error message string
+#define CHK_EQL(err_code, exp_err_code) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR(MB_FAILURE, "Returned error code is not expected"); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string
+#define CHK_EQL1(err_code, exp_err_code, err_msg_to_set) \
+ do { \
+ if (exp_err_code != err_code) { \
+ SET_ERR(MB_FAILURE, err_msg_to_set); \
+ } \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string stream
+#define CHK_EQL1_STR(err_code, exp_err_code, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR_STR(MB_FAILURE, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string
+#define CHK_EQL2(err_code, exp_err_code, err_code_to_set, err_msg_to_set) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR(err_code_to_set, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_EQL2_STR(err_code, exp_err_code, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
+ } while (false)
+#endif
+
+} // namespace moab
diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 09f4219..8ffe2a3 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -43,6 +43,7 @@
#include "moab/Forward.hpp"
#include "moab/Range.hpp"
#include "moab/Compiler.hpp"
+#include "moab/ErrorHandler.hpp"
// include files
#include <string>
https://bitbucket.org/fathomteam/moab/commits/ac408a159b79/
Changeset: ac408a159b79
Branch: None
User: danwu
Date: 2014-07-14 17:30:24
Summary: Adding example to simulate MOAB's enhanced error handling in parallel. All of the errors are contrived, used for simulation purpose only.
Affected #: 2 files
diff --git a/examples/ErrorHandlingSimulation.cpp b/examples/ErrorHandlingSimulation.cpp
new file mode 100644
index 0000000..ffdc831
--- /dev/null
+++ b/examples/ErrorHandlingSimulation.cpp
@@ -0,0 +1,100 @@
+/** @example ErrorHandlingSimulation.cpp
+ * Description: This example simulates MOAB's enhanced error handling in parallel. \n
+ * All of the errors are contrived, used for simulation purpose only. \n
+ *
+ * <b>To run</b>: mpiexec -np 4 ./ErrorHandlingSimulation <test_case_num(1 to 4)> \n
+ */
+
+#include "moab/ErrorHandler.hpp"
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+#include <iostream>
+#include <stdlib.h>
+
+using namespace moab;
+using namespace std;
+
+// Functions that create and handle contrived errors
+// Call hierarchy: A calls B, and B calls C
+ErrorCode FunctionC(int test_case_num, int rank)
+{
+ switch (test_case_num) {
+ case 1:
+ // Simulate a global fatal error MB_NOT_IMPLEMENTED on all processors
+ // Note, it is printed by root processor 0 only
+ SET_GLB_ERR(MB_NOT_IMPLEMENTED, "A contrived global error MB_NOT_IMPLEMENTED");
+ break;
+ case 2:
+ // Simulate a per-processor relevant error MB_INDEX_OUT_OF_RANGE on all processors
+ // Note, it is printed by all processors
+ SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "A contrived error MB_INDEX_OUT_OF_RANGE on processor " << rank);
+ break;
+ case 3:
+ // Simulate a per-processor relevant error MB_TYPE_OUT_OF_RANGE on all processors except root
+ // Note, it is printed by all non-root processors
+ if (0 != rank)
+ SET_ERR_STR(MB_TYPE_OUT_OF_RANGE, "A contrived error MB_TYPE_OUT_OF_RANGE on processor " << rank);
+ break;
+ case 4:
+ // Simulate a per-processor relevant error MB_INDEX_OUT_OF_RANGE on processor 1
+ // Note, it is printed by processor 1 only
+ if (1 == rank)
+ SET_ERR(MB_INDEX_OUT_OF_RANGE, "A contrived error MB_INDEX_OUT_OF_RANGE on processor 1");
+
+ // Simulate a per-processor relevant error MB_TYPE_OUT_OF_RANGE on processor 3
+ // Note, it is printed by processor 3 only
+ if (3 == rank)
+ SET_ERR(MB_TYPE_OUT_OF_RANGE, "A contrived error MB_TYPE_OUT_OF_RANGE on processor 3");
+ break;
+ default:
+ break;
+ }
+
+ return MB_SUCCESS;
+}
+
+ErrorCode FunctionB(int test_case_num, int rank)
+{
+ ErrorCode err_code = FunctionC(test_case_num, rank);CHK_ERR(err_code);
+
+ return MB_SUCCESS;
+}
+
+ErrorCode FunctionA(int test_case_num, int rank)
+{
+ ErrorCode err_code = FunctionB(test_case_num, rank);CHK_ERR(err_code);
+
+ return MB_SUCCESS;
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 2) {
+ cout << "Usage: " << argv[0] << " <test_case_num(1 to 4)>" << endl;
+ return 0;
+ }
+
+#ifdef USE_MPI
+ MPI_Init(&argc, &argv);
+#endif
+
+ MBErrorHandler_Init();
+
+ int test_case_num = atoi(argv[1]);
+ int rank = 0;
+#ifdef USE_MPI
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+#endif
+
+ ErrorCode rval = FunctionA(test_case_num, rank);CHK_ERR(rval);
+
+ MBErrorHandler_Finalize();
+
+#ifdef USE_MPI
+ MPI_Finalize();
+#endif
+
+ return 0;
+}
diff --git a/examples/makefile b/examples/makefile
index 787c8d3..c4dd9e7 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -11,8 +11,9 @@ EXAMPLES = HelloMOAB GetEntities SetsNTags LoadPartial structuredmesh Structured
PAREXAMPLES = HelloParMOAB ReduceExchangeTags LloydRelaxation CrystalRouterExample
EXOIIEXAMPLES = TestExodusII
F90EXAMPLES = DirectAccessNoHolesF90 PushParMeshIntoMoabF90
+ERROREXAMPLES = ErrorHandlingSimulation
-default: ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES}
+default: ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES} ${ERROREXAMPLES}
HelloMOAB: HelloMOAB.o ${MOAB_LIBDIR}/libMOAB.la
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
@@ -70,9 +71,12 @@ VisTags: VisTags.o ${MOAB_LIBDIR}/libMOAB.la
ReadWriteTest: ReadWriteTest.o ${MOAB_LIBDIR}/libMOAB.la
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
-
+
+ErrorHandlingSimulation: ErrorHandlingSimulation.o ${MOAB_LIBDIR}/libMOAB.la
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
clean:
- rm -rf *.o *.mod *.h5m ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES}
+ rm -rf *.o *.mod *.h5m ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES} ${ERROREXAMPLES}
.cpp.o:
${MOAB_CXX} ${CXXFLAGS} ${MOAB_CXXFLAGS} ${MOAB_CPPFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -c $<
https://bitbucket.org/fathomteam/moab/commits/84ef2def3842/
Changeset: 84ef2def3842
Branch: None
User: danwu
Date: 2014-07-14 17:30:24
Summary: Applied new error handling code to a few places in Core.cpp and ReadParallel.cpp, to test serial or parallel read of climate .nc files (with errors returned) later.
Affected #: 4 files
diff --git a/src/Core.cpp b/src/Core.cpp
index 0bd882f..01b5b9b 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -483,6 +483,7 @@ ErrorCode Core::load_file( const char* file_name,
rval = ReadParallel(this,pcomm).load_file( file_name, file_set, opts, &sl );
else
rval = ReadParallel(this,pcomm).load_file( file_name, file_set, opts );
+ CHK_ERR(rval);
#else
mError->set_last_error( "PARALLEL option not valid, this instance"
" compiled for serial execution.\n" );
@@ -494,6 +495,7 @@ ErrorCode Core::load_file( const char* file_name,
rval = serial_load_file( file_name, file_set, opts, &sl );
else
rval = serial_load_file( file_name, file_set, opts );
+ CHK_ERR(rval);
}
if (MB_SUCCESS == rval && !opts.all_seen()) {
@@ -544,8 +546,9 @@ ErrorCode Core::serial_load_file( const char* file_name,
status = stat(file_name, &stat_data);
#endif
if (status) {
- mError->set_last_error( "%s: %s", file_name, strerror(errno) );
- return MB_FILE_DOES_NOT_EXIST;
+ //mError->set_last_error( "%s: %s", file_name, strerror(errno) );
+ //return MB_FILE_DOES_NOT_EXIST;
+ SET_GLB_ERR_STR(MB_FILE_DOES_NOT_EXIST, file_name << ": " << strerror(errno));
}
#if defined(WIN32) || defined(WIN64) || defined(MSC_VER)
else if (_S_IFDIR(stat_data.st_mode)) {
@@ -608,6 +611,7 @@ ErrorCode Core::serial_load_file( const char* file_name,
if (MB_SUCCESS != rval) {
clean_up_failed_read( initial_ents, initial_tags );
+ SET_ERR(rval, "Failed to load file after trying all possible readers");
}
else if (file_set) {
Range new_ents;
diff --git a/src/Makefile.am b/src/Makefile.am
index f55d82c..bc3a8de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,7 @@ BUILT_SOURCES = MBCN_protos.h
# Some variables
AM_CPPFLAGS += -DIS_BUILDING_MB \
+ -DLOCDIR=src/ \
-I. \
-I$(srcdir)/io \
-I$(srcdir)/io/mhdf/include \
diff --git a/src/parallel/Makefile.am b/src/parallel/Makefile.am
index b80b85e..5a39552 100644
--- a/src/parallel/Makefile.am
+++ b/src/parallel/Makefile.am
@@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = foreign
noinst_LTLIBRARIES = libMOABpar.la
# Some variables
-AM_CPPFLAGS += -DIS_BUILDING_MB -DSRCDIR=$(srcdir) \
+AM_CPPFLAGS += -DIS_BUILDING_MB -DSRCDIR=$(srcdir) -DLOCDIR=src/parallel/ \
-I$(srcdir)/.. -I.. -I$(srcdir)/../io \
-I$(srcdir)/../io/mhdf/include
diff --git a/src/parallel/ReadParallel.cpp b/src/parallel/ReadParallel.cpp
index fe4ed55..06faf6d 100644
--- a/src/parallel/ReadParallel.cpp
+++ b/src/parallel/ReadParallel.cpp
@@ -235,6 +235,7 @@ ErrorCode ReadParallel::load_file(const char **file_names,
reader_rank, cputime,
resolve_dim, shared_dim,
ghost_dim, bridge_dim, num_layers, addl_ents);
+ CHK_ERR(result);
if (parallel_mode == POPT_BCAST_DELETE && !is_reader)
opts.mark_all_seen();
@@ -519,11 +520,12 @@ ErrorCode ReadParallel::load_file(const char **file_names,
if (MB_SUCCESS != tmp_result) {
result = tmp_result;
if (myPcomm->proc_config().proc_size() != 1) {
- std::ostringstream ostr;
- ostr << "Failed in step " << ParallelActionsNames[*vit] << std::endl;
- std::string tmp_str;
- if (MB_SUCCESS == mbImpl->get_last_error(tmp_str)) ostr << tmp_str << std::endl;
- RR(ostr.str());
+ //std::ostringstream ostr;
+ //ostr << "Failed in step " << ParallelActionsNames[*vit] << std::endl;
+ //std::string tmp_str;
+ //if (MB_SUCCESS == mbImpl->get_last_error(tmp_str)) ostr << tmp_str << std::endl;
+ //RR(ostr.str());
+ SET_ERR_STR(result, "Failed in step " << ParallelActionsNames[*vit]);
}
break;
}
https://bitbucket.org/fathomteam/moab/commits/e57113d57239/
Changeset: e57113d57239
Branch: danwu/error_handling_enhancement
User: danwu
Date: 2014-07-14 17:30:24
Summary: Applied new error handling code to ReadNC.cpp and NCHelper.cpp. Added two examples that read climate .nc files and trace back returned errors.
Affected #: 7 files
diff --git a/.gitignore b/.gitignore
index 52e35a8..ae08a0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ examples/DeformMeshRemap
examples/DirectAccessNoHoles
examples/DirectAccessNoHolesF90
examples/DirectAccessWithHoles
+examples/ErrorHandlingSimulation
examples/examples.make
examples/freem.mod
examples/GetEntities
@@ -55,6 +56,8 @@ examples/ReduceExchangeTags
examples/SetsNTags
examples/structuredmesh
examples/StructuredMeshSimple
+examples/TestErrorHandling
+examples/TestErrorHandlingPar
examples/TestExodusII
history??.jou
hpctoolkit-*
diff --git a/examples/TestErrorHandling.cpp b/examples/TestErrorHandling.cpp
new file mode 100644
index 0000000..34d618c
--- /dev/null
+++ b/examples/TestErrorHandling.cpp
@@ -0,0 +1,93 @@
+/** @example TestErrorHandling.cpp \n
+ * Description: This example tests MOAB's trace back error handler in serial. \n
+ *
+ * <b>To run</b>: ./TestErrorHandling <test_case_num(1 to 3)> \n
+ */
+
+#include "moab/Core.hpp"
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+#include <iostream>
+
+using namespace moab;
+using namespace std;
+
+// In this test case, an error MB_NOT_IMPLEMENTED is returned by MOAB
+ErrorCode TestErrorHandling_1()
+{
+ Core moab;
+ Interface& mb = moab;
+
+ // Load a CAM-FV file and read a variable on edges (not supported yet)
+ string test_file = string(MESH_DIR) + string("/io/fv3x46x72.t.3.nc");
+ ErrorCode rval = mb.load_file(test_file.c_str(), NULL, "VARIABLE=US");CHK_ERR(rval);
+
+ return MB_SUCCESS;
+}
+
+// In this test case, an error MB_TYPE_OUT_OF_RANGE is returned by MOAB
+ErrorCode TestErrorHandling_2()
+{
+ Core moab;
+ Interface& mb = moab;
+
+ // Load a HOMME file with an invalid GATHER_SET option
+ string test_file = string(MESH_DIR) + string("/io/homme3x3458.t.3.nc");
+ ErrorCode rval = mb.load_file(test_file.c_str(), NULL, "VARIABLE=T;GATHER_SET=0.1");CHK_ERR(rval);
+
+ return MB_SUCCESS;
+}
+
+// In this test case, an error MB_FAILURE is returned by MOAB
+ErrorCode TestErrorHandling_3()
+{
+ Core moab;
+ Interface& mb = moab;
+
+ // Load a CAM-FV file with and a NULL file set
+ string test_file = string(MESH_DIR) + string("/io/fv3x46x72.t.3.nc");
+ ErrorCode rval = mb.load_file(test_file.c_str(), NULL, "NOMESH;VARIABLE=");CHK_ERR(rval);
+
+ return MB_SUCCESS;
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 2) {
+ cout << "Usage: " << argv[0] << " <test_case_num(1 to 3)>" << endl;
+ return 0;
+ }
+
+#ifdef USE_MPI
+ MPI_Init(&argc, &argv);
+#endif
+
+ MBErrorHandler_Init();
+
+ ErrorCode rval = MB_SUCCESS;
+
+ int test_case_num = atoi(argv[1]);
+ switch (test_case_num) {
+ case 1:
+ rval = TestErrorHandling_1();CHK_ERR(rval);
+ break;
+ case 2:
+ rval = TestErrorHandling_2();CHK_ERR(rval);
+ break;
+ case 3:
+ rval = TestErrorHandling_3();CHK_ERR(rval);
+ break;
+ default:
+ break;
+ }
+
+ MBErrorHandler_Finalize();
+
+#ifdef USE_MPI
+ MPI_Finalize();
+#endif
+
+ return 0;
+}
diff --git a/examples/TestErrorHandlingPar.cpp b/examples/TestErrorHandlingPar.cpp
new file mode 100644
index 0000000..2fd3171
--- /dev/null
+++ b/examples/TestErrorHandlingPar.cpp
@@ -0,0 +1,93 @@
+/** @example TestErrorHandlingPar.cpp \n
+ * Description: This example tests MOAB's trace back error handler in parallel.\n
+ *
+ * <b>To run</b>: mpiexec -np <n> ./TestErrorHandlingPar <test_case_num(1 to 2)> \n
+ */
+
+#include "moab/Core.hpp"
+#ifdef USE_MPI
+#include "moab_mpi.h"
+#endif
+
+#include <iostream>
+
+using namespace moab;
+using namespace std;
+
+// In this test case, a global fatal error MB_NOT_IMPLEMENTED is returned by MOAB
+// Note, it is printed by root processor 0 only
+ErrorCode TestErrorHandlingPar_1()
+{
+ Core moab;
+ Interface& mb = moab;
+
+ std::string opts = ";;";
+#ifdef USE_MPI
+ // Use parallel options
+ opts += "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ";
+#endif
+
+ // Load a CAM-FV file and read a variable on edges (not supported yet)
+ string test_file = string(MESH_DIR) + string("/io/fv3x46x72.t.3.nc");
+ opts += ";VARIABLE=US";
+ ErrorCode rval = mb.load_file(test_file.c_str(), NULL, opts.c_str());CHK_ERR(rval);
+
+ return MB_SUCCESS;
+}
+
+// In this test case, a per-processor relevant error MB_FAILURE is returned by MOAB
+// Note, it is printed by all processors
+ErrorCode TestErrorHandlingPar_2()
+{
+ Core moab;
+ Interface& mb = moab;
+
+ std::string opts = ";;";
+#ifdef USE_MPI
+ // Use parallel options
+ opts += "PARALLEL=READ_PART;PARTITION_METHOD=UNKNOWN";
+#endif
+
+ // Load a CAM-FV file with an unknown partition method specified
+ string test_file = string(MESH_DIR) + string("/io/fv3x46x72.t.3.nc");
+ opts += ";VARIABLE=T";
+ ErrorCode rval = mb.load_file(test_file.c_str(), NULL, opts.c_str());CHK_ERR(rval);
+
+ return MB_SUCCESS;
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 2) {
+ cout << "Usage: " << argv[0] << " <test_case_num(1 to 2>" << endl;
+ return 0;
+ }
+
+#ifdef USE_MPI
+ MPI_Init(&argc, &argv);
+#endif
+
+ MBErrorHandler_Init();
+
+ ErrorCode rval = MB_SUCCESS;
+
+ int test_case_num = atoi(argv[1]);
+ switch (test_case_num) {
+ case 1:
+ rval = TestErrorHandlingPar_1();CHK_ERR(rval);
+ break;
+ case 2:
+ rval = TestErrorHandlingPar_2();CHK_ERR(rval);
+ break;
+ default:
+ break;
+ }
+
+ MBErrorHandler_Finalize();
+
+#ifdef USE_MPI
+ MPI_Finalize();
+#endif
+
+ return 0;
+}
diff --git a/examples/makefile b/examples/makefile
index c4dd9e7..09a5406 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -11,7 +11,7 @@ EXAMPLES = HelloMOAB GetEntities SetsNTags LoadPartial structuredmesh Structured
PAREXAMPLES = HelloParMOAB ReduceExchangeTags LloydRelaxation CrystalRouterExample
EXOIIEXAMPLES = TestExodusII
F90EXAMPLES = DirectAccessNoHolesF90 PushParMeshIntoMoabF90
-ERROREXAMPLES = ErrorHandlingSimulation
+ERROREXAMPLES = ErrorHandlingSimulation TestErrorHandling TestErrorHandlingPar
default: ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES} ${ERROREXAMPLES}
@@ -67,14 +67,20 @@ DeformMeshRemap: DeformMeshRemap.o ${MOAB_LIBDIR}/libMOAB.la
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} -lmbcoupler ${MOAB_LIBS_LINK}
VisTags: VisTags.o ${MOAB_LIBDIR}/libMOAB.la
- ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
ReadWriteTest: ReadWriteTest.o ${MOAB_LIBDIR}/libMOAB.la
- ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
ErrorHandlingSimulation: ErrorHandlingSimulation.o ${MOAB_LIBDIR}/libMOAB.la
${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+TestErrorHandling: TestErrorHandling.o ${MOAB_LIBDIR}/libMOAB.la
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+TestErrorHandlingPar: TestErrorHandlingPar.o ${MOAB_LIBDIR}/libMOAB.la
+ ${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
clean:
rm -rf *.o *.mod *.h5m ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES} ${ERROREXAMPLES}
diff --git a/src/io/Makefile.am b/src/io/Makefile.am
index 2d2d60b..d0f8d48 100644
--- a/src/io/Makefile.am
+++ b/src/io/Makefile.am
@@ -10,6 +10,7 @@ noinst_LTLIBRARIES = libmoabio.la
libmoabio_la_LIBADD = $(NETCDF_LIBS) $(PNETCDF_LIBS) $(CGNS_LIBS) $(HDF5_LIBS)
AM_CPPFLAGS += -DIS_BUILDING_MB \
+ -DLOCDIR=src/io/ \
-I.. -I$(srcdir)/.. -I$(srcdir)/../parallel
if NETCDF_FILE
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 613ce13..27dd3f7 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -7,15 +7,8 @@
#include <sstream>
-#include "moab/ReadUtilIface.hpp"
#include "MBTagConventions.hpp"
-#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
-
-#define ERRORS(err, str) \
- if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
-
namespace moab {
NCHelper* NCHelper::get_nc_helper(ReadNC* readNC, int fileId, const FileOptions& opts, EntityHandle fileSet)
@@ -54,7 +47,7 @@ NCHelper* NCHelper::get_nc_helper(ReadNC* readNC, int fileId, const FileOptions&
return new (std::nothrow) NCHelperHOMME(readNC, fileId, opts, fileSet);
// gcrm reader
else if (NCHelperGCRM::can_read_file(readNC))
- return new (std::nothrow) NCHelperGCRM(readNC, fileId, opts, fileSet);
+ return new (std::nothrow) NCHelperGCRM(readNC, fileId, opts, fileSet);
}
// Unknown NetCDF grid (will fill this in later for POP, CICE and CLM)
@@ -80,22 +73,20 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
tag_name = "__NUM_DIMS";
int numDims = dimNames.size();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 1, MB_TYPE_INTEGER, numDimsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __NUM_DIMS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(numDimsTag, &_fileSet, 1, &numDims);
- ERRORR(rval, "Trouble setting data for __NUM_DIMS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__NUM_VARS>
Tag numVarsTag = 0;
tag_name = "__NUM_VARS";
int numVars = varInfo.size();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 1, MB_TYPE_INTEGER, numVarsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __NUM_VARS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(numVarsTag, &_fileSet, 1, &numVars);
- ERRORR(rval, "Trouble setting data for __NUM_VARS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__DIM_NAMES>
Tag dimNamesTag = 0;
@@ -108,24 +99,22 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
}
int dimnamesSz = dimnames.size();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, dimNamesTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __DIM_NAMES tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
const void* ptr = dimnames.c_str();
rval = mbImpl->tag_set_by_ptr(dimNamesTag, &_fileSet, 1, &ptr, &dimnamesSz);
- ERRORR(rval, "Trouble setting data for __DIM_NAMES tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__DIM_LENS>
Tag dimLensTag = 0;
tag_name = "__DIM_LENS";
int dimLensSz = dimLens.size();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimLensTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __DIM_LENS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
ptr = &(dimLens[0]);
rval = mbImpl->tag_set_by_ptr(dimLensTag, &_fileSet, 1, &ptr, &dimLensSz);
- ERRORR(rval, "Trouble setting data for __DIM_LENS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__VAR_NAMES>
Tag varNamesTag = 0;
@@ -138,12 +127,11 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
}
int varnamesSz = varnames.size();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, varNamesTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __VAR_NAMES tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
ptr = varnames.c_str();
rval = mbImpl->tag_set_by_ptr(varNamesTag, &_fileSet, 1, &ptr, &varnamesSz);
- ERRORR(rval, "Trouble setting data for __VAR_NAMES tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// __<dim_name>_LOC_MINMAX (for time)
for (unsigned int i = 0; i != dimNamesSz; i++) {
@@ -156,11 +144,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
val[0] = 0;
val[1] = nTimeSteps - 1;
rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __<dim_name>_LOC_MINMAX tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
- ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_MINMAX tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
}
}
@@ -180,11 +167,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
ss_tag_name << "__" << dimNames[i] << "_LOC_VALS";
tag_name = ss_tag_name.str();
rval = mbImpl->tag_get_handle(tag_name.c_str(), val.size(), MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
- ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
}
}
@@ -201,41 +187,39 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
for (unsigned int i = 0; i != varDimSz; i++) {
Tag tmptag = 0;
std::string tmptagname = dimNames[varInfo[mapIter->first].varDims[i]];
- mbImpl->tag_get_handle(tmptagname.c_str(), 0, MB_TYPE_OPAQUE, tmptag, MB_TAG_ANY);
+ rval = mbImpl->tag_get_handle(tmptagname.c_str(), 0, MB_TYPE_OPAQUE, tmptag, MB_TAG_ANY);
+ CHK_ERR1_STR(rval, "Trouble getting tag " << tmptagname);
varDimTags[i] = tmptag;
}
rval = mbImpl->tag_get_handle(tag_name.c_str(), varDimSz, MB_TYPE_HANDLE, varNamesDimsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __<var_name>_DIMS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(varNamesDimsTag, &_fileSet, 1, &(varDimTags[0]));
- ERRORR(rval, "Trouble setting data for __<var_name>_DIMS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
}
// <PARTITION_METHOD>
Tag part_tag = scdi->part_method_tag();
if (!part_tag)
- ERRORR(MB_FAILURE, "Trouble getting PARTITION_METHOD tag.");
+ SET_ERR(MB_FAILURE, "Trouble getting PARTITION_METHOD tag");
rval = mbImpl->tag_set_data(part_tag, &_fileSet, 1, &partMethod);
- ERRORR(rval, "Trouble setting data for PARTITION_METHOD tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1(rval, "Trouble setting data to PARTITION_METHOD tag");
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__GLOBAL_ATTRIBS>
tag_name = "__GLOBAL_ATTRIBS";
Tag globalAttTag = 0;
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, globalAttTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __GLOBAL_ATTRIBS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
std::string gattVal;
std::vector<int> gattLen;
rval = create_attrib_string(globalAtts, gattVal, gattLen);
- ERRORR(rval, "Trouble creating global attribute string.");
+ CHK_ERR1(rval, "Trouble creating global attribute string");
const void* gattptr = gattVal.c_str();
int globalAttSz = gattVal.size();
rval = mbImpl->tag_set_by_ptr(globalAttTag, &_fileSet, 1, &gattptr, &globalAttSz);
- ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__GLOBAL_ATTRIBS_LEN>
tag_name = "__GLOBAL_ATTRIBS_LEN";
@@ -243,11 +227,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
if (gattLen.size() == 0)
gattLen.push_back(0);
rval = mbImpl->tag_get_handle(tag_name.c_str(), gattLen.size(), MB_TYPE_INTEGER, globalAttLenTag, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __GLOBAL_ATTRIBS_LEN tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(globalAttLenTag, &_fileSet, 1, &gattLen[0]);
- ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS_LEN tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// __<var_name>_ATTRIBS and __<var_name>_ATTRIBS_LEN
for (mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter) {
@@ -256,7 +239,7 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
tag_name = ssTagName.str();
Tag varAttTag = 0;
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, varAttTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __<var_name>_ATTRIBS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
std::string varAttVal;
std::vector<int> varAttLen;
@@ -272,16 +255,15 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
}
else {
rval = create_attrib_string(mapIter->second.varAtts, varAttVal, varAttLen);
- ERRORR(rval, "Trouble creating attribute string.");
+ CHK_ERR1_STR(rval, "Trouble creating attribute string for variable " << mapIter->first);
}
const void* varAttPtr = varAttVal.c_str();
int varAttSz = varAttVal.size();
if (0 == varAttSz)
varAttSz = 1;
rval = mbImpl->tag_set_by_ptr(varAttTag, &_fileSet, 1, &varAttPtr, &varAttSz);
- ERRORR(rval, "Trouble setting data for __<var_name>_ATTRIBS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
ssTagName << "_LEN";
tag_name = ssTagName.str();
@@ -289,11 +271,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
if (0 == varAttLen.size())
varAttLen.push_back(0);
rval = mbImpl->tag_get_handle(tag_name.c_str(), varAttLen.size(), MB_TYPE_INTEGER, varAttLenTag, MB_TAG_SPARSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating __<var_name>_ATTRIBS_LEN tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
rval = mbImpl->tag_set_data(varAttLenTag, &_fileSet, 1, &varAttLen[0]);
- ERRORR(rval, "Trouble setting data for __<var_name>_ATTRIBS_LEN tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
}
// <__VAR_NAMES_LOCATIONS>
@@ -302,14 +283,13 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
std::vector<int> varNamesLocs(varInfo.size());
rval = mbImpl->tag_get_handle(tag_name.c_str(), varNamesLocs.size(), MB_TYPE_INTEGER, varNamesLocsTag, MB_TAG_CREAT
| MB_TAG_SPARSE);
- ERRORR(rval, "Trouble creating __VAR_NAMES_LOCATIONS tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
for (mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter) {
varNamesLocs[std::distance(varInfo.begin(), mapIter)] = mapIter->second.entLoc;
}
rval = mbImpl->tag_set_data(varNamesLocsTag, &_fileSet, 1, &varNamesLocs[0]);
- ERRORR(rval, "Trouble setting data for __VAR_NAMES_LOCATIONS tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
// <__MESH_TYPE>
Tag meshTypeTag = 0;
@@ -317,13 +297,12 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
std::string meshTypeName = get_mesh_type_name();
rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, meshTypeTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Trouble creating __MESH_TYPE tag.");
+ CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
ptr = meshTypeName.c_str();
int leng = meshTypeName.size();
rval = mbImpl->tag_set_by_ptr(meshTypeTag, &_fileSet, 1, &ptr, &leng);
- ERRORR(rval, "Trouble setting data for __MESH_TYPE tag.");
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+ CHK_ERR1_STR(rval, "Trouble setting data to conventional tag " << tag_name);
+ dbgOut.tprintf(2, "Conventional tag %s created\n", tag_name.c_str());
return MB_SUCCESS;
}
@@ -344,9 +323,9 @@ ErrorCode NCHelper::update_time_tag_vals()
const void* data = NULL;
int time_tag_size = 0;
rval = mbImpl->tag_get_handle(time_tag_name.c_str(), 0, MB_TYPE_DOUBLE, time_tag, MB_TAG_VARLEN);
- ERRORR(rval, "Trouble getting time tag.");
+ CHK_ERR1_STR(rval, "Trouble getting tag " << time_tag_name);
rval = mbImpl->tag_get_by_ptr(time_tag, &_fileSet, 1, &data, &time_tag_size);
- ERRORR(rval, "Trouble getting values for time tag.");
+ CHK_ERR1_STR(rval, "Trouble getting data of tag " << time_tag_name);
const double* time_tag_vals = static_cast<const double*>(data);
// Merge tVals (read from current file) to existing time tag
@@ -375,7 +354,7 @@ ErrorCode NCHelper::update_time_tag_vals()
data = &merged_time_vals[0];
time_tag_size = merged_time_vals.size();
rval = mbImpl->tag_set_by_ptr(time_tag, &_fileSet, 1, &data, &time_tag_size);
- ERRORR(rval, "Failed to set data for time tag.");
+ CHK_ERR1_STR(rval, "Trouble setting data to tag " << time_tag_name);
return MB_SUCCESS;
}
@@ -424,7 +403,7 @@ ErrorCode NCHelper::read_variables_setup(std::vector<std::string>& var_names, st
vdatas.push_back(vd);
}
else {
- ERRORR(MB_FAILURE, "Couldn't find specified variable.");
+ SET_ERR_STR(MB_FAILURE, "Couldn't find specified variable " << var_names[i]);
}
}
}
@@ -470,7 +449,7 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = read_variables_to_set_allocate(vdatas, tstep_nums);
- ERRORR(rval, "Trouble allocating space to read set variables.");
+ CHK_ERR1(rval, "Trouble allocating space to read set variables");
// Finally, read into that space
int success;
@@ -490,27 +469,30 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
case NC_CHAR:
success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
&vdatas[i].readCounts[0], (char*) data);
- ERRORS(success, "Failed to read char data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read byte/char data for variable " << vdatas[i].varName);
break;
case NC_SHORT:
case NC_INT:
success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
&vdatas[i].readCounts[0], (int*) data);
- ERRORS(success, "Failed to read int data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read short/int data for variable " << vdatas[i].varName);
break;
case NC_FLOAT:
case NC_DOUBLE:
success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
&vdatas[i].readCounts[0], (double*) data);
- ERRORS(success, "Failed to read double data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read float/double data for variable " << vdatas[i].varName);
break;
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << vdatas[i].varName);
}
dbgOut.tprintf(2, "Setting data for variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
rval = mbImpl->tag_set_by_ptr(vdatas[i].varTags[t], &_fileSet, 1, &data, &vdatas[i].sz);
- ERRORR(rval, "Failed to set data for variable.");
+ CHK_ERR1_STR(rval, "Trouble setting tag data for variable " << vdatas[i].varName);
// Memory pointed by pointer data can be deleted, as tag_set_by_ptr() has already copied the tag values
switch (vdatas[i].varDataType) {
@@ -553,7 +535,7 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
std::map<std::string, ReadNC::VarData>::iterator vmit = varInfo.find(var_name);
if (varInfo.end() == vmit)
- return MB_FAILURE;
+ SET_ERR_STR(MB_FAILURE, "Couldn't find variable " << var_name);
assert(lmin >= 0 && lmax >= lmin);
NCDF_SIZE tstart = lmin;
@@ -571,10 +553,11 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
case NC_DOUBLE:
// Read float as double
success = NCFUNCAG(_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
- ERRORS(success, "Failed to get coordinate values.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read float/double data for variable " << var_name);
break;
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << var_name);
}
return MB_SUCCESS;
@@ -611,11 +594,11 @@ ErrorCode NCHelper::get_tag_to_set(ReadNC::VarData& var_data, int tstep_num, Tag
rval = mbImpl->tag_get_handle(tag_name.str().c_str(), 0, MB_TYPE_DOUBLE, tagh, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
break;
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << var_data.varName);
}
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.str().c_str());
+ CHK_ERR1_STR(rval, "Trouble creating tag " << tag_name.str());
+ dbgOut.tprintf(2, "Tag %s created\n", tag_name.str().c_str());
return rval;
}
@@ -648,11 +631,11 @@ ErrorCode NCHelper::get_tag_to_nonset(ReadNC::VarData& var_data, int tstep_num,
rval = mbImpl->tag_get_handle(tag_name.str().c_str(), num_lev, MB_TYPE_DOUBLE, tagh, MB_TAG_DENSE | MB_TAG_CREAT);
break;
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << var_data.varName);
}
- if (MB_SUCCESS == rval)
- dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.str().c_str());
+ CHK_ERR1_STR(rval, "Trouble creating tag " << tag_name.str());
+ dbgOut.tprintf(2, "Tag %s created\n", tag_name.str().c_str());
return rval;
}
@@ -673,39 +656,44 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
sz = attIt->second.attLen;
attData = (char *) malloc(sz);
success = NCFUNC(get_att_text)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (char*) attData);
- ERRORS(success, "Failed to read attribute char data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read byte/char data for attribute " << attIt->second.attName);
ssAtt << "char;";
break;
case NC_SHORT:
sz = attIt->second.attLen * sizeof(short);
attData = (short *) malloc(sz);
success = NCFUNC(get_att_short)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (short*) attData);
- ERRORS(success, "Failed to read attribute short data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read short data for attribute " << attIt->second.attName);
ssAtt << "short;";
break;
case NC_INT:
sz = attIt->second.attLen * sizeof(int);
attData = (int *) malloc(sz);
success = NCFUNC(get_att_int)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (int*) attData);
- ERRORS(success, "Failed to read attribute int data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read int data for attribute " << attIt->second.attName);
ssAtt << "int;";
break;
case NC_FLOAT:
sz = attIt->second.attLen * sizeof(float);
attData = (float *) malloc(sz);
success = NCFUNC(get_att_float)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (float*) attData);
- ERRORS(success, "Failed to read attribute float data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read float data for attribute " << attIt->second.attName);
ssAtt << "float;";
break;
case NC_DOUBLE:
sz = attIt->second.attLen * sizeof(double);
attData = (double *) malloc(sz);
success = NCFUNC(get_att_double)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (double*) attData);
- ERRORS(success, "Failed to read attribute double data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read double data for attribute " << attIt->second.attName);
ssAtt << "double;";
break;
default:
- ERRORR(MB_FAILURE, "Unexpected attribute data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for attribute " << attIt->second.attName);
}
char* tmpc = (char *) attData;
for (unsigned int counter = 0; counter != sz; ++counter)
@@ -739,7 +727,7 @@ ErrorCode NCHelper::create_dummy_variables()
int sizeTotalVar = varInfo.size();
std::string var_name(dimNames[i]);
ReadNC::VarData& data = varInfo[var_name];
- data.varName = std::string(var_name);
+ data.varName = var_name;
data.varId = sizeTotalVar;
data.varTags.resize(1, 0);
data.varDataType = NC_INT;
@@ -747,23 +735,23 @@ ErrorCode NCHelper::create_dummy_variables()
data.varDims[0] = (int)i;
data.numAtts = 0;
data.entLoc = ReadNC::ENTLOCSET;
- dummyVarNames.insert(dimNames[i]);
- dbgOut.tprintf(2, "Dummy coordinate variable created for dimension %s\n", dimNames[i].c_str());
+ dummyVarNames.insert(var_name);
+ dbgOut.tprintf(2, "Dummy coordinate variable created for dimension %s\n", var_name.c_str());
// Create a corresponding sparse tag
Tag tagh;
- ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 0, MB_TYPE_INTEGER, tagh,
+ ErrorCode rval = mbImpl->tag_get_handle(var_name.c_str(), 0, MB_TYPE_INTEGER, tagh,
MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
- ERRORR(rval, "Failed to create tag for a dummy coordinate variable.");
+ CHK_ERR1_STR(rval, "Trouble creating tag for dummy coordinate variable " << var_name);
// Tag value is the dimension length
const void* ptr = &dimLens[i];
// Tag size is 1
int size = 1;
rval = mbImpl->tag_set_by_ptr(tagh, &_fileSet, 1, &ptr, &size);
- ERRORR(rval, "Failed to set data for dimension tag.");
+ CHK_ERR1_STR(rval, "Trouble setting tag data for dummy coordinate variable " << var_name);
- dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
+ dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", var_name.c_str());
}
return MB_SUCCESS;
@@ -784,7 +772,7 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
vdatas[i].readCounts.push_back(1);
// Next: other dimensions
- for (unsigned int idx = 1; idx != vdatas[i].varDims.size(); idx++){
+ for (unsigned int idx = 1; idx != vdatas[i].varDims.size(); idx++) {
vdatas[i].readStarts.push_back(0);
vdatas[i].readCounts.push_back(dimLens[vdatas[i].varDims[idx]]);
}
@@ -796,7 +784,7 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
vdatas[i].readCounts.push_back(1);
}
else {
- for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); idx++){
+ for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); idx++) {
vdatas[i].readStarts.push_back(0);
vdatas[i].readCounts.push_back(dimLens[vdatas[i].varDims[idx]]);
}
@@ -813,13 +801,13 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
if (tstep_nums[t] >= dimLens[tDim]) {
- ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number.");
+ SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number " << tstep_nums[t]);
}
// Get the tag to read into
if (!vdatas[i].varTags[t]) {
rval = get_tag_to_set(vdatas[i], tstep_nums[t], vdatas[i].varTags[t]);
- ERRORR(rval, "Trouble getting tag for a set variable.");
+ CHK_ERR1_STR(rval, "Trouble getting tag to set variable " << vdatas[i].varName);
}
switch (vdatas[i].varDataType) {
@@ -836,7 +824,7 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
vdatas[i].varDatas[t] = new double[vdatas[i].sz];
break;
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << vdatas[i].varName);
}
// Loop continues only for set variables with timesteps, e.g. xtime(Time) or xtime(Time, StrLen)
@@ -854,7 +842,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
// Get the number of vertices
int num_verts;
ErrorCode rval = mbImpl->get_number_entities_by_dimension(_fileSet, 0, num_verts);
- ERRORR(rval, "Trouble getting number of vertices.");
+ CHK_ERR1(rval, "Trouble getting number of vertices");
/*
// Check against parameters
@@ -862,7 +850,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
if (num_verts > 0) {
int expected_verts = (lDims[3] - lDims[0] + 1) * (lDims[4] - lDims[1] + 1) * (-1 == lDims[2] ? 1 : lDims[5] - lDims[2] + 1);
if (num_verts != expected_verts) {
- ERRORR(MB_FAILURE, "Number of vertices doesn't match.");
+ SET_ERR(MB_FAILURE, "Number of vertices doesn't match");
}
}
*/
@@ -870,7 +858,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
// Check the number of elements too
int num_elems;
rval = mbImpl->get_number_entities_by_dimension(_fileSet, (-1 == lCDims[2] ? 2 : 3), num_elems);
- ERRORR(rval, "Trouble getting number of elements.");
+ CHK_ERR1(rval, "Trouble getting number of elements");
/*
// Check against parameters
@@ -878,7 +866,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
if (num_elems > 0) {
int expected_elems = (lCDims[3] - lCDims[0] + 1) * (lCDims[4] - lCDims[1] + 1) * (-1 == lCDims[2] ? 1 : (lCDims[5] - lCDims[2] + 1));
if (num_elems != expected_elems) {
- ERRORR(MB_FAILURE, "Number of elements doesn't match.");
+ SET_ERR(MB_FAILURE, "Number of elements doesn't match");
}
}
*/
@@ -900,7 +888,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1),
NULL, 0, scd_box, locallyPeriodic, &parData, true);
- ERRORR(rval, "Trouble creating scd vertex sequence.");
+ CHK_ERR1(rval, "Trouble creating scd vertex sequence");
// Add verts to tmp_range first, so we can duplicate global ids in vertex ids
tmp_range.insert(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
@@ -909,11 +897,11 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
int count;
void* data;
rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), tmp_range.end(), count, data);
- ERRORR(rval, "Failed to get tag iterator on file id tag.");
+ CHK_ERR1(rval, "Failed to iterate file ID tag on local vertices");
assert(count == scd_box->num_vertices());
int* fid_data = (int*) data;
rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), tmp_range.end(), count, data);
- ERRORR(rval, "Failed to get tag iterator on global id tag.");
+ CHK_ERR1(rval, "Failed to iterate global ID tag on local vertices");
assert(count == scd_box->num_vertices());
int* gid_data = (int*) data;
for (int i = 0; i < count; i++)
@@ -924,14 +912,14 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
tmp_range.insert(scd_box->box_set());
rval = mbImpl->add_entities(_fileSet, tmp_range);
- ERRORR(rval, "Couldn't add new vertices to file set.");
+ CHK_ERR1(rval, "Couldn't add new vertices to current file set");
dbgOut.tprintf(1, "scdbox %d quads, %d vertices\n", scd_box->num_elements(), scd_box->num_vertices());
// Set the vertex coordinates
double *xc, *yc, *zc;
rval = scd_box->get_coordinate_arrays(xc, yc, zc);
- ERRORR(rval, "Couldn't get vertex coordinate arrays.");
+ CHK_ERR1(rval, "Couldn't get vertex coordinate arrays");
int i, j, k, il, jl, kl;
int dil = lDims[3] - lDims[0] + 1;
@@ -958,7 +946,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
std::vector<int> gids(num_verts);
Range verts(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
rval = mbImpl->tag_get_data(mGlobalIdTag, verts, &gids[0]);
- ERRORR(rval, "Trouble getting gid values.");
+ CHK_ERR1(rval, "Trouble getting local gid values of vertices");
int vmin = *(std::min_element(gids.begin(), gids.end())), vmax = *(std::max_element(gids.begin(), gids.end()));
dbgOut.tprintf(1, "Vertex gids %d-%d\n", vmin, vmax);
#endif
@@ -970,14 +958,14 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
assert(scd_box->boundary_complete());
EntityHandle dum_ent = scd_box->start_element();
rval = mbImpl->list_entities(&dum_ent, 1);
- ERRORR(rval, "Trouble listing first hex.");
+ CHK_ERR1(rval, "Trouble listing first hex");
std::vector<EntityHandle> connect;
rval = mbImpl->get_connectivity(&dum_ent, 1, connect);
- ERRORR(rval, "Trouble getting connectivity.");
+ CHK_ERR1(rval, "Trouble getting connectivity");
rval = mbImpl->list_entities(&connect[0], connect.size());
- ERRORR(rval, "Trouble listing element connectivity.");
+ CHK_ERR1(rval, "Trouble listing element connectivity");
}
Range edges;
@@ -985,7 +973,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
// Create COORDS tag for quads
rval = create_quad_coordinate_tag();
- ERRORR(rval, "Trouble creating coordinate tags to entities quads");
+ CHK_ERR1(rval, "Trouble creating COORDS tag for quads");
return MB_SUCCESS;
}
@@ -996,16 +984,16 @@ ErrorCode ScdNCHelper::read_variables(std::vector<std::string>& var_names, std::
std::vector<ReadNC::VarData> vsetdatas;
ErrorCode rval = read_variables_setup(var_names, tstep_nums, vdatas, vsetdatas);
- ERRORR(rval, "Trouble setting up read variable.");
+ CHK_ERR1(rval, "Trouble setting up to read variables");
if (!vsetdatas.empty()) {
rval = read_variables_to_set(vsetdatas, tstep_nums);
- ERRORR(rval, "Trouble read variables to set.");
+ CHK_ERR1(rval, "Trouble reading variables to set");
}
if (!vdatas.empty()) {
rval = read_scd_variables_to_nonset(vdatas, tstep_nums);
- ERRORR(rval, "Trouble read variables to entities verts/edges/faces.");
+ CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
}
return MB_SUCCESS;
@@ -1024,18 +1012,18 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
// Get vertices
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);
- ERRORR(rval, "Trouble getting vertices in current file set.");
+ CHK_ERR1(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" &&
verts.psize() == 1);
Range edges;
rval = mbImpl->get_entities_by_dimension(_fileSet, 1, edges);
- ERRORR(rval, "Trouble getting edges in current file set.");
+ CHK_ERR1(rval, "Trouble getting edges in current file set");
// Get faces
Range faces;
rval = mbImpl->get_entities_by_dimension(_fileSet, 2, faces);
- ERRORR(rval, "Trouble getting faces in current file set.");
+ CHK_ERR1(rval, "Trouble getting faces in current file set");
assert("Should only have a single face subrange, since they were read in one shot" &&
faces.psize() == 1);
@@ -1045,7 +1033,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
if (isParallel) {
ParallelComm*& myPcomm = _readNC->myPcomm;
rval = myPcomm->filter_pstatus(faces, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &faces_owned);
- ERRORR(rval, "Trouble getting owned faces in current file set.");
+ CHK_ERR1(rval, "Trouble getting owned faces in current file set");
}
else
faces_owned = faces; // Not running in parallel, but still with MPI
@@ -1083,7 +1071,8 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
case ReadNC::ENTLOCNSEDGE:
case ReadNC::ENTLOCEWEDGE:
case ReadNC::ENTLOCEDGE:
- ERRORR(MB_NOT_IMPLEMENTED, "Reading edge data not implemented yet.");
+ // Not implemented yet, set a global error
+ SET_GLB_ERR(MB_NOT_IMPLEMENTED, "Reading edge data is not implemented yet");
break;
case ReadNC::ENTLOCFACE:
// Faces
@@ -1098,27 +1087,27 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
#endif
break;
default:
- ERRORR(MB_FAILURE, "Unexpected entity location type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected entity location type for variable " << vdatas[i].varName);
}
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
if (tstep_nums[t] >= dimLens[tDim]) {
- ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number.");
+ SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number " << tstep_nums[t]);
}
// Get the tag to read into
if (!vdatas[i].varTags[t]) {
rval = get_tag_to_nonset(vdatas[i], tstep_nums[t], vdatas[i].varTags[t], vdatas[i].numLev);
- ERRORR(rval, "Trouble getting tag.");
+ CHK_ERR1_STR(rval, "Trouble getting tag to non-set variable " << vdatas[i].varName);
}
// Get ptr to tag space
void* data;
int count;
rval = mbImpl->tag_iterate(vdatas[i].varTags[t], range->begin(), range->end(), count, data);
- ERRORR(rval, "Failed to get tag iterator.");
+ CHK_ERR1_STR(rval, "Failed to iterate tag for non-set variable " << vdatas[i].varName);
assert((unsigned)count == range->size());
vdatas[i].varDatas[t] = data;
}
@@ -1137,7 +1126,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
DebugOutput& dbgOut = _readNC->dbgOut;
ErrorCode rval = read_scd_variables_to_nonset_allocate(vdatas, tstep_nums);
- ERRORR(rval, "Trouble allocating space to read non-set variables.");
+ CHK_ERR1(rval, "Trouble allocating space to read non-set variables");
// Finally, read into that space
int success;
@@ -1163,7 +1152,8 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
std::vector<char> tmpchardata(sz);
success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
&tmpchardata[0]);
- ERRORS(success, "Failed to read char data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read byte/char data for variable " << vdatas[i].varName);
if (vdatas[i].numLev > 1)
// Transpose (lev, lat, lon) to (lat, lon, lev)
kji_to_jik(ni, nj, nk, data, &tmpchardata[0]);
@@ -1178,7 +1168,8 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
std::vector<int> tmpintdata(sz);
success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
&tmpintdata[0]);
- ERRORS(success, "Failed to read int data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read short/int data for variable " << vdatas[i].varName);
if (vdatas[i].numLev > 1)
// Transpose (lev, lat, lon) to (lat, lon, lev)
kji_to_jik(ni, nj, nk, data, &tmpintdata[0]);
@@ -1193,7 +1184,8 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
std::vector<double> tmpdoubledata(sz);
success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
&tmpdoubledata[0]);
- ERRORS(success, "Failed to read double data.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Failed to read float/double data for variable " << vdatas[i].varName);
if (vdatas[i].numLev > 1)
// Transpose (lev, lat, lon) to (lat, lon, lev)
kji_to_jik(ni, nj, nk, data, &tmpdoubledata[0]);
@@ -1204,7 +1196,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
break;
}
default:
- ERRORR(MB_FAILURE, "Unexpected variable data type.");
+ SET_ERR_STR(MB_FAILURE, "Unexpected data type for variable " << vdatas[i].varName);
}
}
}
@@ -1225,7 +1217,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
Range ents;
ErrorCode rval = mbImpl->get_entities_by_type(_fileSet, moab::MBQUAD, ents);
- ERRORR(rval, "Trouble getting QUAD entity.");
+ CHK_ERR1(rval, "Trouble getting quads");
std::size_t numOwnedEnts = 0;
#ifdef USE_MPI
@@ -1234,7 +1226,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
if (isParallel) {
ParallelComm*& myPcomm = _readNC->myPcomm;
rval = myPcomm->filter_pstatus(ents, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &ents_owned);
- ERRORR(rval, "Trouble getting owned QUAD entity.");
+ CHK_ERR1(rval, "Trouble getting owned quads");
numOwnedEnts = ents_owned.size();
}
else {
@@ -1262,7 +1254,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
std::string tag_name = "COORDS";
Tag tagh = 0;
rval = mbImpl->tag_get_handle(tag_name.c_str(), 3, MB_TYPE_DOUBLE, tagh, MB_TAG_DENSE | MB_TAG_CREAT);
- ERRORR(rval, "Trouble creating COORDS tag.");
+ CHK_ERR1(rval, "Trouble creating COORDS tag");
void *data;
int count;
@@ -1271,7 +1263,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
#else
rval = mbImpl->tag_iterate(tagh, ents.begin(), ents.end(), count, data);
#endif
- ERRORR(rval, "Failed to get COORDS tag iterator.");
+ CHK_ERR1(rval, "Failed to iterate COORDS tag on quads");
assert(count == (int)numOwnedEnts);
double* quad_data = (double*) data;
std::copy(coords.begin(), coords.end(), quad_data);
@@ -1285,11 +1277,11 @@ ErrorCode UcdNCHelper::read_variables(std::vector<std::string>& var_names, std::
std::vector<ReadNC::VarData> vsetdatas;
ErrorCode rval = read_variables_setup(var_names, tstep_nums, vdatas, vsetdatas);
- ERRORR(rval, "Trouble setting up read variable.");
+ CHK_ERR1(rval, "Trouble setting up to read variables");
if (!vsetdatas.empty()) {
rval = read_variables_to_set(vsetdatas, tstep_nums);
- ERRORR(rval, "Trouble read variables to set.");
+ CHK_ERR1(rval, "Trouble reading variables to set");
}
if (!vdatas.empty()) {
@@ -1300,7 +1292,7 @@ ErrorCode UcdNCHelper::read_variables(std::vector<std::string>& var_names, std::
// Without pnetcdf support, we will use old read
rval = read_ucd_variables_to_nonset(vdatas, tstep_nums);
#endif
- ERRORR(rval, "Trouble read variables to entities verts/edges/faces.");
+ CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
}
return MB_SUCCESS;
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 64d67ab..9d7a49b 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -5,12 +5,6 @@
#include "MBTagConventions.hpp"
#include "moab/FileOptions.hpp"
-#define ERRORR(rval, str) \
- if (MB_SUCCESS != rval) { readMeshIface->report_error("%s", str); return rval; }
-
-#define ERRORS(err, str) \
- if (err) { readMeshIface->report_error("%s", str); return MB_FAILURE; }
-
namespace moab {
ReaderIface* ReadNC::factory(Interface* iface)
@@ -51,15 +45,14 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Get and cache predefined tag handles
int dum_val = 0;
rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE | MB_TAG_CREAT, &dum_val);
- if (MB_SUCCESS != rval)
- return rval;
+ CHK_ERR1(rval, "Trouble getting global ID tag");
// Store the pointer to the tag; if not null, set when global id tag
// is set too, with the same data, duplicated
mpFileIdTag = file_id_tag;
rval = parse_options(opts, var_names, tstep_nums, tstep_vals);
- ERRORR(rval, "Trouble parsing option string.");
+ CHK_ERR1(rval, "Trouble parsing option string");
// Open the file
dbgOut.tprintf(1, "Opening file %s\n", file_name);
@@ -74,21 +67,21 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
#else
success = NCFUNC(open)(file_name, 0, &fileId);
#endif
-
- ERRORS(success, "Trouble opening file.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble opening file " << file_name);
// Read the header (num dimensions, dimensions, num variables, global attribs)
rval = read_header();
- ERRORR(rval, "Trouble reading file header.");
+ CHK_ERR1(rval, "Trouble reading file header");
// Make sure there's a file set to put things in
EntityHandle tmp_set;
if (noMesh && !file_set) {
- ERRORR(MB_FAILURE, "NOMESH option requires non-NULL file set on input.");
+ SET_ERR(MB_FAILURE, "NOMESH option requires non-NULL file set on input");
}
else if (!file_set || (file_set && *file_set == 0)) {
rval = mbImpl->create_meshset(MESHSET_SET, tmp_set);
- ERRORR(rval, "Trouble creating file set.");
+ CHK_ERR1(rval, "Trouble creating file set");
}
else
tmp_set = *file_set;
@@ -105,17 +98,17 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Get appropriate NC helper instance based on information read from the header
myHelper = NCHelper::get_nc_helper(this, fileId, opts, tmp_set);
if (NULL == myHelper) {
- ERRORR(MB_FAILURE, "Failed to get NCHelper class instance.");
+ SET_ERR(MB_FAILURE, "Failed to get NCHelper class instance");
}
// Initialize mesh values
rval = myHelper->init_mesh_vals();
- ERRORR(rval, "Trouble initializing mesh values.");
+ CHK_ERR1(rval, "Trouble initializing mesh values");
// Check existing mesh from last read
if (noMesh && !noVars) {
rval = myHelper->check_existing_mesh();
- ERRORR(rval, "Trouble checking mesh from last read.");
+ CHK_ERR1(rval, "Trouble checking mesh from last read");
}
// Create some conventional tags, e.g. __NUM_DIMS
@@ -126,7 +119,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
int def_val = 0;
rval = mbImpl->tag_get_handle("__CONV_TAGS_CREATED", 1, MB_TYPE_INTEGER, convTagsCreated,
MB_TAG_SPARSE | MB_TAG_CREAT, &def_val);
- ERRORR(rval, "Trouble getting _CONV_TAGS_CREATED tag.");
+ CHK_ERR1(rval, "Trouble getting _CONV_TAGS_CREATED tag");
int create_conv_tags_flag = 0;
rval = mbImpl->tag_get_data(convTagsCreated, &tmp_set, 1, &create_conv_tags_flag);
// The first read to the file set
@@ -134,14 +127,14 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Read dimensions (coordinate variables) by default to create tags like __<var_name>_DIMS
// This is done only once (assume that all files read to the file set have the same dimensions)
rval = myHelper->read_variables(dimNames, tstep_nums);
- ERRORR(rval, "Trouble reading dimensions.");
+ CHK_ERR1(rval, "Trouble reading dimensions");
rval = myHelper->create_conventional_tags(tstep_nums);
- ERRORR(rval, "Trouble creating NC conventional tags.");
+ CHK_ERR1(rval, "Trouble creating NC conventional tags");
create_conv_tags_flag = 1;
rval = mbImpl->tag_set_data(convTagsCreated, &tmp_set, 1, &create_conv_tags_flag);
- ERRORR(rval, "Trouble setting data for _CONV_TAGS_CREATED tag.");
+ CHK_ERR1(rval, "Trouble setting data to _CONV_TAGS_CREATED tag");
}
// Another read to the file set
else {
@@ -149,7 +142,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// If timesteps spread across files, merge time values read
// from current file to existing time tag
rval = myHelper->update_time_tag_vals();
- ERRORR(rval, "Trouble updating time tag values.");
+ CHK_ERR1(rval, "Trouble updating time tag values");
}
}
@@ -157,7 +150,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
Range faces;
if (!noMesh) {
rval = myHelper->create_mesh(faces);
- ERRORR(rval, "Trouble creating mesh.");
+ CHK_ERR1(rval, "Trouble creating mesh");
}
// Read specified variables onto grid
@@ -165,7 +158,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
if (var_names.empty()) {
// If VARIABLE option is missing, read all variables
rval = myHelper->read_variables(var_names, tstep_nums);
- ERRORR(rval, "Trouble reading all variables.");
+ CHK_ERR1(rval, "Trouble reading all variables");
}
else {
// Exclude dimensions that are read to the file set by default
@@ -177,7 +170,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
if (!non_dim_var_names.empty()) {
rval = myHelper->read_variables(non_dim_var_names, tstep_nums);
- ERRORR(rval, "Trouble reading specified variables.");
+ CHK_ERR1(rval, "Trouble reading specified variables");
}
}
}
@@ -187,17 +180,17 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
if (isParallel) {
EntityHandle partn_set;
rval = mbImpl->create_meshset(MESHSET_SET, partn_set);
- ERRORR(rval, "Trouble creating partition set.");
+ CHK_ERR1(rval, "Trouble creating partition set");
rval = mbImpl->add_entities(partn_set, faces);
- ERRORR(rval, "Couldn't add new faces to partition set.");
+ CHK_ERR1(rval, "Couldn't add new faces to partition set");
Range verts;
rval = mbImpl->get_connectivity(faces, verts);
- ERRORR(rval, "Couldn't get verts of faces.");
+ CHK_ERR1(rval, "Couldn't get verts of faces");
rval = mbImpl->add_entities(partn_set, verts);
- ERRORR(rval, "Couldn't add new verts to partition set.");
+ CHK_ERR1(rval, "Couldn't add new verts to partition set");
myPcomm->partition_sets().insert(partn_set);
@@ -205,8 +198,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
Tag part_tag = myPcomm->partition_tag();
int dum_rank = myPcomm->proc_config().proc_rank();
rval = mbImpl->tag_set_data(part_tag, &partn_set, 1, &dum_rank);
- if (MB_SUCCESS != rval)
- return rval;
+ CHK_ERR1(rval, "Trouble writing partition tag name on partition set");
}
#endif
@@ -215,7 +207,8 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Close the file
success = NCFUNC(close)(fileId);
- ERRORS(success, "Trouble closing file.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble closing file");
return MB_SUCCESS;
}
@@ -279,20 +272,17 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
rval = opts.get_int_option("GATHER_SET", 0, gatherSetRank);
if (MB_TYPE_OUT_OF_RANGE == rval) {
- readMeshIface->report_error("Invalid value for GATHER_SET option");
- return rval;
+ SET_ERR(rval, "Invalid value for GATHER_SET option");
}
rval = opts.get_int_option("TIMESTEPBASE", 0, tStepBase);
if (MB_TYPE_OUT_OF_RANGE == rval) {
- readMeshIface->report_error("Invalid value for TIMESTEPBASE option");
- return rval;
+ SET_ERR(rval, "Invalid value for TIMESTEPBASE option");
}
rval = opts.get_int_option("TRIVIAL_PARTITION_SHIFT", 1, trivialPartitionShift);
if (MB_TYPE_OUT_OF_RANGE == rval) {
- readMeshIface->report_error("Invalid value for TRIVIAL_PARTITION_SHIFT option");
- return rval;
+ SET_ERR(rval, "Invalid value for TRIVIAL_PARTITION_SHIFT option");
}
#ifdef USE_MPI
@@ -307,8 +297,7 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
int pcomm_no = 0;
rval = opts.get_int_option("PARALLEL_COMM", pcomm_no);
if (MB_TYPE_OUT_OF_RANGE == rval) {
- readMeshIface->report_error("Invalid value for PARALLEL_COMM option");
- return rval;
+ SET_ERR(rval, "Invalid value for PARALLEL_COMM option");
}
myPcomm = ParallelComm::get_pcomm(mbImpl, pcomm_no);
if (0 == myPcomm) {
@@ -320,8 +309,7 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
int dum;
rval = opts.match_option("PARTITION_METHOD", ScdParData::PartitionMethodNames, dum);
if (MB_FAILURE == rval) {
- readMeshIface->report_error("Unknown partition method specified");
- return rval;
+ SET_ERR(rval, "Unknown partition method specified");
}
else if (MB_ENTITY_NOT_FOUND == rval)
partMethod = ScdParData::ALLJORKORI;
@@ -340,21 +328,22 @@ ErrorCode ReadNC::read_header()
int numgatts;
int success;
success = NCFUNC(inq_natts )(fileId, &numgatts);
- ERRORS(success, "Couldn't get number of global attributes.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Couldn't get number of global attributes");
// Read attributes into globalAtts
ErrorCode result = get_attributes(NC_GLOBAL, numgatts, globalAtts);
- ERRORR(result, "Trouble getting attributes.");
+ CHK_ERR1(result, "Trouble getting global attributes");
dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
// Read in dimensions into dimNames and dimLens
result = get_dimensions(fileId, dimNames, dimLens);
- ERRORR(result, "Trouble getting dimensions.");
+ CHK_ERR1(result, "Trouble getting dimensions");
dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());
// Read in variables into varInfo
result = get_variables();
- ERRORR(result, "Trouble getting variables.");
+ CHK_ERR1(result, "Trouble getting variables");
dbgOut.tprintf(1, "Read %u variables\n", (unsigned int) varInfo.size());
return MB_SUCCESS;
@@ -367,12 +356,14 @@ ErrorCode ReadNC::get_attributes(int var_id, int num_atts, std::map<std::string,
for (int i = 0; i < num_atts; i++) {
// Get the name
int success = NCFUNC(inq_attname)(fileId, var_id, i, dum_name);
- ERRORS(success, "Trouble getting attribute name.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble getting attribute name");
AttData &data = atts[std::string(dum_name)];
data.attName = std::string(dum_name);
success = NCFUNC(inq_att)(fileId, var_id, dum_name, &data.attDataType, &data.attLen);
- ERRORS(success, "Trouble getting attribute info.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble getting info for attribute " << data.attName);
data.attVarId = var_id;
dbgOut.tprintf(2, "%sAttribute %s: length=%u, varId=%d, type=%d\n", (prefix ? prefix : ""), data.attName.c_str(),
@@ -387,11 +378,11 @@ ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_name
// Get the number of dimensions
int num_dims;
int success = NCFUNC(inq_ndims)(file_id, &num_dims);
- ERRORS(success, "Trouble getting number of dimensions.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble getting number of dimensions");
if (num_dims > NC_MAX_DIMS) {
- readMeshIface->report_error("ReadNC: File contains %d dims but NetCDF library supports only %d\n", num_dims, (int) NC_MAX_DIMS);
- return MB_FAILURE;
+ SET_ERR_STR(MB_FAILURE, "ReadNC: File contains " << num_dims << " dims but NetCDF library supports only " << NC_MAX_DIMS);
}
char dim_name[NC_MAX_NAME + 1];
@@ -401,7 +392,8 @@ ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_name
for (int i = 0; i < num_dims; i++) {
success = NCFUNC(inq_dim)(file_id, i, dim_name, &dim_len);
- ERRORS(success, "Trouble getting dimension info.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble getting dimension info");
dim_names[i] = std::string(dim_name);
dim_lens[i] = dim_len;
@@ -428,11 +420,11 @@ ErrorCode ReadNC::get_variables()
// Get the number of variables
int num_vars;
int success = NCFUNC(inq_nvars)(fileId, &num_vars);
- ERRORS(success, "Trouble getting number of variables.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble getting number of variables");
if (num_vars > NC_MAX_VARS) {
- readMeshIface->report_error("ReadNC: File contains %d vars but NetCDF library supports only %d\n", num_vars, (int) NC_MAX_VARS);
- return MB_FAILURE;
+ SET_ERR_STR(MB_FAILURE, "ReadNC: File contains " << num_vars << " vars but NetCDF library supports only " << NC_MAX_VARS);
}
char var_name[NC_MAX_NAME + 1];
@@ -441,7 +433,8 @@ ErrorCode ReadNC::get_variables()
for (int i = 0; i < num_vars; i++) {
// Get the name first, so we can allocate a map iterate for this var
success = NCFUNC(inq_varname )(fileId, i, var_name);
- ERRORS(success, "Trouble getting var name.");
+ if (success)
+ SET_ERR(MB_FAILURE, "Trouble getting variable name");
VarData &data = varInfo[std::string(var_name)];
data.varName = std::string(var_name);
data.varId = i;
@@ -449,26 +442,30 @@ ErrorCode ReadNC::get_variables()
// Get the data type
success = NCFUNC(inq_vartype)(fileId, i, &data.varDataType);
- ERRORS(success, "Trouble getting variable data type.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble getting data type for variable " << data.varName);
// Get the number of dimensions, then the dimensions
success = NCFUNC(inq_varndims)(fileId, i, &var_ndims);
- ERRORS(success, "Trouble getting number of dims of a variable.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble getting number of dims for variable " << data.varName);
data.varDims.resize(var_ndims);
success = NCFUNC(inq_vardimid)(fileId, i, &data.varDims[0]);
- ERRORS(success, "Trouble getting variable dimensions.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble getting dimensions for variable " << data.varName);
// Finally, get the number of attributes, then the attributes
success = NCFUNC(inq_varnatts)(fileId, i, &data.numAtts);
- ERRORS(success, "Trouble getting number of dims of a variable.");
+ if (success)
+ SET_ERR_STR(MB_FAILURE, "Trouble getting number of dims for variable " << data.varName);
// Print debug info here so attribute info comes afterwards
dbgOut.tprintf(2, "Variable %s: Id=%d, numAtts=%d, datatype=%d, num_dims=%u\n", data.varName.c_str(), data.varId, data.numAtts,
data.varDataType, (unsigned int) data.varDims.size());
ErrorCode rval = get_attributes(i, data.numAtts, data.varAtts, " ");
- ERRORR(rval, "Trouble getting attributes for a variable.");
+ CHK_ERR1_STR(rval, "Trouble getting attributes for variable " << data.varName);
}
return MB_SUCCESS;
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.
1
0
commit/MOAB: iulian07: Merged in iulian07/vtk_polydata (pull request #33)
by commits-noreply@bitbucket.org 14 Jul '14
by commits-noreply@bitbucket.org 14 Jul '14
14 Jul '14
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/d5336a950414/
Changeset: d5336a950414
Branch: master
User: iulian07
Date: 2014-07-14 16:15:43
Summary: Merged in iulian07/vtk_polydata (pull request #33)
fix vtk polydata reader
Affected #: 5 files
diff --git a/MeshFiles/unittest/io/Makefile.am b/MeshFiles/unittest/io/Makefile.am
index f259b82..2fd6cb3 100644
--- a/MeshFiles/unittest/io/Makefile.am
+++ b/MeshFiles/unittest/io/Makefile.am
@@ -30,5 +30,6 @@ EXTRA_DIST = HommeMapping.nc \
cube.stp \
cylcube.sat \
cylcube.stp \
+ poly8-10.vtk \
gcrm_r3.nc
diff --git a/MeshFiles/unittest/io/poly8-10.vtk b/MeshFiles/unittest/io/poly8-10.vtk
new file mode 100644
index 0000000..3a4d242
--- /dev/null
+++ b/MeshFiles/unittest/io/poly8-10.vtk
@@ -0,0 +1,42 @@
+# vtk DataFile Version 3.0
+MOAB 4.7.0pre
+ASCII
+DATASET POLYDATA
+POINTS 26 double
+3.073901530231682e-06 2.977455744718462e-01 0.000000000000000e+00
+-7.071067811865476e-01 7.071067811865475e-01 0.000000000000000e+00
+-1.715691137876366e-01 3.536798274750831e-01 0.000000000000000e+00
+-4.719776146377113e-01 1.857355490854607e-01 0.000000000000000e+00
+-8.508854127205038e-01 3.599944589578263e-01 0.000000000000000e+00
+2.775557561562891e-16 1.000000000000000e+00 0.000000000000000e+00
+-3.406715072241552e-01 8.588892413936710e-01 0.000000000000000e+00
+1.715662369808998e-01 3.536768053562428e-01 0.000000000000000e+00
+4.719754417201190e-01 1.857347459630188e-01 0.000000000000000e+00
+-4.719756118732749e-01 -1.857348097293946e-01 0.000000000000000e+00
+-1.000000000000000e+00 1.110223024625157e-16 0.000000000000000e+00
+-8.508847507623047e-01 -3.599960570662885e-01 0.000000000000000e+00
+7.071067811865476e-01 7.071067811865476e-01 0.000000000000000e+00
+3.406701269292776e-01 8.588898131305294e-01 0.000000000000000e+00
+8.508845922027242e-01 3.599964398629780e-01 0.000000000000000e+00
+-7.071067811865476e-01 -7.071067811865476e-01 0.000000000000000e+00
+4.719777412790575e-01 -1.857356073815120e-01 0.000000000000000e+00
+7.071067811865472e-01 -7.071067811865477e-01 0.000000000000000e+00
+-3.051853356210140e-16 -1.000000000000000e+00 0.000000000000000e+00
+1.715687253344436e-01 -3.536802010232855e-01 0.000000000000000e+00
+-3.319925237351595e-06 -2.977459818644166e-01 0.000000000000000e+00
+-1.715662714497118e-01 -3.536770586038507e-01 0.000000000000000e+00
+-3.406707216059742e-01 -8.588895668073767e-01 0.000000000000000e+00
+3.406712167592965e-01 -8.588893617081550e-01 0.000000000000000e+00
+1.000000000000000e+00 -2.775557561562891e-17 0.000000000000000e+00
+8.508853951409249e-01 -3.599945013986841e-01 0.000000000000000e+00
+POLYGONS 10 64
+6 21 22 18 23 19 20
+6 20 0 7 8 16 19
+5 10 4 3 9 11
+5 12 13 7 8 14
+5 24 14 8 16 25
+5 21 9 11 15 22
+6 7 0 2 6 5 13
+5 19 23 17 25 16
+5 3 4 1 6 2
+6 21 9 3 2 0 20
diff --git a/src/io/ReadVtk.cpp b/src/io/ReadVtk.cpp
index 2936a85..90b7a41 100644
--- a/src/io/ReadVtk.cpp
+++ b/src/io/ReadVtk.cpp
@@ -685,7 +685,7 @@ ErrorCode ReadVtk::vtk_read_polygons( FileTokenizer& tokens,
if (prev +1 != handle) {
if (first) { // true except for first iteration (first == 0)
- if (first < elem_list.back().front()) // only need new range if order would get mixed up
+ if ( elem_list.empty() || first < elem_list.back().front()) // only need new range if order would get mixed up, or we just began inserting
elem_list.push_back( empty );
elem_list.back().insert( first, prev );
}
@@ -694,7 +694,7 @@ ErrorCode ReadVtk::vtk_read_polygons( FileTokenizer& tokens,
prev = handle;
}
if (first) { // true unless no elements (size[0] == 0)
- if (first < elem_list.back().front()) // only need new range if order would get mixed up
+ if (elem_list.empty() || first < elem_list.back().front()) // only need new range if order would get mixed up, or we just began inserting
elem_list.push_back( empty );
elem_list.back().insert( first, prev );
}
diff --git a/test/io/VtkTest.cpp b/test/io/VtkTest.cpp
index d6208a2..076c28b 100644
--- a/test/io/VtkTest.cpp
+++ b/test/io/VtkTest.cpp
@@ -12,6 +12,14 @@ using namespace moab;
#include <algorithm>
#include <sstream>
+#include "TestUtil.hpp"
+
+#ifdef MESHDIR
+static const char poly_example[] = STRINGIFY(MESHDIR) "/io/poly8-10.vtk";
+#else
+static const char poly_example[] = "poly8-10.vtk";
+#endif
+
#define DECLARE_TEST(A) \
bool test_ ## A(); \
int A ## _reg_var = register_test( &test_ ## A, #A );
@@ -38,6 +46,7 @@ DECLARE_TEST(quad4)
DECLARE_TEST(quad8)
DECLARE_TEST(quad9)
DECLARE_TEST(polygon)
+DECLARE_TEST(polygon_mix)
DECLARE_TEST(tet4)
DECLARE_TEST(tet10)
DECLARE_TEST(hex8)
@@ -155,7 +164,8 @@ int main( int argc, char* argv[] )
return fail_count;
}
-
+// CHECK is defined in TestUtil now
+#undef CHECK
#define CHECK(A) if (is_error((A))) return do_error( #A, __LINE__ )
static bool do_error( const char* string, int line )
{
@@ -383,6 +393,19 @@ bool test_polygon()
return test_read_write_element( coords, 13, conn, conn, 16, 2, 7, MBPOLYGON );
}
+bool test_polygon_mix()
+{
+ // just read the polygon file with mixed sequences
+ Core moab;
+ Interface& mb = moab;
+
+ ErrorCode rval = mb.load_file(poly_example);
+ if (MB_SUCCESS!=rval)
+ return false;
+
+ return true;
+
+}
bool test_tet4()
{
const double coords[] =
diff --git a/tools/size.cpp b/tools/size.cpp
index 7d4311d..737fb00 100644
--- a/tools/size.cpp
+++ b/tools/size.cpp
@@ -169,7 +169,7 @@ static ErrorCode gather_set_stats( EntityHandle set, set_stats& stats )
{
if (type == MBPOLYGON) {
edge_vtx_idx[0] = e;
- edge_vtx_idx[1] = e+1;
+ edge_vtx_idx[1] = (e+1)%num_edges;
}
else
CN::SubEntityVertexIndices( type, 1, e, edge_vtx_idx );
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.
1
0
commit/MOAB: iulian07: Merged in iulian07/without_hdf5 (pull request #34)
by commits-noreply@bitbucket.org 14 Jul '14
by commits-noreply@bitbucket.org 14 Jul '14
14 Jul '14
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/fda46ce7dea8/
Changeset: fda46ce7dea8
Branch: master
User: iulian07
Date: 2014-07-14 16:14:00
Summary: Merged in iulian07/without_hdf5 (pull request #34)
configure without hdf5 in parallel fix
Affected #: 6 files
diff --git a/itaps/igeom/Makefile.am b/itaps/igeom/Makefile.am
index 93314d0..28d619d 100644
--- a/itaps/igeom/Makefile.am
+++ b/itaps/igeom/Makefile.am
@@ -27,7 +27,10 @@ libFBiGeomMOAB_la_include_HEADERS = \
FBiGeom_f.h
# stuff for test program
-check_PROGRAMS = testgeom testSmoothGeom testSmooth2
+check_PROGRAMS =
+if HDF5_FILE
+ check_PROGRAMS += testgeom testSmoothGeom testSmooth2
+
testgeom_SOURCES = testgeom.cc
testgeom_DEPENDENCIES = libFBiGeomMOAB.la \
$(top_builddir)/itaps/imesh/libiMesh.la \
@@ -54,7 +57,9 @@ testSmooth2_LDADD = libFBiGeomMOAB.la \
$(top_builddir)/itaps/imesh/libiMesh.la \
$(top_builddir)/src/libMOAB.la \
${MOAB_CXX_LINKFLAGS} ${MOAB_CXX_LIBS}
-
+
+endif
+
TESTS = $(check_PROGRAMS)
# Automake doesn't seem to have a directory defined for
diff --git a/itaps/imesh/Makefile.am b/itaps/imesh/Makefile.am
index 647b8c1..06e2c50 100644
--- a/itaps/imesh/Makefile.am
+++ b/itaps/imesh/Makefile.am
@@ -37,7 +37,9 @@ if PARALLEL
AM_CPPFLAGS += -I$(top_srcdir)/src/parallel -I$(top_srcdir)/src/parallel/moab
# check_PROGRAMS += partest iMeshP_unit_tests moabtest
- check_PROGRAMS += partest MOAB_iMeshP_unit_tests
+if PARALLEL_HDF5
+ check_PROGRAMS += MOAB_iMeshP_unit_tests partest
+endif
# moabtest_SOURCES = moabtest.F
# check_PROGRAMS += ftest
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 10ce709..886ef77 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -8143,9 +8143,11 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
if (MB_SUCCESS != result && print_em) {
+#ifdef HDF5_FILE
std::ostringstream ent_str;
ent_str << "mesh." << procConfig.proc_rank() << ".h5m";
mbImpl->write_mesh(ent_str.str().c_str());
+#endif
}
return result;
diff --git a/test/io/read_gcrm_nc.cpp b/test/io/read_gcrm_nc.cpp
index c4a2290..b079574 100644
--- a/test/io/read_gcrm_nc.cpp
+++ b/test/io/read_gcrm_nc.cpp
@@ -71,8 +71,6 @@ void test_read_all()
ErrorCode rval = mb.load_file(example, 0, opts.c_str());
CHECK_ERR(rval);
- mb.write_file("gcrm.h5m");
-
int procs = 1;
#ifdef USE_MPI
ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
diff --git a/test/parallel/Makefile.am b/test/parallel/Makefile.am
index b42ba0b..4d7705b 100644
--- a/test/parallel/Makefile.am
+++ b/test/parallel/Makefile.am
@@ -31,8 +31,6 @@ if USE_MPIEXEC
endif
TESTS = pcomm_unit \
- parallel_unit_tests \
- uber_parallel_test \
scdtest \
pcomm_serial \
par_spatial_locator_test \
@@ -42,7 +40,9 @@ TESTS = pcomm_unit \
$(MBCSLAM_TESTS)
if PARALLEL_HDF5
- HDF5_TESTS = parallel_hdf5_test mhdf_parallel parallel_write_test
+ HDF5_TESTS = parallel_hdf5_test mhdf_parallel parallel_write_test \
+ parallel_unit_tests \
+ uber_parallel_test
else
HDF5_TESTS =
endif
@@ -61,19 +61,31 @@ else
endif
endif
+
if ENABLE_mbcoupler
+if PARALLEL_HDF5
COUPLER_TESTS = par_coupler_test
else
COUPLER_TESTS =
+endif
+else
+ COUPLER_TESTS =
endif
if ENABLE_mbcslam
+if PARALLEL_HDF5
MBCSLAM_TESTS = par_intx_sph
else
+ MBCSLAM_TESTS =
+endif
+else
MBCSLAM_TESTS =
endif
-check_PROGRAMS = $(TESTS) mbparallelcomm_test partcheck structured3 parmerge
+check_PROGRAMS = $(TESTS) mbparallelcomm_test partcheck structured3
+if PARALLEL_HDF5
+ check_PROGRAMS += parmerge
+endif
pcomm_unit_SOURCES = pcomm_unit.cpp
parallel_hdf5_test_SOURCES = parallel_hdf5_test.cc
diff --git a/test/parallel/ucdtrvpart.cpp b/test/parallel/ucdtrvpart.cpp
index cdd5e70..062f1c1 100644
--- a/test/parallel/ucdtrvpart.cpp
+++ b/test/parallel/ucdtrvpart.cpp
@@ -128,8 +128,10 @@ void test_read_parallel(int num_verts, bool test_nb_nodes)
CHECK_EQUAL(total_verts, num_verts);
}
+#ifdef HDF5_PARALLEL
std::string write_options("PARALLEL=WRITE_PART;");
mb.write_file("test.h5m", NULL, write_options.c_str());
+#endif
}
void test_multiple_loads_of_same_file()
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.
1
0
commit/MOAB: vijaysm: Updating the DagMC test to conform to API change.
by commits-noreply@bitbucket.org 13 Jul '14
by commits-noreply@bitbucket.org 13 Jul '14
13 Jul '14
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/ce71dc160fd2/
Changeset: ce71dc160fd2
Branch: vijaysm/memory_api_llu
User: vijaysm
Date: 2014-07-14 04:30:21
Summary: Updating the DagMC test to conform to API change.
Affected #: 1 file
diff --git a/tools/dagmc/ray_fire_test.cc b/tools/dagmc/ray_fire_test.cc
index cc73a38..e7496af 100644
--- a/tools/dagmc/ray_fire_test.cc
+++ b/tools/dagmc/ray_fire_test.cc
@@ -500,9 +500,9 @@ void write_obbtree_histogram( EntityHandle root, OrientedBoxTreeTool& tree, std:
}
-void moab_memory_estimates( Interface* mbi, int& moab_data_bytes, int& moab_alldata_est_bytes ){
+void moab_memory_estimates( Interface* mbi, unsigned long long& moab_data_bytes, unsigned long long& moab_alldata_est_bytes ){
- unsigned long storage, amortized_storage;
+ unsigned long long storage, amortized_storage;
mbi->estimated_memory_use( NULL, 0, &storage, &amortized_storage );
moab_data_bytes = storage;
@@ -550,7 +550,7 @@ void dump_pyfile( char* filename, double timewith, double timewithout, double tm
DICT_VAL(timewith-timewithout);
}
DICT_VAL(tmem);
- int moab_data_bytes, moab_alldata_est_bytes;
+ unsigned long long moab_data_bytes, moab_alldata_est_bytes;
moab_memory_estimates( dagmc.moab_instance(), moab_data_bytes, moab_alldata_est_bytes );
DICT_VAL( moab_data_bytes );
DICT_VAL( moab_alldata_est_bytes );
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.
1
0
3 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/b79528d925af/
Changeset: b79528d925af
Branch: None
User: vijaysm
Date: 2014-07-13 20:55:01
Summary: Making an API change to estimate the memory usage in all of the MOAB routines: changing long to long long
Affected #: 10 files
diff --git a/src/AEntityFactory.cpp b/src/AEntityFactory.cpp
index e29df97..650ad49 100644
--- a/src/AEntityFactory.cpp
+++ b/src/AEntityFactory.cpp
@@ -1473,8 +1473,8 @@ ErrorCode AEntityFactory::set_adjacency_ptr( EntityHandle entity,
}
-void AEntityFactory::get_memory_use( unsigned long& entity_total,
- unsigned long& memory_total )
+void AEntityFactory::get_memory_use( unsigned long long& entity_total,
+ unsigned long long& memory_total )
{
entity_total = memory_total = 0;
@@ -1506,8 +1506,8 @@ void AEntityFactory::get_memory_use( unsigned long& entity_total,
ErrorCode AEntityFactory::get_memory_use( const Range& ents_in,
- unsigned long& min_per_ent,
- unsigned long& amortized )
+ unsigned long long& min_per_ent,
+ unsigned long long& amortized )
{
min_per_ent = amortized = 0;
SequenceData* prev_data = 0;
diff --git a/src/AEntityFactory.hpp b/src/AEntityFactory.hpp
index 5d3c3f3..c84a0d3 100644
--- a/src/AEntityFactory.hpp
+++ b/src/AEntityFactory.hpp
@@ -163,11 +163,11 @@ public:
ErrorCode merge_adjust_adjacencies(EntityHandle entity_to_keep,
EntityHandle entity_to_remove);
- void get_memory_use( unsigned long& total_entity_storage,
- unsigned long& total_storage );
+ void get_memory_use( unsigned long long& total_entity_storage,
+ unsigned long long& total_storage );
ErrorCode get_memory_use( const Range& entities,
- unsigned long& total_entity_storage,
- unsigned long& total_amortized_storage );
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_amortized_storage );
private:
diff --git a/src/AdaptiveKDTree.cpp b/src/AdaptiveKDTree.cpp
index 4b104b4..f629cc4 100644
--- a/src/AdaptiveKDTree.cpp
+++ b/src/AdaptiveKDTree.cpp
@@ -2154,7 +2154,7 @@ namespace moab {
all.merge( elem2d );
all.merge( elem3d );
tree_sets.insert( myRoot );
- unsigned long set_used, set_amortized, set_store_used, set_store_amortized,
+ unsigned long long set_used, set_amortized, set_store_used, set_store_amortized,
set_tag_used, set_tag_amortized, elem_used, elem_amortized;
moab()->estimated_memory_use( tree_sets,
&set_used, &set_amortized,
diff --git a/src/Core.cpp b/src/Core.cpp
index 0bd882f..620c2dd 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -3851,22 +3851,22 @@ ErrorCode Core::get_set_iterators(EntityHandle meshset,
}
void Core::estimated_memory_use_internal( const Range* ents,
- unsigned long* total_storage,
- unsigned long* total_amortized_storage,
- unsigned long* entity_storage,
- unsigned long* amortized_entity_storage,
- unsigned long* adjacency_storage,
- unsigned long* amortized_adjacency_storage,
+ unsigned long long* total_storage,
+ unsigned long long* total_amortized_storage,
+ unsigned long long* entity_storage,
+ unsigned long long* amortized_entity_storage,
+ unsigned long long* adjacency_storage,
+ unsigned long long* amortized_adjacency_storage,
const Tag* tag_array,
unsigned num_tags,
- unsigned long* tag_storage,
- unsigned long* amortized_tag_storage )
+ unsigned long long* tag_storage,
+ unsigned long long* amortized_tag_storage )
{
// Figure out which values we need to calulate
- unsigned long i_entity_storage, ia_entity_storage,
+ unsigned long long i_entity_storage, ia_entity_storage,
i_adjacency_storage, ia_adjacency_storage,
i_tag_storage, ia_tag_storage;
- unsigned long *total_tag_storage = 0,
+ unsigned long long *total_tag_storage = 0,
*amortized_total_tag_storage =0;
if (!tag_array) {
total_tag_storage = tag_storage;
@@ -3998,16 +3998,16 @@ void Core::estimated_memory_use_internal( const Range* ents,
void Core::estimated_memory_use( const EntityHandle* ent_array,
unsigned long num_ents,
- unsigned long* total_storage,
- unsigned long* total_amortized_storage,
- unsigned long* entity_storage,
- unsigned long* amortized_entity_storage,
- unsigned long* adjacency_storage,
- unsigned long* amortized_adjacency_storage,
+ unsigned long long* total_storage,
+ unsigned long long* total_amortized_storage,
+ unsigned long long* entity_storage,
+ unsigned long long* amortized_entity_storage,
+ unsigned long long* adjacency_storage,
+ unsigned long long* amortized_adjacency_storage,
const Tag* tag_array,
unsigned num_tags,
- unsigned long* tag_storage,
- unsigned long* amortized_tag_storage )
+ unsigned long long* tag_storage,
+ unsigned long long* amortized_tag_storage )
{
Range range;
@@ -4035,16 +4035,16 @@ void Core::estimated_memory_use( const EntityHandle* ent_array,
}
void Core::estimated_memory_use( const Range& ents,
- unsigned long* total_storage,
- unsigned long* total_amortized_storage,
- unsigned long* entity_storage,
- unsigned long* amortized_entity_storage,
- unsigned long* adjacency_storage,
- unsigned long* amortized_adjacency_storage,
+ unsigned long long* total_storage,
+ unsigned long long* total_amortized_storage,
+ unsigned long long* entity_storage,
+ unsigned long long* amortized_entity_storage,
+ unsigned long long* adjacency_storage,
+ unsigned long long* amortized_adjacency_storage,
const Tag* tag_array,
unsigned num_tags,
- unsigned long* tag_storage,
- unsigned long* amortized_tag_storage )
+ unsigned long long* tag_storage,
+ unsigned long long* amortized_tag_storage )
{
estimated_memory_use_internal( &ents,
total_storage, total_amortized_storage,
diff --git a/src/SequenceManager.cpp b/src/SequenceManager.cpp
index f896cf2..8ca1755 100644
--- a/src/SequenceManager.cpp
+++ b/src/SequenceManager.cpp
@@ -767,13 +767,13 @@ SequenceManager::replace_subsequence( EntitySequence* new_seq )
return typeData[type].replace_subsequence( new_seq, &tagSizes[0], tagSizes.size() );
}
-void SequenceManager::get_memory_use( unsigned long& total_entity_storage,
- unsigned long& total_storage ) const
+void SequenceManager::get_memory_use( unsigned long long& total_entity_storage,
+ unsigned long long& total_storage ) const
{
total_entity_storage = 0;
total_storage = 0;
- unsigned long temp_entity, temp_total;
+ unsigned long long temp_entity, temp_total;
for (EntityType i = MBVERTEX; i < MBMAXTYPE; ++i) {
temp_entity = temp_total = 0;
get_memory_use( i, temp_entity, temp_total );
@@ -783,19 +783,19 @@ void SequenceManager::get_memory_use( unsigned long& total_entity_storage,
}
void SequenceManager::get_memory_use( EntityType type,
- unsigned long& total_entity_storage,
- unsigned long& total_storage ) const
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_storage ) const
{
typeData[type].get_memory_use( total_entity_storage, total_storage );
}
void SequenceManager::get_memory_use( const Range& entities,
- unsigned long& total_entity_storage,
- unsigned long& total_amortized_storage ) const
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_amortized_storage ) const
{
total_entity_storage = 0;
total_amortized_storage = 0;
- unsigned long temp_entity, temp_total;
+ unsigned long long temp_entity, temp_total;
Range::const_pair_iterator i;
for (i = entities.const_pair_begin(); i != entities.const_pair_end(); ++i) {
const EntityType t1 = TYPE_FROM_HANDLE(i->first);
diff --git a/src/SequenceManager.hpp b/src/SequenceManager.hpp
index 50b1010..be70710 100644
--- a/src/SequenceManager.hpp
+++ b/src/SequenceManager.hpp
@@ -236,16 +236,16 @@ class SequenceManager
const TypeSequenceManager& entity_map( EntityType type ) const
{ return typeData[type]; }
- void get_memory_use( unsigned long& total_entity_storage,
- unsigned long& total_storage ) const;
+ void get_memory_use( unsigned long long& total_entity_storage,
+ unsigned long long& total_storage ) const;
void get_memory_use( EntityType type,
- unsigned long& total_entity_storage,
- unsigned long& total_storage ) const;
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_storage ) const;
void get_memory_use( const Range& entities,
- unsigned long& total_entity_storage,
- unsigned long& total_amortized_storage ) const;
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_amortized_storage ) const;
diff --git a/src/TypeSequenceManager.cpp b/src/TypeSequenceManager.cpp
index 50d6ef6..59f1d42 100644
--- a/src/TypeSequenceManager.cpp
+++ b/src/TypeSequenceManager.cpp
@@ -807,8 +807,8 @@ ErrorCode TypeSequenceManager::notify_prepended( iterator seq )
return rval;
}
-void TypeSequenceManager::get_memory_use( unsigned long& entity_storage,
- unsigned long& total_storage ) const
+void TypeSequenceManager::get_memory_use( unsigned long long& entity_storage,
+ unsigned long long& total_storage ) const
{
entity_storage = total_storage = 0;
if (empty())
@@ -825,8 +825,8 @@ void TypeSequenceManager::get_memory_use( unsigned long& entity_storage,
void TypeSequenceManager::append_memory_use( EntityHandle first,
EntityHandle last,
const SequenceData* data,
- unsigned long& entity_storage,
- unsigned long& total_storage ) const
+ unsigned long long& entity_storage,
+ unsigned long long& total_storage ) const
{
const unsigned long allocated_count = data->size();
@@ -865,8 +865,8 @@ void TypeSequenceManager::append_memory_use( EntityHandle first,
void TypeSequenceManager::get_memory_use( EntityHandle first,
EntityHandle last,
- unsigned long& entity_storage,
- unsigned long& total_storage ) const
+ unsigned long long& entity_storage,
+ unsigned long long& total_storage ) const
{
entity_storage = total_storage = 0;
diff --git a/src/TypeSequenceManager.hpp b/src/TypeSequenceManager.hpp
index f69bf15..bbc89fd 100644
--- a/src/TypeSequenceManager.hpp
+++ b/src/TypeSequenceManager.hpp
@@ -75,8 +75,8 @@ private:
void append_memory_use( EntityHandle first,
EntityHandle last,
const SequenceData* data,
- unsigned long& entity_storage,
- unsigned long& total_storage ) const;
+ unsigned long long& entity_storage,
+ unsigned long long& total_storage ) const;
// check if sequence at passed iterator should be merged with
// the subsequent sequence, and if so merge them retaining i.
@@ -332,12 +332,12 @@ public:
*/
ErrorCode notify_appended( iterator seq );
- void get_memory_use( unsigned long& total_entity_storage,
- unsigned long& total_storage ) const;
+ void get_memory_use( unsigned long long& total_entity_storage,
+ unsigned long long& total_storage ) const;
void get_memory_use( EntityHandle start, EntityHandle end,
- unsigned long& total_entity_storage,
- unsigned long& total_amortized_storage ) const;
+ unsigned long long& total_entity_storage,
+ unsigned long long& total_amortized_storage ) const;
unsigned long get_sequence_count() const
{ return sequenceSet.size(); }
diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index aa7d9da..d767226 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -1224,16 +1224,16 @@ public:
*/
void estimated_memory_use( const EntityHandle* ent_array = 0,
unsigned long num_ents = 0,
- unsigned long* total_storage = 0,
- unsigned long* total_amortized_storage = 0,
- unsigned long* entity_storage = 0,
- unsigned long* amortized_entity_storage = 0,
- unsigned long* adjacency_storage = 0,
- unsigned long* amortized_adjacency_storage = 0,
+ unsigned long long* total_storage = 0,
+ unsigned long long* total_amortized_storage = 0,
+ unsigned long long* entity_storage = 0,
+ unsigned long long* amortized_entity_storage = 0,
+ unsigned long long* adjacency_storage = 0,
+ unsigned long long* amortized_adjacency_storage = 0,
const Tag* tag_array = 0,
unsigned num_tags = 0,
- unsigned long* tag_storage = 0,
- unsigned long* amortized_tag_storage = 0 );
+ unsigned long long* tag_storage = 0,
+ unsigned long long* amortized_tag_storage = 0 );
/**\brief Calculate amount of memory used to store MOAB data
*
@@ -1262,16 +1262,16 @@ public:
* all tags.
*/
void estimated_memory_use( const Range& ents,
- unsigned long* total_storage = 0,
- unsigned long* total_amortized_storage = 0,
- unsigned long* entity_storage = 0,
- unsigned long* amortized_entity_storage = 0,
- unsigned long* adjacency_storage = 0,
- unsigned long* amortized_adjacency_storage = 0,
+ unsigned long long* total_storage = 0,
+ unsigned long long* total_amortized_storage = 0,
+ unsigned long long* entity_storage = 0,
+ unsigned long long* amortized_entity_storage = 0,
+ unsigned long long* adjacency_storage = 0,
+ unsigned long long* amortized_adjacency_storage = 0,
const Tag* tag_array = 0,
unsigned num_tags = 0,
- unsigned long* tag_storage = 0,
- unsigned long* amortized_tag_storage = 0 );
+ unsigned long long* tag_storage = 0,
+ unsigned long long* amortized_tag_storage = 0 );
void print_database() const;
@@ -1284,16 +1284,16 @@ private:
Core& operator=( const Core& copy );
void estimated_memory_use_internal( const Range* ents,
- unsigned long* total_storage,
- unsigned long* total_amortized_storage,
- unsigned long* entity_storage,
- unsigned long* amortized_entity_storage,
- unsigned long* adjacency_storage,
- unsigned long* amortized_adjacency_storage,
+ unsigned long long* total_storage,
+ unsigned long long* total_amortized_storage,
+ unsigned long long* entity_storage,
+ unsigned long long* amortized_entity_storage,
+ unsigned long long* adjacency_storage,
+ unsigned long long* amortized_adjacency_storage,
const Tag* tag_array,
unsigned num_tags,
- unsigned long* tag_storage,
- unsigned long* amortized_tag_storage );
+ unsigned long long* tag_storage,
+ unsigned long long* amortized_tag_storage );
//! database init and de-init routines
ErrorCode initialize();
diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 09f4219..88ce232 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -1043,16 +1043,16 @@ public:
*/
virtual void estimated_memory_use( const EntityHandle* ent_array = 0,
unsigned long num_ents = 0,
- unsigned long* total_storage = 0,
- unsigned long* total_amortized_storage = 0,
- unsigned long* entity_storage = 0,
- unsigned long* amortized_entity_storage = 0,
- unsigned long* adjacency_storage = 0,
- unsigned long* amortized_adjacency_storage = 0,
+ unsigned long long* total_storage = 0,
+ unsigned long long* total_amortized_storage = 0,
+ unsigned long long* entity_storage = 0,
+ unsigned long long* amortized_entity_storage = 0,
+ unsigned long long* adjacency_storage = 0,
+ unsigned long long* amortized_adjacency_storage = 0,
const Tag* tag_array = 0,
unsigned num_tags = 0,
- unsigned long* tag_storage = 0,
- unsigned long* amortized_tag_storage = 0 ) = 0;
+ unsigned long long* tag_storage = 0,
+ unsigned long long* amortized_tag_storage = 0 ) = 0;
/**\brief Calculate amount of memory used to store MOAB data
*
@@ -1082,16 +1082,16 @@ public:
* for all tags.
*/
virtual void estimated_memory_use( const Range& ents,
- unsigned long* total_storage = 0,
- unsigned long* total_amortized_storage = 0,
- unsigned long* entity_storage = 0,
- unsigned long* amortized_entity_storage = 0,
- unsigned long* adjacency_storage = 0,
- unsigned long* amortized_adjacency_storage = 0,
+ unsigned long long* total_storage = 0,
+ unsigned long long* total_amortized_storage = 0,
+ unsigned long long* entity_storage = 0,
+ unsigned long long* amortized_entity_storage = 0,
+ unsigned long long* adjacency_storage = 0,
+ unsigned long long* amortized_adjacency_storage = 0,
const Tag* tag_array = 0,
unsigned num_tags = 0,
- unsigned long* tag_storage = 0,
- unsigned long* amortized_tag_storage = 0 ) = 0;
+ unsigned long long* tag_storage = 0,
+ unsigned long long* amortized_tag_storage = 0 ) = 0;
/**@}*/
/** \name Higher-order elements */
https://bitbucket.org/fathomteam/moab/commits/2c9939708a03/
Changeset: 2c9939708a03
Branch: None
User: vijaysm
Date: 2014-07-13 20:55:27
Summary: Modifying the mbmem (memory estimator) tool to use the new API
Affected #: 1 file
diff --git a/tools/mbmem.cpp b/tools/mbmem.cpp
index a881fcd..538abca 100644
--- a/tools/mbmem.cpp
+++ b/tools/mbmem.cpp
@@ -116,14 +116,14 @@ int main( int argc, char* argv[] )
// struct to store memory stats
struct MemStats {
- unsigned long total_storage;
- unsigned long total_amortized;
- unsigned long entity_storage;
- unsigned long entity_amortized;
- unsigned long adjacency_storage;
- unsigned long adjacency_amortized;
- unsigned long tag_storage;
- unsigned long tag_amortized;
+ unsigned long long total_storage;
+ unsigned long long total_amortized;
+ unsigned long long entity_storage;
+ unsigned long long entity_amortized;
+ unsigned long long adjacency_storage;
+ unsigned long long adjacency_amortized;
+ unsigned long long tag_storage;
+ unsigned long long tag_amortized;
};
// test if MemStats object indicates no memory
@@ -136,7 +136,7 @@ static void get_mem_stats( moab::Interface& mb,
moab::EntityType type = moab::MBMAXTYPE );
// Formatted string representation of memory size value
-static std::string memstr( unsigned long val );
+static std::string memstr( unsigned long long val );
// Get string describing tag data type
static std::string tag_type_string( moab::Interface& mb, moab::Tag tag );
@@ -244,7 +244,7 @@ void print_memory_stats( moab::Interface& mb,
if (moab::MB_SUCCESS != rval || name.empty())
name = ANON_TAG_NAME;
- unsigned long occupied, allocated;
+ unsigned long long occupied, allocated;
mb.estimated_memory_use( 0, 0, 0, 0, 0, 0, 0, 0, &*ti, 1, &occupied, &allocated );
std::cout << std::left << std::setw(maxlen) << name << ' '
@@ -270,8 +270,8 @@ void print_memory_stats( moab::Interface& mb,
if (sysstats) {
std::FILE* filp = std::fopen("/proc/self/stat", "r");
- unsigned long vsize;
- long rss;
+ unsigned long long vsize;
+ long long rss;
if (filp && 2 == std::fscanf(filp,
"%*d " // pid
"%*s " // comm
@@ -295,8 +295,8 @@ void print_memory_stats( moab::Interface& mb,
"%*d " // num_threads
"%*d " // itrealvalue
"%*u " // starttime
- "%lu " // vsize
- "%ld", // rss
+ "%llu " // vsize
+ "%lld", // rss
&vsize, &rss )) {
#ifndef _MSC_VER
rss *= getpagesize();
@@ -313,7 +313,7 @@ void print_memory_stats( moab::Interface& mb,
std::cerr << "getrusage failed" << std::endl;
}
else {
- long int tmp_rss = sysdata.ru_maxrss;
+ long long int tmp_rss = sysdata.ru_maxrss;
rss *= getpagesize();
std::cerr << std::endl << "SYSTEM:"
<< std::endl << "Resident set size: " << memstr(tmp_rss)
@@ -360,17 +360,17 @@ void get_mem_stats( moab::Interface& mb,
}
// rounded division
-static unsigned long rdiv( unsigned long num, unsigned long den )
+static unsigned long long rdiv( unsigned long long num, unsigned long long den )
{
return (num + den/2) / den;
}
-std::string memstr( unsigned long val )
+std::string memstr( unsigned long long val )
{
- const unsigned long kb = 1024;
- const unsigned long mb = kb*kb;
- const unsigned long gb = kb*mb;
- const unsigned long tb = kb*gb;
+ const unsigned long long kb = 1024;
+ const unsigned long long mb = kb*kb;
+ const unsigned long long gb = kb*mb;
+ const unsigned long long tb = kb*gb;
std::ostringstream s;
if (UNITS == HUMAN) {
@@ -388,7 +388,7 @@ std::string memstr( unsigned long val )
s << "0 ";
}
else {
- unsigned long den = 1;
+ unsigned long long den = 1;
switch (UNITS) {
case BYTES: den = 1; break;
case KILOBYTES: den = kb; break;
https://bitbucket.org/fathomteam/moab/commits/f24cd5db25f9/
Changeset: f24cd5db25f9
Branch: vijaysm/memory_api_llu
User: vijaysm
Date: 2014-07-13 20:55:50
Summary: Fixing all the tests to conform to the new long long API change
Affected #: 4 files
diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index d70753f..3b6795c 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -6044,7 +6044,7 @@ ErrorCode mb_poly_adjacency_test2()
ErrorCode mb_memory_use_test()
{
Core mb;
- unsigned long init_total, total_with_elem, total_with_tag, total_with_tag_data;
+ unsigned long long init_total, total_with_elem, total_with_tag, total_with_tag_data;
mb.estimated_memory_use(0,0,0,&init_total);
double coords[12] = { 1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0 };
@@ -6060,7 +6060,7 @@ ErrorCode mb_memory_use_test()
if (total_with_elem <= init_total)
return MB_FAILURE;
- unsigned long min, am;
+ unsigned long long min, am;
Range r;
r.insert( elem );
mb.estimated_memory_use( r, &min, &am );
diff --git a/test/kd_tree_time.cpp b/test/kd_tree_time.cpp
index 9c34430..ecc3024 100644
--- a/test/kd_tree_time.cpp
+++ b/test/kd_tree_time.cpp
@@ -19,7 +19,7 @@ void print_file_stats(Interface& moab)
ErrorCode rval;
int num_tri;
Range sets;
- unsigned long set_mem, set_am, tag_mem, tag_am;
+ unsigned long long set_mem, set_am, tag_mem, tag_am;
rval = moab.get_number_entities_by_type(0, MBTRI, num_tri);
if (MB_SUCCESS != rval)
@@ -31,8 +31,8 @@ void print_file_stats(Interface& moab)
moab.estimated_memory_use(sets, 0, 0, &set_mem, &set_am, 0, 0, 0, 0, &tag_mem, &tag_am);
printf("Triangles: %d\n", num_tri);
printf("Sets: %lu\n", (unsigned long)sets.size());
- printf("Set storage: %lu (%lu)\n", set_mem, set_am);
- printf("Tag storage: %lu (%lu)\n", tag_mem, tag_am);
+ printf("Set storage: %llu (%llu)\n", set_mem, set_am);
+ printf("Tag storage: %llu (%llu)\n", tag_mem, tag_am);
}
int main(int argc, char* argv[])
diff --git a/test/obb/obb_tree_tool.cpp b/test/obb/obb_tree_tool.cpp
index f6fb539..bb76d88 100644
--- a/test/obb/obb_tree_tool.cpp
+++ b/test/obb/obb_tree_tool.cpp
@@ -60,10 +60,10 @@ static void usage( bool err = true )
}
#if defined(_MSC_VER) || defined(__MINGW32__)
-static void memory_use( unsigned long& vsize, unsigned long& rss )
+static void memory_use( unsigned long long& vsize, unsigned long long& rss )
{ vsize = rss = 0; }
#else
-static void memory_use( unsigned long& vsize, unsigned long& rss )
+static void memory_use( unsigned long long& vsize, unsigned long long& rss )
{
char buffer[512];
int filp = open( "/proc/self/stat", O_RDONLY );
@@ -80,7 +80,7 @@ static void memory_use( unsigned long& vsize, unsigned long& rss )
"%*u %*u %*d %*d " // utime stime cutime cstime
"%*d %*d %*d " // priority nice (unused)
"%*d %*u " // itrealval starttime
- "%lu %lu", &vsize, &rss );
+ "%llu %llu", &vsize, &rss );
rss *= getpagesize();
}
#endif
@@ -374,7 +374,7 @@ void print_stats( Interface* interface )
interface->get_entities_by_type( 0, MBVERTEX, verts );
triangles.merge( verts );
tree_sets.insert( root );
- unsigned long set_used, set_amortized, set_store_used, set_store_amortized,
+ unsigned long long set_used, set_amortized, set_store_used, set_store_amortized,
set_tag_used, set_tag_amortized, tri_used, tri_amortized;
interface->estimated_memory_use( tree_sets,
&set_used, &set_amortized,
@@ -388,7 +388,7 @@ void print_stats( Interface* interface )
tool.stats( root, std::cout );
- unsigned long real_rss, real_vsize;
+ unsigned long long real_rss, real_vsize;
memory_use( real_vsize, real_rss );
printf("------------------------------------------------------------------\n");
diff --git a/test/perf/point_location/point_location.cpp b/test/perf/point_location/point_location.cpp
index 4f5ddcc..39fde21 100644
--- a/test/perf/point_location/point_location.cpp
+++ b/test/perf/point_location/point_location.cpp
@@ -143,7 +143,7 @@ int main( int argc, char* argv[] )
// GET MEMORY USE BEFORE BUILDING TREE
- unsigned long init_total_storage;
+ unsigned long long init_total_storage;
mb.estimated_memory_use( 0, 0, &init_total_storage );
// RUN TIMING TEST
@@ -159,7 +159,7 @@ int main( int argc, char* argv[] )
break;
}
- unsigned long fini_total_storage;
+ unsigned long long fini_total_storage;
mb.estimated_memory_use( 0, 0, &fini_total_storage );
// VALIDATE RESULTS
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.
1
0
9 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/7310978da774/
Changeset: 7310978da774
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Added the HalfFacetRep class and one test code.
Affected #: 7 files
diff --git a/MeshFiles/unittest/Makefile.am b/MeshFiles/unittest/Makefile.am
index bc4f522..2bd2a8a 100644
--- a/MeshFiles/unittest/Makefile.am
+++ b/MeshFiles/unittest/Makefile.am
@@ -34,5 +34,6 @@ EXTRA_DIST = 125hex.g \
BedCrop2.h5m \
mpas_p8.h5m \
Homme_2pt.h5m \
- surfrandomtris-4part.h5m
+ surfrandomtris-4part.h5m \
+ hexes_mixed.vtk
diff --git a/MeshFiles/unittest/hexes_mixed.vtk b/MeshFiles/unittest/hexes_mixed.vtk
new file mode 100755
index 0000000..8ee5c11
--- /dev/null
+++ b/MeshFiles/unittest/hexes_mixed.vtk
@@ -0,0 +1,45 @@
+# vtk DataFile Version 3.0
+This file was written using writevtk_unstr.m
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 18 double
+0 -1 0
+0 1 0
+1 -1 0
+1 1 0
+-1 1 0
+-1 -1 0
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+-1 1 1
+-1 -1 1
+0 -1 -1
+0 1 -1
+1 -1 -1
+1 1 -1
+-1 1 -1
+-1 -1 -1
+
+CELLS 9 59
+2 0 1
+4 0 1 7 6
+4 0 2 3 1
+4 0 12 13 1
+4 0 1 4 5
+8 0 2 3 1 6 8 9 7
+8 5 0 1 4 11 6 7 10
+8 12 14 15 13 0 2 3 1
+8 17 12 13 16 5 0 1 4
+
+CELL_TYPES 9
+3
+9
+9
+9
+9
+12
+12
+12
+12
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/fathomteam/moab/commits/796dd1576217/
Changeset: 796dd1576217
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Added interface to AHF functionalities through the get_adjacencies
functions.
Affected #: 10 files
diff --git a/configure.ac b/configure.ac
index 890f70d..b0905cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -657,6 +657,13 @@ MB_OPTIONAL_TOOL([mbdepth], [yes])
MB_OPTIONAL_TOOL([refiner], [no])
MB_OPTIONAL_TOOL([h5mtools], [yes])
MB_OPTIONAL_TOOL([mbcslam], [no])
+MB_OPTIONAL_TOOL([ahf], [no])
+
+
+if test "xyes" = "x$ENABLE_ahf"; then
+ AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+fi
+
if test "xyes" = "x$ENABLE_refiner"; then
if test "xyes" != "x$WITH_MPI"; then
@@ -1333,3 +1340,27 @@ if test "x$WARN_PARALLEL_HDF5_NO_COMPLEX" = "xyes"; then
*************************************************************************])
fi
+################################################################################
+# AHF OPTIONS
+################################################################################
+#AC_ARG_ENABLE([ahf],
+#[AC_HELP_STRING([--enable-ahf],[use the half facet representation])],
+#[ case "${enableval}" in
+# yes) ahf1=true ;;
+# no) ahf1=false ;;
+# *) AC_MSG_ERROR([bad value]) ;;
+#esac],[ahf1=false])
+ #ENABLE_AHF=$enableval],[ENABLE_AHF=no] )
+
+#if test "x$ENABLE_AHF" = "xyes"; then
+# AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+#fi
+#AM_CONDITIONAL([ENABLE_AHF],[test x$ahf1 = xtrue])
+#AC_SUBST(ENABLE_AHF)
+
+
+#test "xyes" != "x$WITH_AHF" || AM_CPPFLAGS="$AM_CPPFLAGS -DUSE_AHF"
+#AM_CONDITIONAL(USE_AHF, [test "xno" != "x$WITH_AHF"])
+
+
+
diff --git a/src/Core.cpp b/src/Core.cpp
index 0bd882f..3641fd5 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -56,6 +56,10 @@
#include <errno.h>
#include <string.h>
+#ifdef USE_AHF
+#include "moab/HalfFacetRep.hpp"
+#endif
+
#ifdef USE_MPI
/* Leave ParallelComm.hpp before mpi.h or MPICH2 will fail
* because its C++ headers do not like SEEK_* macros.
@@ -272,6 +276,12 @@ ErrorCode Core::initialize()
geom_dimension_tag();
globalId_tag();
+#ifdef USE_AHF
+ ahfRep = new HalfFacetRep(this);
+ if (!ahfRep)
+ return MB_MEMORY_ALLOCATION_FAILED;
+#endif
+
return MB_SUCCESS;
}
@@ -322,6 +332,11 @@ void Core::deinitialize()
if (mpiFinalize)
MPI_Finalize();
#endif
+
+#ifdef USE_AHF
+ delete ahfRep;
+ ahfRep = 0;
+#endif
}
ErrorCode Core::query_interface_type( const std::type_info& type, void*& ptr )
@@ -1338,6 +1353,80 @@ ErrorCode get_adjacencies_union( Core* gMB,
return result;
}
+
+///////////////////////////
+///
+#ifdef USE_AHF
+template <typename ITER> static inline
+ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+ ITER begin, ITER end,
+ const int to_dimension,
+ std::vector<EntityHandle>& adj_entities )
+{
+ const size_t SORT_THRESHOLD = 200;
+ std::vector<EntityHandle> temp_vec;
+ std::vector<EntityHandle>::iterator adj_it, w_it;
+ ErrorCode result = MB_SUCCESS;
+
+ if (begin == end) {
+ adj_entities.clear(); // intersection
+ return MB_SUCCESS;
+ }
+
+ // First iteration is a special case if input list is empty.
+ // Rather than returning nothing (intersecting with empty
+ // input list), we begin with the adjacencies for the first entity.
+ if (adj_entities.empty()) {
+ EntityType type = TYPE_FROM_HANDLE(*begin);
+
+ if(to_dimension == 0 && type != MBPOLYHEDRON)
+ result = mb->get_connectivity(&(*begin), 1, adj_entities);
+ else
+ result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
+ if (MB_SUCCESS != result)
+ return result;
+ ++begin;
+ }
+
+ for (ITER from_it = begin; from_it != end; from_it++)
+ {
+ // running results kept in adj_entities; clear temp_vec, which is working space
+ temp_vec.clear();
+
+ // get the next set of adjacencies
+ EntityType type = TYPE_FROM_HANDLE(*from_it);
+ if(to_dimension == 0 && type != MBPOLYHEDRON)
+ result = mb->get_connectivity(&(*from_it), 1, temp_vec);
+ else
+ result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
+ if (MB_SUCCESS != result)
+ return result;
+
+ // otherwise intersect with the current set of results
+ w_it = adj_it = adj_entities.begin();
+ if (temp_vec.size()*adj_entities.size() < SORT_THRESHOLD) {
+ for (; adj_it != adj_entities.end(); ++adj_it)
+ if (std::find(temp_vec.begin(), temp_vec.end(), *adj_it) != temp_vec.end())
+ { *w_it = *adj_it; ++w_it; }
+ }
+ else {
+ std::sort( temp_vec.begin(), temp_vec.end() );
+ for (; adj_it != adj_entities.end(); ++adj_it)
+ if (std::binary_search(temp_vec.begin(), temp_vec.end(), *adj_it))
+ { *w_it = *adj_it; ++w_it; }
+ }
+ adj_entities.erase( w_it, adj_entities.end() );
+
+ // we're intersecting, so if there are no more results, we're done
+ if (adj_entities.empty())
+ break;
+ }
+
+ return MB_SUCCESS;
+}
+#endif
+///////////////////////////////////////////
+
template <typename ITER> static inline
ErrorCode get_adjacencies_intersection( Core* mb,
ITER begin, ITER end,
@@ -1445,37 +1534,116 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
const int to_dimension,
const bool create_if_missing,
std::vector<EntityHandle> &adj_entities,
- const int operation_type )
+ const int operation_type
+#ifdef USE_AHF
+ , const bool use_ahf)
+#else
+ )
+#endif
{
- if (operation_type == Interface::INTERSECT)
- return get_adjacencies_intersection( this, from_entities, from_entities+num_entities,
- to_dimension, create_if_missing, adj_entities );
- else if (operation_type != Interface::UNION)
- return MB_FAILURE;
- // do union
- ErrorCode result;
- std::vector<EntityHandle> tmp_storage;
- const EntityHandle* conn;
- int len;
- for (int i = 0; i < num_entities; ++i) {
- if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
- result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
- adj_entities.insert( adj_entities.end(), conn, conn+len );
- if (MB_SUCCESS != result)
- return result;
+#ifdef USE_AHF
+ bool can_handle = true;
+ int source_dim = this->dimension_from_handle(from_entities[0]);
+
+ if ((source_dim > to_dimension) && (to_dimension != 0))
+ {
+ std::cout<<"Currently Not Supported by MOAB_AHF: Down Adjacencies"<<std::endl;
+ std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;
}
- else {
- result = aEntityFactory->get_adjacencies(from_entities[i], to_dimension,
- create_if_missing, adj_entities);
- if (MB_SUCCESS != result)
- return result;
+ else if (((source_dim == 0) && (to_dimension == 2))||((source_dim == 0) && (to_dimension == 3)))
+ {
+ std::cout<<"Currently Not Supported by MOAB_AHF: Vertex to face/cell"<<std::endl;
+ std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;
+ }
+ else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
+ {
+ std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
+ std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;
+ }
+ else if (create_if_missing)
+ {
+ std::cout<<"Currently Not Supporteded by MOAB_AHF: create_if_missing capability "<<std::endl;
+ std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;
}
- }
- std::sort( adj_entities.begin(), adj_entities.end() );
- adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
- return MB_SUCCESS;
+ if ((use_ahf) && (can_handle))
+ {
+
+ if (operation_type == Interface::INTERSECT)
+ return get_adjacencies_intersection_ahf(this, from_entities, from_entities+num_entities,
+ to_dimension, adj_entities );
+ else if (operation_type != Interface::UNION)
+ return MB_FAILURE;
+
+ // do union
+ ErrorCode result;
+ std::vector<EntityHandle> tmp_storage;
+ const EntityHandle* conn;
+ int len;
+ for (int i = 0; i < num_entities; ++i) {
+ if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
+ result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
+ adj_entities.insert( adj_entities.end(), conn, conn+len );
+ if (MB_SUCCESS != result)
+ return result;
+ }
+ else {
+ result = ahfRep->get_adjacencies(from_entities[i], to_dimension, adj_entities);
+ if (MB_SUCCESS != result)
+ return result;
+ }
+ }
+ std::sort( adj_entities.begin(), adj_entities.end() );
+ adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
+
+ }
+ else
+ {
+
+#endif
+
+ if (operation_type == Interface::INTERSECT)
+ return get_adjacencies_intersection( this, from_entities, from_entities+num_entities,
+ to_dimension, create_if_missing, adj_entities );
+ else if (operation_type != Interface::UNION)
+ return MB_FAILURE;
+
+ // do union
+ ErrorCode result;
+ std::vector<EntityHandle> tmp_storage;
+ const EntityHandle* conn;
+ int len;
+ for (int i = 0; i < num_entities; ++i) {
+ if(to_dimension == 0 && TYPE_FROM_HANDLE(from_entities[0]) != MBPOLYHEDRON) {
+ result = get_connectivity(from_entities[i], conn, len, false, &tmp_storage);
+ adj_entities.insert( adj_entities.end(), conn, conn+len );
+ if (MB_SUCCESS != result)
+ return result;
+ }
+ else {
+ result = aEntityFactory->get_adjacencies(from_entities[i], to_dimension,
+ create_if_missing, adj_entities);
+ if (MB_SUCCESS != result)
+ return result;
+ }
+ }
+ std::sort( adj_entities.begin(), adj_entities.end() );
+ adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
+
+ //return MB_SUCCESS;
+
+
+#ifdef USE_AHF
+ }
+#endif
+
+return MB_SUCCESS;
+
}
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 95efb7e..f3818a6 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -17,21 +17,32 @@
#pragma warning (disable : 4786)
#endif
+#include "moab/HalfFacetRep.hpp"
#include <iostream>
#include <assert.h>
-#include <time.h>
#include <vector>
-#include <queue>
-#include <stack>
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "moab/CN.hpp"
-#include "moab/HalfFacetRep.hpp"
namespace moab {
const int MAXSIZE = 500;
+ HalfFacetRep::HalfFacetRep(Core *impl)
+ {
+ assert(NULL != impl);
+ mb = impl;
+ mInitAHFmaps = false;
+ }
+
+ HalfFacetRep::~HalfFacetRep()
+ {
+ ErrorCode result;
+ result = deinitialize();
+ //if (MB_SUCCESS != result) return result;
+ }
+
MESHTYPE HalfFacetRep::get_mesh_type(int nverts, int nedges, int nfaces, int ncells)
{
MESHTYPE mesh_type;
@@ -58,7 +69,9 @@ namespace moab {
* initialize *
******************************************************/
- ErrorCode HalfFacetRep::initialize(){
+ ErrorCode HalfFacetRep::initialize()
+ {
+ mInitAHFmaps = true;
ErrorCode error;
@@ -436,36 +449,100 @@ namespace moab {
* User interface for adjacency functions *
********************************************************/
- ErrorCode HalfFacetRep::get_upward_incidences(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lids)
+ ErrorCode HalfFacetRep::get_adjacencies(const EntityHandle source_entity,
+ const unsigned int target_dimension,
+ std::vector<EntityHandle> &target_entities)
+ {
+
+ ErrorCode error;
+
+ unsigned int source_dimension = mb->dimension_from_handle(source_entity);
+
+ if (mInitAHFmaps == false)
+ {
+ error = initialize();
+ if (MB_SUCCESS != error) return error;
+ }
+
+ if ((source_dimension == 0) && (target_dimension == 1))
+ {
+ error = get_up_adjacencies_1d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+
+ else if ((source_dimension == 1) && (target_dimension == 2))
+ {
+ error = get_up_adjacencies_2d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if ((source_dimension == 1) && (target_dimension == 3))
+ {
+ error = get_up_adjacencies_edg_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if ((source_dimension == 2) && (target_dimension ==3))
+ {
+ error = get_up_adjacencies_face_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (source_dimension == target_dimension)
+ {
+ if (target_dimension == 1)
+ {
+ error = get_neighbor_adjacencies_1d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+
+ else if (target_dimension == 2)
+ {
+ error = get_neighbor_adjacencies_2d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (target_dimension == 3)
+ {
+ error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ }
+ return MB_SUCCESS;
+ }
+
+
+ ErrorCode HalfFacetRep::get_up_adjacencies(EntityHandle ent,
+ int out_dim,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * lids)
{
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
if ((in_dim == 0) && (out_dim == 1))
{
- error = get_upward_incidences_1d(ent, adjents, local_id, lids);
+ error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
if (MB_SUCCESS != error) return error;
}
else if ((in_dim == 1) && (out_dim == 2))
{
- error = get_upward_incidences_2d(ent, adjents, local_id, lids);
+ error = get_up_adjacencies_2d(ent, adjents, local_id, lids);
if (MB_SUCCESS != error) return error;
}
else if ((in_dim == 1) && (out_dim == 3))
{
- error = get_upward_incidences_edg_3d(ent, adjents, local_id, lids);
+ error = get_up_adjacencies_edg_3d(ent, adjents, local_id, lids);
if (MB_SUCCESS != error) return error;
}
else if ((in_dim == 2) && (out_dim ==3))
{
- error = get_upward_incidences_face_3d(ent, adjents, local_id, lids);
+ error = get_up_adjacencies_face_3d(ent, adjents, local_id, lids);
if (MB_SUCCESS != error) return error;
}
return MB_SUCCESS;
}
- ErrorCode HalfFacetRep::get_neighbor_adjacencies(EntityHandle ent, std::vector<EntityHandle> &adjents)
+ ErrorCode HalfFacetRep::get_neighbor_adjacencies(EntityHandle ent,
+ std::vector<EntityHandle> &adjents)
{
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
@@ -619,8 +696,11 @@ namespace moab {
return MB_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_1d( EntityHandle vid, std::vector< EntityHandle > &adjents, bool local_id, std::vector<int> * lvids){
- ErrorCode error;
+ ErrorCode HalfFacetRep::get_up_adjacencies_1d( EntityHandle vid,
+ std::vector< EntityHandle > &adjents,
+ bool local_id,
+ std::vector<int> * lvids){
+ ErrorCode error;
EntityHandle start_eid, eid, sibeid[2];
int start_lid, lid, siblid[2];
@@ -655,7 +735,8 @@ namespace moab {
return MB_SUCCESS;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_neighbor_adjacencies_1d( EntityHandle eid, std::vector<EntityHandle> &adjents){
+ ErrorCode HalfFacetRep::get_neighbor_adjacencies_1d( EntityHandle eid,
+ std::vector<EntityHandle> &adjents){
ErrorCode error;
@@ -912,9 +993,65 @@ namespace moab {
return MB_SUCCESS;
}
+ ///////////////////////////////////////////////////////////////////
+ /* ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+ {
+ ErrorCode error;
+
+ EntityHandle fid; int lid;
+ error = mb->tag_get_data(v2he_fid, &vid, 1, &fid);
+ if (MB_SUCCESS != error) return error;
+ error = mb->tag_get_data(v2he_leid, &vid, 1, &lid);
+ if (MB_SUCCESS != error) return error;
+
+ if (fid != 0)
+ {
+ adjents.push_back(fid);
+
+ EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
+ int queue_lid[MAXSIZE];
+ for (int i = 0; i< MAXSIZE; i++)
+ {
+ queue_fid[i] = 0;
+ queue_lid[i] = 0;
+ trackfaces[i] = 0;
+ }
+ int qsize = 0, tcount = -1;
+ int num_qvals = 0;
+ error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+ if (MB_SUCCESS != error) return error;
+
+ while (num_qvals < *qsize)
+ {
+ EntityHandle curfid = queue_fid[num_qvals];
+ int curlid = queue_lid[num_qvals];
+ num_qvals += 1;
+
+ EntityHandle he2_fid; int he2_lid;
+ error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
+ if (MB_SUCCESS != error) return error;
+ bool found_ent = find_match_in_array(he2_fid, trackfaces, tcount[0]);
+
+ if (found_ent)
+ continue;
+ tcount[0] += 1;
+ trackfaces[tcount[0]] = he2_fid;
+
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ if (MB_SUCCESS != error) return error;
+
+ adjents.push_back(he2_fid);
+
+ }
+ }
+ }
+*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_2d( EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * leids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_2d( EntityHandle eid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * leids)
{
// Given an explicit edge eid, find the incident faces.
@@ -928,7 +1065,7 @@ namespace moab {
// Step 2: If there is a corresponding half-edge, collect all sibling half-edges and store the incident faces.
if (found)
{
- error = get_upward_incidences_2d(he_fid, he_lid, true, adjents, local_id, leids);
+ error = get_up_adjacencies_2d(he_fid, he_lid, true, adjents, local_id, leids);
if (MB_SUCCESS != error) return error;
}
@@ -936,7 +1073,12 @@ namespace moab {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_2d( EntityHandle fid, int leid, bool add_inent, std::vector<EntityHandle> &fids, bool local_id, std::vector<int> * leids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_2d( EntityHandle fid,
+ int leid,
+ bool add_inent,
+ std::vector<EntityHandle> &fids,
+ bool local_id,
+ std::vector<int> * leids)
{
// Given an implicit half-edge <fid, leid>, find the incident half-edges.
ErrorCode error;
@@ -982,7 +1124,13 @@ namespace moab {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_2d(EntityHandle fid, int lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount)
+ ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle fid,
+ int lid,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount)
{
ErrorCode error;
@@ -1035,7 +1183,9 @@ namespace moab {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool HalfFacetRep::find_matching_halfedge( EntityHandle eid, EntityHandle *hefid, int *helid){
+ bool HalfFacetRep::find_matching_halfedge( EntityHandle eid,
+ EntityHandle *hefid,
+ int *helid){
ErrorCode error;
std::vector<EntityHandle> conn(2);
error = mb->get_connectivity(&eid, 1, conn);
@@ -1071,7 +1221,14 @@ namespace moab {
return found;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid, EntityHandle he_fid, int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount)
+ ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid,
+ EntityHandle he_fid,
+ int he_lid,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount)
{
ErrorCode error;
EntityHandle he2_fid = 0; int he2_lid = 0;
@@ -1086,16 +1243,20 @@ namespace moab {
tcount[0] += 1;
trackfaces[tcount[0]] = he_fid;
- error = get_upward_incidences_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
if (MB_SUCCESS != error) return error;
- error = get_upward_incidences_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
if (MB_SUCCESS != error) return error;
return MB_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::another_halfedge( EntityHandle vid, EntityHandle he_fid, int he_lid, EntityHandle *he2_fid, int *he2_lid)
+ ErrorCode HalfFacetRep::another_halfedge( EntityHandle vid,
+ EntityHandle he_fid,
+ int he_lid,
+ EntityHandle *he2_fid,
+ int *he2_lid)
{
ErrorCode error;
int nepf;
@@ -1121,7 +1282,14 @@ namespace moab {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount, EntityHandle *he_fid, int *he_lid)
+ bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount,
+ EntityHandle *he_fid,
+ int *he_lid)
{
ErrorCode error;
int nepf = local_maps_2d(*_faces.begin());
@@ -1162,7 +1330,7 @@ namespace moab {
error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
if (MB_SUCCESS != error) return error;
- error = get_upward_incidences_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
if (MB_SUCCESS != error) return error;
counter += 1;
@@ -1174,14 +1342,15 @@ namespace moab {
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid, std::vector<EntityHandle> &adjents)
+ ErrorCode HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid,
+ std::vector<EntityHandle> &adjents)
{
ErrorCode error;
if (fid != 0){
int nepf = local_maps_2d(fid);
for (int lid = 0; lid < nepf; ++lid){
- error = get_upward_incidences_2d(fid, lid, false, adjents);
+ error = get_up_adjacencies_2d(fid, lid, false, adjents);
if (MB_SUCCESS != error) return error;
}
}
@@ -1212,7 +1381,7 @@ namespace moab {
int id = nepf*(*f-firstF)+l;
if (!trackF[id])
{
- error = get_upward_incidences_2d(*f,l, false, adj_fids, true, &adj_lids);
+ error = get_up_adjacencies_2d(*f,l, false, adj_fids, true, &adj_lids);
if (MB_SUCCESS != error) return error;
total_edges -= adj_fids.size();
@@ -1530,7 +1699,10 @@ namespace moab {
}
//////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_edg_3d( EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * leids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle eid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * leids)
{
ErrorCode error;
@@ -1542,7 +1714,7 @@ namespace moab {
//Find all incident cells
if (found)
{
- error =get_upward_incidences_edg_3d(cid, leid, adjents, local_id, leids);
+ error =get_up_adjacencies_edg_3d(cid, leid, adjents, local_id, leids);
if (MB_SUCCESS != error) return error;
}
@@ -1550,7 +1722,11 @@ namespace moab {
}
//////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_edg_3d( EntityHandle cid, int leid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * leids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle cid,
+ int leid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * leids)
{
ErrorCode error;
@@ -1648,7 +1824,10 @@ namespace moab {
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_face_3d( EntityHandle fid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lfids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_face_3d( EntityHandle fid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * lfids)
{
ErrorCode error;
@@ -1657,14 +1836,18 @@ namespace moab {
bool found = find_matching_halfface(fid, &cid, &lid);
if (found){
- error = get_upward_incidences_face_3d(cid, lid, adjents, local_id, lfids);
+ error = get_up_adjacencies_face_3d(cid, lid, adjents, local_id, lfids);
if (MB_SUCCESS != error) return error;
}
return MB_SUCCESS;
}
///////////////////////////////////////////
- ErrorCode HalfFacetRep::get_upward_incidences_face_3d( EntityHandle cid, int lfid, std::vector<EntityHandle> &adjents, bool local_id, std::vector<int> * lfids)
+ ErrorCode HalfFacetRep::get_up_adjacencies_face_3d( EntityHandle cid,
+ int lfid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id,
+ std::vector<int> * lfids)
{
ErrorCode error;
@@ -1701,7 +1884,9 @@ namespace moab {
return MB_SUCCESS;
}
/////////////////////////////////////////////////////////////////
- bool HalfFacetRep::find_matching_implicit_edge_in_cell( EntityHandle eid, EntityHandle *cid, int *leid)
+ bool HalfFacetRep::find_matching_implicit_edge_in_cell( EntityHandle eid,
+ EntityHandle *cid,
+ int *leid)
{
ErrorCode error;
diff --git a/src/Makefile.am b/src/Makefile.am
index e2bf713..6fac039 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -226,6 +226,12 @@ if HAVE_CGM
AM_CPPFLAGS += @CGM_CPPFLAGS@ -DCGM @MOAB_CGM_DEFINES@
endif
+# if ENABLE_ahf
+ # libMOAB_la_SOURCES += HalfFacetRep.cpp
+ # nobase_libMOAB_la_include_HEADERS += moab/HalfFacetRep.hpp
+# AM_CPPFLAGS += -DUSE_AHF
+# endif
+
MBCN_protos.h: MBCN.h $(top_srcdir)/itaps/mkprotos.sh
$(AM_V_GEN)$(top_srcdir)/itaps/mkprotos.sh MBCN MOAB $< $@ MOAB_FCDefs.h
diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index aa7d9da..941129a 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -35,6 +35,10 @@ class EntitySequence;
class FileOptions;
class SetIterator;
+#ifdef USE_AHF
+class HalfFacetRep;
+#endif
+
#ifdef XPCOM_MB
#define MBCORE_CID \
@@ -311,12 +315,18 @@ public:
get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies );
\endcode */
- virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
- const int num_entities,
- const int to_dimension,
- const bool create_if_missing,
- std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT);
+ virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+ const int num_entities,
+ const int to_dimension,
+ const bool create_if_missing,
+ std::vector<EntityHandle>& adj_entities,
+ const int operation_type = Interface::INTERSECT
+ #ifdef USE_AHF
+ , const bool use_ahf = false);
+ #else
+ );
+ #endif
+
virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
const int num_entities,
@@ -1126,7 +1136,12 @@ public:
//! return the a_entity_factory pointer
AEntityFactory *a_entity_factory() { return aEntityFactory; }
const AEntityFactory *a_entity_factory() const { return aEntityFactory; }
-
+
+#ifdef USE_AHF
+ HalfFacetRep *a_half_facet_rep() { return ahfRep; }
+ const HalfFacetRep *a_half_facet_rep() const {return ahfRep; }
+#endif
+
//! return set of registered IO tools
ReaderWriterSet* reader_writer_set() { return readerWriterSet; }
@@ -1347,6 +1362,10 @@ private:
//! list of iterators
std::vector<SetIterator*> setIterators;
+
+#ifdef USE_AHF
+ HalfFacetRep *ahfRep;
+#endif
};
diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index eca5e91..3d1069a 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -52,14 +52,15 @@ namespace moab {
VOLUME_MIXED //Volume mesh with embedded curves and surfaces
};
-
+ class Core;
+
class HalfFacetRep{
public:
- HalfFacetRep(Interface *impl) : mb(impl) {}
+ HalfFacetRep(Core *impl);
- ~HalfFacetRep() {}
+ ~HalfFacetRep();
// User interface functions
@@ -74,6 +75,12 @@ namespace moab {
//! Prints the tag values.
ErrorCode print_tags();
+
+ ErrorCode get_adjacencies(const EntityHandle source_entity,
+ const unsigned int target_dimension,
+ std::vector<EntityHandle> &target_entities);
+
+
//! Get the upward incidences associated with an entity.
/** Given an entity of dimension <em>d</em>, gather all the incident <em>D(>d)</em> dimensional entities.
* Parameters:
@@ -84,7 +91,11 @@ namespace moab {
* \param lids Vector in which the local id's are returned.
*/
- ErrorCode get_upward_incidences(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lids = NULL );
+ ErrorCode get_up_adjacencies(EntityHandle ent,
+ int out_dim,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * lids = NULL );
//! Get the same-dimensional entities connected with an entity.
/** Given an entity of dimension <em>d</em>, gather all the entities connected via <em>d-1</em> dimensional entities.
@@ -94,7 +105,8 @@ namespace moab {
* \param adjents Vector in which the neighbor entities are returned.
*/
- ErrorCode get_neighbor_adjacencies(EntityHandle ent, std::vector<EntityHandle> &adjents);
+ ErrorCode get_neighbor_adjacencies(EntityHandle ent,
+ std::vector<EntityHandle> &adjents);
// 1D Maps and queries
@@ -127,7 +139,10 @@ namespace moab {
* \param lvids Vector returning the local vertex id's
*/
- ErrorCode get_upward_incidences_1d(EntityHandle vid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lvids = NULL);
+ ErrorCode get_up_adjacencies_1d(EntityHandle vid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * lvids = NULL);
//! Given an edge, finds vertex-connected neighbor edges
/** Given an edge, it gathers all the incident edges of each vertex of the edge.
@@ -136,7 +151,8 @@ namespace moab {
* \param adjents Vector returning neighbor edges
*/
- ErrorCode get_neighbor_adjacencies_1d(EntityHandle eid, std::vector<EntityHandle> &adjents);
+ ErrorCode get_neighbor_adjacencies_1d(EntityHandle eid,
+ std::vector<EntityHandle> &adjents);
// 2D Maps and queries
@@ -161,6 +177,9 @@ namespace moab {
ErrorCode determine_incident_halfedges(Range &faces);
+ /* ErrorCode get_up_adjacencies_2d(EntityHandle vid,
+ std::vector<EntityHandle> &adjents);*/
+
//! Given an edge, finds the faces incident on it.
/** Given an edge, it first finds a matching half-edge corresponding to eid, and then
* collects all the incident half-edges/faces via the sibhes map.
@@ -171,7 +190,10 @@ namespace moab {
* \param leids Vector returning local edge ids
*/
- ErrorCode get_upward_incidences_2d(EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+ ErrorCode get_up_adjacencies_2d(EntityHandle eid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * leids = NULL);
//! Given a half-edge <fid, leid>, finds the faces incident on it.
/**
@@ -184,7 +206,12 @@ namespace moab {
* \param leids Vector returning local edge ids
*/
- ErrorCode get_upward_incidences_2d(EntityHandle fid, int leid, bool add_inent, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+ ErrorCode get_up_adjacencies_2d(EntityHandle fid,
+ int leid,
+ bool add_inent,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * leids = NULL);
//! Given an edge, finds edge-connected neighbor face
/** Given an face, it gathers all the neighbor faces of each local edge of the face.
@@ -193,7 +220,8 @@ namespace moab {
* \param adjents Vector returning neighbor faces
*/
- ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid, std::vector<EntityHandle> &adjents);
+ ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
+ std::vector<EntityHandle> &adjents);
//! Given a range of faces, finds the total number of edges.
@@ -229,7 +257,8 @@ namespace moab {
* \param isborder: A dense tag over all vertices of size 1. Value is true for a border vertex, otherwise is false.
*/
- ErrorCode determine_border_vertices( Range &cells, Tag isborder);
+ ErrorCode determine_border_vertices( Range &cells,
+ Tag isborder);
//! Given an edge, finds the cells incident on it.
/** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
@@ -241,7 +270,10 @@ namespace moab {
* \param leids Vector returning local edge ids
*/
- ErrorCode get_upward_incidences_edg_3d(EntityHandle eid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+ ErrorCode get_up_adjacencies_edg_3d(EntityHandle eid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * leids = NULL);
//! Given a local edge <cid, leid>, finds the cells incident on it.
/** Given a local edge, it gathers all the incident cells via the sibhfs map.
@@ -253,7 +285,10 @@ namespace moab {
* \param leids Vector returning local edge ids
*/
- ErrorCode get_upward_incidences_edg_3d(EntityHandle cid, int leid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * leids = NULL);
+ ErrorCode get_up_adjacencies_edg_3d(EntityHandle cid,
+ int leid, std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * leids = NULL);
//! Given an face, finds the cells incident on it.
/** Given an face, it first finds a matching half-face in a cell corresponding to face, and then
@@ -265,7 +300,10 @@ namespace moab {
* \param leids Vector returning local face ids
*/
- ErrorCode get_upward_incidences_face_3d(EntityHandle fid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lfids = NULL);
+ ErrorCode get_up_adjacencies_face_3d(EntityHandle fid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * lfids = NULL);
//! Given a local face <cid, lfid>, finds the cells incident on it.
/** Given a local face, it gathers all the incident cells via the sibhfs map.
@@ -277,7 +315,11 @@ namespace moab {
* \param lfids Vector returning local face ids
*/
- ErrorCode get_upward_incidences_face_3d(EntityHandle cid, int lfid, std::vector<EntityHandle> &adjents, bool local_id = false, std::vector<int> * lfids = NULL);
+ ErrorCode get_up_adjacencies_face_3d(EntityHandle cid,
+ int lfid,
+ std::vector<EntityHandle> &adjents,
+ bool local_id = false,
+ std::vector<int> * lfids = NULL);
//! Given a cell, finds face-connected neighbor cells
/** Given a cell, it gathers all the neighbor cells of each local face of the cell.
@@ -286,12 +328,17 @@ namespace moab {
* \param adjents Vector returning neighbor cells
*/
- ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
+ ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
+ std::vector<EntityHandle> &adjents);
protected:
- Interface * mb;
+ Core * mb;
+
+ HalfFacetRep();
+
+ bool mInitAHFmaps;
enum {
MAX_VERTICES = 8,
@@ -351,14 +398,23 @@ namespace moab {
* queue of half-edges, if they do not already exist in the queue. This function is used to increment the
* search space for finding a matching half-edge.
* Parameters:
- * \param <EntityHandle he_fid, int he_lid> The query half-edge
- * \param queue_fid, queue_lid, qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
+ * \param he_fid EntityHandle of query half-edge
+ * \param he_lid Local id of query half-edge
+ * \param queue_fid
+ * \param queue_lid
+ * \param qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
* \param trackfaces Array containing faces. If fid of an incident half-edge doesn't belong to trackfaces,
* the half-edge is added to the queue.
* \param tcount Current size of trackfaces
*/
- ErrorCode get_upward_incidences_2d(EntityHandle he_fid, int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount);
+ ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
+ int he_lid,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount);
//! Given an edge, finds a matching half-edge in the surface.
/** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
@@ -369,7 +425,9 @@ namespace moab {
* \param hefid, helid: Returns the matching half-edge corresponding to the query edge.
*/
- bool find_matching_halfedge( EntityHandle eid, EntityHandle *hefid, int *helid);
+ bool find_matching_halfedge( EntityHandle eid,
+ EntityHandle *hefid,
+ int *helid);
//! Gather half-edges to a queue of half-edges.
/** Given a vertex vid, and a half-edge <he_fid,he_lid>, add another half-edge in the same face sharing the vertex
@@ -381,7 +439,14 @@ namespace moab {
* \param trackfaces, tcount
*/
- ErrorCode gather_halfedges( EntityHandle vid, EntityHandle he_fid, int he_lid, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount);
+ ErrorCode gather_halfedges( EntityHandle vid,
+ EntityHandle he_fid,
+ int he_lid,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount);
//! Obtains another half-edge belonging to the same face as the input half-edge
/** It uses the local maps to find another half-edge that is either incident or outgoing depending
@@ -392,7 +457,11 @@ namespace moab {
* \param <EntityHandle he2_fid, int he2_lid>: Returns another half-edge in the same he_fid sharing vid.
*/
- ErrorCode another_halfedge( EntityHandle vid, EntityHandle he_fid, int he_lid, EntityHandle *he2_fid, int *he2_lid);
+ ErrorCode another_halfedge( EntityHandle vid,
+ EntityHandle he_fid,
+ int he_lid,
+ EntityHandle *he2_fid,
+ int *he2_lid);
//! Collect and compare to find a matching half-edge with the given edge connectivity.
/** Given edge connectivity, compare to an input list of half-edges to find a matching half-edge
@@ -404,7 +473,14 @@ namespace moab {
* \param <EntityHandle he_fid, int he_lid>: Returns matching half-edge
*/
- bool collect_and_compare(std::vector<EntityHandle> &edg_vert, EntityHandle *queue_fid, int *queue_lid, int *qsize, EntityHandle *trackfaces, int *tcount, EntityHandle *he_fid, int *he_lid);
+ bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
+ EntityHandle *queue_fid,
+ int *queue_lid,
+ int *qsize,
+ EntityHandle *trackfaces,
+ int *tcount,
+ EntityHandle *he_fid,
+ int *he_lid);
//! The local maps for 3D entities.
@@ -469,7 +545,9 @@ namespace moab {
* \param leid Returns the local id of the edge corresponding to the input edge w.r.t the incident cell.
*/
- bool find_matching_implicit_edge_in_cell( EntityHandle eid, EntityHandle *cid, int *leid);
+ bool find_matching_implicit_edge_in_cell( EntityHandle eid,
+ EntityHandle *cid,
+ int *leid);
//! Given a face, finds a matching local face in an incident cell.
/** Find a local face with the same connectivity as the input face, belonging to an incident cell.
@@ -479,9 +557,15 @@ namespace moab {
* \param lfid Returns the local id of the face corresponding to the input face w.r.t the incident cell.
*/
- bool find_matching_halfface(EntityHandle fid, EntityHandle *cid, int *leid);
+ bool find_matching_halfface(EntityHandle fid,
+ EntityHandle *cid,
+ int *leid);
- bool find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index = false, int *index = NULL);
+ bool find_match_in_array(EntityHandle ent,
+ EntityHandle *ent_list,
+ int count,
+ bool get_index = false,
+ int *index = NULL);
};
diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 09f4219..bfd5fb0 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -624,7 +624,12 @@ public:
const int to_dimension,
const bool create_if_missing,
std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT) = 0;
+ const int operation_type = Interface::INTERSECT
+ #ifdef USE_AHF
+ , const bool use_ahf = false) = 0;
+ #else
+ ) = 0;
+ #endif
//! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
/** Identical to vector-based get_adjacencies function, except results are returned in a
diff --git a/test/Makefile.am b/test/Makefile.am
index fe7edb6..34432d0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,6 +61,10 @@ if HDF5_FILE
lloyd_smoother_test
endif
+if ENABLE_ahf
+ TESTS += ahf_mbintf_test
+endif
+
# merge_test \ # input files no longer exist?
# test_tag_server \ # fails
@@ -154,6 +158,11 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
ahf_test_SOURCES = test_ahf_moab.cpp
+if ENABLE_ahf
+ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+endif
+
+
if PARALLEL
moab_test_CPPFLAGS += -I$(top_srcdir)/src/parallel
kd_tree_test_CPPFLAGS += -I$(top_srcdir)/src/parallel
diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
new file mode 100755
index 0000000..9bf76ef
--- /dev/null
+++ b/test/test_ahf_mb_interface.cpp
@@ -0,0 +1,174 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include "TestUtil.hpp"
+
+using namespace moab;
+
+#ifdef MESHDIR
+static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+#else
+static const char example[] = "/hexes_mixed.vtk";
+#endif
+
+void ahf_mbintf_test()
+{
+
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ ErrorCode error = mbImpl->load_file(example);
+ CHECK_ERR(error);
+
+ /*Create ranges for handles of explicit elements of the mixed mesh*/
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range mbents, ahfents;
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(),mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ1: For every edge, obtain neighbor edges
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 2D Queries
+ //IQ2: For every edge, obtain incident faces
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ2: For every face, obtain neighbor faces
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 3D Queries
+ // IQ 31: For every edge, obtain incident cells
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ32: For every face, obtain incident cells
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ3: For every cell, obtain neighbor cells
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+}
+
+int main(int argc, char *argv[])
+{
+ int result = 0;
+
+ argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
+
+ result += RUN_TEST(ahf_mbintf_test);
+
+ return result;
+}
+
diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index ff97fb1..93bd947 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -34,7 +34,7 @@ void ahf_test()
error = mbImpl->get_entities_by_dimension( 0, 3, cells);
// Create an ahf instance
- HalfFacetRep ahf(mbImpl);
+ HalfFacetRep ahf(&moab);
// Call the initialize function which creates the maps for each dimension
ahf.initialize();
@@ -47,7 +47,7 @@ void ahf_test()
//IQ1: For every vertex, obtain incident edges
for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
adjents.clear();
- error = ahf.get_upward_incidences( *i, 1, adjents);
+ error = ahf.get_up_adjacencies( *i, 1, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
@@ -82,7 +82,7 @@ void ahf_test()
//IQ2: For every edge, obtain incident faces
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
- error = ahf.get_upward_incidences( *i, 2, adjents);
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
@@ -117,7 +117,7 @@ void ahf_test()
// IQ 31: For every edge, obtain incident cells
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
- error = ahf.get_upward_incidences( *i, 3, adjents);
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -134,7 +134,7 @@ void ahf_test()
//IQ32: For every face, obtain incident cells
for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
adjents.clear();
- error = ahf.get_upward_incidences( *i, 3, adjents);
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -165,7 +165,7 @@ void ahf_test()
CHECK(!mbents.size());
}
- ahf.deinitialize();
+ //ahf.deinitialize();
}
https://bitbucket.org/fathomteam/moab/commits/7431d9311014/
Changeset: 7431d9311014
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Removed tag_iterate from sibling half-facet maps. Changed input to
test_ahf_moab to read in meshfile from command line. Added a test code
for timing and memory requirements.
Affected #: 9 files
diff --git a/src/Core.cpp b/src/Core.cpp
index 3641fd5..692495b 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -1540,6 +1540,12 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
#else
)
#endif
+/*ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
+ const int num_entities,
+ const int to_dimension,
+ const bool create_if_missing,
+ std::vector<EntityHandle> &adj_entities,
+ const int operation_type)*/
{
#ifdef USE_AHF
@@ -1558,6 +1564,12 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
can_handle = false;
}
+ else if (to_dimension == 4)
+ {
+ std::cout<<"Currently Not Supported by MOAB_AHF: meshsets"<<std::endl;
+ std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;
+ }
else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
{
std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
@@ -1571,7 +1583,9 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
can_handle = false;
}
+
if ((use_ahf) && (can_handle))
+ //if (can_handle)
{
if (operation_type == Interface::INTERSECT)
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index f3818a6..449a48a 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -27,7 +27,7 @@
namespace moab {
- const int MAXSIZE = 500;
+ const int MAXSIZE = 150;
HalfFacetRep::HalfFacetRep(Core *impl)
{
@@ -573,15 +573,6 @@ namespace moab {
{
ErrorCode error;
- EntityHandle start_edge = *edges.begin();
- int count, *sibhvs_lvid_ptr; EntityHandle *sibhvs_eid_ptr;
- error = mb->tag_iterate(sibhvs_eid, edges.begin(), edges.end(), count, (void*&)sibhvs_eid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) edges.size());
- error = mb->tag_iterate(sibhvs_lvid, edges.begin(), edges.end(), count, (void*&)sibhvs_lvid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) edges.size());
-
//Step 1: Create an index list storing the starting position for each vertex
int nv = _verts.size();
int *is_index = new int[nv+1];
@@ -595,8 +586,10 @@ namespace moab {
error = mb->get_connectivity(&*eid, 1, conn);
if (MB_SUCCESS != error) return error;
- is_index[conn[0]-*_verts.begin()+1] += 1;
- is_index[conn[1]-*_verts.begin()+1] += 1;
+ int index = _verts.index(conn[0]);
+ is_index[index+1] += 1;
+ index = _verts.index(conn[1]);
+ is_index[index+1] += 1;
}
is_index[0] = 0;
@@ -615,7 +608,7 @@ namespace moab {
for (int j = 0; j< 2; j++)
{
- int v = conn[j] - *_verts.begin();
+ int v = _verts.index(conn[j]);
v2hv_map_eid[is_index[v]] = *eid;
v2hv_map_lvid[is_index[v]] = j;
is_index[v] += 1;
@@ -633,26 +626,59 @@ namespace moab {
error = mb->get_connectivity(&*eid, 1, conn);
if (MB_SUCCESS != error) return error;
+ EntityHandle sibeid[2];
+ int siblvid[2];
+
+ error = mb->tag_get_data(sibhvs_eid, &*eid, 1, sibeid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhvs_lvid, &*eid, 1, siblvid);
+ if (MB_SUCCESS != error) return error;
+
for (int k =0; k<2; k++)
{
- if (sibhvs_eid_ptr[2*(*eid-start_edge)+k] != 0)
+
+ if (sibeid[k] != 0)
continue;
- int v = conn[k] - *_verts.begin();
+ int v = _verts.index(conn[k]);
int last = is_index[v+1] - 1;
if (last > is_index[v])
{
EntityHandle prev_eid = v2hv_map_eid[last];
int prev_lvid = v2hv_map_lvid[last];
+
+ EntityHandle seteid[2];
+ int setlvid[2];
+ error = mb->tag_get_data(sibhvs_eid, &prev_eid, 1, seteid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+ if (MB_SUCCESS != error) return error;
+
for (int i=is_index[v]; i<=last; i++)
{
EntityHandle cur_eid = v2hv_map_eid[i];
int cur_lvid = v2hv_map_lvid[i];
- sibhvs_eid_ptr[2*(prev_eid-start_edge) + prev_lvid] = cur_eid;
- sibhvs_lvid_ptr[2*(prev_eid-start_edge) + prev_lvid] = cur_lvid;
+
+
+ seteid[prev_lvid] = cur_eid;
+ setlvid[prev_lvid] = cur_lvid;
+
+ error = mb->tag_set_data(sibhvs_eid, &prev_eid, 1, seteid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_set_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+ if (MB_SUCCESS != error) return error;
prev_eid = cur_eid;
prev_lvid = cur_lvid;
+ error = mb->tag_get_data(sibhvs_eid, &prev_eid, 1, seteid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhvs_lvid, &prev_eid, 1, setlvid);
+ if (MB_SUCCESS != error) return error;
+
}
}
}
@@ -663,6 +689,7 @@ namespace moab {
delete [] is_index;
delete [] v2hv_map_eid;
delete [] v2hv_map_lvid;
+
return MB_SUCCESS;
}
@@ -797,7 +824,7 @@ namespace moab {
int nepf;
if (type == MBTRI) nepf = 3;
else if (type ==MBQUAD) nepf = 4;
-
+
return nepf;
}
/////////////////////////////////////////////////////////////////////////////////
@@ -807,16 +834,13 @@ namespace moab {
// next: Local ids of next edges
// prev: Local ids of prev edges
- if (nepf == 3)
- {
- next[0] = 1; next[1] = 2; next[2] = 0;
- prev[0] = 2; prev[1] = 0; prev[2] = 1;
- }
- else if (nepf == 4)
- {
- next[0] = 1; next[1] = 2; next[2] = 3; next[3] = 0;
- prev[0] = 3; prev[1] = 0; prev[2] = 1; prev[3] = 2;
- }
+ for (int k=0; k<nepf-1; k++)
+ {
+ next[k]=k+1;
+ prev[k+1]=k;
+ }
+ next[nepf-1]=0;
+ prev[0] = nepf-1;
return MB_SUCCESS;
}
@@ -826,15 +850,6 @@ namespace moab {
ErrorCode error;
EntityHandle start_face = *faces.begin();
- // Create pointers to the tags for direct access to memory
- int count, *sibhes_leid_ptr; EntityHandle *sibhes_fid_ptr;
- error = mb->tag_iterate(sibhes_fid, faces.begin(), faces.end(), count, (void*&)sibhes_fid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) faces.size());
- error = mb->tag_iterate(sibhes_leid, faces.begin(), faces.end(), count, (void*&)sibhes_leid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) faces.size());
-
int nepf = local_maps_2d(start_face);
int * next = new int[nepf];
int * prev = new int[nepf];
@@ -847,6 +862,7 @@ namespace moab {
for (int i =0; i<nv+1; i++)
is_index[i] = 0;
+ int index;
std::vector<EntityHandle> conn(nepf);
for (Range::iterator fid = faces.begin(); fid != faces.end(); ++fid)
{
@@ -856,7 +872,8 @@ namespace moab {
for (int i = 0; i<nepf; i++)
{
- is_index[conn[i]-*_verts.begin()+1] += 1;
+ index = _verts.index(conn[i]);
+ is_index[index+1] += 1;
}
}
is_index[0] = 0;
@@ -877,7 +894,7 @@ namespace moab {
for (int j = 0; j< nepf; j++)
{
- int v = conn[j] - *_verts.begin();
+ int v = _verts.index(conn[j]);
v2nv[is_index[v]] = conn[next[j]];
v2he_map_fid[is_index[v]] = *fid;
v2he_map_leid[is_index[v]] = j;
@@ -889,6 +906,7 @@ namespace moab {
is_index[i+1] = is_index[i];
is_index[0] = 0;
+
//Step 3: Fill up sibling half-verts map
for (Range::iterator fid = faces.begin(); fid != faces.end(); ++fid)
{
@@ -896,13 +914,22 @@ namespace moab {
error = mb->get_connectivity(&*fid, 1, conn);
if (MB_SUCCESS != error) return error;
+ EntityHandle *sibfid = new EntityHandle[nepf];
+ int *sibleid = new int[nepf];
+
+ error = mb->tag_get_data(sibhes_fid, &*fid, 1, sibfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhes_leid, &*fid, 1, sibleid);
+ if (MB_SUCCESS != error) return error;
+
for (int k =0; k<nepf; k++)
{
- if (sibhes_fid_ptr[nepf*(*fid-start_face)+k] != 0)
+ if (sibfid[k] != 0)
continue;
- int v = conn[k] - *_verts.begin();
- int vn = conn[next[k]] - *_verts.begin();
+ int v = _verts.index(conn[k]);
+ int vn = _verts.index(conn[next[k]]);
EntityHandle first_fid = *fid;
int first_leid = k;
@@ -910,38 +937,87 @@ namespace moab {
EntityHandle prev_fid = *fid;
int prev_leid = k;
- for (int index = is_index[vn]; index <= is_index[vn+1]-1; index++)
+ EntityHandle *setfid = new EntityHandle[nepf];
+ int *setleid = new int[nepf];
+
+ for (index = is_index[vn]; index <= is_index[vn+1]-1; index++)
{
if (v2nv[index] == conn[k])
{
EntityHandle cur_fid = v2he_map_fid[index];
int cur_leid = v2he_map_leid[index];
- sibhes_fid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_fid;
- sibhes_leid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_leid;
+
+ error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+
+ setfid[prev_leid] = cur_fid;
+ setleid[prev_leid] = cur_leid;
+
+ error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+
prev_fid = cur_fid;
prev_leid = cur_leid;
+
}
}
- for (int index = is_index[v]; index <= is_index[v+1]-1; index++)
+ for (index = is_index[v]; index <= is_index[v+1]-1; index++)
{
if ((v2nv[index] == conn[next[k]])&&(v2he_map_fid[index] != *fid))
{
+
EntityHandle cur_fid = v2he_map_fid[index];
int cur_leid = v2he_map_leid[index];
- sibhes_fid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_fid;
- sibhes_leid_ptr[nepf*(prev_fid-start_face)+prev_leid] = cur_leid;
+
+ error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+
+ setfid[prev_leid] = cur_fid;
+ setleid[prev_leid] = cur_leid;
+
+ error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+
prev_fid = cur_fid;
prev_leid = cur_leid;
}
}
if (prev_fid != first_fid){
- sibhes_fid_ptr[nepf*(prev_fid-start_face) + prev_leid] = first_fid;
- sibhes_leid_ptr[nepf*(prev_fid-start_face) + prev_leid] = first_leid;
- }
+ error = mb->tag_get_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+
+ setfid[prev_leid] = first_fid;
+ setleid[prev_leid] = first_leid;
+
+ error = mb->tag_set_data(sibhes_fid, &prev_fid, 1, setfid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_set_data(sibhes_leid, &prev_fid, 1, setleid);
+ if (MB_SUCCESS != error) return error;
+ }
+ delete [] setfid;
+ delete [] setleid;
}
+ delete [] sibfid;
+ delete [] sibleid;
}
delete [] next;
@@ -1311,7 +1387,7 @@ namespace moab {
error = mb->get_connectivity(&curfid, 1, conn);
if (MB_SUCCESS != error) return error;
- int id = next[curlid];
+ int id = next[curlid];
if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
*he_fid = curfid;
*he_lid = curlid;
@@ -1336,7 +1412,7 @@ namespace moab {
counter += 1;
}
- delete [] next;
+ delete [] next;
delete [] prev;
return found;
}
@@ -1417,7 +1493,7 @@ namespace moab {
}
/////////////////////////////////////////////
- HalfFacetRep::LocalMaps3D HalfFacetRep::lConnMap3D[4] =
+ const HalfFacetRep::LocalMaps3D HalfFacetRep::lConnMap3D[4] =
{
// Tet
{4, 6, 4, {3,3,3,3}, {{0,1,3},{1,2,3},{2,0,3},{0,2,1}}, {3,3,3,3}, {{0,2,3},{0,1,3},{1,2,3},{0,1,2}}, {{0,1},{1,2},{2,0},{0,3},{1,3},{2,3}}, {{3,0},{3,1},{3,2},{0,2},{0,1},{1,2}}, {{0,4,3},{1,5,4},{2,3,5},{2,1,0}}, {{-1,0,2,3},{0,-1,1,4},{2,1,-1,5},{3,4,5,-1}}},
@@ -1439,16 +1515,6 @@ namespace moab {
{
ErrorCode error;
EntityHandle start_cell = *cells.begin();
-
- int count, *sibhfs_lfid_ptr;
- EntityHandle *sibhfs_cid_ptr;
- error = mb->tag_iterate(sibhfs_cid, cells.begin(), cells.end(), count, (void*&)sibhfs_cid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) cells.size());
- error = mb->tag_iterate(sibhfs_lfid, cells.begin(), cells.end(), count, (void*&)sibhfs_lfid_ptr);
- if (MB_SUCCESS != error) return error;
- assert(count == (int) cells.size());
-
int index = get_index_from_type(start_cell);
int nvpc = lConnMap3D[index].num_verts_in_cell;
int nfpc = lConnMap3D[index].num_faces_in_cell;
@@ -1459,6 +1525,7 @@ namespace moab {
for (int i =0; i<nv+1; i++)
is_index[i] = 0;
+ int vindex;
std::vector<EntityHandle> conn(nvpc);
for (Range::iterator cid = cells.begin(); cid != cells.end(); ++cid)
{
@@ -1476,7 +1543,8 @@ namespace moab {
if (v <= conn[id])
v = conn[id];
}
- is_index[v-*_verts.begin()+1] += 1;
+ vindex = _verts.index(v);
+ is_index[vindex+1] += 1;
}
}
is_index[0] = 0;
@@ -1518,7 +1586,7 @@ namespace moab {
error = local_maps_2d(nvF, next, prev);
if (MB_SUCCESS != error) return error;
- int v = vmax - *_verts.begin();
+ int v = _verts.index(vmax);
v2oe_v1[is_index[v]] = vs[next[lv]];
v2oe_v2[is_index[v]] = vs[prev[lv]];
v2hf_map_cid[is_index[v]] = *cid;
@@ -1542,9 +1610,18 @@ namespace moab {
error = mb->get_connectivity(&*cid, 1, conn);
if (MB_SUCCESS != error) return error;
+ EntityHandle *sibcid = new EntityHandle[nfpc];
+ int *siblfid = new int[nfpc];
+
+ error = mb->tag_get_data(sibhfs_cid, &*cid, 1, sibcid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhfs_lfid, &*cid, 1, siblfid);
+ if (MB_SUCCESS != error) return error;
+
for (int i =0; i<nfpc; i++)
{
- if (sibhfs_cid_ptr[nfpc*(*cid-start_cell)+i] != 0)
+ if (sibcid[i] != 0)
continue;
@@ -1568,31 +1645,60 @@ namespace moab {
error = local_maps_2d(nvF, next, prev);
if (MB_SUCCESS != error) return error;
- int v = vmax - *_verts.begin();
+ int v = _verts.index(vmax);
EntityHandle v1 = vs[prev[lv]];
EntityHandle v2 = vs[next[lv]];
+ EntityHandle *setcid = new EntityHandle[nfpc];
+ int *setlfid = new int[nfpc];
+
for (int ind = is_index[v]; ind <= is_index[v+1]-1; ind++)
{
if ((v2oe_v1[ind] == v1)&&(v2oe_v2[ind] == v2))
{
-
+ // Map to opposite hf
EntityHandle cur_cid = v2hf_map_cid[ind];
int cur_lfid = v2hf_map_lfid[ind];
- sibhfs_cid_ptr[nfpc*(*cid-start_cell)+i] = cur_cid;
- sibhfs_lfid_ptr[nfpc*(*cid-start_cell)+i] = cur_lfid;
+ error = mb->tag_get_data(sibhfs_cid, &*cid, 1, setcid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhfs_lfid, &*cid, 1, setlfid);
+ if (MB_SUCCESS != error) return error;
+
+ setcid[i] = cur_cid;
+ setlfid[i] = cur_lfid;
+
+ error = mb->tag_set_data(sibhfs_cid, &*cid, 1, setcid);
+ if (MB_SUCCESS != error) return error;
+ error = mb->tag_set_data(sibhfs_lfid, &*cid, 1, setlfid);
+ if (MB_SUCCESS != error) return error;
+
+ //Map opposite hf to current cell
+ error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, setcid);
+ if (MB_SUCCESS != error) return error;
+
+ error = mb->tag_get_data(sibhfs_lfid, &cur_cid, 1, setlfid);
+ if (MB_SUCCESS != error) return error;
- sibhfs_cid_ptr[nfpc*(cur_cid-start_cell)+cur_lfid] = *cid;
- sibhfs_lfid_ptr[nfpc*(cur_cid-start_cell)+cur_lfid] = i;
+ setcid[cur_lfid] = *cid;
+ setlfid[cur_lfid] = i;
+ error = mb->tag_set_data(sibhfs_cid, &cur_cid, 1, setcid);
+ if (MB_SUCCESS != error) return error;
+ error = mb->tag_set_data(sibhfs_lfid, &cur_cid, 1, setlfid);
+ if (MB_SUCCESS != error) return error;
}
}
delete [] next;
delete [] prev;
delete [] vs;
+ delete [] setcid;
+ delete [] setlfid;
}
+ delete sibcid;
+ delete siblfid;
}
@@ -2115,10 +2221,8 @@ namespace moab {
bool HalfFacetRep::find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index, int *index)
{
bool found = false;
- // std::cout<<"count = "<<count<<std::endl;
for (int i = 0; i<= count; i++)
{
- // std::cout<<"For i = "<<i<<": ent-ent_list[i] = "<<(int)(ent-ent_list[i])<<std::endl;
if (!((int)(ent - ent_list[i])))
{
found = true;
diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index 941129a..20aafdc 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -328,6 +328,16 @@ public:
#endif
+ /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+ const int num_entities,
+ const int to_dimension,
+ const bool create_if_missing,
+ std::vector<EntityHandle>& adj_entities,
+ const int operation_type = Interface::INTERSECT);*/
+
+
+
+
virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
const int num_entities,
const int to_dimension,
diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index 3d1069a..344dbd1 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -533,7 +533,7 @@ namespace moab {
int lookup_leids[MAX_VERTICES][MAX_VERTICES];
};
- static LocalMaps3D lConnMap3D[4];
+ static const LocalMaps3D lConnMap3D[4];
int get_index_from_type(EntityHandle cid);
diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index bfd5fb0..57252e9 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -630,6 +630,12 @@ public:
#else
) = 0;
#endif
+ /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+ const int num_entities,
+ const int to_dimension,
+ const bool create_if_missing,
+ std::vector<EntityHandle>& adj_entities,
+ const int operation_type = Interface::INTERSECT) = 0; */
//! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
/** Identical to vector-based get_adjacencies function, except results are returned in a
diff --git a/test/Makefile.am b/test/Makefile.am
index 34432d0..1354e3c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,9 +61,9 @@ if HDF5_FILE
lloyd_smoother_test
endif
-if ENABLE_ahf
- TESTS += ahf_mbintf_test
-endif
+# if ENABLE_ahf
+# TESTS += ahf_mbintf_test
+# endif
# merge_test \ # input files no longer exist?
# test_tag_server \ # fails
@@ -158,9 +158,9 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
ahf_test_SOURCES = test_ahf_moab.cpp
-if ENABLE_ahf
-ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-endif
+# if ENABLE_ahf
+# ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+# endif
if PARALLEL
diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index f946f94..32e2a57 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,13 +7,14 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
LDADD = $(top_builddir)/src/libMOAB.la
-check_PROGRAMS = perf seqperf adj_time perftool
+check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time
noinst_PROGRAMS =
perf_SOURCES = perf.cpp
seqperf_SOURCES = seqperf.cpp
adj_time_SOURCES = adj_time.cpp
perftool_SOURCES = perftool.cpp
+ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
if ENABLE_imesh
LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
diff --git a/test/perf/test_ahf_mem_time.cpp b/test/perf/test_ahf_mem_time.cpp
new file mode 100755
index 0000000..9c72ae7
--- /dev/null
+++ b/test/perf/test_ahf_mem_time.cpp
@@ -0,0 +1,281 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_elapsed, time_avg;
+
+ // Create an ahf instance
+ HalfFacetRep ahf(&moab);
+
+ // Call the initialize function which creates the maps for each dimension
+ time_start = wtime();
+
+ ahf.initialize();
+
+ time_elapsed = wtime() - time_start;
+ std::cout << "Time taken to construct the MDS = "<<time_elapsed<<" secs"<<std::endl;
+
+ //Storage Costs after calling ahf initialize
+ unsigned long TotS, TAS, ES, AES, AS, AAS, TS, ATS;
+ TotS = TAS = ES = AES = AS = AAS = TS = ATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &TotS, &TAS, &ES, &AES, &AS, &AAS, NULL, 0, &TS, &ATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<TotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<TAS<<std::endl;
+ std::cout<<"Entity storage = "<<ES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<AES<<std::endl;
+ std::cout<<"Adjacency storage = "<<AS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<AAS<<std::endl;
+ std::cout<<"Tag storage = "<<TS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<ATS<<std::endl;
+ std::cout<<std::endl;
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ std::vector<int> lids;
+ Range mbents;
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 1, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute incident edges to a vertex = "<< time_avg<<" secs" <<std::endl;
+
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"MOAB: Average time taken to compute incident edges to a vertex = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+
+ //NQ1: For every edge, obtain neighbor edges
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute neighbor edges of an edge = "<<time_avg<<" secs" << std::endl;
+
+ error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB: Average time taken to compute neighbor edges of an edge = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+
+
+ // 2D Queries
+ //IQ21: For every edge, obtain incident faces
+ std::cout<<"2D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute incident faces on an edge = "<<time_avg<<" secs" <<std::endl;
+
+ error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB: Average time taken to compute incident faces on an edge = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //NQ2: For every face, obtain neighbor faces
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute neighbor faces of a face = "<< time_avg<<" secs" <<std::endl;
+
+ error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, mbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"MOAB: Average time taken to compute neighbor faces of a face = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+
+ // 3D Queries
+ // IQ 31: For every edge, obtain incident cells
+ std::cout<<"3D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute incident cells on an edge = "<<time_avg <<" secs"<<std::endl;
+
+ error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"MOAB: Average time taken to compute incident cells on an edge = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //IQ32: For every face, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute incident cells on a face = "<<time_avg <<" secs"<<std::endl;
+
+ error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"MOAB: Average time taken to compute incident cells on a face = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //NQ3: For every cell, obtain neighbor cells
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"MOAB_AHF: Average time taken to compute neighbor cells of a cell = "<< time_avg <<" secs" << std::endl;
+
+ error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, mbents);
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"MOAB: Average time taken to compute neighbor cells of a cell = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+
+ ahf.deinitialize();
+
+ //Storage Costs after calling ahf deinitialize
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index 93bd947..e415186 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -11,172 +11,203 @@
using namespace moab;
#ifdef MESHDIR
-static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+std::string TestDir(STRINGIFY(MESHDIR));
#else
-static const char example[] = "/hexes_mixed.vtk";
+std::string TestDir(".");
#endif
-void ahf_test()
-{
-
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- ErrorCode error = mbImpl->load_file(example);
- CHECK_ERR(error);
-
- /*Create ranges for handles of explicit elements of the mixed mesh*/
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- // Create an ahf instance
- HalfFacetRep ahf(&moab);
-
- // Call the initialize function which creates the maps for each dimension
- ahf.initialize();
-
- //Perform queries
- std::vector<EntityHandle> adjents;
- Range mbents, ahfents;
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 1, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(),mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- //NQ1: For every edge, obtain neighbor edges
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- // 2D Queries
- //IQ2: For every edge, obtain incident faces
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 2, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
+std::string filename;
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
+int number_tests_successful = 0;
+int number_tests_failed = 0;
- //NQ2: For every face, obtain neighbor faces
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+ if (rv == MB_SUCCESS) {
+ std::cout << "Success";
+ number_successful++;
+ } else {
+ std::cout << "Failure";
+ number_failed++;
}
+}
- // 3D Queries
- // IQ 31: For every edge, obtain incident cells
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 3, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
- //IQ32: For every face, obtain incident cells
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 3, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
+ErrorCode ahf_test(Core *moab)
+{
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
+ Interface* mbImpl = &*moab;
+ MeshTopoUtil mtu(mbImpl);
- //NQ3: For every cell, obtain neighbor cells
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ ErrorCode error = mbImpl->load_file(filename.c_str());
CHECK_ERR(error);
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- //ahf.deinitialize();
+ /*Create ranges for handles of explicit elements of the mixed mesh*/
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ // Create an ahf instance
+ HalfFacetRep ahf(&*moab);
+
+ // Call the initialize function which creates the maps for each dimension
+ ahf.initialize();
+
+ //ahf.print_tags();
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range mbents, ahfents;
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 1, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(),mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ1: For every edge, obtain neighbor edges
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 2D Queries
+ //IQ2: For every edge, obtain incident faces
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ2: For every face, obtain neighbor faces
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 3D Queries
+ // IQ 31: For every edge, obtain incident cells
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ32: For every face, obtain incident cells
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ3: For every cell, obtain neighbor cells
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ return MB_SUCCESS;
}
int main(int argc, char *argv[])
{
- int result = 0;
-
- argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
-
- result += RUN_TEST(ahf_test);
-
- return result;
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ Core moab;
+ ErrorCode result;
+
+ std::cout<<" ahf_test: ";
+ result = ahf_test(&moab);
+ handle_error_code(result, number_tests_failed, number_tests_successful);
+ std::cout<<"\n";
+
+ return number_tests_failed;
}
https://bitbucket.org/fathomteam/moab/commits/7c0456989c29/
Changeset: 7c0456989c29
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Removed 'use_ahf' flag from get_adjacencies interface in Core/Interface.
Passed make check.
Affected #: 9 files
diff --git a/src/Core.cpp b/src/Core.cpp
index 692495b..3340934 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -280,6 +280,7 @@ ErrorCode Core::initialize()
ahfRep = new HalfFacetRep(this);
if (!ahfRep)
return MB_MEMORY_ALLOCATION_FAILED;
+ mesh_modified = false;
#endif
return MB_SUCCESS;
@@ -1353,14 +1354,11 @@ ErrorCode get_adjacencies_union( Core* gMB,
return result;
}
-
-///////////////////////////
-///
-#ifdef USE_AHF
template <typename ITER> static inline
-ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+ErrorCode get_adjacencies_intersection( Core* mb,
ITER begin, ITER end,
const int to_dimension,
+ const bool create_if_missing,
std::vector<EntityHandle>& adj_entities )
{
const size_t SORT_THRESHOLD = 200;
@@ -1378,11 +1376,13 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
// input list), we begin with the adjacencies for the first entity.
if (adj_entities.empty()) {
EntityType type = TYPE_FROM_HANDLE(*begin);
-
- if(to_dimension == 0 && type != MBPOLYHEDRON)
+ if (to_dimension == CN::Dimension(type))
+ adj_entities.push_back(*begin);
+ else if(to_dimension == 0 && type != MBPOLYHEDRON)
result = mb->get_connectivity(&(*begin), 1, adj_entities);
else
- result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
+ result = mb->a_entity_factory()->get_adjacencies(*begin, to_dimension,
+ create_if_missing, adj_entities);
if (MB_SUCCESS != result)
return result;
++begin;
@@ -1395,10 +1395,13 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
// get the next set of adjacencies
EntityType type = TYPE_FROM_HANDLE(*from_it);
- if(to_dimension == 0 && type != MBPOLYHEDRON)
+ if (to_dimension == CN::Dimension(type))
+ temp_vec.push_back(*from_it);
+ else if(to_dimension == 0 && type != MBPOLYHEDRON)
result = mb->get_connectivity(&(*from_it), 1, temp_vec);
else
- result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
+ result = mb->a_entity_factory()->get_adjacencies(*from_it, to_dimension,
+ create_if_missing, temp_vec);
if (MB_SUCCESS != result)
return result;
@@ -1424,14 +1427,43 @@ ErrorCode get_adjacencies_intersection_ahf(Core *mb,
return MB_SUCCESS;
}
-#endif
-///////////////////////////////////////////
template <typename ITER> static inline
ErrorCode get_adjacencies_intersection( Core* mb,
ITER begin, ITER end,
const int to_dimension,
const bool create_if_missing,
+ Range& adj_entities )
+{
+ std::vector<EntityHandle> results;
+ ErrorCode rval = moab::get_adjacencies_intersection( mb, begin, end, to_dimension,
+ create_if_missing, results );
+ if (MB_SUCCESS != rval)
+ return rval;
+
+ if (adj_entities.empty()) {
+ std::copy( results.begin(), results.end(), range_inserter(adj_entities) );
+ return MB_SUCCESS;
+ }
+
+ Range::iterator it = adj_entities.begin();
+ while (it != adj_entities.end()) {
+ if (std::find( results.begin(), results.end(), *it) == results.end())
+ it = adj_entities.erase( it );
+ else
+ ++it;
+ }
+ return MB_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////
+//////////////////////////////////////////
+#ifdef USE_AHF
+
+template <typename ITER> static inline
+ErrorCode get_adjacencies_intersection_ahf(Core *mb,
+ ITER begin, ITER end,
+ const int to_dimension,
std::vector<EntityHandle>& adj_entities )
{
const size_t SORT_THRESHOLD = 200;
@@ -1449,13 +1481,11 @@ ErrorCode get_adjacencies_intersection( Core* mb,
// input list), we begin with the adjacencies for the first entity.
if (adj_entities.empty()) {
EntityType type = TYPE_FROM_HANDLE(*begin);
- if (to_dimension == CN::Dimension(type))
- adj_entities.push_back(*begin);
- else if(to_dimension == 0 && type != MBPOLYHEDRON)
+
+ if(to_dimension == 0 && type != MBPOLYHEDRON)
result = mb->get_connectivity(&(*begin), 1, adj_entities);
else
- result = mb->a_entity_factory()->get_adjacencies(*begin, to_dimension,
- create_if_missing, adj_entities);
+ result = mb->a_half_facet_rep()->get_adjacencies(*begin, to_dimension, adj_entities);
if (MB_SUCCESS != result)
return result;
++begin;
@@ -1468,13 +1498,10 @@ ErrorCode get_adjacencies_intersection( Core* mb,
// get the next set of adjacencies
EntityType type = TYPE_FROM_HANDLE(*from_it);
- if (to_dimension == CN::Dimension(type))
- temp_vec.push_back(*from_it);
- else if(to_dimension == 0 && type != MBPOLYHEDRON)
+ if(to_dimension == 0 && type != MBPOLYHEDRON)
result = mb->get_connectivity(&(*from_it), 1, temp_vec);
else
- result = mb->a_entity_factory()->get_adjacencies(*from_it, to_dimension,
- create_if_missing, temp_vec);
+ result = mb->a_half_facet_rep()->get_adjacencies(*from_it, to_dimension, temp_vec);
if (MB_SUCCESS != result)
return result;
@@ -1500,52 +1527,16 @@ ErrorCode get_adjacencies_intersection( Core* mb,
return MB_SUCCESS;
}
+#endif
-template <typename ITER> static inline
-ErrorCode get_adjacencies_intersection( Core* mb,
- ITER begin, ITER end,
- const int to_dimension,
- const bool create_if_missing,
- Range& adj_entities )
-{
- std::vector<EntityHandle> results;
- ErrorCode rval = moab::get_adjacencies_intersection( mb, begin, end, to_dimension,
- create_if_missing, results );
- if (MB_SUCCESS != rval)
- return rval;
-
- if (adj_entities.empty()) {
- std::copy( results.begin(), results.end(), range_inserter(adj_entities) );
- return MB_SUCCESS;
- }
-
- Range::iterator it = adj_entities.begin();
- while (it != adj_entities.end()) {
- if (std::find( results.begin(), results.end(), *it) == results.end())
- it = adj_entities.erase( it );
- else
- ++it;
- }
- return MB_SUCCESS;
-}
+///////////////////////////////////////////
ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
const int num_entities,
const int to_dimension,
const bool create_if_missing,
std::vector<EntityHandle> &adj_entities,
- const int operation_type
-#ifdef USE_AHF
- , const bool use_ahf)
-#else
- )
-#endif
-/*ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
- const int num_entities,
- const int to_dimension,
- const bool create_if_missing,
- std::vector<EntityHandle> &adj_entities,
- const int operation_type)*/
+ const int operation_type)
{
#ifdef USE_AHF
@@ -1553,41 +1544,22 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
int source_dim = this->dimension_from_handle(from_entities[0]);
if ((source_dim > to_dimension) && (to_dimension != 0))
- {
- std::cout<<"Currently Not Supported by MOAB_AHF: Down Adjacencies"<<std::endl;
- std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
- can_handle = false;
- }
- else if (((source_dim == 0) && (to_dimension == 2))||((source_dim == 0) && (to_dimension == 3)))
- {
- std::cout<<"Currently Not Supported by MOAB_AHF: Vertex to face/cell"<<std::endl;
- std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
- can_handle = false;
- }
+ can_handle = false; //NOT SUPPORTED: Down adjacencies
else if (to_dimension == 4)
- {
- std::cout<<"Currently Not Supported by MOAB_AHF: meshsets"<<std::endl;
- std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
- can_handle = false;
- }
- else if (TYPE_FROM_HANDLE(from_entities[0]) == MBPOLYHEDRON)
- {
- std::cout<<"Currently Not Supported by MOAB_AHF: Polyhedron Meshes"<<std::endl;
- std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
- can_handle = false;
- }
+ can_handle = false; // NOT SUPPORTED: meshsets
else if (create_if_missing)
- {
- std::cout<<"Currently Not Supporteded by MOAB_AHF: create_if_missing capability "<<std::endl;
- std::cout<<"Reverting to MOAB adjacency functionality"<<std::endl;
+ can_handle = false;//NOT SUPPORTED: create_if_missing
+
+ bool mixed = ahfRep->check_mixed_entity_type(); //NOT SUPPORTED: mixed entity types or polygonal/hedrals types
+ if (mixed)
can_handle = false;
- }
+ if (mesh_modified)
+ can_handle = false;
- if ((use_ahf) && (can_handle))
- //if (can_handle)
+ if (can_handle)
{
-
+ ErrorCode result;
if (operation_type == Interface::INTERSECT)
return get_adjacencies_intersection_ahf(this, from_entities, from_entities+num_entities,
to_dimension, adj_entities );
@@ -1595,7 +1567,7 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
return MB_FAILURE;
// do union
- ErrorCode result;
+
std::vector<EntityHandle> tmp_storage;
const EntityHandle* conn;
int len;
@@ -1668,14 +1640,14 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
Range &adj_entities,
const int operation_type )
{
- if (operation_type == Interface::INTERSECT)
- return get_adjacencies_intersection( this, from_entities, from_entities + num_entities,
- to_dimension, create_if_missing, adj_entities );
- else if (operation_type == Interface::UNION)
- return get_adjacencies_union( this, from_entities, from_entities + num_entities,
- to_dimension, create_if_missing, adj_entities );
- else
- return MB_FAILURE;
+ if (operation_type == Interface::INTERSECT)
+ return get_adjacencies_intersection( this, from_entities, from_entities + num_entities,
+ to_dimension, create_if_missing, adj_entities );
+ else if (operation_type == Interface::UNION)
+ return get_adjacencies_union( this, from_entities, from_entities + num_entities,
+ to_dimension, create_if_missing, adj_entities );
+ else
+ return MB_FAILURE;
}
ErrorCode Core::get_connectivity( const Range& from_entities,
@@ -2754,6 +2726,11 @@ ErrorCode Core::create_element(const EntityType type,
if (MB_SUCCESS == status)
status = aEntityFactory->notify_create_entity( handle, connectivity, num_nodes);
+#ifdef USE_AHF
+ mesh_modified = true;
+#endif
+
+
return status;
}
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 449a48a..18a8a0d 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -34,6 +34,8 @@ namespace moab {
assert(NULL != impl);
mb = impl;
mInitAHFmaps = false;
+ chk_mixed = false;
+ is_mixed = false;
}
HalfFacetRep::~HalfFacetRep()
@@ -65,6 +67,89 @@ namespace moab {
return mesh_type;
}
+ const HalfFacetRep::adj_matrix HalfFacetRep::adjMatrix[7] =
+ {
+ // Stores the adjacency matrix for each mesh type.
+ //CURVE
+ {{{0,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}},
+
+ //SURFACE
+ {{{0,0,1,0},{0,0,0,0},{1,0,1,0},{0,0,0,0}}},
+
+ //SURFACE_MIXED
+ {{{0,1,1,0},{1,1,1,0},{1,0,1,0},{0,0,0,0}}},
+
+ //VOLUME
+ {{{0,0,0,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}}},
+
+ //VOLUME_MIXED_1
+ {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,0,0,1}}},
+
+ //VOLUME_MIXED_2
+ {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,0,1}}},
+
+ //VOLUME_MIXED
+ {{{0,1,1,1},{1,1,1,1},{1,0,1,1},{1,0,0,1}}}
+ };
+
+ int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
+ {
+ int index;
+ if (mesh_type == CURVE) index = 0;
+ else if (mesh_type == SURFACE) index = 1;
+ else if (mesh_type == SURFACE_MIXED) index = 2;
+ else if (mesh_type == VOLUME) index = 3;
+ else if (mesh_type == VOLUME_MIXED_1) index = 4;
+ else if (mesh_type == VOLUME_MIXED_2) index = 5;
+ else if (mesh_type == VOLUME_MIXED) index = 6;
+ return index;
+ }
+
+ bool HalfFacetRep::check_mixed_entity_type()
+ {
+ if (!chk_mixed)
+ {
+ chk_mixed = true;
+
+ ErrorCode error;
+ Range felems, celems;
+
+ error = mb->get_entities_by_dimension( 0, 2, felems );
+ if (MB_SUCCESS != error) return error;
+
+ if (felems.size()){
+ Range tris, quad, poly;
+ tris = felems.subset_by_type(MBTRI);
+ quad = felems.subset_by_type(MBQUAD);
+ poly = felems.subset_by_type(MBPOLYGON);
+ if ((tris.size()&&quad.size())||(tris.size()&&poly.size())||(quad.size()&&poly.size()))
+ is_mixed = true;
+ if (poly.size())
+ is_mixed = true;
+
+ return is_mixed;
+ }
+
+ error = mb->get_entities_by_dimension( 0, 3, celems);
+ if (MB_SUCCESS != error) return error;
+ if (celems.size()){
+ Range tet, pyr, prism, hex, polyhed;
+ tet = celems.subset_by_type(MBTET);
+ pyr = celems.subset_by_type(MBPYRAMID);
+ prism = celems.subset_by_type(MBPRISM);
+ hex = celems.subset_by_type(MBHEX);
+ polyhed = celems.subset_by_type(MBPOLYHEDRON);
+ if ((tet.size() && pyr.size())||(tet.size() && prism.size())||(tet.size() && hex.size())||(tet.size()&&polyhed.size())||(pyr.size() && prism.size())||(pyr.size() && hex.size()) ||(pyr.size()&&polyhed.size())|| (prism.size() && hex.size())||(prism.size()&&polyhed.size())||(hex.size()&&polyhed.size()))
+ is_mixed = true;
+
+ if (polyhed.size())
+ is_mixed = true;
+ return is_mixed;
+ }
+ }
+ return is_mixed;
+ }
+
/*******************************************************
* initialize *
******************************************************/
@@ -93,8 +178,10 @@ namespace moab {
int ncells = _cells.size();
MESHTYPE mesh_type = get_mesh_type(nverts, nedges, nfaces, ncells);
- std::cout<<"MeshType = "<<mesh_type<<std::endl;
-
+ thismeshtype = mesh_type;
+ std::cout<<"MeshType = "<<thismeshtype<<std::endl;
+
+ //Initialize mesh type specific maps
if (mesh_type == CURVE){
error = init_curve();
if (MB_SUCCESS != error) return error;
@@ -460,50 +547,78 @@ namespace moab {
if (mInitAHFmaps == false)
{
- error = initialize();
- if (MB_SUCCESS != error) return error;
- }
-
- if ((source_dimension == 0) && (target_dimension == 1))
- {
- error = get_up_adjacencies_1d(source_entity, target_entities);
+ error = initialize();
if (MB_SUCCESS != error) return error;
}
- else if ((source_dimension == 1) && (target_dimension == 2))
- {
- error = get_up_adjacencies_2d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if ((source_dimension == 1) && (target_dimension == 3))
- {
- error = get_up_adjacencies_edg_3d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if ((source_dimension == 2) && (target_dimension ==3))
- {
- error = get_up_adjacencies_face_3d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if (source_dimension == target_dimension)
+ int mindex = get_index_for_meshtype(thismeshtype);
+ int adj_possible = adjMatrix[mindex].val[source_dimension][target_dimension];
+
+ if (adj_possible)
{
- if (target_dimension == 1)
+
+ if (source_dimension == 0) // Vertex to up adjacencies
{
- error = get_neighbor_adjacencies_1d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
+ if (target_dimension == 1)
+ {
+ error = get_up_adjacencies_1d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (target_dimension == 2)
+ {
+ error = get_up_adjacencies_vert_2d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (target_dimension == 3)
+ {
+ error = get_up_adjacencies_vert_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
}
- else if (target_dimension == 2)
+ else if (source_dimension == 1) // Edge to up adjacencies
{
- error = get_neighbor_adjacencies_2d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
+ if (target_dimension == 2)
+ {
+ error = get_up_adjacencies_2d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (target_dimension == 3)
+ {
+ error = get_up_adjacencies_edg_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
}
- else if (target_dimension == 3)
+
+ else if ((source_dimension == 2) && (target_dimension ==3)) // Face to up adjacencies
{
- error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+ error = get_up_adjacencies_face_3d(source_entity, target_entities);
if (MB_SUCCESS != error) return error;
}
+
+ else if (source_dimension == target_dimension) // Same dimensional adjacencies
+ {
+ if (target_dimension == 1)
+ {
+ error = get_neighbor_adjacencies_1d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+
+ else if (target_dimension == 2)
+ {
+ error = get_neighbor_adjacencies_2d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (target_dimension == 3)
+ {
+ error = get_neighbor_adjacencies_3d(source_entity, target_entities);
+ if (MB_SUCCESS != error) return error;
+ }
+ }
}
+ else
+ return MB_SUCCESS;
+
return MB_SUCCESS;
}
@@ -517,10 +632,23 @@ namespace moab {
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
- if ((in_dim == 0) && (out_dim == 1))
+ if (in_dim == 0)
{
- error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
- if (MB_SUCCESS != error) return error;
+ if (out_dim == 1)
+ {
+ error = get_up_adjacencies_1d(ent, adjents, local_id, lids);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (out_dim == 2)
+ {
+ error = get_up_adjacencies_vert_2d(ent, adjents);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if (out_dim == 3)
+ {
+ error = get_up_adjacencies_vert_3d(ent, adjents);
+ if (MB_SUCCESS != error) return error;
+ }
}
else if ((in_dim == 1) && (out_dim == 2))
@@ -1070,7 +1198,7 @@ namespace moab {
return MB_SUCCESS;
}
///////////////////////////////////////////////////////////////////
- /* ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+ ErrorCode HalfFacetRep::get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents)
{
ErrorCode error;
@@ -1092,12 +1220,12 @@ namespace moab {
queue_lid[i] = 0;
trackfaces[i] = 0;
}
- int qsize = 0, tcount = -1;
+ int qsize = 0, count = -1;
int num_qvals = 0;
- error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+ error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
if (MB_SUCCESS != error) return error;
- while (num_qvals < *qsize)
+ while (num_qvals < qsize)
{
EntityHandle curfid = queue_fid[num_qvals];
int curlid = queue_lid[num_qvals];
@@ -1107,22 +1235,23 @@ namespace moab {
error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
if (MB_SUCCESS != error) return error;
- bool found_ent = find_match_in_array(he2_fid, trackfaces, tcount[0]);
+ bool found_ent = find_match_in_array(he2_fid, trackfaces, count);
if (found_ent)
continue;
- tcount[0] += 1;
- trackfaces[tcount[0]] = he2_fid;
+ count += 1;
+ trackfaces[count] = he2_fid;
- error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
if (MB_SUCCESS != error) return error;
adjents.push_back(he2_fid);
}
}
+ return MB_SUCCESS;
}
-*/
+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ErrorCode HalfFacetRep::get_up_adjacencies_2d( EntityHandle eid,
std::vector<EntityHandle> &adjents,
@@ -1803,6 +1932,85 @@ namespace moab {
return MB_SUCCESS;
}
+ ////////////////////////////////////////////////////////////////////////
+ ErrorCode HalfFacetRep::get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents)
+ {
+ ErrorCode error;
+
+ // Obtain a half-face incident on v
+ EntityHandle cur_cid = 0;
+ error = mb->tag_get_data(v2hf_cid, &vid, 1, &cur_cid);
+ if (MB_SUCCESS != error) return error;
+
+ int index = get_index_from_type(cur_cid);
+ int nvpc = lConnMap3D[index].num_verts_in_cell;
+ int nfpc = lConnMap3D[index].num_faces_in_cell;
+
+ // Collect all incident cells
+ if (cur_cid != 0){
+ EntityHandle Stkcells[MAXSIZE], trackcells[MAXSIZE];
+ for (int i = 0; i< MAXSIZE; i++)
+ {
+ Stkcells[i] = 0;
+ trackcells[i] = 0;
+ }
+ int Stksize = 0, count = -1;
+ Stkcells[0] = cur_cid;
+
+ while (Stksize >= 0 ){
+ cur_cid = Stkcells[Stksize];
+ Stksize -= 1 ;
+
+ bool found = find_match_in_array(cur_cid, trackcells, count);
+ if (!found){
+ count += 1;
+ trackcells[count] = cur_cid;
+
+ // Add the current cell
+ adjents.push_back(cur_cid);
+ }
+
+ // Connectivity of the cell
+ std::vector<EntityHandle> conn;
+ error = mb->get_connectivity(&cur_cid, 1, conn);
+ if (MB_SUCCESS != error) return error;
+
+ // Local id of vid in the cell and the half-faces incident on it
+ int lv;
+ for (int i = 0; i< nvpc; ++i){
+ if (conn[i] == vid)
+ lv = i;
+ };
+
+ int nhf_thisv = lConnMap3D[index].v2hf_num[lv];
+
+ // Add other cells that are incident on vid to the stack
+ std::vector<EntityHandle> sib_cids(nfpc);
+ error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
+ if (MB_SUCCESS != error) return error;
+
+ // Add new cells into the stack
+ EntityHandle ngb;
+ for (int i = 0; i < nhf_thisv; ++i){
+ int ind = lConnMap3D[index].v2hf[lv][i];
+ ngb = sib_cids[ind];
+
+ if (ngb) {
+ bool found_ent = find_match_in_array(ngb, trackcells, count);
+
+ if (!found_ent){
+ Stksize += 1;
+ Stkcells[Stksize] = ngb;
+ }
+ }
+ }
+ // Add the current cell
+ //adjents.push_back(cur_cid);
+ }
+ }
+
+ return MB_SUCCESS;
+ }
//////////////////////////////////////////////////////////////////////////////////////////////
ErrorCode HalfFacetRep::get_up_adjacencies_edg_3d( EntityHandle eid,
@@ -2126,23 +2334,23 @@ namespace moab {
error = mb->get_connectivity(&cur_cid, 1, conn);
if (MB_SUCCESS != error) return error;
- // Local id of fid_verts[0] in the cell
- int lv0;
- for (int i = 0; i< nvpc; ++i){
- if (conn[i] == fid_verts[0])
- {
- lv0 = i;
- }
+ // Local id of fid_verts[0] in the cell
+ int lv0;
+ for (int i = 0; i< nvpc; ++i){
+ if (conn[i] == fid_verts[0])
+ {
+ lv0 = i;
+ }
};
- int nhf_thisv = lConnMap3D[index].v2hf_num[lv0];
+ int nhf_thisv = lConnMap3D[index].v2hf_num[lv0];
// Search each half-face to match input face
for(int i = 0; i < nhf_thisv; ++i){
int lfid = lConnMap3D[index].v2hf[lv0][i];
int nv_curF = lConnMap3D[index].hf2v_num[lfid];
if (nv_curF != nvF)
- continue;
+ continue;
// Connectivity of the current half-face
@@ -2150,7 +2358,7 @@ namespace moab {
for(int l = 0; l < nvF; ++l){
int ind = lConnMap3D[index].hf2v[lfid][l];
vthisface[l] = conn[ind];
- };
+ };
// Match this half-face with input fid
@@ -2163,32 +2371,32 @@ namespace moab {
lid[0] = lfid;
break;
- }
- }
+ }
+ }
- // Add other cells that are incident on fid_verts[0]
- std::vector<EntityHandle> sib_cids(nfpc);
- error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
- if (MB_SUCCESS != error) return error;
+ // Add other cells that are incident on fid_verts[0]
+ std::vector<EntityHandle> sib_cids(nfpc);
+ error = mb->tag_get_data(sibhfs_cid, &cur_cid, 1, &sib_cids[0]);
+ if (MB_SUCCESS != error) return error;
- // Add new cells into the stack
- EntityHandle ngb;
- for (int i = 0; i < nhf_thisv; ++i){
- int ind = lConnMap3D[index].v2hf[lv0][i];
- ngb = sib_cids[ind];
+ // Add new cells into the stack
+ EntityHandle ngb;
+ for (int i = 0; i < nhf_thisv; ++i){
+ int ind = lConnMap3D[index].v2hf[lv0][i];
+ ngb = sib_cids[ind];
- if (ngb) {
+ if (ngb) {
- bool found_ent = find_match_in_array(ngb, trackcells, count);
+ bool found_ent = find_match_in_array(ngb, trackcells, count);
- if (!found_ent){
- Stksize += 1;
- Stkcells[Stksize] = ngb;
- }
- }
- }
- }
- }
+ if (!found_ent){
+ Stksize += 1;
+ Stkcells[Stksize] = ngb;
+ }
+ }
+ }
+ }
+ }
return found;
}
diff --git a/src/moab/Core.hpp b/src/moab/Core.hpp
index 20aafdc..d8b155e 100644
--- a/src/moab/Core.hpp
+++ b/src/moab/Core.hpp
@@ -315,30 +315,16 @@ public:
get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies );
\endcode */
- virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+ virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
const int num_entities,
const int to_dimension,
const bool create_if_missing,
std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT
- #ifdef USE_AHF
- , const bool use_ahf = false);
- #else
- );
- #endif
-
-
- /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
- const int num_entities,
- const int to_dimension,
- const bool create_if_missing,
- std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT);*/
-
+ const int operation_type = Interface::INTERSECT);
- virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
+ virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
const int num_entities,
const int to_dimension,
const bool create_if_missing,
@@ -1375,6 +1361,7 @@ private:
#ifdef USE_AHF
HalfFacetRep *ahfRep;
+ bool mesh_modified;
#endif
};
diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index 344dbd1..a228520 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -62,6 +62,8 @@ namespace moab {
~HalfFacetRep();
+ bool check_mixed_entity_type();
+
// User interface functions
//! Creates all the necessary tags to store the maps. Constructs the sibling-half-facet and vertex-to-incident-half-facet maps for each dimension present in the input.
@@ -177,8 +179,7 @@ namespace moab {
ErrorCode determine_incident_halfedges(Range &faces);
- /* ErrorCode get_up_adjacencies_2d(EntityHandle vid,
- std::vector<EntityHandle> &adjents);*/
+ ErrorCode get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents);
//! Given an edge, finds the faces incident on it.
/** Given an edge, it first finds a matching half-edge corresponding to eid, and then
@@ -260,6 +261,9 @@ namespace moab {
ErrorCode determine_border_vertices( Range &cells,
Tag isborder);
+
+ ErrorCode get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents);
+
//! Given an edge, finds the cells incident on it.
/** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
* collects all the incident cells via the sibhfs map.
@@ -353,9 +357,20 @@ namespace moab {
Tag sibhes_fid, sibhes_leid, v2he_fid, v2he_leid;
Tag sibhfs_cid, sibhfs_lfid, v2hf_cid, v2hf_lfid;
-
+ MESHTYPE thismeshtype;
MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
+ struct adj_matrix{
+ int val[4][4];
+ };
+
+ static const adj_matrix adjMatrix[7];
+ int get_index_for_meshtype(MESHTYPE mesh_type);
+
+ // These two flags are for checking mixed entity type meshes
+ bool is_mixed;
+ bool chk_mixed;
+
ErrorCode init_curve();
ErrorCode init_surface();
ErrorCode init_volume();
@@ -364,6 +379,7 @@ namespace moab {
ErrorCode deinit_surface();
ErrorCode deinit_volume();
+
//! Contains the local information for 2D entities
/** Given a face, find the face type specific information
* Parameters:
diff --git a/src/moab/Interface.hpp b/src/moab/Interface.hpp
index 57252e9..0b9e8e9 100644
--- a/src/moab/Interface.hpp
+++ b/src/moab/Interface.hpp
@@ -619,23 +619,13 @@ public:
get_adjacencies( from_entities, 2, 1, false, adjacencies, Interface::INTERSECT);
\endcode
*/
+
virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
const int num_entities,
const int to_dimension,
const bool create_if_missing,
std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT
- #ifdef USE_AHF
- , const bool use_ahf = false) = 0;
- #else
- ) = 0;
- #endif
- /*virtual ErrorCode get_adjacencies(const EntityHandle *from_entities,
- const int num_entities,
- const int to_dimension,
- const bool create_if_missing,
- std::vector<EntityHandle>& adj_entities,
- const int operation_type = Interface::INTERSECT) = 0; */
+ const int operation_type = Interface::INTERSECT) = 0;
//! Get the adjacencies associated with a vector of entities to entities of a specfied dimension.
/** Identical to vector-based get_adjacencies function, except results are returned in a
diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index d70753f..a4f5d8a 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -6559,7 +6559,7 @@ ErrorCode mb_skin_verts_common( unsigned dim, bool skin_elems )
std::cout << "Extra/non-returned elements created: " << extra << std::endl;
return MB_FAILURE;
}
-
+
// check that each skin vertex has the correct number of adjacent quads
missing.clear(); extra.clear();
for (Range::iterator i = expected.begin(); i != expected.end(); ++i) {
diff --git a/test/Makefile.am b/test/Makefile.am
index 1354e3c..33ca518 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,9 +61,9 @@ if HDF5_FILE
lloyd_smoother_test
endif
-# if ENABLE_ahf
-# TESTS += ahf_mbintf_test
-# endif
+if ENABLE_ahf
+ TESTS += ahf_mbintf_test
+endif
# merge_test \ # input files no longer exist?
# test_tag_server \ # fails
@@ -158,9 +158,9 @@ lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
ahf_test_SOURCES = test_ahf_moab.cpp
-# if ENABLE_ahf
-# ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-# endif
+if ENABLE_ahf
+ ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
+endif
if PARALLEL
diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index 9bf76ef..3d8257f 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -41,7 +41,7 @@ void ahf_mbintf_test()
//IQ1: For every vertex, obtain incident edges
for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
@@ -58,7 +58,7 @@ void ahf_mbintf_test()
//NQ1: For every edge, obtain neighbor edges
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
@@ -76,7 +76,7 @@ void ahf_mbintf_test()
//IQ2: For every edge, obtain incident faces
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
@@ -93,7 +93,7 @@ void ahf_mbintf_test()
//NQ2: For every face, obtain neighbor faces
for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
@@ -111,7 +111,7 @@ void ahf_mbintf_test()
// IQ 31: For every edge, obtain incident cells
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -128,7 +128,7 @@ void ahf_mbintf_test()
//IQ32: For every face, obtain incident cells
for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
@@ -145,7 +145,7 @@ void ahf_mbintf_test()
//NQ3: For every cell, obtain neighbor cells
for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents, Interface::INTERSECT, true);
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
CHECK_ERR(error);
mbents.clear();
error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index e415186..a9185ae 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -97,7 +97,25 @@ ErrorCode ahf_test(Core *moab)
}
// 2D Queries
- //IQ2: For every edge, obtain incident faces
+
+ // IQ21: For every vertex, obtain incident faces
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ22: For every edge, obtain incident faces
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
error = ahf.get_up_adjacencies( *i, 2, adjents);
@@ -132,7 +150,24 @@ ErrorCode ahf_test(Core *moab)
}
// 3D Queries
- // IQ 31: For every edge, obtain incident cells
+ //IQ 31: For every vertex, obtain incident cells
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // IQ 32: For every edge, obtain incident cells
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
error = ahf.get_up_adjacencies( *i, 3, adjents);
@@ -149,7 +184,7 @@ ErrorCode ahf_test(Core *moab)
CHECK(!mbents.size());
}
- //IQ32: For every face, obtain incident cells
+ //IQ33: For every face, obtain incident cells
for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
adjents.clear();
error = ahf.get_up_adjacencies( *i, 3, adjents);
https://bitbucket.org/fathomteam/moab/commits/38d5e3b3418e/
Changeset: 38d5e3b3418e
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Removed unnecessary printouts. Added two examples for comparing timing
and memory efficiency of MOAB and MOAB_AHF adjacencies.
Affected #: 6 files
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 18a8a0d..af8c187 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -179,7 +179,6 @@ namespace moab {
MESHTYPE mesh_type = get_mesh_type(nverts, nedges, nfaces, ncells);
thismeshtype = mesh_type;
- std::cout<<"MeshType = "<<thismeshtype<<std::endl;
//Initialize mesh type specific maps
if (mesh_type == CURVE){
@@ -812,7 +811,6 @@ namespace moab {
}
}
- std::cout<<"Finished creating sibling half-verts map"<<std::endl;
delete [] is_index;
delete [] v2hv_map_eid;
@@ -846,7 +844,6 @@ namespace moab {
}
}
}
- std::cout<<"Finished creating incident half-verts map"<<std::endl;
return MB_SUCCESS;
}
@@ -1155,7 +1152,6 @@ namespace moab {
delete [] v2he_map_fid;
delete [] v2he_map_leid;
- std::cout<<"Finished creating sibling half-edges map"<<std::endl;
return MB_SUCCESS;
}
@@ -1190,10 +1186,10 @@ namespace moab {
if (MB_SUCCESS != error) return error;
error = mb->tag_set_data(v2he_leid, &v, 1, &lid);
if (MB_SUCCESS != error) return error;
- }
- }
+ }
+ }
}
- std::cout<<"Finished creating incident half-edges map"<<std::endl;
+
return MB_SUCCESS;
}
@@ -1837,7 +1833,6 @@ namespace moab {
delete [] v2hf_map_cid;
delete [] v2hf_map_lfid;
- std::cout<<"Finished creating sibling half-faces map"<<std::endl;
return MB_SUCCESS;
@@ -1891,7 +1886,6 @@ namespace moab {
}
}
- std::cout<<"Finished creating incident half-faces"<<std::endl;
return MB_SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 32e2a57..556554c 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,7 +7,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
LDADD = $(top_builddir)/src/libMOAB.la
-check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time
+check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time adj_without_ahf
noinst_PROGRAMS =
perf_SOURCES = perf.cpp
@@ -15,6 +15,7 @@ seqperf_SOURCES = seqperf.cpp
adj_time_SOURCES = adj_time.cpp
perftool_SOURCES = perftool.cpp
ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
+adj_without_ahf_SOURCES = adj_without_ahf_mem_time.cpp
if ENABLE_imesh
LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
@@ -24,4 +25,9 @@ if ENABLE_imesh
tstt_perf_binding_SOURCES = tstt_perf_binding.cpp
endif
+if ENABLE_ahf
+ check_PROGRAMS += adj_with_ahf
+ adj_with_ahf_SOURCES = adj_with_ahf_mem_time.cpp
+endif
+
diff --git a/test/perf/adj_with_ahf_mem_time.cpp b/test/perf/adj_with_ahf_mem_time.cpp
new file mode 100755
index 0000000..dbf4558
--- /dev/null
+++ b/test/perf/adj_with_ahf_mem_time.cpp
@@ -0,0 +1,209 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ std::cout<<std::endl;
+ std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_avg;
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+
+ // This call should create all the necessary ahf maps
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+ //NQ1: For every edge, obtain neighbor edges
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+
+ // 2D Queries
+ std::cout<<"2D QUERIES"<<std::endl;
+ //IQ21: For every vertex, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+
+
+ //IQ22: For every edge, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+
+
+ //NQ2: For every face, obtain neighbor faces
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+
+ // 3D Queries
+ std::cout<<"3D QUERIES"<<std::endl;
+ //IQ31: For every vertex, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+
+ // IQ 32: For every edge, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+
+ //IQ32: For every face, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+
+ //NQ3: For every cell, obtain neighbor cells
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
+
+
+ //Storage Costs after calling ahf deinitialize
+ std::cout<<std::endl;
+ std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/perf/adj_without_ahf_mem_time.cpp b/test/perf/adj_without_ahf_mem_time.cpp
new file mode 100755
index 0000000..cd4d58c
--- /dev/null
+++ b/test/perf/adj_without_ahf_mem_time.cpp
@@ -0,0 +1,223 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ std::cout<<std::endl;
+ std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_avg;
+
+ //Perform queries
+ std::vector<EntityHandle> mbents;
+ Range ngbents;
+
+ // This call should create all the necessary moab adjacency lists
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //NQ1: For every edge, obtain neighbor edges
+ error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+
+
+ // 2D Queries
+ std::cout<<"2D QUERIES"<<std::endl;
+ //IQ21: For every vertex, obtain incident faces
+ error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //IQ22: For every edge, obtain incident faces
+ error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //NQ2: For every face, obtain neighbor faces
+ error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+
+ // 3D Queries
+ std::cout<<"3D QUERIES"<<std::endl;
+ //IQ31: For every vertex, obtain incident cells
+ error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+
+ // IQ 32: For every edge, obtain incident cells
+ error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //IQ32: For every face, obtain incident cells
+ error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //NQ3: For every cell, obtain neighbor cells
+ error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+
+ //Storage Costs after calling ahf deinitialize
+ std::cout<<std::endl;
+ std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/perf/ahf_intfc_mem_time.cpp b/test/perf/ahf_intfc_mem_time.cpp
new file mode 100755
index 0000000..6d8ef14
--- /dev/null
+++ b/test/perf/ahf_intfc_mem_time.cpp
@@ -0,0 +1,309 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_avg;
+
+ //Storage Costs after calling ahf initialize
+ unsigned long TotS, TAS, ES, AES, AS, AAS, TS, ATS;
+ TotS = TAS = ES = AES = AS = AAS = TS = ATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &TotS, &TAS, &ES, &AES, &AS, &AAS, NULL, 0, &TS, &ATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<TotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<TAS<<std::endl;
+ std::cout<<"Entity storage = "<<ES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<AES<<std::endl;
+ std::cout<<"Adjacency storage = "<<AS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<AAS<<std::endl;
+ std::cout<<"Tag storage = "<<TS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<ATS<<std::endl;
+ std::cout<<std::endl;
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range mbents;
+
+ // This call should create all the necessary ahf maps
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+ // This call should create all the necessary moab adjacency lists
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //NQ1: For every edge, obtain neighbor edges
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+
+ error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+
+
+ // 2D Queries
+ std::cout<<"2D QUERIES"<<std::endl;
+ //IQ21: For every vertex, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+
+ error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //IQ22: For every edge, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+
+ error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+ //NQ2: For every face, obtain neighbor faces
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+
+ error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, mbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+
+
+ // 3D Queries
+ std::cout<<"3D QUERIES"<<std::endl;
+ //IQ31: For every vertex, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+ error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+
+ // IQ 32: For every edge, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+ error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //IQ32: For every face, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+
+ error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+
+ //NQ3: For every cell, obtain neighbor cells
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
+
+ error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, mbents);
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+
+ //Storage Costs after calling ahf deinitialize
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index 3d8257f..f4f754f 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -73,7 +73,24 @@ void ahf_mbintf_test()
}
// 2D Queries
- //IQ2: For every edge, obtain incident faces
+ // IQ21: For every vertex, obtain incident faces
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ22: For every edge, obtain incident faces
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
@@ -108,7 +125,24 @@ void ahf_mbintf_test()
}
// 3D Queries
- // IQ 31: For every edge, obtain incident cells
+ //IQ 31: For every vertex, obtain incident cells
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // IQ 32: For every edge, obtain incident cells
for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
adjents.clear();
error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
https://bitbucket.org/fathomteam/moab/commits/dfc0e561138a/
Changeset: dfc0e561138a
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Corrected memory deallocation. Removed warnings when configured with
--enable-ahf.
Affected #: 3 files
diff --git a/src/Core.cpp b/src/Core.cpp
index 3340934..9bfb9ca 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -302,6 +302,11 @@ void Core::deinitialize()
delete *vit;
#endif
+#ifdef USE_AHF
+ delete ahfRep;
+ ahfRep = 0;
+#endif
+
if (aEntityFactory)
delete aEntityFactory;
@@ -334,10 +339,6 @@ void Core::deinitialize()
MPI_Finalize();
#endif
-#ifdef USE_AHF
- delete ahfRep;
- ahfRep = 0;
-#endif
}
ErrorCode Core::query_interface_type( const std::type_info& type, void*& ptr )
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index af8c187..fbda680 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -38,16 +38,12 @@ namespace moab {
is_mixed = false;
}
- HalfFacetRep::~HalfFacetRep()
- {
- ErrorCode result;
- result = deinitialize();
- //if (MB_SUCCESS != result) return result;
- }
+ HalfFacetRep::~HalfFacetRep() {}
+
MESHTYPE HalfFacetRep::get_mesh_type(int nverts, int nedges, int nfaces, int ncells)
{
- MESHTYPE mesh_type;
+ MESHTYPE mesh_type = CURVE;
if (nverts && nedges && (!nfaces) && (!ncells))
mesh_type = CURVE;
@@ -94,7 +90,7 @@ namespace moab {
int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
{
- int index;
+ int index = 0;
if (mesh_type == CURVE) index = 0;
else if (mesh_type == SURFACE) index = 1;
else if (mesh_type == SURFACE_MIXED) index = 2;
@@ -181,42 +177,42 @@ namespace moab {
thismeshtype = mesh_type;
//Initialize mesh type specific maps
- if (mesh_type == CURVE){
+ if (thismeshtype == CURVE){
error = init_curve();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == SURFACE){
+ else if (thismeshtype == SURFACE){
error = init_surface();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == SURFACE_MIXED){
+ else if (thismeshtype == SURFACE_MIXED){
error = init_curve();
if (MB_SUCCESS != error) return error;
error = init_surface();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME){
+ else if (thismeshtype == VOLUME){
error = init_volume();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED_1){
+ else if (thismeshtype == VOLUME_MIXED_1){
error = init_curve();
if (MB_SUCCESS != error) return error;
error = init_volume();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED_2){
+ else if (thismeshtype == VOLUME_MIXED_2){
error = init_surface();
if (MB_SUCCESS != error) return error;
error = init_volume();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED){
+ else if (thismeshtype == VOLUME_MIXED){
error = init_curve();
if (MB_SUCCESS != error) return error;
error = init_surface();
@@ -329,39 +325,38 @@ namespace moab {
ErrorCode HalfFacetRep::deinitialize()
{
ErrorCode error;
- MESHTYPE mesh_type = get_mesh_type(_verts.size(), _edges.size(), _faces.size(), _cells.size());
- if (mesh_type == CURVE){
+ if (thismeshtype == CURVE){
error = deinit_curve();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == SURFACE){
+ else if (thismeshtype == SURFACE){
error = deinit_surface();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == SURFACE_MIXED){
+ else if (thismeshtype == SURFACE_MIXED){
error = deinit_curve();
if (MB_SUCCESS != error) return error;
error = deinit_surface();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME){
+ else if (thismeshtype == VOLUME){
error = deinit_volume();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED_1){
+ else if (thismeshtype == VOLUME_MIXED_1){
error = deinit_curve();
if (MB_SUCCESS != error) return error;
error = deinit_volume();
if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED_2){
+ else if (thismeshtype == VOLUME_MIXED_2){
error = deinit_surface();
if (MB_SUCCESS != error) return error;
error = deinit_volume();
- if (MB_SUCCESS != error) return error;
+ if (MB_SUCCESS != error) return error;
}
- else if (mesh_type == VOLUME_MIXED){
+ else if (thismeshtype == VOLUME_MIXED){
error = deinit_curve();
if (MB_SUCCESS != error) return error;
error = deinit_surface();
@@ -946,7 +941,7 @@ namespace moab {
// nepf: Number of edges per face
EntityType type = mb->type_from_handle(face);
- int nepf;
+ int nepf = 0;
if (type == MBTRI) nepf = 3;
else if (type ==MBQUAD) nepf = 4;
@@ -1603,7 +1598,7 @@ namespace moab {
int HalfFacetRep::get_index_from_type(EntityHandle cid)
{
- int index;
+ int index = 0;
EntityType type = mb->type_from_handle(cid);
if (type == MBTET)
index = 0;
@@ -1822,8 +1817,8 @@ namespace moab {
delete [] setcid;
delete [] setlfid;
}
- delete sibcid;
- delete siblfid;
+ delete [] sibcid;
+ delete [] siblfid;
}
@@ -1970,7 +1965,7 @@ namespace moab {
if (MB_SUCCESS != error) return error;
// Local id of vid in the cell and the half-faces incident on it
- int lv;
+ int lv = -1;
for (int i = 0; i< nvpc; ++i){
if (conn[i] == vid)
lv = i;
@@ -2241,7 +2236,7 @@ namespace moab {
error =mb->get_connectivity(&cell_id, 1, conn);
if (MB_SUCCESS != error) return error;
- int lv0 = -1, lv1 = -1, lv;
+ int lv0 = -1, lv1 = -1, lv = -1;
//locate v_origin in poped out tet, check if v_end is in
for (int i = 0; i<nvpc; i++){
@@ -2329,7 +2324,7 @@ namespace moab {
if (MB_SUCCESS != error) return error;
// Local id of fid_verts[0] in the cell
- int lv0;
+ int lv0 = -1;
for (int i = 0; i< nvpc; ++i){
if (conn[i] == fid_verts[0])
{
diff --git a/test/test_ahf_moab.cpp b/test/test_ahf_moab.cpp
index a9185ae..759f7b0 100755
--- a/test/test_ahf_moab.cpp
+++ b/test/test_ahf_moab.cpp
@@ -218,6 +218,8 @@ ErrorCode ahf_test(Core *moab)
CHECK(!mbents.size());
}
+ ahf.deinitialize();
+
return MB_SUCCESS;
}
https://bitbucket.org/fathomteam/moab/commits/f70fc9fbb253/
Changeset: f70fc9fbb253
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Changed ahf moab interface test to accept an input file.
Affected #: 1 file
diff --git a/test/test_ahf_mb_interface.cpp b/test/test_ahf_mb_interface.cpp
index f4f754f..321d043 100755
--- a/test/test_ahf_mb_interface.cpp
+++ b/test/test_ahf_mb_interface.cpp
@@ -11,198 +11,228 @@
using namespace moab;
#ifdef MESHDIR
-static const char example[] = STRINGIFY(MESHDIR) "/hexes_mixed.vtk";
+std::string TestDir(STRINGIFY(MESHDIR));
#else
-static const char example[] = "/hexes_mixed.vtk";
+std::string TestDir(".");
#endif
-void ahf_mbintf_test()
-{
-
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- ErrorCode error = mbImpl->load_file(example);
- CHECK_ERR(error);
-
- /*Create ranges for handles of explicit elements of the mixed mesh*/
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- //Perform queries
- std::vector<EntityHandle> adjents;
- Range mbents, ahfents;
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(),mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- //NQ1: For every edge, obtain neighbor edges
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
+std::string filename;
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- // 2D Queries
- // IQ21: For every vertex, obtain incident faces
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- //IQ22: For every edge, obtain incident faces
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- //NQ2: For every face, obtain neighbor faces
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
- CHECK_ERR(error);
+int number_tests_successful = 0;
+int number_tests_failed = 0;
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- // 3D Queries
- //IQ 31: For every vertex, obtain incident cells
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
-
- // IQ 32: For every edge, obtain incident cells
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+ if (rv == MB_SUCCESS) {
+ std::cout << "Success";
+ number_successful++;
+ } else {
+ std::cout << "Failure";
+ number_failed++;
}
+}
- //IQ32: For every face, obtain incident cells
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
- CHECK_ERR(error);
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
-
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
+ErrorCode ahf_mbintfc_test(Core *moab)
+{
+ Interface* mbImpl = &*moab;
+ MeshTopoUtil mtu(mbImpl);
- //NQ3: For every cell, obtain neighbor cells
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ ErrorCode error = mbImpl->load_file(filename.c_str());
CHECK_ERR(error);
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
- CHECK_ERR(error);
-
- CHECK_EQUAL(adjents.size(), mbents.size());
- std::sort(adjents.begin(), adjents.end());
- std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
- mbents = subtract(mbents, ahfents);
- CHECK(!mbents.size());
- }
+ /*Create ranges for handles of explicit elements of the mixed mesh*/
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range mbents, ahfents;
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(),mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ1: For every edge, obtain neighbor edges
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 2D Queries
+ // IQ21: For every vertex, obtain incident faces
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ22: For every edge, obtain incident faces
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ2: For every face, obtain neighbor faces
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 3D Queries
+ //IQ 31: For every vertex, obtain incident cells
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // IQ 32: For every edge, obtain incident cells
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ32: For every face, obtain incident cells
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ3: For every cell, obtain neighbor cells
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 3, false, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ return MB_SUCCESS;
}
int main(int argc, char *argv[])
{
- int result = 0;
- argv[0] = argv[argc - argc]; // Followed read_mpas_nc.cpp test for removing warnings in serial mode about unused variables.
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ Core moab;
+ ErrorCode result;
- result += RUN_TEST(ahf_mbintf_test);
+ std::cout<<" ahf_mbintfc_test: ";
+ result = ahf_mbintfc_test(&moab);
+ handle_error_code(result, number_tests_failed, number_tests_successful);
+ std::cout<<"\n";
- return result;
+ return number_tests_failed;
}
https://bitbucket.org/fathomteam/moab/commits/f7794c267f95/
Changeset: f7794c267f95
Branch: None
User: nray
Date: 2014-07-13 04:18:47
Summary: Added down adjacencies. Merged separate performance tests for AHF and
MOAB adjacencies into one. Some optimization.
Affected #: 11 files
diff --git a/src/Core.cpp b/src/Core.cpp
index 9bfb9ca..e8cdf33 100644
--- a/src/Core.cpp
+++ b/src/Core.cpp
@@ -1542,11 +1542,8 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
#ifdef USE_AHF
bool can_handle = true;
- int source_dim = this->dimension_from_handle(from_entities[0]);
- if ((source_dim > to_dimension) && (to_dimension != 0))
- can_handle = false; //NOT SUPPORTED: Down adjacencies
- else if (to_dimension == 4)
+ if (to_dimension == 4)
can_handle = false; // NOT SUPPORTED: meshsets
else if (create_if_missing)
can_handle = false;//NOT SUPPORTED: create_if_missing
@@ -1555,7 +1552,7 @@ ErrorCode Core::get_adjacencies( const EntityHandle *from_entities,
if (mixed)
can_handle = false;
- if (mesh_modified)
+ if (mesh_modified) //NOT SUPPORTED: modified mesh
can_handle = false;
if (can_handle)
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index fbda680..4e363e3 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -27,8 +27,6 @@
namespace moab {
- const int MAXSIZE = 150;
-
HalfFacetRep::HalfFacetRep(Core *impl)
{
assert(NULL != impl);
@@ -73,19 +71,19 @@ namespace moab {
{{{0,0,1,0},{0,0,0,0},{1,0,1,0},{0,0,0,0}}},
//SURFACE_MIXED
- {{{0,1,1,0},{1,1,1,0},{1,0,1,0},{0,0,0,0}}},
+ {{{0,1,1,0},{1,1,1,0},{1,1,1,0},{0,0,0,0}}},
//VOLUME
{{{0,0,0,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}}},
//VOLUME_MIXED_1
- {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,0,0,1}}},
+ {{{0,1,0,1},{1,1,0,1},{0,0,0,0},{1,1,0,1}}},
//VOLUME_MIXED_2
- {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,0,1}}},
+ {{{0,0,1,1},{0,0,0,0},{1,0,1,1},{1,0,1,1}}},
//VOLUME_MIXED
- {{{0,1,1,1},{1,1,1,1},{1,0,1,1},{1,0,0,1}}}
+ {{{0,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}}
};
int HalfFacetRep::get_index_for_meshtype(MESHTYPE mesh_type)
@@ -278,6 +276,17 @@ namespace moab {
error = determine_incident_halfedges(_faces);
if (MB_SUCCESS != error) return error;
+ //Create face tags
+ error = mb->tag_get_handle("__VISITED_FACE", 1, MB_TYPE_INTEGER, visited_face, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
+ if (MB_SUCCESS != error) return error;
+
+ //Initialize queues for storing face and local id's during local search
+ for (int i = 0; i< MAXSIZE; i++)
+ {
+ queue_fid[i] = 0;
+ queue_lid[i] = 0;
+ }
+
delete [] sdefval;
delete [] sval;
@@ -299,6 +308,7 @@ namespace moab {
sval[i] = 0;
}
+ //Create tags to store ahf maps for volume
error = mb->tag_get_handle("__SIBHFS_CID", nfpc, MB_TYPE_HANDLE, sibhfs_cid, MB_TAG_DENSE | MB_TAG_CREAT, sdefval);
if (MB_SUCCESS != error) return error;
error = mb->tag_get_handle("__SIBHFS_LFID", nfpc, MB_TYPE_INTEGER, sibhfs_lfid, MB_TAG_DENSE | MB_TAG_CREAT, sval);
@@ -308,11 +318,17 @@ namespace moab {
error = mb->tag_get_handle("__V2HF_LFID", 1, MB_TYPE_INTEGER, v2hf_lfid, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
if (MB_SUCCESS != error) return error;
+ //Construct the maps
error = determine_sibling_halffaces(_cells);
if (MB_SUCCESS != error) return error;
error = determine_incident_halffaces(_cells);
if (MB_SUCCESS != error) return error;
+
+ //Create cell tag
+ error = mb->tag_get_handle("__VISITED_CELL", 1, MB_TYPE_INTEGER, visited_cell, MB_TAG_DENSE | MB_TAG_CREAT, &ival);
+ if (MB_SUCCESS != error) return error;
+
delete [] sdefval;
delete [] sval;
@@ -393,6 +409,9 @@ namespace moab {
error = mb->tag_delete(v2he_leid);
if (MB_SUCCESS != error) return error;
+ error = mb->tag_delete(visited_face);
+ if (MB_SUCCESS != error) return error;
+
return MB_SUCCESS;
}
@@ -407,6 +426,10 @@ namespace moab {
error = mb->tag_delete(v2hf_lfid);
if (MB_SUCCESS != error) return error;
+ error = mb->tag_delete(visited_cell);
+ if (MB_SUCCESS != error) return error;
+
+
return MB_SUCCESS;
}
@@ -550,64 +573,20 @@ namespace moab {
if (adj_possible)
{
-
- if (source_dimension == 0) // Vertex to up adjacencies
- {
- if (target_dimension == 1)
- {
- error = get_up_adjacencies_1d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if (target_dimension == 2)
- {
- error = get_up_adjacencies_vert_2d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if (target_dimension == 3)
- {
- error = get_up_adjacencies_vert_3d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- }
-
- else if (source_dimension == 1) // Edge to up adjacencies
+ if (source_dimension < target_dimension)
{
- if (target_dimension == 2)
- {
- error = get_up_adjacencies_2d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if (target_dimension == 3)
- {
- error = get_up_adjacencies_edg_3d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
+ error = get_up_adjacencies(source_entity, target_dimension, target_entities);
+ if (MB_SUCCESS != error) return error;
}
-
- else if ((source_dimension == 2) && (target_dimension ==3)) // Face to up adjacencies
+ else if (source_dimension == target_dimension)
{
- error = get_up_adjacencies_face_3d(source_entity, target_entities);
+ error = get_neighbor_adjacencies(source_entity, target_entities);
if (MB_SUCCESS != error) return error;
}
-
- else if (source_dimension == target_dimension) // Same dimensional adjacencies
+ else
{
- if (target_dimension == 1)
- {
- error = get_neighbor_adjacencies_1d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
-
- else if (target_dimension == 2)
- {
- error = get_neighbor_adjacencies_2d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
- else if (target_dimension == 3)
- {
- error = get_neighbor_adjacencies_3d(source_entity, target_entities);
- if (MB_SUCCESS != error) return error;
- }
+ error = get_down_adjacencies(source_entity, target_dimension, target_entities);
+ if (MB_SUCCESS != error) return error;
}
}
else
@@ -688,6 +667,28 @@ namespace moab {
return MB_SUCCESS;
}
+ ErrorCode HalfFacetRep::get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents)
+ {
+ ErrorCode error;
+ int in_dim = mb->dimension_from_handle(ent);
+ if ((in_dim == 2)&&(out_dim == 1))
+ {
+ error = get_down_adjacencies_2d(ent, adjents);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if ((in_dim == 3)&&(out_dim == 1))
+ {
+ error = get_down_adjacencies_edg_3d(ent, adjents);
+ if (MB_SUCCESS != error) return error;
+ }
+ else if ((in_dim == 3)&&(out_dim == 2))
+ {
+ error = get_down_adjacencies_face_3d(ent, adjents);
+ if (MB_SUCCESS != error) return error;
+ }
+ return MB_SUCCESS;
+ }
+
/********************************************************
* 1D: sibhvs, v2hv, incident and neighborhood queries *
*********************************************************/
@@ -1203,17 +1204,9 @@ namespace moab {
{
adjents.push_back(fid);
- EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
- int queue_lid[MAXSIZE];
- for (int i = 0; i< MAXSIZE; i++)
- {
- queue_fid[i] = 0;
- queue_lid[i] = 0;
- trackfaces[i] = 0;
- }
- int qsize = 0, count = -1;
+ int qsize = 0;
int num_qvals = 0;
- error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
+ error = gather_halfedges(vid, fid, lid, &qsize);
if (MB_SUCCESS != error) return error;
while (num_qvals < qsize)
@@ -1226,20 +1219,35 @@ namespace moab {
error = another_halfedge(vid, curfid, curlid, &he2_fid, &he2_lid);
if (MB_SUCCESS != error) return error;
- bool found_ent = find_match_in_array(he2_fid, trackfaces, count);
+ int val;
+ error = mb->tag_get_data(visited_face, &he2_fid, 1, &val);
+ if (MB_SUCCESS != error) return error;
- if (found_ent)
+ if (val)
continue;
- count += 1;
- trackfaces[count] = he2_fid;
- error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, &qsize, trackfaces, &count);
+ val = 1;
+ error = mb->tag_set_data(visited_face, &he2_fid, 1, &val);
if (MB_SUCCESS != error) return error;
- adjents.push_back(he2_fid);
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, &qsize);
+ if (MB_SUCCESS != error) return error;
+ adjents.push_back(he2_fid);
}
- }
+
+ //Change the visited faces to false, also empty the queue
+ for (int i = 0; i<qsize; i++)
+ {
+ int val = 0;
+ error = mb->tag_set_data(visited_face, &queue_fid[i], 1, &val);
+ if (MB_SUCCESS != error) return error;
+
+ queue_fid[i] = 0;
+ queue_lid[i] = 0;
+ }
+
+ }
return MB_SUCCESS;
}
@@ -1251,7 +1259,6 @@ namespace moab {
{
// Given an explicit edge eid, find the incident faces.
-
ErrorCode error;
EntityHandle he_fid=0; int he_lid=0;
@@ -1322,11 +1329,8 @@ namespace moab {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ErrorCode HalfFacetRep::get_up_adjacencies_2d(EntityHandle fid,
int lid,
- EntityHandle *queue_fid,
- int *queue_lid,
- int *qsize,
- EntityHandle *trackfaces,
- int *tcount)
+ int *qsize
+ )
{
ErrorCode error;
@@ -1345,7 +1349,6 @@ namespace moab {
int index = 0;
bool found_ent = find_match_in_array(fid, queue_fid, qsize[0]-1, true, &index);
if ((!found_ent)||((found_ent) && (queue_lid[index] != lid)))
-
{
queue_fid[qsize[0]] = fid;
queue_lid[qsize[0]] = lid;
@@ -1354,14 +1357,14 @@ namespace moab {
}
while ((curfid != fid)&&(curfid != 0)) {
+ int val;
+ error = mb->tag_get_data(visited_face, &curfid, 1, &val);
+ if (MB_SUCCESS != error) return error;
- bool found = find_match_in_array(curfid, trackfaces, tcount[0]);
-
- if (!found){
+ if (!val){
queue_fid[qsize[0]] = curfid;
queue_lid[qsize[0]] = curlid;
qsize[0] += 1;
-
}
sib_fids.clear();
@@ -1396,22 +1399,26 @@ namespace moab {
bool found = false;
if (fid!=0){
- EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
- int queue_lid[MAXSIZE];
- for (int i = 0; i< MAXSIZE; i++)
- {
- queue_fid[i] = 0;
- queue_lid[i] = 0;
- trackfaces[i] = 0;
- }
- int qsize = 0, tcount = -1;
+
+ int qsize = 0;
EntityHandle vid = conn[0];
- error = gather_halfedges(vid, fid, lid, queue_fid, queue_lid, &qsize, trackfaces, &tcount);
+ error = gather_halfedges(vid, fid, lid, &qsize);
if (MB_SUCCESS != error) return error;
- found = collect_and_compare(conn, queue_fid, queue_lid, &qsize, trackfaces, &tcount, hefid, helid);
+ found = collect_and_compare(conn, &qsize, hefid, helid);
+
+ //Change the visited faces to false
+ for (int i = 0; i<qsize; i++)
+ {
+ int val = 0;
+ error = mb->tag_set_data(visited_face, &queue_fid[i], 1, &val);
+ if (MB_SUCCESS != error) return error;
+
+ queue_fid[i] = 0;
+ queue_lid[i] = 0;
+ }
}
return found;
@@ -1420,11 +1427,8 @@ namespace moab {
ErrorCode HalfFacetRep::gather_halfedges( EntityHandle vid,
EntityHandle he_fid,
int he_lid,
- EntityHandle *queue_fid,
- int *queue_lid,
- int *qsize,
- EntityHandle *trackfaces,
- int *tcount)
+ int *qsize
+ )
{
ErrorCode error;
EntityHandle he2_fid = 0; int he2_lid = 0;
@@ -1436,12 +1440,14 @@ namespace moab {
*qsize += 1;
queue_fid[*qsize] = he2_fid; queue_lid[*qsize] = he2_lid;
*qsize += 1;
- tcount[0] += 1;
- trackfaces[tcount[0]] = he_fid;
+
+ int val = 1;
+ error = mb->tag_set_data(visited_face, &he_fid, 1, &val);
+ if (MB_SUCCESS != error) return error;
- error = get_up_adjacencies_2d(he_fid, he_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he_fid, he_lid, qsize);
if (MB_SUCCESS != error) return error;
- error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, qsize);
if (MB_SUCCESS != error) return error;
return MB_SUCCESS;
@@ -1479,11 +1485,7 @@ namespace moab {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool HalfFacetRep::collect_and_compare(std::vector<EntityHandle> &edg_vert,
- EntityHandle *queue_fid,
- int *queue_lid,
- int *qsize,
- EntityHandle *trackfaces,
- int *tcount,
+ int *qsize,
EntityHandle *he_fid,
int *he_lid)
{
@@ -1503,41 +1505,45 @@ namespace moab {
int curlid = queue_lid[num_qvals];
num_qvals += 1;
- std::vector<EntityHandle> conn(nepf);
- error = mb->get_connectivity(&curfid, 1, conn);
- if (MB_SUCCESS != error) return error;
+ std::vector<EntityHandle> conn(nepf);
+ error = mb->get_connectivity(&curfid, 1, conn);
+ if (MB_SUCCESS != error) return error;
- int id = next[curlid];
- if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
- *he_fid = curfid;
- *he_lid = curlid;
- found = true;
- break;
- }
+ int id = next[curlid];
+ if (((conn[curlid]==edg_vert[0])&&(conn[id]==edg_vert[1]))||((conn[curlid]==edg_vert[1])&&(conn[id]==edg_vert[0]))){
+ *he_fid = curfid;
+ *he_lid = curlid;
+ found = true;
+ break;
+ }
- bool found_ent = find_match_in_array(curfid, trackfaces, tcount[0]);
+ int val;
+ error = mb->tag_get_data(visited_face, &curfid, 1, &val);
+ if (MB_SUCCESS != error) return error;
- if (found_ent)
- continue;
- tcount[0] += 1;
- trackfaces[tcount[0]] = curfid;
+ if (val)
+ continue;
- EntityHandle he2_fid; int he2_lid;
- error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
+ val=1;
+ error = mb->tag_set_data(visited_face, &curfid, 1, &val);
+ if (MB_SUCCESS != error) return error;
- if (MB_SUCCESS != error) return error;
- error = get_up_adjacencies_2d(he2_fid, he2_lid, queue_fid, queue_lid, qsize, trackfaces, tcount);
- if (MB_SUCCESS != error) return error;
+ EntityHandle he2_fid; int he2_lid;
+ error = another_halfedge(edg_vert[0], curfid, curlid, &he2_fid, &he2_lid);
+
+ if (MB_SUCCESS != error) return error;
+ error = get_up_adjacencies_2d(he2_fid, he2_lid, qsize);
+ if (MB_SUCCESS != error) return error;
+
+ counter += 1;
+ }
- counter += 1;
- }
-
delete [] next;
delete [] prev;
return found;
}
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
ErrorCode HalfFacetRep::get_neighbor_adjacencies_2d( EntityHandle fid,
std::vector<EntityHandle> &adjents)
{
@@ -1554,6 +1560,50 @@ namespace moab {
return MB_SUCCESS;
}
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ ErrorCode HalfFacetRep::get_down_adjacencies_2d(EntityHandle fid, std::vector<EntityHandle> &adjents)
+ {
+ //Returns explicit edges, if any, of the face
+ ErrorCode error;
+ int nepf = local_maps_2d(fid);
+ std::vector<EntityHandle> conn(nepf);
+ error = mb->get_connectivity(&fid, 1, conn);
+ if (error != MB_SUCCESS) return error;
+
+ //Gather all the incident edges on each vertex of the face
+ std::vector< std::vector<EntityHandle> > temp(nepf);
+ for (int i=0; i<nepf; i++)
+ {
+ error = get_up_adjacencies_1d(conn[i], temp[i]);
+ if (error != MB_SUCCESS) return error;
+ std::sort(temp[i].begin(), temp[i].end());
+ }
+
+ //Loop over all the local edges and find the intersection.
+ for (int i = 0; i < nepf; ++i)
+ {
+ std::vector<EntityHandle> common(10);
+ std::vector<EntityHandle>::iterator it;
+ if (i == nepf-1){
+ it = std::set_intersection(temp[i].begin(), temp[i].end(), temp[0].begin(), temp[0].end(), common.begin());
+ if (*common.begin() == 0)
+ continue;
+
+ adjents.push_back(*common.begin());
+ }
+ else
+ {
+ it = std::set_intersection(temp[i].begin(), temp[i].end(), temp[i+1].begin(), temp[i+1].end(), common.begin());
+ if (*common.begin() == 0)
+ continue;
+
+ adjents.push_back(*common.begin());
+ }
+ }
+ return MB_SUCCESS;
+ }
+
////////////////////////////////////////////////////////////////////////////////////////////////
int HalfFacetRep::find_total_edges_2d(Range &faces)
{
@@ -2087,15 +2137,15 @@ namespace moab {
{
idx = lConnMap3D[index].hf2v[lfid][j];
if (vert0 == sib_conn[idx])
- lv0 = idx;
- if (vert1 == sib_conn[idx])
- lv1 = idx;
- }
+ lv0 = idx;
+ if (vert1 == sib_conn[idx])
+ lv1 = idx;
+ }
- assert((lv0 >= 0) && (lv1 >= 0));
- cur_leid = lConnMap3D[index].lookup_leids[lv0][lv1];
+ assert((lv0 >= 0) && (lv1 >= 0));
+ cur_leid = lConnMap3D[index].lookup_leids[lv0][lv1];
- int chk_lfid = lConnMap3D[index].e2hf[cur_leid][0];
+ int chk_lfid = lConnMap3D[index].e2hf[cur_leid][0];
if (lfid == chk_lfid)
lface = 1;
@@ -2414,6 +2464,96 @@ namespace moab {
return MB_SUCCESS;
}
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ ErrorCode HalfFacetRep::get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents)
+ {
+ //Returns explicit edges, if any, of the face
+ ErrorCode error;
+ int index = get_index_from_type(cid);
+ int nvpc = lConnMap3D[index].num_verts_in_cell;
+ int nepc = lConnMap3D[index].num_edges_in_cell;
+
+ std::vector<EntityHandle> conn(nvpc);
+ error = mb->get_connectivity(&cid, 1, conn);
+ if (error != MB_SUCCESS) return error;
+
+ //Gather all the incident edges on each vertex of the face
+ std::vector< std::vector<EntityHandle> > temp(nvpc);
+ for (int i=0; i<nvpc; i++)
+ {
+ error = get_up_adjacencies_1d(conn[i], temp[i]);
+ if (error != MB_SUCCESS) return error;
+ std::sort(temp[i].begin(), temp[i].end());
+ }
+
+ //Loop over all the local edges and find the intersection.
+ for (int i = 0; i < nepc; ++i)
+ {
+ std::vector<EntityHandle> common(10);
+ std::vector<EntityHandle>::iterator it;
+
+ int lv0 = lConnMap3D[index].e2v[i][0];
+ int lv1 = lConnMap3D[index].e2v[i][1];
+
+ it = std::set_intersection(temp[lv0].begin(), temp[lv0].end(), temp[lv1].begin(), temp[lv1].end(), common.begin());
+ if (*common.begin() == 0)
+ continue;
+
+ adjents.push_back(*common.begin());
+ }
+ return MB_SUCCESS;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ ErrorCode HalfFacetRep::get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents)
+ {
+ //Returns explicit edges, if any, of the face
+ ErrorCode error;
+ int index = get_index_from_type(cid);
+ int nvpc = lConnMap3D[index].num_verts_in_cell;
+ int nfpc = lConnMap3D[index].num_faces_in_cell;
+
+ std::vector<EntityHandle> conn(nvpc);
+ error = mb->get_connectivity(&cid, 1, conn);
+ if (error != MB_SUCCESS) return error;
+
+ //Gather all the incident edges on each vertex of the face
+ std::vector< std::vector<EntityHandle> > temp(nvpc);
+ for (int i=0; i<nvpc; i++)
+ {
+ error = get_up_adjacencies_vert_2d(conn[i], temp[i]);
+ if (error != MB_SUCCESS) return error;
+ std::sort(temp[i].begin(), temp[i].end());
+ }
+
+ //Loop over all the local faces and find the intersection.
+ for (int i = 0; i < nfpc; ++i)
+ {
+ std::vector<EntityHandle> results(100);
+ std::vector<EntityHandle>::iterator it;
+
+ int nvF = lConnMap3D[index].hf2v_num[i];
+
+ int lv0 = lConnMap3D[index].hf2v[i][0];
+ int lv1 = lConnMap3D[index].hf2v[i][1];
+ std::set_intersection(temp[lv0].begin(), temp[lv0].end(), temp[lv1].begin(), temp[lv1].end(), std::back_inserter(results));
+
+ std::vector<EntityHandle> common(100);
+ for (int k = 2; k < nvF; k++){
+ common.clear();
+ int lv = lConnMap3D[index].hf2v[i][k];
+ std::set_intersection(temp[lv].begin(), temp[lv].end(), results.begin(), results.end(), std::back_inserter(common));
+ }
+
+ if (*common.begin() == 0)
+ continue;
+
+ adjents.push_back(*common.begin());
+ }
+ return MB_SUCCESS;
+ }
+
+
///////////////////////////////////////////////////////////////////////////////////////////
bool HalfFacetRep::find_match_in_array(EntityHandle ent, EntityHandle *ent_list, int count, bool get_index, int *index)
{
diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index a228520..c960330 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -41,22 +41,24 @@ namespace moab {
* \
*/
- //! ENUM for the type of input mesh.
- enum MESHTYPE{
- CURVE = 0, //Homogeneous curve mesh
- SURFACE, // Homogeneous surface mesh
- SURFACE_MIXED, // Mixed surface with embedded curves
- VOLUME, // Homogeneous volume mesh
- VOLUME_MIXED_1, // Volume mesh with embedded curves
- VOLUME_MIXED_2, // Volume mesh with embedded surface
- VOLUME_MIXED //Volume mesh with embedded curves and surfaces
- };
+const int MAXSIZE = 150;
- class Core;
+//! ENUM for the type of input mesh.
+enum MESHTYPE{
+ CURVE = 0, //Homogeneous curve mesh
+ SURFACE, // Homogeneous surface mesh
+ SURFACE_MIXED, // Mixed surface with embedded curves
+ VOLUME, // Homogeneous volume mesh
+ VOLUME_MIXED_1, // Volume mesh with embedded curves
+ VOLUME_MIXED_2, // Volume mesh with embedded surface
+ VOLUME_MIXED //Volume mesh with embedded curves and surfaces
+};
- class HalfFacetRep{
-
- public:
+class Core;
+
+class HalfFacetRep{
+
+public:
HalfFacetRep(Core *impl);
@@ -78,6 +80,7 @@ namespace moab {
ErrorCode print_tags();
+
ErrorCode get_adjacencies(const EntityHandle source_entity,
const unsigned int target_dimension,
std::vector<EntityHandle> &target_entities);
@@ -110,6 +113,9 @@ namespace moab {
ErrorCode get_neighbor_adjacencies(EntityHandle ent,
std::vector<EntityHandle> &adjents);
+ ErrorCode get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents);
+
+
// 1D Maps and queries
//! Given a range of edges, determines the map for sibling half-verts and stores them into SIBHVS_EID, SIBHVS_LVID tags.
@@ -224,6 +230,9 @@ namespace moab {
ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
std::vector<EntityHandle> &adjents);
+ ErrorCode get_down_adjacencies_2d(EntityHandle fid,
+ std::vector<EntityHandle> &adjents);
+
//! Given a range of faces, finds the total number of edges.
int find_total_edges_2d(Range &faces);
@@ -334,6 +343,11 @@ namespace moab {
ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
std::vector<EntityHandle> &adjents);
+
+
+ ErrorCode get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
+
+ ErrorCode get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
protected:
@@ -356,6 +370,13 @@ namespace moab {
Tag sibhvs_eid, sibhvs_lvid, v2hv_eid, v2hv_lvid;
Tag sibhes_fid, sibhes_leid, v2he_fid, v2he_leid;
Tag sibhfs_cid, sibhfs_lfid, v2hf_cid, v2hf_lfid;
+ Tag visited_face, visited_cell;
+
+ EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
+ int queue_lid[MAXSIZE];
+
+
+
MESHTYPE thismeshtype;
MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
@@ -426,11 +447,7 @@ namespace moab {
ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
int he_lid,
- EntityHandle *queue_fid,
- int *queue_lid,
- int *qsize,
- EntityHandle *trackfaces,
- int *tcount);
+ int *qsize);
//! Given an edge, finds a matching half-edge in the surface.
/** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
@@ -455,14 +472,10 @@ namespace moab {
* \param trackfaces, tcount
*/
- ErrorCode gather_halfedges( EntityHandle vid,
+ ErrorCode gather_halfedges(EntityHandle vid,
EntityHandle he_fid,
int he_lid,
- EntityHandle *queue_fid,
- int *queue_lid,
- int *qsize,
- EntityHandle *trackfaces,
- int *tcount);
+ int *qsize);
//! Obtains another half-edge belonging to the same face as the input half-edge
/** It uses the local maps to find another half-edge that is either incident or outgoing depending
@@ -490,11 +503,7 @@ namespace moab {
*/
bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
- EntityHandle *queue_fid,
- int *queue_lid,
int *qsize,
- EntityHandle *trackfaces,
- int *tcount,
EntityHandle *he_fid,
int *he_lid);
diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 556554c..1e1da98 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,7 +7,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
LDADD = $(top_builddir)/src/libMOAB.la
-check_PROGRAMS = perf seqperf adj_time perftool ahf_mem_time adj_without_ahf
+check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time ahf_mem_time
noinst_PROGRAMS =
perf_SOURCES = perf.cpp
@@ -15,7 +15,7 @@ seqperf_SOURCES = seqperf.cpp
adj_time_SOURCES = adj_time.cpp
perftool_SOURCES = perftool.cpp
ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
-adj_without_ahf_SOURCES = adj_without_ahf_mem_time.cpp
+adj_mem_time_SOURCES = adj_mem_time.cpp
if ENABLE_imesh
LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
@@ -25,9 +25,3 @@ if ENABLE_imesh
tstt_perf_binding_SOURCES = tstt_perf_binding.cpp
endif
-if ENABLE_ahf
- check_PROGRAMS += adj_with_ahf
- adj_with_ahf_SOURCES = adj_with_ahf_mem_time.cpp
-endif
-
-
diff --git a/test/perf/adj_mem_time.cpp b/test/perf/adj_mem_time.cpp
new file mode 100755
index 0000000..56b8fb7
--- /dev/null
+++ b/test/perf/adj_mem_time.cpp
@@ -0,0 +1,337 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ std::cout<<std::endl;
+ std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_avg;
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range ngbents;
+
+ // This call should create all the necessary ahf maps or adjacency lists
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ1: For every edge, obtain neighbor edges
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+#endif
+
+ // 2D Queries
+ std::cout<<"2D QUERIES"<<std::endl;
+ //IQ21: For every vertex, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //IQ22: For every edge, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ2: For every face, obtain neighbor faces
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ2: For every face, obtain its edges
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Face -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ // 3D Queries
+ std::cout<<"3D QUERIES"<<std::endl;
+ //IQ31: For every vertex, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ // IQ 32: For every edge, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ //IQ32: For every face, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ3: For every cell, obtain neighbor cells
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ31: For every cell, obtain its edges
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ32: For every cell, obtain its faces
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ //Storage Costs after calling ahf deinitialize
+ std::cout<<std::endl;
+ std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<std::endl;
+#ifdef USE_AHF
+ std::cout<<"AHF adjacency tag storage = "<<eTS-sTS<<std::endl;
+ std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+#else
+ std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+#endif
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/perf/adj_with_ahf_mem_time.cpp b/test/perf/adj_with_ahf_mem_time.cpp
deleted file mode 100755
index dbf4558..0000000
--- a/test/perf/adj_with_ahf_mem_time.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*This function tests the AHF datastructures on CST meshes*/
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <vector>
-#include "moab/Core.hpp"
-#include "moab/Range.hpp"
-#include "moab/MeshTopoUtil.hpp"
-#include "moab/HalfFacetRep.hpp"
-#include <sys/time.h>
-
-using namespace moab;
-
-#ifdef MESHDIR
-std::string TestDir(STRINGIFY(MESHDIR));
-#else
-std::string TestDir(".");
-#endif
-
-std::string filename;
-
-double wtime() {
- double y = -1;
- struct timeval cur_time;
- gettimeofday(&cur_time, NULL);
- y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
- return (y);
-}
-
-int main(int argc, char **argv)
-{
- // Read the input mesh
- filename = TestDir + "/hexes_mixed.vtk";
-
- if (argc==1)
- std::cout<<"Using default input file:"<<filename<<std::endl;
- else if (argc==2)
- filename = argv[1];
- else {
- std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
- return 1;
- }
-
- ErrorCode error;
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- error = mbImpl->load_file( filename.c_str());
- if (MB_SUCCESS != error) {
- std::cerr << filename <<": failed to load file." << std::endl;
- return error;
- }
-
- //Create ranges for handles of explicit elements of the mixed mesh
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- int nverts = verts.size();
- int nedges = edges.size();
- int nfaces = faces.size();
- int ncells = cells.size();
-
- std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
-
-
- //Storage Costs before calling ahf functionalities
- std::cout<<std::endl;
- std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
- unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
- sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<sTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
- std::cout<<"Entity storage = "<<sES<<std::endl;
- std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
- std::cout<<"Adjacency storage = "<<sAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
- std::cout<<std::endl;
-
-
- double time_start, time_avg;
-
- //Perform queries
- std::vector<EntityHandle> adjents;
-
- // This call should create all the necessary ahf maps
- error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- std::cout<<"1D QUERIES"<<std::endl;
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
- std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
-
- //NQ1: For every edge, obtain neighbor edges
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
-
- // 2D Queries
- std::cout<<"2D QUERIES"<<std::endl;
- //IQ21: For every vertex, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
-
-
- //IQ22: For every edge, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
-
-
- //NQ2: For every face, obtain neighbor faces
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
-
-
- // 3D Queries
- std::cout<<"3D QUERIES"<<std::endl;
- //IQ31: For every vertex, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
-
- // IQ 32: For every edge, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
-
- //IQ32: For every face, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
-
- //NQ3: For every cell, obtain neighbor cells
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
-
-
- //Storage Costs after calling ahf deinitialize
- std::cout<<std::endl;
- std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
- unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
- eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<eTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
- std::cout<<"Entity storage = "<<eES<<std::endl;
- std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
- std::cout<<"Adjacency storage = "<<eAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
- std::cout<<"Tag storage = "<<eTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
- std::cout<<std::endl;
-
- return 0;
-}
-
diff --git a/test/perf/adj_without_ahf_mem_time.cpp b/test/perf/adj_without_ahf_mem_time.cpp
deleted file mode 100755
index cd4d58c..0000000
--- a/test/perf/adj_without_ahf_mem_time.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/*This function tests the AHF datastructures on CST meshes*/
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <vector>
-#include "moab/Core.hpp"
-#include "moab/Range.hpp"
-#include "moab/MeshTopoUtil.hpp"
-#include "moab/HalfFacetRep.hpp"
-#include <sys/time.h>
-
-using namespace moab;
-
-#ifdef MESHDIR
-std::string TestDir(STRINGIFY(MESHDIR));
-#else
-std::string TestDir(".");
-#endif
-
-std::string filename;
-
-double wtime() {
- double y = -1;
- struct timeval cur_time;
- gettimeofday(&cur_time, NULL);
- y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
- return (y);
-}
-
-int main(int argc, char **argv)
-{
- // Read the input mesh
- filename = TestDir + "/hexes_mixed.vtk";
-
- if (argc==1)
- std::cout<<"Using default input file:"<<filename<<std::endl;
- else if (argc==2)
- filename = argv[1];
- else {
- std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
- return 1;
- }
-
- ErrorCode error;
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- error = mbImpl->load_file( filename.c_str());
- if (MB_SUCCESS != error) {
- std::cerr << filename <<": failed to load file." << std::endl;
- return error;
- }
-
- //Create ranges for handles of explicit elements of the mixed mesh
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- int nverts = verts.size();
- int nedges = edges.size();
- int nfaces = faces.size();
- int ncells = cells.size();
-
- std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
-
-
- //Storage Costs before calling ahf functionalities
- std::cout<<std::endl;
- std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
- unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
- sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<sTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
- std::cout<<"Entity storage = "<<sES<<std::endl;
- std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
- std::cout<<"Adjacency storage = "<<sAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
- std::cout<<std::endl;
-
-
- double time_start, time_avg;
-
- //Perform queries
- std::vector<EntityHandle> mbents;
- Range ngbents;
-
- // This call should create all the necessary moab adjacency lists
- error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- std::cout<<"1D QUERIES"<<std::endl;
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
- std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ1: For every edge, obtain neighbor edges
- error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
- std::cout<<std::endl;
-
-
- // 2D Queries
- std::cout<<"2D QUERIES"<<std::endl;
- //IQ21: For every vertex, obtain incident faces
- error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //IQ22: For every edge, obtain incident faces
- error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ2: For every face, obtain neighbor faces
- error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
-
- // 3D Queries
- std::cout<<"3D QUERIES"<<std::endl;
- //IQ31: For every vertex, obtain incident cells
- error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
-
- // IQ 32: For every edge, obtain incident cells
- error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- //IQ32: For every face, obtain incident cells
- error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- //NQ3: For every cell, obtain neighbor cells
- error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
- std::cout<<std::endl;
-
- //Storage Costs after calling ahf deinitialize
- std::cout<<std::endl;
- std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
- unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
- eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<eTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
- std::cout<<"Entity storage = "<<eES<<std::endl;
- std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
- std::cout<<"Adjacency storage = "<<eAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
- std::cout<<"Tag storage = "<<eTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
- std::cout<<std::endl;
-
- return 0;
-}
-
diff --git a/test/perf/ahf_intfc_mem_time.cpp b/test/perf/ahf_intfc_mem_time.cpp
deleted file mode 100755
index 6d8ef14..0000000
--- a/test/perf/ahf_intfc_mem_time.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*This function tests the AHF datastructures on CST meshes*/
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <vector>
-#include "moab/Core.hpp"
-#include "moab/Range.hpp"
-#include "moab/MeshTopoUtil.hpp"
-#include "moab/HalfFacetRep.hpp"
-#include <sys/time.h>
-
-using namespace moab;
-
-#ifdef MESHDIR
-std::string TestDir(STRINGIFY(MESHDIR));
-#else
-std::string TestDir(".");
-#endif
-
-std::string filename;
-
-double wtime() {
- double y = -1;
- struct timeval cur_time;
- gettimeofday(&cur_time, NULL);
- y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
- return (y);
-}
-
-int main(int argc, char **argv)
-{
- // Read the input mesh
- filename = TestDir + "/hexes_mixed.vtk";
-
- if (argc==1)
- std::cout<<"Using default input file:"<<filename<<std::endl;
- else if (argc==2)
- filename = argv[1];
- else {
- std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
- return 1;
- }
-
- ErrorCode error;
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- error = mbImpl->load_file( filename.c_str());
- if (MB_SUCCESS != error) {
- std::cerr << filename <<": failed to load file." << std::endl;
- return error;
- }
-
- //Create ranges for handles of explicit elements of the mixed mesh
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- int nverts = verts.size();
- int nedges = edges.size();
- int nfaces = faces.size();
- int ncells = cells.size();
-
- std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
-
-
- //Storage Costs before calling ahf functionalities
- unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
- sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<sTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
- std::cout<<"Entity storage = "<<sES<<std::endl;
- std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
- std::cout<<"Adjacency storage = "<<sAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
- std::cout<<std::endl;
-
-
- double time_start, time_avg;
-
- //Storage Costs after calling ahf initialize
- unsigned long TotS, TAS, ES, AES, AS, AAS, TS, ATS;
- TotS = TAS = ES = AES = AS = AAS = TS = ATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &TotS, &TAS, &ES, &AES, &AS, &AAS, NULL, 0, &TS, &ATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<TotS<<std::endl;
- std::cout<<"Total amortized storage = "<<TAS<<std::endl;
- std::cout<<"Entity storage = "<<ES<<std::endl;
- std::cout<<"Amortized entity storage = "<<AES<<std::endl;
- std::cout<<"Adjacency storage = "<<AS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<AAS<<std::endl;
- std::cout<<"Tag storage = "<<TS<<std::endl;
- std::cout<<"Amortized tag storage = "<<ATS<<std::endl;
- std::cout<<std::endl;
-
- //Perform queries
- std::vector<EntityHandle> adjents;
- Range mbents;
-
- // This call should create all the necessary ahf maps
- error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
-
- // This call should create all the necessary moab adjacency lists
- error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, mbents );
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- std::cout<<"1D QUERIES"<<std::endl;
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
- std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
-
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
- std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ1: For every edge, obtain neighbor edges
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
-
- error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
- std::cout<<std::endl;
-
-
- // 2D Queries
- std::cout<<"2D QUERIES"<<std::endl;
- //IQ21: For every vertex, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
-
- error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //IQ22: For every edge, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
-
- error = mbImpl->get_adjacencies( &*edges.begin(), 1, 2, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ2: For every face, obtain neighbor faces
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
-
- error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, mbents);
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
-
- // 3D Queries
- std::cout<<"3D QUERIES"<<std::endl;
- //IQ31: For every vertex, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
- error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
-
- // IQ 32: For every edge, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
- error = mbImpl->get_adjacencies(&*edges.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- //IQ32: For every face, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
-
- error = mbImpl->get_adjacencies(&*faces.begin(), 1, 3, false, mbents);
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- mbents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- //NQ3: For every cell, obtain neighbor cells
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
-
- error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, mbents);
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- mbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
- std::cout<<std::endl;
-
- //Storage Costs after calling ahf deinitialize
- unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
- eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<eTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
- std::cout<<"Entity storage = "<<eES<<std::endl;
- std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
- std::cout<<"Adjacency storage = "<<eAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
- std::cout<<"Tag storage = "<<eTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
- std::cout<<std::endl;
-
- return 0;
-}
-
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/fathomteam/moab/commits/77765758fc68/
Changeset: 77765758fc68
Branch: nray/feature_ahf
User: nray
Date: 2014-07-13 04:18:47
Summary: Removed redundant test codes. Added assertion checks to interface
functions.
Affected #: 10 files
diff --git a/src/HalfFacetRep.cpp b/src/HalfFacetRep.cpp
index 4e363e3..209cc9e 100755
--- a/src/HalfFacetRep.cpp
+++ b/src/HalfFacetRep.cpp
@@ -561,6 +561,7 @@ namespace moab {
ErrorCode error;
unsigned int source_dimension = mb->dimension_from_handle(source_entity);
+ assert((source_dimension <= target_dimension) || (source_dimension > target_dimension));
if (mInitAHFmaps == false)
{
@@ -584,7 +585,7 @@ namespace moab {
if (MB_SUCCESS != error) return error;
}
else
- {
+ {
error = get_down_adjacencies(source_entity, target_dimension, target_entities);
if (MB_SUCCESS != error) return error;
}
@@ -604,6 +605,7 @@ namespace moab {
{
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
+ assert((in_dim >=0 && in_dim <= 2) && (out_dim > in_dim));
if (in_dim == 0)
{
@@ -647,6 +649,7 @@ namespace moab {
{
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
+ assert(in_dim >=1 && in_dim <= 3);
if (in_dim == 1)
{
@@ -671,6 +674,8 @@ namespace moab {
{
ErrorCode error;
int in_dim = mb->dimension_from_handle(ent);
+ assert((in_dim >=2 && in_dim <= 3) && (out_dim < in_dim));
+
if ((in_dim == 2)&&(out_dim == 1))
{
error = get_down_adjacencies_2d(ent, adjents);
diff --git a/src/moab/HalfFacetRep.hpp b/src/moab/HalfFacetRep.hpp
index c960330..8a8d80a 100755
--- a/src/moab/HalfFacetRep.hpp
+++ b/src/moab/HalfFacetRep.hpp
@@ -31,13 +31,18 @@ namespace moab {
* \ 2. V2HF: Maps each vertex to an incident half-facet
* \ Using these two maps, a range of adjacency queries is performed. The maps are stored in dense tags over entities and vertices.
* \
- * \ Current support for adjacency functions:
+ * \ Adjacency functions:
* \ 1. upward-incidence queries: vertex -> edge, edge -> faces, edge -> cells, face ->cells
* \ 2. neighborhood (same-dimensional) adjacency queries: edge -> edges, face -> faces, cell -> cells, etc.
- * \
+ * \ 3. downward adjacency queries: face -> edges, cell -> edges, etc.
+ * \
* \ Mesh types supported:
* \ 1D(edges), 2D(triangles, quads), 3D(tet, pyramid, prism, hex), Mixed dimensional meshes
- * \ NOT SUPPORTED: Meshes with mixed entity types of same dimension. Ex. a volume mesh with both tets and prisms.
+ * \
+ * \ CURRENTLY NOT SUPPORTED:
+ * \ 1. Meshes with mixed entity types of same dimension. Ex. a volume mesh with both tets and prisms.
+ * \ 2. create_if_missing = true
+ * \ 3. Modified meshes
* \
*/
@@ -79,7 +84,13 @@ public:
//! Prints the tag values.
ErrorCode print_tags();
-
+ //! Get the adjacencies associated with an entity.
+ /** Given an entity of dimension <em>d</em>, gather all the adjacent <em>D</em> dimensional entities where <em>D >, = , < d </em>.
+ *
+ * \param source_entity EntityHandle to which adjacent entities have to be found.
+ * \param target_dimension Int Dimension of the desired adjacent entities.
+ * \param target_entities Vector in which the adjacent EntityHandle are returned.
+ */
ErrorCode get_adjacencies(const EntityHandle source_entity,
const unsigned int target_dimension,
@@ -88,7 +99,7 @@ public:
//! Get the upward incidences associated with an entity.
/** Given an entity of dimension <em>d</em>, gather all the incident <em>D(>d)</em> dimensional entities.
- * Parameters:
+ * :
* \param ent EntityHandle to which incident entities have to be found.
* \param out_dim Dimension of the desired incidence information.
* \param adjents Vector in which the incident entities are returned.
@@ -105,7 +116,7 @@ public:
//! Get the same-dimensional entities connected with an entity.
/** Given an entity of dimension <em>d</em>, gather all the entities connected via <em>d-1</em> dimensional entities.
* Same as bridge_adjacencies in MOAB.
- * Parameters:
+ *
* \param ent EntityHandle to which neighbor entities have to be found.
* \param adjents Vector in which the neighbor entities are returned.
*/
@@ -113,6 +124,14 @@ public:
ErrorCode get_neighbor_adjacencies(EntityHandle ent,
std::vector<EntityHandle> &adjents);
+ //! Get the downward adjacent entities connected with an entity.
+ /** Given an entity of dimension <em>d</em>, gather all the <em>d-1</em> dimensional entities.
+ *
+ * \param ent EntityHandle to which neighbor entities have to be found.
+ * \param out_dim Dimension of the desired downward adjacency.
+ * \param adjents Vector in which the neighbor entities are returned.
+ */
+
ErrorCode get_down_adjacencies(EntityHandle ent, int out_dim, std::vector<EntityHandle> &adjents);
@@ -122,7 +141,7 @@ public:
/** Compute all sibling half-vertices for all half-vertices in the given curve. The sibling half-verts is
* defined in terms of the containing edge and the local id of the vertex w.r.t that edge.
* That is, the map consists of two pieces of information: <EntityHandle eid, int lvid>
- * Parameters:
+ *
* \param edges Range of edges.
*/
@@ -131,7 +150,7 @@ public:
//! Given a range of edges, determines the map for incident half-verts and stores them into V2HV_EID, V2HV_LVID tags.
/** Compute a map between a vertex and an incident half-vertex. This map is not always required, but is
* essential for local neighborhood searching as it acts like an anchor to start the search.
- * Parameters:
+ *
* \param edges Range of edges
*/
@@ -140,7 +159,7 @@ public:
//! Given a vertex, finds the edges incident on it.
/** Given a vertex handle, it starts by first finding an incident half-vert by using the incident
* half-vert map, and then obtaining all the sibling half-verts of the corresponding half-vertex.
- * Parameters:
+ *
* \param vid EntityHandle of the query vertex
* \param adjents Vector returning the incident edges
* \param local_id False by default. If true, returns the local vertex id's corresponding to vid
@@ -154,7 +173,7 @@ public:
//! Given an edge, finds vertex-connected neighbor edges
/** Given an edge, it gathers all the incident edges of each vertex of the edge.
- * Parameters:
+ *
* \param eid EntityHandle of the query edge
* \param adjents Vector returning neighbor edges
*/
@@ -169,7 +188,7 @@ public:
/** Compute all sibling half-edges for all half-edges in the given surface.
* The sibling half-edges is defined in terms of the containing face and the local id of the edge w.r.t that entity.
* That is, the map consists of two pieces of information: <EntityHandle fid, int leid>
- * Parameters:
+ *
* \param faces Range of faces
*/
@@ -179,18 +198,26 @@ public:
/** Compute a map between a vertex and an incident half-edge.
* This map is not always required, but is essential for local neighborhood searching as it acts
* like an anchor to start the search.
- * Parameters:
+ *
* \param faces Range of faces
*/
ErrorCode determine_incident_halfedges(Range &faces);
+ //! Given a vertex, finds the faces incident on it.
+ /** Given a vertex, it first finds an incident half-edge via v2he map, and then
+ * collects all the incident half-edges/faces via the sibhes map.
+ *
+ * \param vid EntityHandle of the query vertex
+ * \param adjents Vector returning the incident faces
+ */
+
ErrorCode get_up_adjacencies_vert_2d(EntityHandle vid, std::vector<EntityHandle> &adjents);
//! Given an edge, finds the faces incident on it.
/** Given an edge, it first finds a matching half-edge corresponding to eid, and then
* collects all the incident half-edges/faces via the sibhes map.
- * Parameters:
+ *
* \param eid EntityHandle of the query edge
* \param adjents Vector returning the incident faces
* \param local_id By default false. If true, returns the local edge id's corresponding to the input edge
@@ -204,7 +231,7 @@ public:
//! Given a half-edge <fid, leid>, finds the faces incident on it.
/**
- * Parameters:
+ *
* \param fid EntityHandle of the containing face
* \param leid local id of the edge w.r.t to the face
* \param add_inent If true, adds the input fid into the returning vector of adjents.
@@ -222,7 +249,7 @@ public:
//! Given an edge, finds edge-connected neighbor face
/** Given an face, it gathers all the neighbor faces of each local edge of the face.
- * Parameters:
+ *
* \param fid EntityHandle of the query face
* \param adjents Vector returning neighbor faces
*/
@@ -230,6 +257,14 @@ public:
ErrorCode get_neighbor_adjacencies_2d(EntityHandle fid,
std::vector<EntityHandle> &adjents);
+ //! Given a face, finds its edges.
+ /** Given a face, it first finds incident edges on each vertex of the face, and then
+ * it performs a set intersection to gather all the edges of the given face.
+ *
+ * \param fid EntityHandle of the query face
+ * \param adjents Vector returning its edges
+ */
+
ErrorCode get_down_adjacencies_2d(EntityHandle fid,
std::vector<EntityHandle> &adjents);
@@ -243,7 +278,7 @@ public:
/** Compute all sibling half-faces for all half-faces in the given volume.
* The sibling half-faces is defined in terms of the containing cell and the local id of the face w.r.t that cell.
* That is, the map consists of two pieces of information: <EntityHandle cid, int lfid>
- * Parameters:
+ *
* \param faces Range of cells
*/
@@ -253,7 +288,7 @@ public:
/** Compute a map between a vertex and an incident half-face.
* This map is not always required, but is essential for local neighborhood searching as it acts
* like an anchor to start the search.
- * Parameters:
+ *
* \param faces Range of cells
*/
@@ -262,7 +297,7 @@ public:
//! Given a range of cells, tags all border vertices with a true value.
/** Tag border vertices by using the sibhf_cid map. All vertices on half-faces with no sibling
* half-faces are considered as border vertices.
- * Parameters:
+ *
* \param cells Range of cells
* \param isborder: A dense tag over all vertices of size 1. Value is true for a border vertex, otherwise is false.
*/
@@ -270,13 +305,20 @@ public:
ErrorCode determine_border_vertices( Range &cells,
Tag isborder);
+ //! Given a vertex, finds the cells incident on it.
+ /** Given a vertex, it first finds an incident half-face via v2hf map, and then
+ * collects all the incident half-faces via the sibhfs map.
+ *
+ * \param vid EntityHandle of the query vertex
+ * \param adjents Vector returning the incident cells
+ */
ErrorCode get_up_adjacencies_vert_3d(EntityHandle vid, std::vector<EntityHandle> &adjents);
//! Given an edge, finds the cells incident on it.
/** Given an edge, it first finds a matching local edge in a cell corresponding to eid, and then
* collects all the incident cells via the sibhfs map.
- * Parameters:
+ *
* \param eid EntityHandle of the query edge
* \param adjents Vector returning the incident cells
* \param local_id By default false. If true, returns the local edge id's corresponding to the input edge
@@ -290,7 +332,7 @@ public:
//! Given a local edge <cid, leid>, finds the cells incident on it.
/** Given a local edge, it gathers all the incident cells via the sibhfs map.
- * Parameters:
+ *
* \param cid EntityHandle of the cell containing the local edge
* \param leid local edge id w.r.t the cell
* \param adjents Vector returning the incident cells
@@ -306,7 +348,7 @@ public:
//! Given an face, finds the cells incident on it.
/** Given an face, it first finds a matching half-face in a cell corresponding to face, and then
* collects all the incident cells via the sibhfs map.
- * Parameters:
+ *
* \param fid EntityHandle of the query face
* \param adjents Vector returning the incident cells
* \param local_id By default false. If true, returns the local face id's corresponding to the input face
@@ -320,7 +362,7 @@ public:
//! Given a local face <cid, lfid>, finds the cells incident on it.
/** Given a local face, it gathers all the incident cells via the sibhfs map.
- * Parameters:
+ *
* \param cid EntityHandle of the cell containing the local edge
* \param lfid local face id w.r.t the cell
* \param adjents Vector returning the incident cells
@@ -336,7 +378,7 @@ public:
//! Given a cell, finds face-connected neighbor cells
/** Given a cell, it gathers all the neighbor cells of each local face of the cell.
- * Parameters:
+ *
* \param cid EntityHandle of the query cell
* \param adjents Vector returning neighbor cells
*/
@@ -344,9 +386,24 @@ public:
ErrorCode get_neighbor_adjacencies_3d(EntityHandle cid,
std::vector<EntityHandle> &adjents);
+ //! Given a cell, finds its edges.
+ /** Given a cell, it first finds incident edges on each vertex of the cell, and then
+ * it performs a set intersection to gather all the edges of the given cell.
+ *
+ * \param cid EntityHandle of the query cell
+ * \param adjents Vector returning its edges
+ */
ErrorCode get_down_adjacencies_edg_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
+ //! Given a cell, finds its faces.
+ /** Given a cell, it first finds incident faces on each vertex of the cell, and then
+ * performs a set intersection to gather all the faces of the given cell.
+ *
+ * \param cid EntityHandle of the query cell
+ * \param adjents Vector returning its faces
+ */
+
ErrorCode get_down_adjacencies_face_3d(EntityHandle cid, std::vector<EntityHandle> &adjents);
@@ -375,9 +432,6 @@ public:
EntityHandle queue_fid[MAXSIZE], trackfaces[MAXSIZE];
int queue_lid[MAXSIZE];
-
-
-
MESHTYPE thismeshtype;
MESHTYPE get_mesh_type(int nverts, int nedges, int nfaces, int ncells);
@@ -403,7 +457,7 @@ public:
//! Contains the local information for 2D entities
/** Given a face, find the face type specific information
- * Parameters:
+ *
* \param face EntityHandle. Used to gather info about the type of face for which local info is required
* \param nepf: Returns the number of vertices/edges for given face type.
*/
@@ -412,7 +466,7 @@ public:
//! Contains the local information for 2D entities
/** Given number of edges, returns local indices of next and previous local edges.
- * Parameters:
+ *
* \param nepf: The number of vertices/edges for given face type.
* \param next, prev: Local ids of next and previous edges w.r.t to the face
*
@@ -434,15 +488,9 @@ public:
/** Given an half-edge, obtain all the incident half-edges via the sibhes map and add them to a given
* queue of half-edges, if they do not already exist in the queue. This function is used to increment the
* search space for finding a matching half-edge.
- * Parameters:
+ *
* \param he_fid EntityHandle of query half-edge
* \param he_lid Local id of query half-edge
- * \param queue_fid
- * \param queue_lid
- * \param qsize Array of faces and local edge ids. qsize is the current size of the queue_fid.
- * \param trackfaces Array containing faces. If fid of an incident half-edge doesn't belong to trackfaces,
- * the half-edge is added to the queue.
- * \param tcount Current size of trackfaces
*/
ErrorCode get_up_adjacencies_2d(EntityHandle he_fid,
@@ -453,7 +501,7 @@ public:
/** Given an edge eid, it first collects few half-edges belonging to one-ring neighborhood of
* the starting vertex of the given edge, and then simultaneously searches and adds to the local list
* of half-edges for searching, till it finds a matching half-edge.
- * Parameters:
+ *
* \param eid EntityHandle of the query edge
* \param hefid, helid: Returns the matching half-edge corresponding to the query edge.
*/
@@ -464,12 +512,6 @@ public:
//! Gather half-edges to a queue of half-edges.
/** Given a vertex vid, and a half-edge <he_fid,he_lid>, add another half-edge in the same face sharing the vertex
- * and add all incident half-edges to the queue via sibhes map.
- * Parameters:
- * \param vid EntityHandle of a vertex in a half-edge
- * \param <EntityHandle he_fid, int he_lid>: Half-edge
- * \param queue_fid, queue_lid, count
- * \param trackfaces, tcount
*/
ErrorCode gather_halfedges(EntityHandle vid,
@@ -480,11 +522,7 @@ public:
//! Obtains another half-edge belonging to the same face as the input half-edge
/** It uses the local maps to find another half-edge that is either incident or outgoing depending
* on vid and input half-edge
- * Parameters:
- * \param vid EntityHandle of a vertex in a half-edge
- * \param <EntityHandle he_fid, int he_lid>: Half-edge
- * \param <EntityHandle he2_fid, int he2_lid>: Returns another half-edge in the same he_fid sharing vid.
- */
+ */
ErrorCode another_halfedge( EntityHandle vid,
EntityHandle he_fid,
@@ -495,11 +533,6 @@ public:
//! Collect and compare to find a matching half-edge with the given edge connectivity.
/** Given edge connectivity, compare to an input list of half-edges to find a matching half-edge
* and add a list of half-edges belonging to the one-ring neighborhood to a queue till it finds a match.
- * Parameters:
- * \param edg_vert End vertices of an edge
- * \param queue_fid, queue_lid, count
- * \param trackfaces, tcount
- * \param <EntityHandle he_fid, int he_lid>: Returns matching half-edge
*/
bool collect_and_compare(std::vector<EntityHandle> &edg_vert,
@@ -564,7 +597,7 @@ public:
//! Given an edge, finds a matching local edge in an incident cell.
/** Find a local edge with the same connectivity as the input edge, belonging to an incident cell.
- * Parameters:
+ *
* \param eid EntityHandle of the edge
* \param cid Returns EntityHandle of the incident cell
* \param leid Returns the local id of the edge corresponding to the input edge w.r.t the incident cell.
@@ -576,7 +609,7 @@ public:
//! Given a face, finds a matching local face in an incident cell.
/** Find a local face with the same connectivity as the input face, belonging to an incident cell.
- * Parameters:
+ *
* \param fid EntityHandle of the face
* \param cid Returns EntityHandle of the incident cell
* \param lfid Returns the local id of the face corresponding to the input face w.r.t the incident cell.
diff --git a/test/Makefile.am b/test/Makefile.am
index 33ca518..d615905 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -49,7 +49,7 @@ TESTS = range_test \
elem_eval_test \
spatial_locator_test \
test_boundbox \
- ahf_test
+ adj_moab_test
if HDF5_FILE
@@ -61,9 +61,6 @@ if HDF5_FILE
lloyd_smoother_test
endif
-if ENABLE_ahf
- TESTS += ahf_mbintf_test
-endif
# merge_test \ # input files no longer exist?
# test_tag_server \ # fails
@@ -156,11 +153,7 @@ coords_connect_iterate_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS)
test_boundbox_SOURCES = test_boundbox.cpp
lloyd_smoother_test_SOURCES = lloyd_smoother_test.cpp
-ahf_test_SOURCES = test_ahf_moab.cpp
-
-if ENABLE_ahf
- ahf_mbintf_test_SOURCES = test_ahf_mb_interface.cpp
-endif
+adj_moab_test_SOURCES = adj_moab_test.cpp
if PARALLEL
diff --git a/test/adj_moab_test.cpp b/test/adj_moab_test.cpp
new file mode 100755
index 0000000..1a6fe5c
--- /dev/null
+++ b/test/adj_moab_test.cpp
@@ -0,0 +1,304 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include "TestUtil.hpp"
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+int number_tests_successful = 0;
+int number_tests_failed = 0;
+
+void handle_error_code(ErrorCode rv, int &number_failed, int &number_successful)
+{
+ if (rv == MB_SUCCESS) {
+ std::cout << "Success";
+ number_successful++;
+ } else {
+ std::cout << "Failure";
+ number_failed++;
+ }
+}
+
+
+ErrorCode ahf_test(Core *moab)
+{
+
+ Interface* mbImpl = &*moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ ErrorCode error = mbImpl->load_file(filename.c_str());
+ CHECK_ERR(error);
+
+ /*Create ranges for handles of explicit elements of the mixed mesh*/
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ // Create an ahf instance
+ HalfFacetRep ahf(&*moab);
+
+ // Call the initialize function which creates the maps for each dimension
+ ahf.initialize();
+
+ //ahf.print_tags();
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range mbents, ahfents;
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 1, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents );
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(),mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ1: For every edge, obtain neighbor edges
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 2D Queries
+
+ // IQ21: For every vertex, obtain incident faces
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ22: For every edge, obtain incident faces
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 2, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ2: For every face, obtain neighbor faces
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //DQ 21: For every face, obtain its edges
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_down_adjacencies( *i, 1, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // 3D Queries
+ //IQ 31: For every vertex, obtain incident cells
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ // IQ 32: For every edge, obtain incident cells
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //IQ33: For every face, obtain incident cells
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_up_adjacencies( *i, 3, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //NQ3: For every cell, obtain neighbor cells
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_neighbor_adjacencies( *i, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+
+ //DQ 31: For every cell, obtain its edges
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_down_adjacencies( *i, 1, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+ //DQ 32: For every cell, obtain its faces
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = ahf.get_down_adjacencies( *i, 2, adjents);
+ CHECK_ERR(error);
+ mbents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, mbents);
+ CHECK_ERR(error);
+
+ CHECK_EQUAL(adjents.size(), mbents.size());
+
+ std::sort(adjents.begin(), adjents.end());
+ std::copy(adjents.begin(), adjents.end(), range_inserter(ahfents));
+ mbents = subtract(mbents, ahfents);
+ CHECK(!mbents.size());
+ }
+
+
+
+ ahf.deinitialize();
+
+ return MB_SUCCESS;
+
+}
+
+int main(int argc, char *argv[])
+{
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ Core moab;
+ ErrorCode result;
+
+ std::cout<<" ahf_test: ";
+ result = ahf_test(&moab);
+ handle_error_code(result, number_tests_failed, number_tests_successful);
+ std::cout<<"\n";
+
+ return number_tests_failed;
+}
+
diff --git a/test/perf/Makefile.am b/test/perf/Makefile.am
index 1e1da98..b8c5d19 100644
--- a/test/perf/Makefile.am
+++ b/test/perf/Makefile.am
@@ -7,15 +7,14 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
LDADD = $(top_builddir)/src/libMOAB.la
-check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time ahf_mem_time
+check_PROGRAMS = perf seqperf adj_time perftool adj_mem_time
noinst_PROGRAMS =
perf_SOURCES = perf.cpp
seqperf_SOURCES = seqperf.cpp
adj_time_SOURCES = adj_time.cpp
perftool_SOURCES = perftool.cpp
-ahf_mem_time_SOURCES = test_ahf_mem_time.cpp
-adj_mem_time_SOURCES = adj_mem_time.cpp
+adj_mem_time_SOURCES = adj_mem_time_test.cpp
if ENABLE_imesh
LDADD += $(top_builddir)/itaps/imesh/libiMesh.la
diff --git a/test/perf/adj_mem_time.cpp b/test/perf/adj_mem_time.cpp
deleted file mode 100755
index 56b8fb7..0000000
--- a/test/perf/adj_mem_time.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*This function tests the AHF datastructures on CST meshes*/
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <vector>
-#include "moab/Core.hpp"
-#include "moab/Range.hpp"
-#include "moab/MeshTopoUtil.hpp"
-#include "moab/HalfFacetRep.hpp"
-#include <sys/time.h>
-
-using namespace moab;
-
-#ifdef MESHDIR
-std::string TestDir(STRINGIFY(MESHDIR));
-#else
-std::string TestDir(".");
-#endif
-
-std::string filename;
-
-double wtime() {
- double y = -1;
- struct timeval cur_time;
- gettimeofday(&cur_time, NULL);
- y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
- return (y);
-}
-
-int main(int argc, char **argv)
-{
- // Read the input mesh
- filename = TestDir + "/hexes_mixed.vtk";
-
- if (argc==1)
- std::cout<<"Using default input file:"<<filename<<std::endl;
- else if (argc==2)
- filename = argv[1];
- else {
- std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
- return 1;
- }
-
- ErrorCode error;
- Core moab;
- Interface* mbImpl = &moab;
- MeshTopoUtil mtu(mbImpl);
-
- error = mbImpl->load_file( filename.c_str());
- if (MB_SUCCESS != error) {
- std::cerr << filename <<": failed to load file." << std::endl;
- return error;
- }
-
- //Create ranges for handles of explicit elements of the mixed mesh
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- int nverts = verts.size();
- int nedges = edges.size();
- int nfaces = faces.size();
- int ncells = cells.size();
-
- std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
-
-
- //Storage Costs before calling ahf functionalities
- std::cout<<std::endl;
- std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
- unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
- sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<sTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
- std::cout<<"Entity storage = "<<sES<<std::endl;
- std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
- std::cout<<"Adjacency storage = "<<sAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
- std::cout<<std::endl;
-
-
- double time_start, time_avg;
-
- //Perform queries
- std::vector<EntityHandle> adjents;
- Range ngbents;
-
- // This call should create all the necessary ahf maps or adjacency lists
- error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- std::cout<<"1D QUERIES"<<std::endl;
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
- //NQ1: For every edge, obtain neighbor edges
-#ifdef USE_AHF
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
- std::cout<<std::endl;
-#else
- error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
- std::cout<<std::endl;
-#endif
-
- // 2D Queries
- std::cout<<"2D QUERIES"<<std::endl;
- //IQ21: For every vertex, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
- //IQ22: For every edge, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
- //NQ2: For every face, obtain neighbor faces
-#ifdef USE_AHF
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
- //DQ2: For every face, obtain its edges
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Face -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
-
- // 3D Queries
- std::cout<<"3D QUERIES"<<std::endl;
- //IQ31: For every vertex, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#endif
-
- // IQ 32: For every edge, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#endif
-
-
- //IQ32: For every face, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-#endif
-
- //NQ3: For every cell, obtain neighbor cells
-#ifdef USE_AHF
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
- std::cout<<std::endl;
-#else
- error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- ngbents.clear();
- error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
- std::cout<<std::endl;
-#endif
-
- //DQ31: For every cell, obtain its edges
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
- //DQ32: For every cell, obtain its faces
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
-#ifdef USE_AHF
- std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#else
- std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-#endif
-
-
- //Storage Costs after calling ahf deinitialize
- std::cout<<std::endl;
- std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
- unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
- eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<eTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
- std::cout<<std::endl;
- std::cout<<"Entity storage = "<<eES<<std::endl;
- std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
- std::cout<<std::endl;
-#ifdef USE_AHF
- std::cout<<"AHF adjacency tag storage = "<<eTS-sTS<<std::endl;
- std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
- std::cout<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
-#else
- std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
- std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
- std::cout<<std::endl;
- std::cout<<"Tag storage = "<<eTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
-#endif
- std::cout<<std::endl;
-
- return 0;
-}
-
diff --git a/test/perf/adj_mem_time_test.cpp b/test/perf/adj_mem_time_test.cpp
new file mode 100755
index 0000000..56b8fb7
--- /dev/null
+++ b/test/perf/adj_mem_time_test.cpp
@@ -0,0 +1,337 @@
+/*This function tests the AHF datastructures on CST meshes*/
+#include <iostream>
+#include <assert.h>
+#include <time.h>
+#include <vector>
+#include "moab/Core.hpp"
+#include "moab/Range.hpp"
+#include "moab/MeshTopoUtil.hpp"
+#include "moab/HalfFacetRep.hpp"
+#include <sys/time.h>
+
+using namespace moab;
+
+#ifdef MESHDIR
+std::string TestDir(STRINGIFY(MESHDIR));
+#else
+std::string TestDir(".");
+#endif
+
+std::string filename;
+
+double wtime() {
+ double y = -1;
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
+ return (y);
+}
+
+int main(int argc, char **argv)
+{
+ // Read the input mesh
+ filename = TestDir + "/hexes_mixed.vtk";
+
+ if (argc==1)
+ std::cout<<"Using default input file:"<<filename<<std::endl;
+ else if (argc==2)
+ filename = argv[1];
+ else {
+ std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
+ return 1;
+ }
+
+ ErrorCode error;
+ Core moab;
+ Interface* mbImpl = &moab;
+ MeshTopoUtil mtu(mbImpl);
+
+ error = mbImpl->load_file( filename.c_str());
+ if (MB_SUCCESS != error) {
+ std::cerr << filename <<": failed to load file." << std::endl;
+ return error;
+ }
+
+ //Create ranges for handles of explicit elements of the mixed mesh
+ Range verts, edges, faces, cells;
+ error = mbImpl->get_entities_by_dimension( 0, 0, verts);
+ error = mbImpl->get_entities_by_dimension( 0, 1, edges);
+ error = mbImpl->get_entities_by_dimension( 0, 2, faces);
+ error = mbImpl->get_entities_by_dimension( 0, 3, cells);
+
+ int nverts = verts.size();
+ int nedges = edges.size();
+ int nfaces = faces.size();
+ int ncells = cells.size();
+
+ std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
+
+
+ //Storage Costs before calling ahf functionalities
+ std::cout<<std::endl;
+ std::cout<<"STORAGE BEFORE CALLING ADJACENCIES"<<std::endl;
+ unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
+ sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<sTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
+ std::cout<<"Entity storage = "<<sES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
+ std::cout<<"Adjacency storage = "<<sAS<<std::endl;
+ std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+ std::cout<<std::endl;
+
+
+ double time_start, time_avg;
+
+ //Perform queries
+ std::vector<EntityHandle> adjents;
+ Range ngbents;
+
+ // This call should create all the necessary ahf maps or adjacency lists
+ error = mbImpl->get_adjacencies( &*verts.begin(), 1, 1, false, adjents );
+
+ //1D Queries //
+ //IQ1: For every vertex, obtain incident edges
+ std::cout<<"1D QUERIES"<<std::endl;
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)verts.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Edges :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ1: For every edge, obtain neighbor edges
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *edges.begin(), 0, 1, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 0, 1, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+ std::cout<<"QUERY: Edge -> Edges :: MOAB: Average time = "<<time_avg<<" secs" << std::endl;
+ std::cout<<std::endl;
+#endif
+
+ // 2D Queries
+ std::cout<<"2D QUERIES"<<std::endl;
+ //IQ21: For every vertex, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //IQ22: For every edge, obtain incident faces
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Edge -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ2: For every face, obtain neighbor faces
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *faces.begin(), 1, 2, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 1, 2, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+ std::cout<<"QUERY: Face -> Faces :: MOAB: Average time = "<< time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ2: For every face, obtain its edges
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Face -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Face -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ // 3D Queries
+ std::cout<<"3D QUERIES"<<std::endl;
+ //IQ31: For every vertex, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Vertex -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ // IQ 32: For every edge, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)edges.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Edge -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ //IQ32: For every face, obtain incident cells
+ time_start = wtime();
+ for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)faces.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Face -> Cells :: MOAB: Average time = "<<time_avg <<" secs"<<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //NQ3: For every cell, obtain neighbor cells
+#ifdef USE_AHF
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies(&*i, 1, 3, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+#else
+ error = mtu.get_bridge_adjacencies( *cells.begin(), 2, 3, ngbents);
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ ngbents.clear();
+ error = mtu.get_bridge_adjacencies( *i, 2, 3, ngbents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+ std::cout<<"QUERY: Cell -> Cells :: MOAB: Average time = "<< time_avg <<" secs" << std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ31: For every cell, obtain its edges
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 1, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Cell -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Cell -> Edges :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+ //DQ32: For every cell, obtain its faces
+ time_start = wtime();
+ for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
+ adjents.clear();
+ error = mbImpl->get_adjacencies( &*i, 1, 2, false, adjents);
+ }
+ time_avg = (wtime()-time_start)/(double)cells.size();
+#ifdef USE_AHF
+ std::cout<<"QUERY: Cell -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#else
+ std::cout<<"QUERY: Cell -> Faces :: MOAB: Average time = "<<time_avg<<" secs" <<std::endl;
+ std::cout<<std::endl;
+#endif
+
+
+ //Storage Costs after calling ahf deinitialize
+ std::cout<<std::endl;
+ std::cout<<"STORAGE AFTER CALLING ADJACENCIES"<<std::endl;
+ unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
+ eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
+ mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
+ std::cout<<std::endl;
+ std::cout<<"Total storage = "<<eTotS<<std::endl;
+ std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Entity storage = "<<eES<<std::endl;
+ std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
+ std::cout<<std::endl;
+#ifdef USE_AHF
+ std::cout<<"AHF adjacency tag storage = "<<eTS-sTS<<std::endl;
+ std::cout<<"Amortized AHF adjacency tag storage = "<<eATS-sATS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Tag storage = "<<sTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
+#else
+ std::cout<<"Adjacency lists storage = "<<eAS<<std::endl;
+ std::cout<<"Amortized adjacency lists storage = "<<eAAS<<std::endl;
+ std::cout<<std::endl;
+ std::cout<<"Tag storage = "<<eTS<<std::endl;
+ std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
+#endif
+ std::cout<<std::endl;
+
+ return 0;
+}
+
diff --git a/test/perf/test_ahf_mem_time.cpp b/test/perf/test_ahf_mem_time.cpp
deleted file mode 100755
index 0882f4f..0000000
--- a/test/perf/test_ahf_mem_time.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*This function tests the AHF datastructures on CST meshes*/
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <vector>
-#include "moab/Core.hpp"
-#include "moab/Range.hpp"
-#include "moab/MeshTopoUtil.hpp"
-#include "moab/HalfFacetRep.hpp"
-#include <sys/time.h>
-
-using namespace moab;
-
-#ifdef MESHDIR
-std::string TestDir(STRINGIFY(MESHDIR));
-#else
-std::string TestDir(".");
-#endif
-
-std::string filename;
-
-double wtime() {
- double y = -1;
- struct timeval cur_time;
- gettimeofday(&cur_time, NULL);
- y = (double)(cur_time.tv_sec) + (double)(cur_time.tv_usec)*1.e-6;
- return (y);
-}
-
-int main(int argc, char **argv)
-{
- // Read the input mesh
- filename = TestDir + "/hexes_mixed.vtk";
-
- if (argc==1)
- std::cout<<"Using default input file:"<<filename<<std::endl;
- else if (argc==2)
- filename = argv[1];
- else {
- std::cerr << "Usage: " << argv[0] << " [filename]" << std::endl;
- return 1;
- }
-
- ErrorCode error;
- Core moab;
- Interface* mbImpl = &moab;
-
- error = mbImpl->load_file( filename.c_str());
- if (MB_SUCCESS != error) {
- std::cerr << filename <<": failed to load file." << std::endl;
- return error;
- }
-
- //Create ranges for handles of explicit elements of the mixed mesh
- Range verts, edges, faces, cells;
- error = mbImpl->get_entities_by_dimension( 0, 0, verts);
- error = mbImpl->get_entities_by_dimension( 0, 1, edges);
- error = mbImpl->get_entities_by_dimension( 0, 2, faces);
- error = mbImpl->get_entities_by_dimension( 0, 3, cells);
-
- int nverts = verts.size();
- int nedges = edges.size();
- int nfaces = faces.size();
- int ncells = cells.size();
-
- std::cout<<"nverts = "<<nverts<<", nedges = "<<nedges<<", nfaces = "<<nfaces<<", ncells = "<<ncells<<std::endl;
-
-
- //Storage Costs before calling ahf functionalities
- unsigned long sTotS, sTAS, sES, sAES, sAS, sAAS, sTS, sATS;
- sTotS = sTAS = sES = sAES = sAS = sAAS = sTS = sATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &sTotS, &sTAS, &sES, &sAES, &sAS, &sAAS, NULL, 0, &sTS, &sATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<sTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<sTAS<<std::endl;
- std::cout<<"Entity storage = "<<sES<<std::endl;
- std::cout<<"Amortized entity storage = "<<sAES<<std::endl;
- std::cout<<"Adjacency storage = "<<sAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<sAAS<<std::endl;
- std::cout<<"Tag storage = "<<sTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<sATS<<std::endl;
- std::cout<<std::endl;
-
-
- double time_start, time_elapsed, time_avg;
-
- // Create an ahf instance
- HalfFacetRep ahf(&moab);
-
- // Call the initialize function which creates the maps for each dimension
- time_start = wtime();
-
- ahf.initialize();
-
- time_elapsed = wtime() - time_start;
- std::cout << "Time taken to construct the MDS = "<<time_elapsed<<" secs"<<std::endl;
-
- //Storage Costs after calling ahf initialize
- unsigned long TotS, TAS, ES, AES, AS, AAS, TS, ATS;
- TotS = TAS = ES = AES = AS = AAS = TS = ATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &TotS, &TAS, &ES, &AES, &AS, &AAS, NULL, 0, &TS, &ATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<TotS<<std::endl;
- std::cout<<"Total amortized storage = "<<TAS<<std::endl;
- std::cout<<"Entity storage = "<<ES<<std::endl;
- std::cout<<"Amortized entity storage = "<<AES<<std::endl;
- std::cout<<"Adjacency storage = "<<AS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<AAS<<std::endl;
- std::cout<<"Tag storage = "<<TS<<std::endl;
- std::cout<<"Amortized tag storage = "<<ATS<<std::endl;
- std::cout<<std::endl;
-
- //Perform queries
- std::vector<EntityHandle> adjents;
-
- //1D Queries //
- //IQ1: For every vertex, obtain incident edges
- std::cout<<"1D QUERIES"<<std::endl;
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 1, adjents);
- }
- time_avg = (wtime()-time_start)/(double)verts.size();
- std::cout<<"QUERY: Vertex -> Edges :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ1: For every edge, obtain neighbor edges
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- }
- std::cout<<"QUERY: Edge -> Edges :: MOAB_AHF: Average time = "<<time_avg<<" secs" << std::endl;
- std::cout<<std::endl;
-
-
- // 2D Queries
- std::cout<<"2D QUERIES"<<std::endl;
- //IQ21: For every vertex, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 2, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //IQ22: For every edge, obtain incident faces
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 2, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Faces :: MOAB_AHF: Average time = "<<time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- //NQ2: For every face, obtain neighbor faces
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Faces :: MOAB_AHF: Average time = "<< time_avg<<" secs" <<std::endl;
- std::cout<<std::endl;
-
- // 3D Queries
- std::cout<<"3D QUERIES"<<std::endl;
- //IQ31: For every vertex, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = verts.begin(); i != verts.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies(*i, 3, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Vertex -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- // IQ 32: For every edge, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = edges.begin(); i != edges.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 3, adjents);
- }
- time_avg = (wtime()-time_start)/(double)edges.size();
- std::cout<<"QUERY: Edge -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
-
- //IQ33: For every face, obtain incident cells
- time_start = wtime();
- for (Range::iterator i = faces.begin(); i != faces.end(); ++i) {
- adjents.clear();
- error = ahf.get_up_adjacencies( *i, 3, adjents);
- }
- time_avg = (wtime()-time_start)/(double)faces.size();
- std::cout<<"QUERY: Face -> Cells :: MOAB_AHF: Average time = "<<time_avg <<" secs"<<std::endl;
- std::cout<<std::endl;
-
- //NQ3: For every cell, obtain neighbor cells
- time_start = wtime();
- for (Range::iterator i = cells.begin(); i != cells.end(); ++i) {
- adjents.clear();
- error = ahf.get_neighbor_adjacencies( *i, adjents);
- }
- time_avg = (wtime()-time_start)/(double)cells.size();
- std::cout<<"QUERY: Cell -> Cells :: MOAB_AHF: Average time = "<< time_avg <<" secs" << std::endl;
- std::cout<<std::endl;
-
- ahf.deinitialize();
-
- //Storage Costs after calling ahf deinitialize
- unsigned long eTotS, eTAS, eES, eAES, eAS, eAAS, eTS, eATS;
- eTotS = eTAS = eES = eAES = eAS = eAAS = eTS = eATS = 0;
- mbImpl->estimated_memory_use(NULL, 0, &eTotS, &eTAS, &eES, &eAES, &eAS, &eAAS, NULL, 0, &eTS, &eATS);
- std::cout<<std::endl;
- std::cout<<"Total storage = "<<eTotS<<std::endl;
- std::cout<<"Total amortized storage = "<<eTAS<<std::endl;
- std::cout<<"Entity storage = "<<eES<<std::endl;
- std::cout<<"Amortized entity storage = "<<eAES<<std::endl;
- std::cout<<"Adjacency storage = "<<eAS<<std::endl;
- std::cout<<"Amortized adjacency storage = "<<eAAS<<std::endl;
- std::cout<<"Tag storage = "<<eTS<<std::endl;
- std::cout<<"Amortized tag storage = "<<eATS<<std::endl;
- std::cout<<std::endl;
-
- return 0;
-}
-
This diff is so big that we needed to truncate the remainder.
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.
1
0
2 new commits in MOAB:
https://bitbucket.org/fathomteam/moab/commits/f34c493671a4/
Changeset: f34c493671a4
Branch: None
User: judajake
Date: 2014-04-05 01:10:51
Summary: update vtk moab
I updated the vtk moab to match https://github.com/robertmaynard/Sandbox.
I did one small change to fix a bug with reading materials
Affected #: 19 files
diff --git a/tools/vtkMOABReaderNew/CMakeLists.txt.in b/tools/vtkMOABReaderNew/CMakeLists.txt.in
index 8b8f888..e005289 100644
--- a/tools/vtkMOABReaderNew/CMakeLists.txt.in
+++ b/tools/vtkMOABReaderNew/CMakeLists.txt.in
@@ -13,13 +13,22 @@ find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
include_directories(${PARAVIEW_INCLUDE_DIRS})
include_directories(@srcdir@)
+include_directories(@srcdir@/detail)
set(headers
- @srcdir@/SimpleMoab.h
- @srcdir@/CellTypeToType.h
+ @srcdir@/CellSets.h
@srcdir@/DataSetConverter.h
- @srcdir@/MixedCellConnectivity.h
- @srcdir@/vtkMoabReader.h
+ @srcdir@/detail/CellTypeToType.h
+ @srcdir@/detail/ContinousCellInfo.h
+ @srcdir@/detail/LoadGeometry.h
+ @srcdir@/detail/MixedCellConnectivity.h
+ @srcdir@/detail/ReadSparseTag.h
+ @srcdir@/detail/ReduceSpectralMesh.h
+ @srcdir@/detail/ReduceSpectralMesh.h
+ @srcdir@/detail/UsageTable.h
+ @srcdir@/ExtractShell.h
+ @srcdir@/FaceSets.h
+ @srcdir@/SimpleMoab.h
)
add_paraview_plugin(vtkMoabReaderPlugin "5.0"
diff --git a/tools/vtkMOABReaderNew/CellSets.h b/tools/vtkMOABReaderNew/CellSets.h
new file mode 100644
index 0000000..6171aec
--- /dev/null
+++ b/tools/vtkMOABReaderNew/CellSets.h
@@ -0,0 +1,75 @@
+
+#ifndef __smoab_CellSets_h
+#define __smoab_CellSets_h
+
+#include "SimpleMoab.h"
+
+namespace smoab
+{
+//----------------------------------------------------------------------------
+class CellSet
+{
+public:
+ CellSet(smoab::EntityHandle p,const smoab::Range& cells):
+ Entity(p),
+ Cells(cells)
+ {}
+
+ const smoab::Range& cells() const { return this->Cells; }
+ EntityHandle entity() const { return this->Entity; }
+
+ bool contains(smoab::EntityHandle c) const
+ {
+ return this->Cells.find(c) != this->Cells.end();
+ }
+
+ void erase(smoab::Range cells)
+ {
+ //seems that erase() has a bug, so use subtract
+ this->Cells = smoab::subtract(this->Cells,cells);
+ }
+
+private:
+ smoab::EntityHandle Entity;
+ smoab::Range Cells;
+};
+
+//----------------------------------------------------------------------------
+//CellSets are just a vector of CellSets
+typedef std::vector<CellSet> CellSets;
+
+//----------------------------------------------------------------------------
+//templated so it works with FaceCellSets and CellSets
+template<typename T>
+smoab::Range getParents(const T& set)
+{
+ typedef typename T::const_iterator iterator;
+ smoab::Range result;
+
+ for(iterator i=set.begin(); i != set.end(); ++i)
+ {
+ result.insert(i->entity());
+ }
+ return result;
+}
+
+//----------------------------------------------------------------------------
+//templated so it works with FaceCellSets and CellSets
+template<typename T>
+smoab::Range getAllCells(const T& set)
+{
+ typedef typename T::const_iterator iterator;
+ smoab::Range result;
+
+ for(iterator i=set.begin(); i != set.end(); ++i)
+ {
+ smoab::Range c = i->cells();
+ result.insert(c.begin(),c.end());
+ }
+ return result;
+}
+
+
+}
+
+#endif
diff --git a/tools/vtkMOABReaderNew/CellTypeToType.h b/tools/vtkMOABReaderNew/CellTypeToType.h
deleted file mode 100644
index 6ff91af..0000000
--- a/tools/vtkMOABReaderNew/CellTypeToType.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __smoab_CellTypeToType_h
-#define __smoab_CellTypeToType_h
-
-#include "SimpleMoab.h"
-#include "vtkCellType.h"
-
-namespace smoab
-{
-template<int> struct CellTypeToType;
-
-int vtkCellType(moab::EntityType t, int &num_connect)
- {
- int ctype = -1;
- switch (t)
- {
- case moab::MBEDGE:
- if (num_connect == 2) ctype = VTK_LINE;
- else if (num_connect == 3) ctype = VTK_QUADRATIC_EDGE;
- break;
- case moab::MBTRI:
- if (num_connect == 3) ctype = VTK_TRIANGLE;
- else if (num_connect == 6) ctype = VTK_QUADRATIC_TRIANGLE;
- else if (num_connect == 7) ctype = VTK_BIQUADRATIC_TRIANGLE;
- break;
- case moab::MBQUAD:
- if (num_connect == 4) ctype = VTK_QUAD;
- else if (num_connect == 8) ctype = VTK_QUADRATIC_QUAD;
- else if (num_connect == 9) ctype = VTK_BIQUADRATIC_QUAD;
- break;
- case moab::MBPOLYGON:
- if (num_connect == 4) ctype = VTK_POLYGON;
- break;
- case moab::MBTET:
- if (num_connect == 4) ctype = VTK_TETRA;
- else if (num_connect == 10) ctype = VTK_QUADRATIC_TETRA;
- break;
- case moab::MBPYRAMID:
- if (num_connect == 5) ctype = VTK_PYRAMID;
- else if (num_connect == 13) ctype = VTK_QUADRATIC_PYRAMID;
- break;
- case moab::MBPRISM:
- if (num_connect == 6) ctype = VTK_WEDGE;
- else if (num_connect == 15) ctype = VTK_QUADRATIC_WEDGE;
- break;
- case moab::MBHEX:
- if (num_connect == 8) ctype = VTK_HEXAHEDRON;
- else if (num_connect == 20) ctype = VTK_QUADRATIC_HEXAHEDRON;
- else if (num_connect == 21) ctype = VTK_QUADRATIC_HEXAHEDRON, num_connect = 20;
- else if (num_connect == 27) ctype = VTK_TRIQUADRATIC_HEXAHEDRON;
- break;
- default:
- ctype = -1;
- break;
- }
- return ctype;
- }
-}
-
-#endif // CELLTYPETOTYPE_H
diff --git a/tools/vtkMOABReaderNew/DataSetConverter.h b/tools/vtkMOABReaderNew/DataSetConverter.h
index bfae086..3edadf0 100644
--- a/tools/vtkMOABReaderNew/DataSetConverter.h
+++ b/tools/vtkMOABReaderNew/DataSetConverter.h
@@ -2,20 +2,16 @@
#define __smoab_DataSetConverter_h
#include "SimpleMoab.h"
-#include "CellTypeToType.h"
-#include "MixedCellConnectivity.h"
+#include "CellSets.h"
+#include "detail/LoadGeometry.h"
+#include "detail/ReadSparseTag.h"
-#include <vtkCellArray.h>
#include <vtkCellData.h>
#include <vtkDoubleArray.h>
#include <vtkFieldData.h>
#include <vtkIntArray.h>
#include <vtkIdTypeArray.h>
#include <vtkNew.h>
-#include <vtkPointData.h>
-#include <vtkPoints.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkUnstructuredGrid.h>
#include <algorithm>
@@ -35,17 +31,13 @@ public:
Moab(interface.Moab),
Tag(tag),
ReadMaterialIds(false),
- ReadProperties(false),
- MaterialName("Material")
+ ReadProperties(false)
{
}
void readMaterialIds(bool add) { this->ReadMaterialIds = add; }
bool readMaterialIds() const { return this->ReadMaterialIds; }
- void materialIdName(const std::string& name) { this->MaterialName = name; }
- const std::string& materialIdName() const { return this->MaterialName; }
-
void readProperties(bool readProps) { this->ReadProperties = readProps; }
bool readProperties() const { return this->ReadProperties; }
@@ -54,109 +46,65 @@ public:
//grid. Currently doesn't support reading properties.
//Will read in material ids, if no material id is assigned to an entity,
//its cells will be given an unique id
+ template<typename VTKGridType>
bool fill(const smoab::Range& entities,
- vtkUnstructuredGrid* grid) const
+ VTKGridType* grid) const
{
//create a helper datastructure which can determines all the unique point ids
//and converts moab connecitvity info to vtk connectivity
- moab::Range cells;
- //append all the entities cells together into a single range
+
+ //get all the cells for each parent entity and create
+ // an entity set of those items
+ int dim = this->Tag->value();
typedef smoab::Range::const_iterator iterator;
+ smoab::CellSets entitySets;
for(iterator i=entities.begin(); i!= entities.end(); ++i)
{
+ smoab::Range entitiesCells;
if(this->Tag->isComparable())
{
//if we are comparable only find the cells that match our tags dimension
- smoab::Range entitiesCells = this->Interface.findEntitiesWithDimension(*i,Tag->value());
- cells.insert(entitiesCells.begin(),entitiesCells.end());
+ entitiesCells = this->Interface.findEntitiesWithDimension(*i,dim,true);
}
else
{
- //this is a bad representation of all other tags, but we are presuming that
- //neuman and dirichlet are on entitysets with no children
- this->Moab->get_entities_by_handle(*i,cells);
+ entitiesCells = this->Interface.findHighestDimensionEntities(*i,true);
}
+ smoab::CellSet set(*i,entitiesCells);
+ entitySets.push_back(set);
}
- smoab::Range points;
- this->loadCellsAndPoints(cells,points,grid);
-
- if(this->readMaterialIds())
- {
- typedef std::vector<smoab::EntityHandle>::const_iterator EntityHandleIterator;
- typedef std::vector<int>::const_iterator IdConstIterator;
- typedef std::vector<int>::iterator IdIterator;
-
- std::vector<smoab::EntityHandle> searchableCells;
- searchableCells.reserve(grid->GetNumberOfCells());
- std::copy(cells.begin(),cells.end(),std::back_inserter(searchableCells));
- cells.clear(); //release memory we don't need
+ moab::Range cells = smoab::getAllCells(entitySets);
- std::vector<int> materialIds(entities.size());
- //first off iterate the entities and determine which ones
- //have moab material ids
+ //convert the datastructure from a list of cells to a vtk data set
+ detail::LoadGeometry loadGeom(cells,dim,this->Interface);
+ loadGeom.fill(grid);
- //wrap this area with scope, to remove local variables
+ if(this->readMaterialIds())
{
- smoab::MaterialTag tag;
- IdIterator materialIndex = materialIds.begin();
- for(iterator i=entities.begin();
- i != entities.end();
- ++i, ++materialIndex)
- {
- moab::Tag mtag = this->Interface.getMoabTag(tag);
-
- int value=-1;
- this->Moab->tag_get_data(mtag,&(*i),1,&value);
- *materialIndex=static_cast<int>(value);
- }
-
- //now determine ids for all entities that don't have materials
- IdConstIterator maxPos = std::max_element(materialIds.begin(),
- materialIds.end());
- int maxMaterial = *maxPos;
- for(IdIterator i=materialIds.begin(); i!= materialIds.end(); ++i)
- {
- if(*i==-1)
- {
- *i = ++maxMaterial;
- }
- }
- }
- //now we create the material field, and set all the values
- vtkNew<vtkIntArray> materialSet;
- materialSet->SetName(this->materialIdName().c_str());
- materialSet->SetNumberOfValues(grid->GetNumberOfCells());
+ detail::ReadSparseTag materialTagReading(entitySets,
+ cells,
+ this->Interface);
- IdConstIterator materialValue = materialIds.begin();
- for(iterator i=entities.begin(); i!= entities.end(); ++i, ++materialValue)
- {
- //this is a time vs memory trade off, I don't want to store
- //the all the cell ids twice over, lets use more time
- smoab::Range entitiesCells;
- if(this->Tag->isComparable())
- {entitiesCells = this->Interface.findEntitiesWithDimension(*i,Tag->value());}
- else
- {this->Moab->get_entities_by_handle(*i,entitiesCells);}
-
- EntityHandleIterator s_begin = searchableCells.begin();
- EntityHandleIterator s_end = searchableCells.end();
- for(iterator j=entitiesCells.begin(); j != entitiesCells.end();++j)
- {
- EntityHandleIterator result = std::lower_bound(s_begin,
- s_end,
- *j);
- std::size_t newId = std::distance(s_begin,result);
- materialSet->SetValue(static_cast<int>(newId), *materialValue);
- }
- }
+ smoab::MaterialTag mtag;
+ vtkNew<vtkIntArray> materials;
+ materials->SetName(mtag.name());
+ materialTagReading.fill(materials.GetPointer(),&mtag);
+ grid->GetCellData()->AddArray(materials.GetPointer());
+ }
- grid->GetCellData()->AddArray(materialSet.GetPointer());
+ //by default we always try to load the default tag
+ detail::ReadSparseTag sTagReading(entitySets,
+ cells,
+ this->Interface);
- }
+ vtkNew<vtkIntArray> sparseTagData;
+ sparseTagData->SetName(this->Tag->name());
+ sTagReading.fill(sparseTagData.GetPointer(),this->Tag);
+ grid->GetCellData()->AddArray(sparseTagData.GetPointer());
return true;
}
@@ -165,28 +113,32 @@ public:
//given a single entity handle create a unstructured grid from it.
//optional third parameter is the material id to use if readMaterialIds
//is on, and no material sparse tag is found for this entity
+ template<typename VTKGridType>
bool fill(const smoab::EntityHandle& entity,
- vtkUnstructuredGrid* grid,
+ VTKGridType* grid,
const int materialId=0) const
{
//create a helper datastructure which can determines all the unique point ids
//and converts moab connecitvity info to vtk connectivity
- moab::Range cells;
+
+ smoab::Range cells;
+ int dim = this->Tag->value();
if(this->Tag->isComparable())
{
//if we are comparable only find the cells that match our tags dimension
- cells = this->Interface.findEntitiesWithDimension(entity,Tag->value());
+ cells = this->Interface.findEntitiesWithDimension(entity,dim,true);
}
else
{
- //this is a bad representation of all other tags, but we are presuming that
- //neuman and dirichlet are on entitysets with no children
- this->Moab->get_entities_by_handle(entity,cells);
+ //load subentities
+ cells = this->Interface.findHighestDimensionEntities(entity,true);
}
- smoab::Range points;
- this->loadCellsAndPoints(cells,points,grid);
+ //convert the datastructure from a list of cells to a vtk data set
+ detail::LoadGeometry loadGeom(cells,dim,this->Interface);
+ loadGeom.fill(grid);
+ const smoab::Range& points = loadGeom.moabPoints();
if(this->readProperties())
{
@@ -194,53 +146,34 @@ public:
this->readProperties(points,grid->GetPointData());
}
+ smoab::CellSets cellSets;
+ smoab::CellSet set(entity,cells);
+ cellSets.push_back(set);
if(this->readMaterialIds())
{
- this->readSparseTag(smoab::MaterialTag(),entity,
- grid->GetNumberOfCells(),
- grid->GetCellData(),
- materialId);
- }
- return true;
- }
+ smoab::MaterialTag mtag;
+ detail::ReadSparseTag materialTagReading(cellSets,
+ cells,
+ this->Interface);
- //----------------------------------------------------------------------------
- void loadCellsAndPoints(const smoab::Range& cells,
- smoab::Range& points,
- vtkUnstructuredGrid* grid) const
- {
+ vtkNew<vtkIntArray> materials;
+ materials->SetName(mtag.name());
+ materialTagReading.fill(materials.GetPointer(),&mtag);
+ grid->GetCellData()->AddArray(materials.GetPointer());
- smoab::MixedCellConnectivity mixConn(cells,this->Moab);
-
- //now that mixConn has all the cells properly stored, lets fixup
- //the ids so that they start at zero and keep the same logical ordering
- //as before.
- vtkIdType numCells, connLen;
- mixConn.compactIds(numCells,connLen);
- this->setGridsTopology(mixConn,grid,numCells,connLen);
+ }
- mixConn.moabPoints(points);
+ //by default we always try to load the default tag
+ detail::ReadSparseTag sTagReading(cellSets,
+ cells,
+ this->Interface);
- vtkNew<vtkPoints> newPoints;
- this->addCoordinates(points,newPoints.GetPointer());
- grid->SetPoints(newPoints.GetPointer());
+ vtkNew<vtkIntArray> sparseTagData;
+ sparseTagData->SetName(this->Tag->name());
+ sTagReading.fill(sparseTagData.GetPointer(),this->Tag);
+ grid->GetCellData()->AddArray(sparseTagData.GetPointer());
- }
-
- //----------------------------------------------------------------------------
- void addCoordinates(smoab::Range pointEntities, vtkPoints* pointContainer) const
- {
- //since the smoab::range are always unique and sorted
- //we can use the more efficient coords_iterate
- //call in moab, which returns moab internal allocated memory
- pointContainer->SetDataTypeToDouble();
- pointContainer->SetNumberOfPoints(pointEntities.size());
-
- //need a pointer to the allocated vtkPoints memory so that we
- //don't need to use an extra copy and we can bypass all vtk's check
- //on out of bounds
- double *rawPoints = static_cast<double*>(pointContainer->GetVoidPointer(0));
- this->Moab->get_coords(pointEntities,rawPoints);
+ return true;
}
private:
@@ -260,36 +193,6 @@ private:
}
//----------------------------------------------------------------------------
- bool readSparseTag(smoab::Tag tag,
- smoab::EntityHandle const& entity,
- vtkIdType length,
- vtkFieldData* field,
- vtkIdType defaultValue) const
- {
-
- typedef std::vector<moab::Tag>::const_iterator iterator;
- moab::Tag mtag = this->Interface.getMoabTag(tag);
-
- int value=0;
- moab::ErrorCode rval = this->Moab->tag_get_data(mtag,&entity,1,&value);
- if(rval!=moab::MB_SUCCESS)
- {
- value = defaultValue;
- }
-
- vtkNew<vtkIntArray> materialSet;
- materialSet->SetNumberOfValues(length);
- materialSet->SetName(this->materialIdName().c_str());
-
- int *raw = static_cast<int*>(materialSet->GetVoidPointer(0));
- std::fill(raw,raw+length,value);
-
- field->AddArray(materialSet.GetPointer());
-
- return true;
- }
-
- //----------------------------------------------------------------------------
void readDenseTags(std::vector<moab::Tag> &tags,
smoab::Range const& entities,
vtkFieldData* field) const
@@ -359,36 +262,7 @@ private:
}
}
- //----------------------------------------------------------------------------
- void setGridsTopology(smoab::MixedCellConnectivity const& mixedCells,
- vtkUnstructuredGrid* grid,
- vtkIdType numCells,
- vtkIdType numConnectivity) const
- {
- //correct the connectivity size to account for the vtk padding
- const vtkIdType vtkConnectivity = numCells + numConnectivity;
- vtkNew<vtkIdTypeArray> cellArray;
- vtkNew<vtkIdTypeArray> cellLocations;
- vtkNew<vtkUnsignedCharArray> cellTypes;
-
- cellArray->SetNumberOfValues(vtkConnectivity);
- cellLocations->SetNumberOfValues(numCells);
- cellTypes->SetNumberOfValues(numCells);
-
- vtkIdType* rawArray = static_cast<vtkIdType*>(cellArray->GetVoidPointer(0));
- vtkIdType* rawLocations = static_cast<vtkIdType*>(cellLocations->GetVoidPointer(0));
- unsigned char* rawTypes = static_cast<unsigned char*>(cellTypes->GetVoidPointer(0));
-
- mixedCells.copyToVtkCellInfo(rawArray,rawLocations,rawTypes);
-
- vtkNew<vtkCellArray> cells;
- cells->SetCells(numCells,cellArray.GetPointer());
- grid->SetCells(cellTypes.GetPointer(),
- cellLocations.GetPointer(),
- cells.GetPointer(),
- NULL,NULL);
- }
};
}
diff --git a/tools/vtkMOABReaderNew/ExtractShell.h b/tools/vtkMOABReaderNew/ExtractShell.h
new file mode 100644
index 0000000..359fbce
--- /dev/null
+++ b/tools/vtkMOABReaderNew/ExtractShell.h
@@ -0,0 +1,80 @@
+#ifndef __smoab_ExtractShell_h
+#define __smoab_ExtractShell_h
+
+#include "SimpleMoab.h"
+#include "detail/UsageTable.h"
+
+#include <algorithm>
+
+namespace smoab{
+
+class ExtractShell
+{
+ const smoab::Interface& Interface;
+ smoab::CellSets VCells;
+
+public:
+ ExtractShell(const smoab::CellSets volCells,
+ const smoab::Interface& interface):
+ Interface(interface),
+ VCells(volCells)
+ {
+ }
+
+ bool findSkins(smoab::CellSets &surfaceCellSets);
+};
+
+
+//----------------------------------------------------------------------------
+bool ExtractShell::findSkins(smoab::CellSets &surfaceCellSets)
+{
+ typedef smoab::Range::const_iterator Iterator;
+
+ typedef smoab::CellSets::const_iterator SetIterator;
+
+
+ smoab::Range cellsToRemove;
+ for(SetIterator set = this->VCells.begin();
+ set != this->VCells.end();
+ ++set)
+ {
+ const smoab::Range &cells = set->cells();
+ this->Interface.createAdjacencies(set->cells(),2);
+
+
+ //we create the usage table for each iteration so that we only
+ //get the shell of each cell set. If we used the table between
+ //sets we would get the shell of the combined sets
+ smoab::detail::UsageTable table;
+ for(Iterator i = cells.begin(); i != cells.end(); ++i)
+ {
+ std::vector<smoab::EntityHandle> faceCells =
+ this->Interface.sideElements(*i,2);
+
+ //the usage id allows you to label cells when going into the table
+ //so that you can extract multiple shells where each is based on
+ //a single region id.
+ std::vector<int> regionId(1,faceCells.size());
+ table.incrementUsage(faceCells,regionId);
+ }
+ smoab::Range surfaceCells = table.singleUsage();
+
+ //create a new cell set that
+ smoab::CellSet surfaceSet(set->entity(),surfaceCells);
+ surfaceCellSets.push_back(surfaceSet);
+
+ smoab::Range subsetToRemove = table.multipleUsage();
+ cellsToRemove.insert(subsetToRemove.begin(),subsetToRemove.end());
+ }
+
+ //we will remove all cells that have multiple usages from the moab database
+ //I really don't care if they already existed or not.
+ this->Interface.remove(cellsToRemove);
+ return true;
+}
+
+
+
+}
+
+#endif // __smoab_ExtractShell_h
diff --git a/tools/vtkMOABReaderNew/FaceSets.h b/tools/vtkMOABReaderNew/FaceSets.h
new file mode 100644
index 0000000..536f3f9
--- /dev/null
+++ b/tools/vtkMOABReaderNew/FaceSets.h
@@ -0,0 +1,256 @@
+#ifndef __smoab_FaceSets_h
+#define __smoab_FaceSets_h
+
+#include "CellSets.h"
+#include <set>
+
+namespace smoab
+{
+//----------------------------------------------------------------------------
+class FaceCellSet : public CellSet
+{
+public:
+ FaceCellSet(int id, smoab::EntityHandle p,const smoab::Range& cells):
+ CellSet(p,cells),
+ ID(id)
+ {}
+
+ int faceId() const { return ID; }
+ void overrideFaceId(int i) { ID = i; } //USE AT YOUR OWN RISK
+
+private:
+ int ID;
+};
+
+
+//----------------------------------------------------------------------------
+typedef std::vector<FaceCellSet> FaceCellSets;
+
+
+//----------------------------------------------------------------------------
+//class that store the regions that a faces is adjacent too
+struct FacesAdjRegions
+{
+ FacesAdjRegions(int f, smoab::EntityHandle r0, smoab::EntityHandle r1):
+ FaceId(f),
+ Region0(r0),
+ Region1(r1)
+ {
+ if (r0 > r1)
+ {
+ std::swap(this->Region0,this->Region1);
+ }
+ }
+
+ FacesAdjRegions(int f):
+ FaceId(f),
+ Region0(-3),
+ Region1(-2)
+ {}
+
+ bool operator<(const FacesAdjRegions& other) const
+ {
+ return (this->FaceId < other.FaceId);
+ }
+
+ smoab::EntityHandle otherId(smoab::EntityHandle other) const
+ {
+ if(other == Region0)
+ {
+ return Region1;
+ }
+ return Region0;
+ }
+
+ int FaceId;
+ smoab::EntityHandle Region0;
+ smoab::EntityHandle Region1;
+};
+//----------------------------------------------------------------------------
+smoab::FaceCellSets findFaceSets(smoab::CellSets shells,
+ smoab::CellSets boundaries,
+ std::set<smoab::FacesAdjRegions>& faceMaps)
+{
+ typedef smoab::CellSets::iterator iterator;
+ typedef smoab::FaceCellSets::iterator faceIterator;
+ typedef std::set<smoab::FacesAdjRegions>::const_iterator FaceAdjIterator;
+
+ //we need to properly label each unique face in shells
+ //we do this by intersecting each shell with each other shell
+ //to find shell on shell contact, and than we intersect each
+ //resulting shell with the boundary conditions
+ //the end result of these intersections will be the new modelfaces
+ int faceId = 1;
+ smoab::FaceCellSets shellFaces;
+
+ //first intersect each shell with each other shell
+ std::set<smoab::FacesAdjRegions> shellFaceContacts;
+ for(iterator i=shells.begin();i!= shells.end();++i)
+ {
+ //copy the cells so we can add a face that represents
+ //all the cells of the region that aren't shared with another region
+ int numCells = i->cells().size(); //size() on range is slow, so cache it
+ for(iterator j = i+1;
+ j != shells.end() && numCells > 0;
+ ++j)
+ {
+ //intersect i and j to make a new face
+ smoab::Range intersection = smoab::intersect(i->cells(),j->cells());
+ if(!intersection.empty())
+ {
+ //don't want to increment faceId when the intersection is empty
+ smoab::FaceCellSet face(faceId++,i->entity(),intersection);
+ shellFaces.push_back(face);
+ i->erase(intersection);
+ j->erase(intersection);
+ numCells -= intersection.size();
+
+ //add this to the face map
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),j->entity());
+ shellFaceContacts.insert(faceInfo);
+ }
+ }
+ //if all the cells for shell i are used, don't add a new
+ //empty face
+ if(numCells > 0)
+ {
+ smoab::FaceCellSet face(faceId++,i->entity(),i->cells());
+ shellFaces.push_back(face);
+
+ //add this to the face map
+ smoab::FacesAdjRegions faceInfo(faceId-1,-1,i->entity());
+ shellFaceContacts.insert(faceInfo);
+ }
+ }
+
+ //now we have all the faces that match shell on shell contact
+ //we know process all the new faces to see if they intersect
+ //with any boundary sets. A boundary set can span multiple
+ //shells so we want to process it as a second loop
+
+ //store the end before we start adding boundary faces, which
+ //we don't need to check agianst other boundaries
+ faceId = 1; //reset the faced id
+
+ //store in a new face set, expanding the current one causes incorrect results
+ smoab::FaceCellSets faces;
+ for(faceIterator i=shellFaces.begin();i != shellFaces.end();++i)
+ {
+ //determine from the shell faces if the new face we are creating
+ //is bounded by two regions or just one
+ smoab::FacesAdjRegions idToSearchFor(i->faceId());
+ FaceAdjIterator adjRegions = shellFaceContacts.find(idToSearchFor);
+ smoab::EntityHandle otherRegionId = adjRegions->otherId(i->entity());
+
+ int numCells = i->cells().size(); //size() on range is slow, so cache it
+ for(iterator j=boundaries.begin();j != boundaries.end(); ++j)
+ {
+ smoab::Range intersect = smoab::intersect(i->cells(),j->cells());
+ if(!intersect.empty())
+ {
+ //don't want to increment faceId when the intersection is empty
+ smoab::FaceCellSet face(faceId++,j->entity(),intersect);
+ faces.push_back(face);
+ i->erase(intersect);
+ numCells -= intersect.size();
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),otherRegionId);
+ faceMaps.insert(faceInfo);
+ }
+ }
+ if(numCells > 0)
+ {
+ smoab::FaceCellSet face(faceId++,i->entity(),i->cells());
+ faces.push_back(face);
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),otherRegionId);
+ faceMaps.insert(faceInfo);
+ }
+ }
+ return faces;
+}
+
+//----------------------------------------------------------------------------
+template<typename T>
+std::vector<T> faceIdsPerCell(const smoab::FaceCellSets& faces)
+{
+ typedef smoab::FaceCellSets::const_iterator iterator;
+ typedef std::vector<smoab::EntityHandle>::const_iterator EntityHandleIterator;
+ typedef smoab::Range::const_iterator RangeIterator;
+
+ //find all the cells that are in the faceCellSet, and than map
+ //the proper face id to that relative position, here comes lower_bounds!
+ std::vector<smoab::EntityHandle> searchableCells;
+ smoab::Range faceRange = smoab::getAllCells(faces);
+ smoab::RangeToVector(faceRange,searchableCells);
+
+ //faceIds will be the resulting array
+ std::vector<T> faceIds(searchableCells.size());
+
+ //construct the start and end iterators for the lower bounds call
+
+ EntityHandleIterator s_begin = searchableCells.begin();
+ EntityHandleIterator s_end = searchableCells.end();
+
+ //search the face cell sets
+ for(iterator i=faces.begin(); i!=faces.end(); ++i)
+ {
+ T value = static_cast<T>(i->faceId());
+ const smoab::Range& entitiesCells = i->cells();
+ for(RangeIterator j=entitiesCells.begin(); j != entitiesCells.end();++j)
+ {
+ EntityHandleIterator result = std::lower_bound(s_begin,
+ s_end,
+ *j);
+ std::size_t newId = std::distance(s_begin,result);
+ faceIds[newId] = value;
+ }
+ }
+ return faceIds;
+}
+
+//----------------------------------------------------------------------------
+//given a face adjacency, determine the regions spare tag values
+template<typename T>
+std::pair<T,T> FaceAdjRegionValues(const smoab::FacesAdjRegions& faceAdj,
+ smoab::Tag* t,
+ const smoab::Interface& interface)
+ {
+ std::pair<T,T> returnValue;
+ const int defaultValue = interface.getDefaultTagVaue<int>(*t);
+
+ /*
+ * IF A REGION IS SET TO -1 WE NEED TO PUSH THAT VALUE DOWN
+ * AS THE MATERIAL, SINCE THE MOAB DEFAULT TAG VALUE WILL
+ * BE CONSIDIERED A REGION, AND WE WANT TO SAY IT BOUNDS THE
+ * VOID REGION
+ */
+ int tagValue = defaultValue; //use tagValue to pass in default value
+ if(faceAdj.Region0 != -1)
+ {
+ tagValue = interface.getTagData(*t,faceAdj.Region0,tagValue);
+ }
+ else
+ {
+ tagValue = -1;
+ }
+
+ //set the first region tag value into the pair we are returing
+ returnValue.first = static_cast<T>(tagValue);
+
+ tagValue = defaultValue; //use tagValue to pass in default value
+ tagValue = interface.getTagData(*t,faceAdj.Region1,tagValue);
+ if(faceAdj.Region1 != -1)
+ {
+ tagValue = interface.getTagData(*t,faceAdj.Region1,tagValue);
+ }
+ else
+ {
+ tagValue = -1;
+ }
+ returnValue.second = static_cast<T>(tagValue);
+
+ return returnValue;
+ }
+
+ } //smoab
+
+#endif
diff --git a/tools/vtkMOABReaderNew/MixedCellConnectivity.h b/tools/vtkMOABReaderNew/MixedCellConnectivity.h
deleted file mode 100644
index 1b26d0f..0000000
--- a/tools/vtkMOABReaderNew/MixedCellConnectivity.h
+++ /dev/null
@@ -1,271 +0,0 @@
-#ifndef __smoab_MixedCellConnectivity_h
-#define __smoab_MixedCellConnectivity_h
-
-#include "vtkCellType.h"
-#include <algorithm>
-
-namespace
-{
-
-template<int N> struct QuadratricOrdering{};
-
-template<> struct QuadratricOrdering<VTK_QUADRATIC_WEDGE>
-{
- static const int NUM_VERTS = 15;
- void reorder(vtkIdType* connectivity) const
- {
- std::swap_ranges(connectivity+9,connectivity+12,connectivity+12);
- }
-};
-
-template<> struct QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON>
-{
- static const int NUM_VERTS = 27;
- void reorder(vtkIdType* connectivity) const
- {
- std::swap_ranges(connectivity+12,connectivity+16,connectivity+16);
-
- //move 20 to 22
- //move 22 to 23
- //move 23 to 20
-
- //swap 20 with 22
- std::swap(connectivity[20],connectivity[23]);
-
- //swap 22 with 23
- std::swap(connectivity[22],connectivity[23]);
- }
-};
-
-template<typename QuadraticOrdering>
-void FixQuadraticIdOrdering(vtkIdType* connectivity, vtkIdType numCells,
- QuadraticOrdering& ordering)
-{
- //skip the first index that holds the length of the cells
- //if we skip it once here, and than properly increment it makes the code
- //far easier
- connectivity+=1;
- for(vtkIdType i=0; i < numCells; ++i)
- {
- ordering.reorder(connectivity);
- connectivity += ordering.NUM_VERTS + 1;
- }
-}
-}
-
-namespace smoab
-{
-
-class MixedCellConnectivity
-{
-public:
- MixedCellConnectivity(smoab::Range const& cells, moab::Interface* moab):
- Connectivity(),
- UniquePoints(),
- Info()
- {
- int count = 0;
- const std::size_t cellSize=cells.size();
- while(count != cellSize)
- {
- EntityHandle* connectivity;
- int numVerts=0, iterationCount=0;
- //use the highly efficent calls, since we know that are of the same dimension
- moab->connect_iterate(cells.begin()+count,
- cells.end(),
- connectivity,
- numVerts,
- iterationCount);
- //if we didn't read anything, break!
- if(iterationCount == 0)
- {
- break;
- }
-
- //identify the cell type that we currently have,
- //store that along with the connectivity in a temp storage vector
- const moab::EntityType type = moab->type_from_handle(*cells.begin()+count);
-
- //while all these cells are contiously of the same type,
- //quadric hexs in vtk have 20 points, but moab has 21 so we
- //need to store this difference
- int numVTKVerts = numVerts;
- int vtkCellType = smoab::vtkCellType(type,numVTKVerts);
-
- RunLengthInfo info = { vtkCellType, numVerts, (numVerts-numVTKVerts), iterationCount };
- this->Info.push_back(info);
- this->Connectivity.push_back(connectivity);
-
- count += iterationCount;
- }
- }
-
- //----------------------------------------------------------------------------
- void compactIds(vtkIdType& numCells, vtkIdType& connectivityLength)
- {
- //converts all the ids to be ordered starting at zero, and also
- //keeping the orginal logical ordering. Stores the result of this
- //operation in the unstrucutred grid that is passed in
-
- //lets determine the total length of the connectivity
- connectivityLength = 0;
- numCells = 0;
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i)
- {
- connectivityLength += (*i).numCells * (*i).numVerts;
- numCells += (*i).numCells;
- }
-
- this->UniquePoints.reserve(connectivityLength);
-
- this->copyConnectivity(this->UniquePoints);
- std::sort(this->UniquePoints.begin(),this->UniquePoints.end());
-
- typedef std::vector<EntityHandle>::iterator EntityIterator;
- EntityIterator newEnd = std::unique(this->UniquePoints.begin(),
- this->UniquePoints.end());
-
- const std::size_t newSize = std::distance(this->UniquePoints.begin(),newEnd);
- this->UniquePoints.resize(newSize);
- }
-
- //----------------------------------------------------------------------------
- void moabPoints(smoab::Range& range) const
- {
- //from the documentation a reverse iterator is the fastest way
- //to insert into a range.
- std::copy(this->UniquePoints.rbegin(),
- this->UniquePoints.rend(),
- moab::range_inserter(range));
- }
-
- //----------------------------------------------------------------------------
- //copy the connectivity from the moab held arrays to the user input vector
- void copyConnectivity(std::vector<EntityHandle>& output) const
- {
- //walk the info to find the length of each sub connectivity array,
- //and insert them into the vector, ordering is implied by the order
- //the connecitivy sub array are added to this class
- ConnConstIterator c = this->Connectivity.begin();
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i,++c)
- {
- //remember our Connectivity is a vector of pointers whose
- //length is held in the info vector.
- const int numUnusedPoints = (*i).numUnusedVerts;
- if(numUnusedPoints==0)
- {
- const int connLength = (*i).numCells * (*i).numVerts;
- std::copy(*c,*c+connLength,std::back_inserter(output));
- }
- else
- {
- //we have cell connectivity that we need to skip,
- //so we have to manual copy each cells connectivity
- const int size = (*i).numCells;
- const int numPoints = (*i).numVerts;
- for(int i=0; i < size; ++i)
- {
- std::copy(*c,*c+numPoints,std::back_inserter(output));
- }
- c+=numPoints + (*i).numUnusedVerts;
- }
-
- }
- }
-
- //copy the information from this contianer to a vtk cell array, and
- //related lookup information
- void copyToVtkCellInfo(vtkIdType* cellArray,
- vtkIdType* cellLocations,
- unsigned char* cellTypes) const
- {
- vtkIdType currentVtkConnectivityIndex = 0;
- ConnConstIterator c = this->Connectivity.begin();
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i, ++c)
- {
- //for this group of the same cell type we need to fill the cellTypes
- const int numCells = (*i).numCells;
- const int numVerts = (*i).numVerts;
-
- std::fill_n(cellTypes,
- numCells,
- static_cast<unsigned char>((*i).type));
-
- //for each cell in this collection that have the same type
- //grab the raw array now, so we can properly increment for each vert in each cell
- EntityHandle* moabConnectivity = *c;
- for(int j=0;j < numCells; ++j)
- {
- cellLocations[j]= currentVtkConnectivityIndex;
-
- //cell arrays start and end are different, since we
- //have to account for element that states the length of each cell
- cellArray[0]=numVerts;
-
- for(int k=0; k < numVerts; ++k, ++moabConnectivity )
- {
- //this is going to be a root of some failures when we start
- //reading really large datasets under 32bit.
-
-
- //fyi, don't use a range ds for unique points, distance
- //function is horribly slow they need to override it
- EntityConstIterator result = std::lower_bound(
- this->UniquePoints.begin(),
- this->UniquePoints.end(),
- *moabConnectivity);
- std::size_t newId = std::distance(this->UniquePoints.begin(),
- result);
- cellArray[k+1] = static_cast<vtkIdType>(newId);
- }
-
- //skip any extra unused points, which is currnetly only
- //the extra center point in moab quadratic hex
- moabConnectivity+=(*i).numUnusedVerts;
-
- currentVtkConnectivityIndex += numVerts+1;
- cellArray += numVerts+1;
- }
-
- //For Tri-Quadratic-Hex and Quadratric-Wedge Moab and VTK
- //Differ on the order of the edge ids. For wedge we need to swap
- //indices 9,10,11 with 12,13,14 for each cell. For Hex we sawp
- //12,13,14,15 with 16,17,18,19
- int vtkCellType = (*i).type;
- vtkIdType* connectivity = cellArray - (numCells * (numVerts+1));
- if(vtkCellType == VTK_TRIQUADRATIC_HEXAHEDRON)
- {
- ::QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON> newOrdering;
- ::FixQuadraticIdOrdering(connectivity, numCells, newOrdering);
- }
- else if(vtkCellType == VTK_QUADRATIC_WEDGE)
- {
- ::QuadratricOrdering<VTK_QUADRATIC_WEDGE> newOrdering;
- ::FixQuadraticIdOrdering(connectivity, numCells, newOrdering);
- }
-
- cellLocations += numCells;
- cellTypes += numCells;
- }
-
- }
-
-private:
- std::vector<EntityHandle*> Connectivity;
- std::vector<EntityHandle> UniquePoints;
-
- struct RunLengthInfo{ int type; int numVerts; int numUnusedVerts; int numCells; };
- std::vector<RunLengthInfo> Info;
-
- typedef std::vector<EntityHandle>::const_iterator EntityConstIterator;
- typedef std::vector<EntityHandle*>::const_iterator ConnConstIterator;
- typedef std::vector<RunLengthInfo>::const_iterator InfoConstIterator;
-};
-}
-#endif // __smoab_MixedCellConnectivity_h
diff --git a/tools/vtkMOABReaderNew/SimpleMoab.h b/tools/vtkMOABReaderNew/SimpleMoab.h
index 8fc54e6..4fb734c 100644
--- a/tools/vtkMOABReaderNew/SimpleMoab.h
+++ b/tools/vtkMOABReaderNew/SimpleMoab.h
@@ -5,6 +5,8 @@
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
+#include "moab/CN.hpp"
+
#include "MBTagConventions.hpp"
#include <iostream>
@@ -26,12 +28,6 @@ using moab::intersect;
using moab::subtract;
using moab::unite;
-//forward declare this->Moab for Tag
-struct Interface;
-
-//forward declar the DataSetConverter so it can be a friend of Interface
-class DataSetConverter;
-
class Tag
{
const std::string Name_;
@@ -66,10 +62,24 @@ public:
GeomTag(int d):Tag("GEOM_DIMENSION"),dim(d){}
GeomTag():Tag("GEOM_DIMENSION"), dim(0){}
+ virtual ~GeomTag(){}
+
bool isComparable() const { return dim > 0; }
int value() const { return dim; }
};
+
+//forward declare this->Moab for Tag
+struct Interface;
+
+//forward declare the DataSetConverter so it can be a friend of Interface
+class DataSetConverter;
+
+//forward declare the LoadGeometry so it can be a friend of Interface
+namespace detail{ class LoadGeometry; }
+namespace detail{ class LoadPoly; }
+
+
//light weight wrapper on a moab this->Moab that exposes only the reduced class
//that we need
class Interface
@@ -102,6 +112,37 @@ public:
}
//----------------------------------------------------------------------------
+ template<typename T>
+ T getDefaultTagVaue(moab::Tag tag) const
+ {
+ T defaultValue;
+ this->Moab->tag_get_default_value(tag,&defaultValue);
+ return defaultValue;
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getDefaultTagVaue(smoab::Tag tag) const
+ {
+ return this->getDefaultTagVaue<T>(getMoabTag(tag));
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getTagData(moab::Tag tag, const smoab::EntityHandle& entity, T value) const
+ {
+ this->Moab->tag_get_data(tag,&entity,1,&value);
+ return value;
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getTagData(smoab::Tag tag, const smoab::EntityHandle& entity, T value = T()) const
+ {
+ return this->getTagData(getMoabTag(tag),entity,value);
+ }
+
+ //----------------------------------------------------------------------------
//returns the moab name for the given entity handle if it has a sparse Name tag
std::string name(const smoab::EntityHandle& entity) const
{
@@ -119,6 +160,19 @@ public:
return std::string(name);
}
+ //----------------------------------------------------------------------------
+ //returns the geometeric dimension of an entity.
+ int dimension(const smoab::EntityHandle& entity) const
+ {
+ return this->Moab->dimension_from_handle(entity);
+ }
+
+ //----------------------------------------------------------------------------
+ //returns the geometeric dimension of an entity.
+ smoab::EntityType entityType(const smoab::EntityHandle& entity) const
+ {
+ return this->Moab->type_from_handle(entity);
+ }
//----------------------------------------------------------------------------
smoab::EntityHandle getRoot() const { return this->Moab->get_root_set(); }
@@ -133,6 +187,17 @@ public:
}
//----------------------------------------------------------------------------
+ //given a single entity handle find all items in that mesh set that aren't
+ //them selves entitysets. If recurse is true we also recurse sub entitysets
+ smoab::Range findAllMeshEntities(smoab::EntityHandle const& entity,
+ bool recurse=false) const
+ {
+ smoab::Range result;
+ this->Moab->get_entities_by_handle(entity,result,recurse);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
//Find all entities with a given tag. We don't use geom as a tag as that
//isn't a fast operation. Yes finding the intersection of geom entities and
//a material / boundary tag will be more work, but it is rarely done currently
@@ -179,60 +244,55 @@ public:
//----------------------------------------------------------------------------
//Find all entities from a given root of a given dimensionality
smoab::Range findEntitiesWithDimension(const smoab::EntityHandle root,
- int dimension) const
+ const int dimension,
+ bool recurse=false) const
{
typedef smoab::Range::const_iterator iterator;
smoab::Range result;
- this->Moab->get_entities_by_dimension(root,dimension,result);
+ this->Moab->get_entities_by_dimension(root,dimension,result,recurse);
-
- smoab::Range children;
- this->Moab->get_child_meshsets(root,children,0);
- for(iterator i=children.begin(); i !=children.end();++i)
+ if(recurse)
{
- this->Moab->get_entities_by_dimension(*i,dimension,result);
+ smoab::Range children;
+ this->Moab->get_child_meshsets(root,children,0);
+ for(iterator i=children.begin(); i !=children.end();++i)
+ {
+ this->Moab->get_entities_by_dimension(*i,dimension,result);
+ }
}
return result;
}
- //----------------------------------------------------------------------------
- smoab::Range findAdjacentEntities(const smoab::EntityHandle& entity,
- int dimension) const
- {
- const int adjType = static_cast<int>(smoab::INTERSECT);
- smoab::Range result;
- const bool create_if_missing = false;
- this->Moab->get_adjacencies(&entity,
- 1,
- dimension,
- create_if_missing,
- result,
- adjType);
- return result;
- }
- //----------------------------------------------------------------------------
- smoab::Range findAdjacentEntities(const smoab::Range& range,
- int dimension,
- const smoab::adjacency_type type = smoab::UNION) const
+ //----------------------------------------------------------------------------
+ smoab::Range findHighestDimensionEntities(const smoab::EntityHandle& entity,
+ bool recurse=false) const
{
- //the smoab and moab adjacent intersection enums are in the same order
- const int adjType = static_cast<int>(type);
- smoab::Range result;
- const bool create_if_missing = false;
- this->Moab->get_adjacencies(range,dimension,
- create_if_missing,
- result,
- adjType);
+ //the goal is to load all entities that are not entity sets of this
+ //node, while also subsetting by the highest dimension
- return result;
+ //lets find the entities of only the highest dimension
+ int num_ents=0;
+ int dim=3;
+ while(num_ents<=0&&dim>0)
+ {
+ this->Moab->get_number_entities_by_dimension(entity,dim,num_ents,recurse);
+ --dim;
+ }
+ ++dim; //reincrement to correct last decrement
+ if(num_ents > 0)
+ {
+ //we have found entities of a given dimension
+ return this->findEntitiesWithDimension(entity,dim,recurse);
+ }
+ return smoab::Range();
}
//----------------------------------------------------------------------------
//Find all elements in the database that have children and zero parents.
//this doesn't find
- smoab::Range findEntityRootParents(smoab::EntityHandle const& root) const
+ smoab::Range findEntityRootParents(const smoab::EntityHandle& root) const
{
smoab::Range parents;
@@ -258,7 +318,7 @@ public:
//----------------------------------------------------------------------------
//finds entities that have zero children and zero parents
- smoab::Range findDetachedEntities(moab::EntityHandle const& root) const
+ smoab::Range findDetachedEntities(const moab::EntityHandle& root) const
{
smoab::Range detached;
@@ -284,7 +344,7 @@ public:
//----------------------------------------------------------------------------
//find all children of the entity passed in that has multiple parents
- smoab::Range findEntitiesWithMultipleParents(smoab::EntityHandle const& root)
+ smoab::Range findEntitiesWithMultipleParents(const smoab::EntityHandle& root) const
{
smoab::Range multipleParents;
typedef moab::Range::const_iterator iterator;
@@ -305,8 +365,114 @@ public:
}
//----------------------------------------------------------------------------
+ //find all entities that are adjacent to a single entity
+ smoab::Range findAdjacencies(const smoab::EntityHandle& entity,
+ int dimension) const
+ {
+ const int adjType = static_cast<int>(smoab::INTERSECT);
+ smoab::Range result;
+ const bool create_if_missing = false;
+ this->Moab->get_adjacencies(&entity,
+ 1,
+ dimension,
+ create_if_missing,
+ result,
+ adjType);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ smoab::Range findAdjacencies(const smoab::Range& range,
+ int dimension,
+ const smoab::adjacency_type type = smoab::UNION) const
+ {
+ //the smoab and moab adjacent intersection enums are in the same order
+ const int adjType = static_cast<int>(type);
+ smoab::Range result;
+ const bool create_if_missing = false;
+ this->Moab->get_adjacencies(range,dimension,
+ create_if_missing,
+ result,
+ adjType);
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ //create adjacencies, only works when the dimension requested is lower than
+ //dimension of the range of entities
+ smoab::Range createAdjacencies(const smoab::Range& range,
+ int dimension,
+ const smoab::adjacency_type type = smoab::UNION) const
+ {
+ //the smoab and moab adjacent intersection enums are in the same order
+ const int adjType = static_cast<int>(type);
+ smoab::Range result;
+ const bool create_if_missing = true;
+ this->Moab->get_adjacencies(range,dimension,
+ create_if_missing,
+ result,
+ adjType);
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ int numChildMeshSets(const smoab::EntityHandle& root) const
+ {
+ int numChildren;
+ this->Moab->num_child_meshsets(root,&numChildren);
+ return numChildren;
+ }
+
+ //----------------------------------------------------------------------------
+ smoab::Range getChildSets(const smoab::EntityHandle& root) const
+ {
+ smoab::Range children;
+ this->Moab->get_child_meshsets(root,children,0);
+ return children;
+ }
+
+ //----------------------------------------------------------------------------
+ //remove a collection of entities from the database
+ void remove(smoab::Range const& toDelete) const
+ {
+ this->Moab->delete_entities(toDelete);
+ }
+
+ //----------------------------------------------------------------------------
+ //a entityHandle with value zero means no side element was found
+ smoab::EntityHandle sideElement(smoab::EntityHandle const& cell,
+ int dim, int side) const
+ {
+ smoab::EntityHandle result(0);
+ this->Moab->side_element(cell,dim,side,result);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ //returns all the existing side elements of a cell, elements that
+ //are zero mean that side element doesn't exist
+ std::vector<smoab::EntityHandle> sideElements(
+ smoab::EntityHandle const& cell,
+ int dim) const
+ {
+ const EntityType volumeCellType = this->Moab->type_from_handle(cell);
+ const int numSides = static_cast<int>(moab::CN::NumSubEntities(
+ volumeCellType, dim));
+
+ std::vector<smoab::EntityHandle> result(numSides);
+ for (int side = 0; side < numSides; ++side)
+ {
+ smoab::EntityHandle *sideElem = &result[side]; //get memory of vector
+ this->Moab->side_element(cell,dim,side,*sideElem);
+ }
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
//prints all elements in a range objects
- void printRange(smoab::Range const& range)
+ void printRange(const smoab::Range& range) const
{
typedef Range::const_iterator iterator;
for(iterator i=range.begin(); i!=range.end(); ++i)
@@ -315,12 +481,25 @@ public:
this->Moab->list_entity(*i);
}
}
-
friend class smoab::DataSetConverter;
+ friend class smoab::detail::LoadGeometry;
+ friend class smoab::detail::LoadPoly;
private:
moab::Interface* Moab;
};
+//----------------------------------------------------------------------------
+void RangeToVector(const smoab::Range &range,
+ std::vector<smoab::EntityHandle>& vector )
+{
+ vector.reserve(range.size());
+ std::copy(range.begin(),
+ range.end(),
+ std::back_inserter(vector));
+}
+
+
+
}
#endif
diff --git a/tools/vtkMOABReaderNew/detail/CellTypeToType.h b/tools/vtkMOABReaderNew/detail/CellTypeToType.h
new file mode 100644
index 0000000..b2955e4
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/CellTypeToType.h
@@ -0,0 +1,147 @@
+#ifndef __smoab_detail_CellTypeToType_h
+#define __smoab_detail_CellTypeToType_h
+
+#include "vtkCellType.h"
+#include <algorithm>
+
+namespace smoab{ namespace detail{
+
+template<int N> struct QuadratricOrdering{};
+
+template<> struct QuadratricOrdering<VTK_QUADRATIC_WEDGE>
+{
+ static const int NUM_VERTS = 15;
+ void reorder(vtkIdType* connectivity) const
+ {
+ std::swap_ranges(connectivity+9,connectivity+12,connectivity+12);
+ }
+};
+
+template<> struct QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON>
+{
+ static const int NUM_VERTS = 27;
+ void reorder(vtkIdType* connectivity) const
+ {
+ std::swap_ranges(connectivity+12,connectivity+16,connectivity+16);
+
+ //move 20 to 22
+ //move 22 to 23
+ //move 23 to 20
+
+ //swap 20 with 22
+ std::swap(connectivity[20],connectivity[23]);
+
+ //swap 22 with 23
+ std::swap(connectivity[22],connectivity[23]);
+ }
+};
+
+template<typename QuadraticOrdering>
+void FixQuadraticIdOrdering(vtkIdType* connectivity, vtkIdType numCells,
+ QuadraticOrdering& ordering)
+{
+ //skip the first index that holds the length of the cells
+ //if we skip it once here, and than properly increment it makes the code
+ //far easier
+ connectivity+=1;
+ for(vtkIdType i=0; i < numCells; ++i)
+ {
+ ordering.reorder(connectivity);
+ connectivity += ordering.NUM_VERTS + 1;
+ }
+}
+
+
+int vtkCellType(moab::EntityType t, int &num_connect)
+ {
+ int ctype = -1;
+ switch (t)
+ {
+ case moab::MBEDGE:
+ if (num_connect == 2) ctype = VTK_LINE;
+ else if (num_connect == 3) ctype = VTK_QUADRATIC_EDGE;
+ break;
+ case moab::MBTRI:
+ if (num_connect == 3) ctype = VTK_TRIANGLE;
+ else if (num_connect == 6) ctype = VTK_QUADRATIC_TRIANGLE;
+ else if (num_connect == 7) ctype = VTK_BIQUADRATIC_TRIANGLE;
+ break;
+ case moab::MBQUAD:
+ if (num_connect == 4) ctype = VTK_QUAD;
+ else if (num_connect == 8) ctype = VTK_QUADRATIC_QUAD;
+ else if (num_connect == 9) ctype = VTK_BIQUADRATIC_QUAD;
+ break;
+ case moab::MBPOLYGON:
+ if (num_connect == 4) ctype = VTK_POLYGON;
+ break;
+ case moab::MBTET:
+ if (num_connect == 4) ctype = VTK_TETRA;
+ else if (num_connect == 10) ctype = VTK_QUADRATIC_TETRA;
+ break;
+ case moab::MBPYRAMID:
+ if (num_connect == 5) ctype = VTK_PYRAMID;
+ else if (num_connect == 13) ctype = VTK_QUADRATIC_PYRAMID;
+ break;
+ case moab::MBPRISM:
+ if (num_connect == 6) ctype = VTK_WEDGE;
+ else if (num_connect == 15) ctype = VTK_QUADRATIC_WEDGE;
+ break;
+ case moab::MBHEX:
+ if (num_connect == 8) ctype = VTK_HEXAHEDRON;
+ else if (num_connect == 20) ctype = VTK_QUADRATIC_HEXAHEDRON;
+ else if (num_connect == 21) ctype = VTK_QUADRATIC_HEXAHEDRON, num_connect = 20;
+ else if (num_connect == 27) ctype = VTK_TRIQUADRATIC_HEXAHEDRON;
+ break;
+ default:
+ ctype = -1;
+ break;
+ }
+ return ctype;
+ }
+
+int vtkLinearCellType(moab::EntityType t, int &num_connect)
+ {
+ int ctype = -1;
+ switch (t)
+ {
+ case moab::MBEDGE:
+ ctype = VTK_LINE;
+ num_connect = 2;
+ break;
+ case moab::MBTRI:
+ ctype = VTK_TRIANGLE;
+ num_connect = 3;
+ break;
+ case moab::MBQUAD:
+ ctype = VTK_QUAD;
+ num_connect = 4;
+ break;
+ case moab::MBPOLYGON:
+ ctype = VTK_POLYGON;
+ num_connect = 4;
+ break;
+ case moab::MBTET:
+ ctype = VTK_TETRA;
+ num_connect = 4;
+ break;
+ case moab::MBPYRAMID:
+ ctype = VTK_PYRAMID;
+ num_connect = 5;
+ break;
+ case moab::MBPRISM:
+ ctype = VTK_WEDGE;
+ num_connect = 6;
+ break;
+ case moab::MBHEX:
+ ctype = VTK_HEXAHEDRON;
+ num_connect = 8;
+ break;
+ default:
+ break;
+ }
+ return ctype;
+ }
+
+} } //namespace smaob::detail
+
+#endif // CELLTYPETOTYPE_H
diff --git a/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h b/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h
new file mode 100644
index 0000000..28319df
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h
@@ -0,0 +1,18 @@
+#ifndef __smoab_detail_ContinousCellInfo_h
+#define __smoab_detail_ContinousCellInfo_h
+
+
+namespace smoab { namespace detail {
+
+struct ContinousCellInfo
+{
+ int type;
+ int numVerts;
+ int numUnusedVerts;
+ int numCells;
+
+};
+
+} } //namespace smoab::detail
+
+#endif
diff --git a/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h b/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h
new file mode 100644
index 0000000..1b94548
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h
@@ -0,0 +1,219 @@
+#ifndef __smoab_LinearCellConnectivity_h
+#define __smoab_LinearCellConnectivity_h
+
+#include "CellTypeToType.h"
+#include "ContinousCellInfo.h"
+
+#include <algorithm>
+#include <vector>
+
+namespace smoab { namespace detail {
+
+namespace internal
+{
+ //we want a subset of the real connetivity array,
+ //this does that for use with a super easy wrapper
+ struct SubsetArray
+ {
+ SubsetArray(EntityHandle* realConn,
+ int numCells,
+ int currentVertsPerCell,
+ int newVertsPerCell):
+ Array()
+ {
+ const int size = numCells*newVertsPerCell;
+ this->Array.reserve(size);
+ if(currentVertsPerCell == newVertsPerCell)
+ {
+ std::copy(realConn,realConn+size, std::back_inserter(this->Array));
+ }
+ else
+ {
+ //skip copy only the first N points which we want
+ //since moab stores linear points first per cell
+ EntityHandle *pos = realConn;
+ for(int i=0; i < numCells;++i)
+ {
+ std::copy(pos,pos+newVertsPerCell,std::back_inserter(this->Array));
+ pos += currentVertsPerCell;
+ }
+ }
+ }
+ typedef std::vector<EntityHandle>::const_iterator const_iterator;
+ typedef std::vector<EntityHandle>::iterator iterator;
+
+ const_iterator begin() const { return this->Array.begin(); }
+ iterator begin() { return this->Array.begin(); }
+
+ const_iterator end() const { return this->Array.end(); }
+ iterator end(){ return this->Array.end(); }
+
+ private:
+ std::vector<EntityHandle> Array;
+ };
+}
+
+class LinearCellConnectivity
+{
+public:
+
+ LinearCellConnectivity(smoab::Range const& cells, moab::Interface* moab):
+ Connectivity(),
+ UniquePoints(),
+ Info()
+ {
+ int count = 0;
+ const std::size_t cellSize=cells.size();
+ while(count != cellSize)
+ {
+ EntityHandle* connectivity;
+ int numVerts=0, iterationCount=0;
+ //use the highly efficent calls, since we know that are of the same dimension
+ moab->connect_iterate(cells.begin()+count,
+ cells.end(),
+ connectivity,
+ numVerts,
+ iterationCount);
+ //if we didn't read anything, break!
+ if(iterationCount == 0)
+ {
+ break;
+ }
+
+ //identify the cell type that we currently have,
+ //store that along with the connectivity in a temp storage vector
+ const moab::EntityType type = moab->type_from_handle(*cells.begin()+count);
+
+ int vtkNumVerts;
+ int vtkCellType = smoab::detail::vtkLinearCellType(type,vtkNumVerts);
+
+ ContinousCellInfo info = { vtkCellType, vtkNumVerts, 0, iterationCount };
+ this->Info.push_back(info);
+
+
+ //we need to copy only a subset of the connectivity array
+ internal::SubsetArray conn(connectivity,iterationCount,numVerts,vtkNumVerts);
+ this->Connectivity.push_back(conn);
+
+ count += iterationCount;
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void compactIds(vtkIdType& numCells, vtkIdType& connectivityLength)
+ {
+ //converts all the ids to be ordered starting at zero, and also
+ //keeping the orginal logical ordering. Stores the result of this
+ //operation in the unstrucutred grid that is passed in
+
+ //lets determine the total length of the connectivity
+ connectivityLength = 0;
+ numCells = 0;
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i)
+ {
+ connectivityLength += (*i).numCells * (*i).numVerts;
+ numCells += (*i).numCells;
+ }
+
+ this->UniquePoints.reserve(connectivityLength);
+
+ this->copyConnectivity(this->UniquePoints);
+ std::sort(this->UniquePoints.begin(),this->UniquePoints.end());
+
+ typedef std::vector<EntityHandle>::iterator EntityIterator;
+ EntityIterator newEnd = std::unique(this->UniquePoints.begin(),
+ this->UniquePoints.end());
+
+ const std::size_t newSize = std::distance(this->UniquePoints.begin(),newEnd);
+ this->UniquePoints.resize(newSize);
+ }
+
+ //----------------------------------------------------------------------------
+ void moabPoints(smoab::Range& range) const
+ {
+ //from the documentation a reverse iterator is the fastest way
+ //to insert into a range.
+ std::copy(this->UniquePoints.rbegin(),
+ this->UniquePoints.rend(),
+ moab::range_inserter(range));
+ }
+
+ //----------------------------------------------------------------------------
+ //copy the connectivity from the moab held arrays to the user input vector
+ void copyConnectivity(std::vector<EntityHandle>& output) const
+ {
+ //walk the info to find the length of each sub connectivity array,
+ //and insert them into the vector, ordering is implied by the order
+ //the connecitivy sub array are added to this class
+ ConnConstIterator c = this->Connectivity.begin();
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i,++c)
+ {
+ //remember our Connectivity is a vector of pointers whose
+ //length is held in the info vector.
+ const int numUnusedPoints = (*i).numUnusedVerts;
+ const int connLength = (*i).numCells * (*i).numVerts;
+ std::copy(c->begin(),c->end(),std::back_inserter(output));
+ }
+ }
+
+ //copy the information from this contianer to a vtk cell array, and
+ //related lookup information
+ void copyToVtkCellInfo(vtkIdType* cellArray) const
+ {
+ ConnConstIterator c = this->Connectivity.begin();
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i, ++c)
+ {
+ //for this group of the same cell type we need to fill the cellTypes
+ const int numCells = (*i).numCells;
+ const int numVerts = (*i).numVerts;
+
+ //for each cell in this collection that have the same type
+ //grab the raw array now, so we can properly increment for each vert in each cell
+ internal::SubsetArray::const_iterator moabConnectivity = c->begin();
+ for(int j=0;j < numCells; ++j)
+ {
+ //cell arrays start and end are different, since we
+ //have to account for element that states the length of each cell
+ cellArray[0]=numVerts;
+
+
+ for(int k=0; k < numVerts; ++k, ++moabConnectivity )
+ {
+ //this is going to be a root of some failures when we start
+ //reading really large datasets under 32bit.
+
+
+ //fyi, don't use a range ds for unique points, distance
+ //function is horribly slow they need to override it
+ EntityConstIterator result = std::lower_bound(
+ this->UniquePoints.begin(),
+ this->UniquePoints.end(),
+ *moabConnectivity);
+ std::size_t newId = std::distance(this->UniquePoints.begin(),
+ result);
+ cellArray[k+1] = static_cast<vtkIdType>(newId);
+ }
+ cellArray += numVerts+1;
+ }
+ }
+ }
+
+private:
+ std::vector<internal::SubsetArray> Connectivity;
+ std::vector<EntityHandle> UniquePoints;
+
+ std::vector<detail::ContinousCellInfo> Info;
+
+ typedef std::vector<EntityHandle>::const_iterator EntityConstIterator;
+ typedef std::vector<internal::SubsetArray>::const_iterator ConnConstIterator;
+ typedef std::vector<detail::ContinousCellInfo>::const_iterator InfoConstIterator;
+};
+} } //namespace smoab::detail
+
+#endif // __smoab_LinearCellConnectivity_h
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/fathomteam/moab/commits/dcd789d7817e/
Changeset: dcd789d7817e
Branch: master
User: vijaysm
Date: 2014-07-13 00:49:31
Summary: Merged in judajake/moab/update_vtk_plugin (pull request #23)
Update VTKReader Paraview plugin for MOAB
Affected #: 19 files
diff --git a/tools/vtkMOABReaderNew/CMakeLists.txt.in b/tools/vtkMOABReaderNew/CMakeLists.txt.in
index 8b8f888..e005289 100644
--- a/tools/vtkMOABReaderNew/CMakeLists.txt.in
+++ b/tools/vtkMOABReaderNew/CMakeLists.txt.in
@@ -13,13 +13,22 @@ find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
include_directories(${PARAVIEW_INCLUDE_DIRS})
include_directories(@srcdir@)
+include_directories(@srcdir@/detail)
set(headers
- @srcdir@/SimpleMoab.h
- @srcdir@/CellTypeToType.h
+ @srcdir@/CellSets.h
@srcdir@/DataSetConverter.h
- @srcdir@/MixedCellConnectivity.h
- @srcdir@/vtkMoabReader.h
+ @srcdir@/detail/CellTypeToType.h
+ @srcdir@/detail/ContinousCellInfo.h
+ @srcdir@/detail/LoadGeometry.h
+ @srcdir@/detail/MixedCellConnectivity.h
+ @srcdir@/detail/ReadSparseTag.h
+ @srcdir@/detail/ReduceSpectralMesh.h
+ @srcdir@/detail/ReduceSpectralMesh.h
+ @srcdir@/detail/UsageTable.h
+ @srcdir@/ExtractShell.h
+ @srcdir@/FaceSets.h
+ @srcdir@/SimpleMoab.h
)
add_paraview_plugin(vtkMoabReaderPlugin "5.0"
diff --git a/tools/vtkMOABReaderNew/CellSets.h b/tools/vtkMOABReaderNew/CellSets.h
new file mode 100644
index 0000000..6171aec
--- /dev/null
+++ b/tools/vtkMOABReaderNew/CellSets.h
@@ -0,0 +1,75 @@
+
+#ifndef __smoab_CellSets_h
+#define __smoab_CellSets_h
+
+#include "SimpleMoab.h"
+
+namespace smoab
+{
+//----------------------------------------------------------------------------
+class CellSet
+{
+public:
+ CellSet(smoab::EntityHandle p,const smoab::Range& cells):
+ Entity(p),
+ Cells(cells)
+ {}
+
+ const smoab::Range& cells() const { return this->Cells; }
+ EntityHandle entity() const { return this->Entity; }
+
+ bool contains(smoab::EntityHandle c) const
+ {
+ return this->Cells.find(c) != this->Cells.end();
+ }
+
+ void erase(smoab::Range cells)
+ {
+ //seems that erase() has a bug, so use subtract
+ this->Cells = smoab::subtract(this->Cells,cells);
+ }
+
+private:
+ smoab::EntityHandle Entity;
+ smoab::Range Cells;
+};
+
+//----------------------------------------------------------------------------
+//CellSets are just a vector of CellSets
+typedef std::vector<CellSet> CellSets;
+
+//----------------------------------------------------------------------------
+//templated so it works with FaceCellSets and CellSets
+template<typename T>
+smoab::Range getParents(const T& set)
+{
+ typedef typename T::const_iterator iterator;
+ smoab::Range result;
+
+ for(iterator i=set.begin(); i != set.end(); ++i)
+ {
+ result.insert(i->entity());
+ }
+ return result;
+}
+
+//----------------------------------------------------------------------------
+//templated so it works with FaceCellSets and CellSets
+template<typename T>
+smoab::Range getAllCells(const T& set)
+{
+ typedef typename T::const_iterator iterator;
+ smoab::Range result;
+
+ for(iterator i=set.begin(); i != set.end(); ++i)
+ {
+ smoab::Range c = i->cells();
+ result.insert(c.begin(),c.end());
+ }
+ return result;
+}
+
+
+}
+
+#endif
diff --git a/tools/vtkMOABReaderNew/CellTypeToType.h b/tools/vtkMOABReaderNew/CellTypeToType.h
deleted file mode 100644
index 6ff91af..0000000
--- a/tools/vtkMOABReaderNew/CellTypeToType.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __smoab_CellTypeToType_h
-#define __smoab_CellTypeToType_h
-
-#include "SimpleMoab.h"
-#include "vtkCellType.h"
-
-namespace smoab
-{
-template<int> struct CellTypeToType;
-
-int vtkCellType(moab::EntityType t, int &num_connect)
- {
- int ctype = -1;
- switch (t)
- {
- case moab::MBEDGE:
- if (num_connect == 2) ctype = VTK_LINE;
- else if (num_connect == 3) ctype = VTK_QUADRATIC_EDGE;
- break;
- case moab::MBTRI:
- if (num_connect == 3) ctype = VTK_TRIANGLE;
- else if (num_connect == 6) ctype = VTK_QUADRATIC_TRIANGLE;
- else if (num_connect == 7) ctype = VTK_BIQUADRATIC_TRIANGLE;
- break;
- case moab::MBQUAD:
- if (num_connect == 4) ctype = VTK_QUAD;
- else if (num_connect == 8) ctype = VTK_QUADRATIC_QUAD;
- else if (num_connect == 9) ctype = VTK_BIQUADRATIC_QUAD;
- break;
- case moab::MBPOLYGON:
- if (num_connect == 4) ctype = VTK_POLYGON;
- break;
- case moab::MBTET:
- if (num_connect == 4) ctype = VTK_TETRA;
- else if (num_connect == 10) ctype = VTK_QUADRATIC_TETRA;
- break;
- case moab::MBPYRAMID:
- if (num_connect == 5) ctype = VTK_PYRAMID;
- else if (num_connect == 13) ctype = VTK_QUADRATIC_PYRAMID;
- break;
- case moab::MBPRISM:
- if (num_connect == 6) ctype = VTK_WEDGE;
- else if (num_connect == 15) ctype = VTK_QUADRATIC_WEDGE;
- break;
- case moab::MBHEX:
- if (num_connect == 8) ctype = VTK_HEXAHEDRON;
- else if (num_connect == 20) ctype = VTK_QUADRATIC_HEXAHEDRON;
- else if (num_connect == 21) ctype = VTK_QUADRATIC_HEXAHEDRON, num_connect = 20;
- else if (num_connect == 27) ctype = VTK_TRIQUADRATIC_HEXAHEDRON;
- break;
- default:
- ctype = -1;
- break;
- }
- return ctype;
- }
-}
-
-#endif // CELLTYPETOTYPE_H
diff --git a/tools/vtkMOABReaderNew/DataSetConverter.h b/tools/vtkMOABReaderNew/DataSetConverter.h
index bfae086..3edadf0 100644
--- a/tools/vtkMOABReaderNew/DataSetConverter.h
+++ b/tools/vtkMOABReaderNew/DataSetConverter.h
@@ -2,20 +2,16 @@
#define __smoab_DataSetConverter_h
#include "SimpleMoab.h"
-#include "CellTypeToType.h"
-#include "MixedCellConnectivity.h"
+#include "CellSets.h"
+#include "detail/LoadGeometry.h"
+#include "detail/ReadSparseTag.h"
-#include <vtkCellArray.h>
#include <vtkCellData.h>
#include <vtkDoubleArray.h>
#include <vtkFieldData.h>
#include <vtkIntArray.h>
#include <vtkIdTypeArray.h>
#include <vtkNew.h>
-#include <vtkPointData.h>
-#include <vtkPoints.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkUnstructuredGrid.h>
#include <algorithm>
@@ -35,17 +31,13 @@ public:
Moab(interface.Moab),
Tag(tag),
ReadMaterialIds(false),
- ReadProperties(false),
- MaterialName("Material")
+ ReadProperties(false)
{
}
void readMaterialIds(bool add) { this->ReadMaterialIds = add; }
bool readMaterialIds() const { return this->ReadMaterialIds; }
- void materialIdName(const std::string& name) { this->MaterialName = name; }
- const std::string& materialIdName() const { return this->MaterialName; }
-
void readProperties(bool readProps) { this->ReadProperties = readProps; }
bool readProperties() const { return this->ReadProperties; }
@@ -54,109 +46,65 @@ public:
//grid. Currently doesn't support reading properties.
//Will read in material ids, if no material id is assigned to an entity,
//its cells will be given an unique id
+ template<typename VTKGridType>
bool fill(const smoab::Range& entities,
- vtkUnstructuredGrid* grid) const
+ VTKGridType* grid) const
{
//create a helper datastructure which can determines all the unique point ids
//and converts moab connecitvity info to vtk connectivity
- moab::Range cells;
- //append all the entities cells together into a single range
+
+ //get all the cells for each parent entity and create
+ // an entity set of those items
+ int dim = this->Tag->value();
typedef smoab::Range::const_iterator iterator;
+ smoab::CellSets entitySets;
for(iterator i=entities.begin(); i!= entities.end(); ++i)
{
+ smoab::Range entitiesCells;
if(this->Tag->isComparable())
{
//if we are comparable only find the cells that match our tags dimension
- smoab::Range entitiesCells = this->Interface.findEntitiesWithDimension(*i,Tag->value());
- cells.insert(entitiesCells.begin(),entitiesCells.end());
+ entitiesCells = this->Interface.findEntitiesWithDimension(*i,dim,true);
}
else
{
- //this is a bad representation of all other tags, but we are presuming that
- //neuman and dirichlet are on entitysets with no children
- this->Moab->get_entities_by_handle(*i,cells);
+ entitiesCells = this->Interface.findHighestDimensionEntities(*i,true);
}
+ smoab::CellSet set(*i,entitiesCells);
+ entitySets.push_back(set);
}
- smoab::Range points;
- this->loadCellsAndPoints(cells,points,grid);
-
- if(this->readMaterialIds())
- {
- typedef std::vector<smoab::EntityHandle>::const_iterator EntityHandleIterator;
- typedef std::vector<int>::const_iterator IdConstIterator;
- typedef std::vector<int>::iterator IdIterator;
-
- std::vector<smoab::EntityHandle> searchableCells;
- searchableCells.reserve(grid->GetNumberOfCells());
- std::copy(cells.begin(),cells.end(),std::back_inserter(searchableCells));
- cells.clear(); //release memory we don't need
+ moab::Range cells = smoab::getAllCells(entitySets);
- std::vector<int> materialIds(entities.size());
- //first off iterate the entities and determine which ones
- //have moab material ids
+ //convert the datastructure from a list of cells to a vtk data set
+ detail::LoadGeometry loadGeom(cells,dim,this->Interface);
+ loadGeom.fill(grid);
- //wrap this area with scope, to remove local variables
+ if(this->readMaterialIds())
{
- smoab::MaterialTag tag;
- IdIterator materialIndex = materialIds.begin();
- for(iterator i=entities.begin();
- i != entities.end();
- ++i, ++materialIndex)
- {
- moab::Tag mtag = this->Interface.getMoabTag(tag);
-
- int value=-1;
- this->Moab->tag_get_data(mtag,&(*i),1,&value);
- *materialIndex=static_cast<int>(value);
- }
-
- //now determine ids for all entities that don't have materials
- IdConstIterator maxPos = std::max_element(materialIds.begin(),
- materialIds.end());
- int maxMaterial = *maxPos;
- for(IdIterator i=materialIds.begin(); i!= materialIds.end(); ++i)
- {
- if(*i==-1)
- {
- *i = ++maxMaterial;
- }
- }
- }
- //now we create the material field, and set all the values
- vtkNew<vtkIntArray> materialSet;
- materialSet->SetName(this->materialIdName().c_str());
- materialSet->SetNumberOfValues(grid->GetNumberOfCells());
+ detail::ReadSparseTag materialTagReading(entitySets,
+ cells,
+ this->Interface);
- IdConstIterator materialValue = materialIds.begin();
- for(iterator i=entities.begin(); i!= entities.end(); ++i, ++materialValue)
- {
- //this is a time vs memory trade off, I don't want to store
- //the all the cell ids twice over, lets use more time
- smoab::Range entitiesCells;
- if(this->Tag->isComparable())
- {entitiesCells = this->Interface.findEntitiesWithDimension(*i,Tag->value());}
- else
- {this->Moab->get_entities_by_handle(*i,entitiesCells);}
-
- EntityHandleIterator s_begin = searchableCells.begin();
- EntityHandleIterator s_end = searchableCells.end();
- for(iterator j=entitiesCells.begin(); j != entitiesCells.end();++j)
- {
- EntityHandleIterator result = std::lower_bound(s_begin,
- s_end,
- *j);
- std::size_t newId = std::distance(s_begin,result);
- materialSet->SetValue(static_cast<int>(newId), *materialValue);
- }
- }
+ smoab::MaterialTag mtag;
+ vtkNew<vtkIntArray> materials;
+ materials->SetName(mtag.name());
+ materialTagReading.fill(materials.GetPointer(),&mtag);
+ grid->GetCellData()->AddArray(materials.GetPointer());
+ }
- grid->GetCellData()->AddArray(materialSet.GetPointer());
+ //by default we always try to load the default tag
+ detail::ReadSparseTag sTagReading(entitySets,
+ cells,
+ this->Interface);
- }
+ vtkNew<vtkIntArray> sparseTagData;
+ sparseTagData->SetName(this->Tag->name());
+ sTagReading.fill(sparseTagData.GetPointer(),this->Tag);
+ grid->GetCellData()->AddArray(sparseTagData.GetPointer());
return true;
}
@@ -165,28 +113,32 @@ public:
//given a single entity handle create a unstructured grid from it.
//optional third parameter is the material id to use if readMaterialIds
//is on, and no material sparse tag is found for this entity
+ template<typename VTKGridType>
bool fill(const smoab::EntityHandle& entity,
- vtkUnstructuredGrid* grid,
+ VTKGridType* grid,
const int materialId=0) const
{
//create a helper datastructure which can determines all the unique point ids
//and converts moab connecitvity info to vtk connectivity
- moab::Range cells;
+
+ smoab::Range cells;
+ int dim = this->Tag->value();
if(this->Tag->isComparable())
{
//if we are comparable only find the cells that match our tags dimension
- cells = this->Interface.findEntitiesWithDimension(entity,Tag->value());
+ cells = this->Interface.findEntitiesWithDimension(entity,dim,true);
}
else
{
- //this is a bad representation of all other tags, but we are presuming that
- //neuman and dirichlet are on entitysets with no children
- this->Moab->get_entities_by_handle(entity,cells);
+ //load subentities
+ cells = this->Interface.findHighestDimensionEntities(entity,true);
}
- smoab::Range points;
- this->loadCellsAndPoints(cells,points,grid);
+ //convert the datastructure from a list of cells to a vtk data set
+ detail::LoadGeometry loadGeom(cells,dim,this->Interface);
+ loadGeom.fill(grid);
+ const smoab::Range& points = loadGeom.moabPoints();
if(this->readProperties())
{
@@ -194,53 +146,34 @@ public:
this->readProperties(points,grid->GetPointData());
}
+ smoab::CellSets cellSets;
+ smoab::CellSet set(entity,cells);
+ cellSets.push_back(set);
if(this->readMaterialIds())
{
- this->readSparseTag(smoab::MaterialTag(),entity,
- grid->GetNumberOfCells(),
- grid->GetCellData(),
- materialId);
- }
- return true;
- }
+ smoab::MaterialTag mtag;
+ detail::ReadSparseTag materialTagReading(cellSets,
+ cells,
+ this->Interface);
- //----------------------------------------------------------------------------
- void loadCellsAndPoints(const smoab::Range& cells,
- smoab::Range& points,
- vtkUnstructuredGrid* grid) const
- {
+ vtkNew<vtkIntArray> materials;
+ materials->SetName(mtag.name());
+ materialTagReading.fill(materials.GetPointer(),&mtag);
+ grid->GetCellData()->AddArray(materials.GetPointer());
- smoab::MixedCellConnectivity mixConn(cells,this->Moab);
-
- //now that mixConn has all the cells properly stored, lets fixup
- //the ids so that they start at zero and keep the same logical ordering
- //as before.
- vtkIdType numCells, connLen;
- mixConn.compactIds(numCells,connLen);
- this->setGridsTopology(mixConn,grid,numCells,connLen);
+ }
- mixConn.moabPoints(points);
+ //by default we always try to load the default tag
+ detail::ReadSparseTag sTagReading(cellSets,
+ cells,
+ this->Interface);
- vtkNew<vtkPoints> newPoints;
- this->addCoordinates(points,newPoints.GetPointer());
- grid->SetPoints(newPoints.GetPointer());
+ vtkNew<vtkIntArray> sparseTagData;
+ sparseTagData->SetName(this->Tag->name());
+ sTagReading.fill(sparseTagData.GetPointer(),this->Tag);
+ grid->GetCellData()->AddArray(sparseTagData.GetPointer());
- }
-
- //----------------------------------------------------------------------------
- void addCoordinates(smoab::Range pointEntities, vtkPoints* pointContainer) const
- {
- //since the smoab::range are always unique and sorted
- //we can use the more efficient coords_iterate
- //call in moab, which returns moab internal allocated memory
- pointContainer->SetDataTypeToDouble();
- pointContainer->SetNumberOfPoints(pointEntities.size());
-
- //need a pointer to the allocated vtkPoints memory so that we
- //don't need to use an extra copy and we can bypass all vtk's check
- //on out of bounds
- double *rawPoints = static_cast<double*>(pointContainer->GetVoidPointer(0));
- this->Moab->get_coords(pointEntities,rawPoints);
+ return true;
}
private:
@@ -260,36 +193,6 @@ private:
}
//----------------------------------------------------------------------------
- bool readSparseTag(smoab::Tag tag,
- smoab::EntityHandle const& entity,
- vtkIdType length,
- vtkFieldData* field,
- vtkIdType defaultValue) const
- {
-
- typedef std::vector<moab::Tag>::const_iterator iterator;
- moab::Tag mtag = this->Interface.getMoabTag(tag);
-
- int value=0;
- moab::ErrorCode rval = this->Moab->tag_get_data(mtag,&entity,1,&value);
- if(rval!=moab::MB_SUCCESS)
- {
- value = defaultValue;
- }
-
- vtkNew<vtkIntArray> materialSet;
- materialSet->SetNumberOfValues(length);
- materialSet->SetName(this->materialIdName().c_str());
-
- int *raw = static_cast<int*>(materialSet->GetVoidPointer(0));
- std::fill(raw,raw+length,value);
-
- field->AddArray(materialSet.GetPointer());
-
- return true;
- }
-
- //----------------------------------------------------------------------------
void readDenseTags(std::vector<moab::Tag> &tags,
smoab::Range const& entities,
vtkFieldData* field) const
@@ -359,36 +262,7 @@ private:
}
}
- //----------------------------------------------------------------------------
- void setGridsTopology(smoab::MixedCellConnectivity const& mixedCells,
- vtkUnstructuredGrid* grid,
- vtkIdType numCells,
- vtkIdType numConnectivity) const
- {
- //correct the connectivity size to account for the vtk padding
- const vtkIdType vtkConnectivity = numCells + numConnectivity;
- vtkNew<vtkIdTypeArray> cellArray;
- vtkNew<vtkIdTypeArray> cellLocations;
- vtkNew<vtkUnsignedCharArray> cellTypes;
-
- cellArray->SetNumberOfValues(vtkConnectivity);
- cellLocations->SetNumberOfValues(numCells);
- cellTypes->SetNumberOfValues(numCells);
-
- vtkIdType* rawArray = static_cast<vtkIdType*>(cellArray->GetVoidPointer(0));
- vtkIdType* rawLocations = static_cast<vtkIdType*>(cellLocations->GetVoidPointer(0));
- unsigned char* rawTypes = static_cast<unsigned char*>(cellTypes->GetVoidPointer(0));
-
- mixedCells.copyToVtkCellInfo(rawArray,rawLocations,rawTypes);
-
- vtkNew<vtkCellArray> cells;
- cells->SetCells(numCells,cellArray.GetPointer());
- grid->SetCells(cellTypes.GetPointer(),
- cellLocations.GetPointer(),
- cells.GetPointer(),
- NULL,NULL);
- }
};
}
diff --git a/tools/vtkMOABReaderNew/ExtractShell.h b/tools/vtkMOABReaderNew/ExtractShell.h
new file mode 100644
index 0000000..359fbce
--- /dev/null
+++ b/tools/vtkMOABReaderNew/ExtractShell.h
@@ -0,0 +1,80 @@
+#ifndef __smoab_ExtractShell_h
+#define __smoab_ExtractShell_h
+
+#include "SimpleMoab.h"
+#include "detail/UsageTable.h"
+
+#include <algorithm>
+
+namespace smoab{
+
+class ExtractShell
+{
+ const smoab::Interface& Interface;
+ smoab::CellSets VCells;
+
+public:
+ ExtractShell(const smoab::CellSets volCells,
+ const smoab::Interface& interface):
+ Interface(interface),
+ VCells(volCells)
+ {
+ }
+
+ bool findSkins(smoab::CellSets &surfaceCellSets);
+};
+
+
+//----------------------------------------------------------------------------
+bool ExtractShell::findSkins(smoab::CellSets &surfaceCellSets)
+{
+ typedef smoab::Range::const_iterator Iterator;
+
+ typedef smoab::CellSets::const_iterator SetIterator;
+
+
+ smoab::Range cellsToRemove;
+ for(SetIterator set = this->VCells.begin();
+ set != this->VCells.end();
+ ++set)
+ {
+ const smoab::Range &cells = set->cells();
+ this->Interface.createAdjacencies(set->cells(),2);
+
+
+ //we create the usage table for each iteration so that we only
+ //get the shell of each cell set. If we used the table between
+ //sets we would get the shell of the combined sets
+ smoab::detail::UsageTable table;
+ for(Iterator i = cells.begin(); i != cells.end(); ++i)
+ {
+ std::vector<smoab::EntityHandle> faceCells =
+ this->Interface.sideElements(*i,2);
+
+ //the usage id allows you to label cells when going into the table
+ //so that you can extract multiple shells where each is based on
+ //a single region id.
+ std::vector<int> regionId(1,faceCells.size());
+ table.incrementUsage(faceCells,regionId);
+ }
+ smoab::Range surfaceCells = table.singleUsage();
+
+ //create a new cell set that
+ smoab::CellSet surfaceSet(set->entity(),surfaceCells);
+ surfaceCellSets.push_back(surfaceSet);
+
+ smoab::Range subsetToRemove = table.multipleUsage();
+ cellsToRemove.insert(subsetToRemove.begin(),subsetToRemove.end());
+ }
+
+ //we will remove all cells that have multiple usages from the moab database
+ //I really don't care if they already existed or not.
+ this->Interface.remove(cellsToRemove);
+ return true;
+}
+
+
+
+}
+
+#endif // __smoab_ExtractShell_h
diff --git a/tools/vtkMOABReaderNew/FaceSets.h b/tools/vtkMOABReaderNew/FaceSets.h
new file mode 100644
index 0000000..536f3f9
--- /dev/null
+++ b/tools/vtkMOABReaderNew/FaceSets.h
@@ -0,0 +1,256 @@
+#ifndef __smoab_FaceSets_h
+#define __smoab_FaceSets_h
+
+#include "CellSets.h"
+#include <set>
+
+namespace smoab
+{
+//----------------------------------------------------------------------------
+class FaceCellSet : public CellSet
+{
+public:
+ FaceCellSet(int id, smoab::EntityHandle p,const smoab::Range& cells):
+ CellSet(p,cells),
+ ID(id)
+ {}
+
+ int faceId() const { return ID; }
+ void overrideFaceId(int i) { ID = i; } //USE AT YOUR OWN RISK
+
+private:
+ int ID;
+};
+
+
+//----------------------------------------------------------------------------
+typedef std::vector<FaceCellSet> FaceCellSets;
+
+
+//----------------------------------------------------------------------------
+//class that store the regions that a faces is adjacent too
+struct FacesAdjRegions
+{
+ FacesAdjRegions(int f, smoab::EntityHandle r0, smoab::EntityHandle r1):
+ FaceId(f),
+ Region0(r0),
+ Region1(r1)
+ {
+ if (r0 > r1)
+ {
+ std::swap(this->Region0,this->Region1);
+ }
+ }
+
+ FacesAdjRegions(int f):
+ FaceId(f),
+ Region0(-3),
+ Region1(-2)
+ {}
+
+ bool operator<(const FacesAdjRegions& other) const
+ {
+ return (this->FaceId < other.FaceId);
+ }
+
+ smoab::EntityHandle otherId(smoab::EntityHandle other) const
+ {
+ if(other == Region0)
+ {
+ return Region1;
+ }
+ return Region0;
+ }
+
+ int FaceId;
+ smoab::EntityHandle Region0;
+ smoab::EntityHandle Region1;
+};
+//----------------------------------------------------------------------------
+smoab::FaceCellSets findFaceSets(smoab::CellSets shells,
+ smoab::CellSets boundaries,
+ std::set<smoab::FacesAdjRegions>& faceMaps)
+{
+ typedef smoab::CellSets::iterator iterator;
+ typedef smoab::FaceCellSets::iterator faceIterator;
+ typedef std::set<smoab::FacesAdjRegions>::const_iterator FaceAdjIterator;
+
+ //we need to properly label each unique face in shells
+ //we do this by intersecting each shell with each other shell
+ //to find shell on shell contact, and than we intersect each
+ //resulting shell with the boundary conditions
+ //the end result of these intersections will be the new modelfaces
+ int faceId = 1;
+ smoab::FaceCellSets shellFaces;
+
+ //first intersect each shell with each other shell
+ std::set<smoab::FacesAdjRegions> shellFaceContacts;
+ for(iterator i=shells.begin();i!= shells.end();++i)
+ {
+ //copy the cells so we can add a face that represents
+ //all the cells of the region that aren't shared with another region
+ int numCells = i->cells().size(); //size() on range is slow, so cache it
+ for(iterator j = i+1;
+ j != shells.end() && numCells > 0;
+ ++j)
+ {
+ //intersect i and j to make a new face
+ smoab::Range intersection = smoab::intersect(i->cells(),j->cells());
+ if(!intersection.empty())
+ {
+ //don't want to increment faceId when the intersection is empty
+ smoab::FaceCellSet face(faceId++,i->entity(),intersection);
+ shellFaces.push_back(face);
+ i->erase(intersection);
+ j->erase(intersection);
+ numCells -= intersection.size();
+
+ //add this to the face map
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),j->entity());
+ shellFaceContacts.insert(faceInfo);
+ }
+ }
+ //if all the cells for shell i are used, don't add a new
+ //empty face
+ if(numCells > 0)
+ {
+ smoab::FaceCellSet face(faceId++,i->entity(),i->cells());
+ shellFaces.push_back(face);
+
+ //add this to the face map
+ smoab::FacesAdjRegions faceInfo(faceId-1,-1,i->entity());
+ shellFaceContacts.insert(faceInfo);
+ }
+ }
+
+ //now we have all the faces that match shell on shell contact
+ //we know process all the new faces to see if they intersect
+ //with any boundary sets. A boundary set can span multiple
+ //shells so we want to process it as a second loop
+
+ //store the end before we start adding boundary faces, which
+ //we don't need to check agianst other boundaries
+ faceId = 1; //reset the faced id
+
+ //store in a new face set, expanding the current one causes incorrect results
+ smoab::FaceCellSets faces;
+ for(faceIterator i=shellFaces.begin();i != shellFaces.end();++i)
+ {
+ //determine from the shell faces if the new face we are creating
+ //is bounded by two regions or just one
+ smoab::FacesAdjRegions idToSearchFor(i->faceId());
+ FaceAdjIterator adjRegions = shellFaceContacts.find(idToSearchFor);
+ smoab::EntityHandle otherRegionId = adjRegions->otherId(i->entity());
+
+ int numCells = i->cells().size(); //size() on range is slow, so cache it
+ for(iterator j=boundaries.begin();j != boundaries.end(); ++j)
+ {
+ smoab::Range intersect = smoab::intersect(i->cells(),j->cells());
+ if(!intersect.empty())
+ {
+ //don't want to increment faceId when the intersection is empty
+ smoab::FaceCellSet face(faceId++,j->entity(),intersect);
+ faces.push_back(face);
+ i->erase(intersect);
+ numCells -= intersect.size();
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),otherRegionId);
+ faceMaps.insert(faceInfo);
+ }
+ }
+ if(numCells > 0)
+ {
+ smoab::FaceCellSet face(faceId++,i->entity(),i->cells());
+ faces.push_back(face);
+ smoab::FacesAdjRegions faceInfo(faceId-1,i->entity(),otherRegionId);
+ faceMaps.insert(faceInfo);
+ }
+ }
+ return faces;
+}
+
+//----------------------------------------------------------------------------
+template<typename T>
+std::vector<T> faceIdsPerCell(const smoab::FaceCellSets& faces)
+{
+ typedef smoab::FaceCellSets::const_iterator iterator;
+ typedef std::vector<smoab::EntityHandle>::const_iterator EntityHandleIterator;
+ typedef smoab::Range::const_iterator RangeIterator;
+
+ //find all the cells that are in the faceCellSet, and than map
+ //the proper face id to that relative position, here comes lower_bounds!
+ std::vector<smoab::EntityHandle> searchableCells;
+ smoab::Range faceRange = smoab::getAllCells(faces);
+ smoab::RangeToVector(faceRange,searchableCells);
+
+ //faceIds will be the resulting array
+ std::vector<T> faceIds(searchableCells.size());
+
+ //construct the start and end iterators for the lower bounds call
+
+ EntityHandleIterator s_begin = searchableCells.begin();
+ EntityHandleIterator s_end = searchableCells.end();
+
+ //search the face cell sets
+ for(iterator i=faces.begin(); i!=faces.end(); ++i)
+ {
+ T value = static_cast<T>(i->faceId());
+ const smoab::Range& entitiesCells = i->cells();
+ for(RangeIterator j=entitiesCells.begin(); j != entitiesCells.end();++j)
+ {
+ EntityHandleIterator result = std::lower_bound(s_begin,
+ s_end,
+ *j);
+ std::size_t newId = std::distance(s_begin,result);
+ faceIds[newId] = value;
+ }
+ }
+ return faceIds;
+}
+
+//----------------------------------------------------------------------------
+//given a face adjacency, determine the regions spare tag values
+template<typename T>
+std::pair<T,T> FaceAdjRegionValues(const smoab::FacesAdjRegions& faceAdj,
+ smoab::Tag* t,
+ const smoab::Interface& interface)
+ {
+ std::pair<T,T> returnValue;
+ const int defaultValue = interface.getDefaultTagVaue<int>(*t);
+
+ /*
+ * IF A REGION IS SET TO -1 WE NEED TO PUSH THAT VALUE DOWN
+ * AS THE MATERIAL, SINCE THE MOAB DEFAULT TAG VALUE WILL
+ * BE CONSIDIERED A REGION, AND WE WANT TO SAY IT BOUNDS THE
+ * VOID REGION
+ */
+ int tagValue = defaultValue; //use tagValue to pass in default value
+ if(faceAdj.Region0 != -1)
+ {
+ tagValue = interface.getTagData(*t,faceAdj.Region0,tagValue);
+ }
+ else
+ {
+ tagValue = -1;
+ }
+
+ //set the first region tag value into the pair we are returing
+ returnValue.first = static_cast<T>(tagValue);
+
+ tagValue = defaultValue; //use tagValue to pass in default value
+ tagValue = interface.getTagData(*t,faceAdj.Region1,tagValue);
+ if(faceAdj.Region1 != -1)
+ {
+ tagValue = interface.getTagData(*t,faceAdj.Region1,tagValue);
+ }
+ else
+ {
+ tagValue = -1;
+ }
+ returnValue.second = static_cast<T>(tagValue);
+
+ return returnValue;
+ }
+
+ } //smoab
+
+#endif
diff --git a/tools/vtkMOABReaderNew/MixedCellConnectivity.h b/tools/vtkMOABReaderNew/MixedCellConnectivity.h
deleted file mode 100644
index 1b26d0f..0000000
--- a/tools/vtkMOABReaderNew/MixedCellConnectivity.h
+++ /dev/null
@@ -1,271 +0,0 @@
-#ifndef __smoab_MixedCellConnectivity_h
-#define __smoab_MixedCellConnectivity_h
-
-#include "vtkCellType.h"
-#include <algorithm>
-
-namespace
-{
-
-template<int N> struct QuadratricOrdering{};
-
-template<> struct QuadratricOrdering<VTK_QUADRATIC_WEDGE>
-{
- static const int NUM_VERTS = 15;
- void reorder(vtkIdType* connectivity) const
- {
- std::swap_ranges(connectivity+9,connectivity+12,connectivity+12);
- }
-};
-
-template<> struct QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON>
-{
- static const int NUM_VERTS = 27;
- void reorder(vtkIdType* connectivity) const
- {
- std::swap_ranges(connectivity+12,connectivity+16,connectivity+16);
-
- //move 20 to 22
- //move 22 to 23
- //move 23 to 20
-
- //swap 20 with 22
- std::swap(connectivity[20],connectivity[23]);
-
- //swap 22 with 23
- std::swap(connectivity[22],connectivity[23]);
- }
-};
-
-template<typename QuadraticOrdering>
-void FixQuadraticIdOrdering(vtkIdType* connectivity, vtkIdType numCells,
- QuadraticOrdering& ordering)
-{
- //skip the first index that holds the length of the cells
- //if we skip it once here, and than properly increment it makes the code
- //far easier
- connectivity+=1;
- for(vtkIdType i=0; i < numCells; ++i)
- {
- ordering.reorder(connectivity);
- connectivity += ordering.NUM_VERTS + 1;
- }
-}
-}
-
-namespace smoab
-{
-
-class MixedCellConnectivity
-{
-public:
- MixedCellConnectivity(smoab::Range const& cells, moab::Interface* moab):
- Connectivity(),
- UniquePoints(),
- Info()
- {
- int count = 0;
- const std::size_t cellSize=cells.size();
- while(count != cellSize)
- {
- EntityHandle* connectivity;
- int numVerts=0, iterationCount=0;
- //use the highly efficent calls, since we know that are of the same dimension
- moab->connect_iterate(cells.begin()+count,
- cells.end(),
- connectivity,
- numVerts,
- iterationCount);
- //if we didn't read anything, break!
- if(iterationCount == 0)
- {
- break;
- }
-
- //identify the cell type that we currently have,
- //store that along with the connectivity in a temp storage vector
- const moab::EntityType type = moab->type_from_handle(*cells.begin()+count);
-
- //while all these cells are contiously of the same type,
- //quadric hexs in vtk have 20 points, but moab has 21 so we
- //need to store this difference
- int numVTKVerts = numVerts;
- int vtkCellType = smoab::vtkCellType(type,numVTKVerts);
-
- RunLengthInfo info = { vtkCellType, numVerts, (numVerts-numVTKVerts), iterationCount };
- this->Info.push_back(info);
- this->Connectivity.push_back(connectivity);
-
- count += iterationCount;
- }
- }
-
- //----------------------------------------------------------------------------
- void compactIds(vtkIdType& numCells, vtkIdType& connectivityLength)
- {
- //converts all the ids to be ordered starting at zero, and also
- //keeping the orginal logical ordering. Stores the result of this
- //operation in the unstrucutred grid that is passed in
-
- //lets determine the total length of the connectivity
- connectivityLength = 0;
- numCells = 0;
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i)
- {
- connectivityLength += (*i).numCells * (*i).numVerts;
- numCells += (*i).numCells;
- }
-
- this->UniquePoints.reserve(connectivityLength);
-
- this->copyConnectivity(this->UniquePoints);
- std::sort(this->UniquePoints.begin(),this->UniquePoints.end());
-
- typedef std::vector<EntityHandle>::iterator EntityIterator;
- EntityIterator newEnd = std::unique(this->UniquePoints.begin(),
- this->UniquePoints.end());
-
- const std::size_t newSize = std::distance(this->UniquePoints.begin(),newEnd);
- this->UniquePoints.resize(newSize);
- }
-
- //----------------------------------------------------------------------------
- void moabPoints(smoab::Range& range) const
- {
- //from the documentation a reverse iterator is the fastest way
- //to insert into a range.
- std::copy(this->UniquePoints.rbegin(),
- this->UniquePoints.rend(),
- moab::range_inserter(range));
- }
-
- //----------------------------------------------------------------------------
- //copy the connectivity from the moab held arrays to the user input vector
- void copyConnectivity(std::vector<EntityHandle>& output) const
- {
- //walk the info to find the length of each sub connectivity array,
- //and insert them into the vector, ordering is implied by the order
- //the connecitivy sub array are added to this class
- ConnConstIterator c = this->Connectivity.begin();
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i,++c)
- {
- //remember our Connectivity is a vector of pointers whose
- //length is held in the info vector.
- const int numUnusedPoints = (*i).numUnusedVerts;
- if(numUnusedPoints==0)
- {
- const int connLength = (*i).numCells * (*i).numVerts;
- std::copy(*c,*c+connLength,std::back_inserter(output));
- }
- else
- {
- //we have cell connectivity that we need to skip,
- //so we have to manual copy each cells connectivity
- const int size = (*i).numCells;
- const int numPoints = (*i).numVerts;
- for(int i=0; i < size; ++i)
- {
- std::copy(*c,*c+numPoints,std::back_inserter(output));
- }
- c+=numPoints + (*i).numUnusedVerts;
- }
-
- }
- }
-
- //copy the information from this contianer to a vtk cell array, and
- //related lookup information
- void copyToVtkCellInfo(vtkIdType* cellArray,
- vtkIdType* cellLocations,
- unsigned char* cellTypes) const
- {
- vtkIdType currentVtkConnectivityIndex = 0;
- ConnConstIterator c = this->Connectivity.begin();
- for(InfoConstIterator i = this->Info.begin();
- i != this->Info.end();
- ++i, ++c)
- {
- //for this group of the same cell type we need to fill the cellTypes
- const int numCells = (*i).numCells;
- const int numVerts = (*i).numVerts;
-
- std::fill_n(cellTypes,
- numCells,
- static_cast<unsigned char>((*i).type));
-
- //for each cell in this collection that have the same type
- //grab the raw array now, so we can properly increment for each vert in each cell
- EntityHandle* moabConnectivity = *c;
- for(int j=0;j < numCells; ++j)
- {
- cellLocations[j]= currentVtkConnectivityIndex;
-
- //cell arrays start and end are different, since we
- //have to account for element that states the length of each cell
- cellArray[0]=numVerts;
-
- for(int k=0; k < numVerts; ++k, ++moabConnectivity )
- {
- //this is going to be a root of some failures when we start
- //reading really large datasets under 32bit.
-
-
- //fyi, don't use a range ds for unique points, distance
- //function is horribly slow they need to override it
- EntityConstIterator result = std::lower_bound(
- this->UniquePoints.begin(),
- this->UniquePoints.end(),
- *moabConnectivity);
- std::size_t newId = std::distance(this->UniquePoints.begin(),
- result);
- cellArray[k+1] = static_cast<vtkIdType>(newId);
- }
-
- //skip any extra unused points, which is currnetly only
- //the extra center point in moab quadratic hex
- moabConnectivity+=(*i).numUnusedVerts;
-
- currentVtkConnectivityIndex += numVerts+1;
- cellArray += numVerts+1;
- }
-
- //For Tri-Quadratic-Hex and Quadratric-Wedge Moab and VTK
- //Differ on the order of the edge ids. For wedge we need to swap
- //indices 9,10,11 with 12,13,14 for each cell. For Hex we sawp
- //12,13,14,15 with 16,17,18,19
- int vtkCellType = (*i).type;
- vtkIdType* connectivity = cellArray - (numCells * (numVerts+1));
- if(vtkCellType == VTK_TRIQUADRATIC_HEXAHEDRON)
- {
- ::QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON> newOrdering;
- ::FixQuadraticIdOrdering(connectivity, numCells, newOrdering);
- }
- else if(vtkCellType == VTK_QUADRATIC_WEDGE)
- {
- ::QuadratricOrdering<VTK_QUADRATIC_WEDGE> newOrdering;
- ::FixQuadraticIdOrdering(connectivity, numCells, newOrdering);
- }
-
- cellLocations += numCells;
- cellTypes += numCells;
- }
-
- }
-
-private:
- std::vector<EntityHandle*> Connectivity;
- std::vector<EntityHandle> UniquePoints;
-
- struct RunLengthInfo{ int type; int numVerts; int numUnusedVerts; int numCells; };
- std::vector<RunLengthInfo> Info;
-
- typedef std::vector<EntityHandle>::const_iterator EntityConstIterator;
- typedef std::vector<EntityHandle*>::const_iterator ConnConstIterator;
- typedef std::vector<RunLengthInfo>::const_iterator InfoConstIterator;
-};
-}
-#endif // __smoab_MixedCellConnectivity_h
diff --git a/tools/vtkMOABReaderNew/SimpleMoab.h b/tools/vtkMOABReaderNew/SimpleMoab.h
index 8fc54e6..4fb734c 100644
--- a/tools/vtkMOABReaderNew/SimpleMoab.h
+++ b/tools/vtkMOABReaderNew/SimpleMoab.h
@@ -5,6 +5,8 @@
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
+#include "moab/CN.hpp"
+
#include "MBTagConventions.hpp"
#include <iostream>
@@ -26,12 +28,6 @@ using moab::intersect;
using moab::subtract;
using moab::unite;
-//forward declare this->Moab for Tag
-struct Interface;
-
-//forward declar the DataSetConverter so it can be a friend of Interface
-class DataSetConverter;
-
class Tag
{
const std::string Name_;
@@ -66,10 +62,24 @@ public:
GeomTag(int d):Tag("GEOM_DIMENSION"),dim(d){}
GeomTag():Tag("GEOM_DIMENSION"), dim(0){}
+ virtual ~GeomTag(){}
+
bool isComparable() const { return dim > 0; }
int value() const { return dim; }
};
+
+//forward declare this->Moab for Tag
+struct Interface;
+
+//forward declare the DataSetConverter so it can be a friend of Interface
+class DataSetConverter;
+
+//forward declare the LoadGeometry so it can be a friend of Interface
+namespace detail{ class LoadGeometry; }
+namespace detail{ class LoadPoly; }
+
+
//light weight wrapper on a moab this->Moab that exposes only the reduced class
//that we need
class Interface
@@ -102,6 +112,37 @@ public:
}
//----------------------------------------------------------------------------
+ template<typename T>
+ T getDefaultTagVaue(moab::Tag tag) const
+ {
+ T defaultValue;
+ this->Moab->tag_get_default_value(tag,&defaultValue);
+ return defaultValue;
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getDefaultTagVaue(smoab::Tag tag) const
+ {
+ return this->getDefaultTagVaue<T>(getMoabTag(tag));
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getTagData(moab::Tag tag, const smoab::EntityHandle& entity, T value) const
+ {
+ this->Moab->tag_get_data(tag,&entity,1,&value);
+ return value;
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename T>
+ T getTagData(smoab::Tag tag, const smoab::EntityHandle& entity, T value = T()) const
+ {
+ return this->getTagData(getMoabTag(tag),entity,value);
+ }
+
+ //----------------------------------------------------------------------------
//returns the moab name for the given entity handle if it has a sparse Name tag
std::string name(const smoab::EntityHandle& entity) const
{
@@ -119,6 +160,19 @@ public:
return std::string(name);
}
+ //----------------------------------------------------------------------------
+ //returns the geometeric dimension of an entity.
+ int dimension(const smoab::EntityHandle& entity) const
+ {
+ return this->Moab->dimension_from_handle(entity);
+ }
+
+ //----------------------------------------------------------------------------
+ //returns the geometeric dimension of an entity.
+ smoab::EntityType entityType(const smoab::EntityHandle& entity) const
+ {
+ return this->Moab->type_from_handle(entity);
+ }
//----------------------------------------------------------------------------
smoab::EntityHandle getRoot() const { return this->Moab->get_root_set(); }
@@ -133,6 +187,17 @@ public:
}
//----------------------------------------------------------------------------
+ //given a single entity handle find all items in that mesh set that aren't
+ //them selves entitysets. If recurse is true we also recurse sub entitysets
+ smoab::Range findAllMeshEntities(smoab::EntityHandle const& entity,
+ bool recurse=false) const
+ {
+ smoab::Range result;
+ this->Moab->get_entities_by_handle(entity,result,recurse);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
//Find all entities with a given tag. We don't use geom as a tag as that
//isn't a fast operation. Yes finding the intersection of geom entities and
//a material / boundary tag will be more work, but it is rarely done currently
@@ -179,60 +244,55 @@ public:
//----------------------------------------------------------------------------
//Find all entities from a given root of a given dimensionality
smoab::Range findEntitiesWithDimension(const smoab::EntityHandle root,
- int dimension) const
+ const int dimension,
+ bool recurse=false) const
{
typedef smoab::Range::const_iterator iterator;
smoab::Range result;
- this->Moab->get_entities_by_dimension(root,dimension,result);
+ this->Moab->get_entities_by_dimension(root,dimension,result,recurse);
-
- smoab::Range children;
- this->Moab->get_child_meshsets(root,children,0);
- for(iterator i=children.begin(); i !=children.end();++i)
+ if(recurse)
{
- this->Moab->get_entities_by_dimension(*i,dimension,result);
+ smoab::Range children;
+ this->Moab->get_child_meshsets(root,children,0);
+ for(iterator i=children.begin(); i !=children.end();++i)
+ {
+ this->Moab->get_entities_by_dimension(*i,dimension,result);
+ }
}
return result;
}
- //----------------------------------------------------------------------------
- smoab::Range findAdjacentEntities(const smoab::EntityHandle& entity,
- int dimension) const
- {
- const int adjType = static_cast<int>(smoab::INTERSECT);
- smoab::Range result;
- const bool create_if_missing = false;
- this->Moab->get_adjacencies(&entity,
- 1,
- dimension,
- create_if_missing,
- result,
- adjType);
- return result;
- }
- //----------------------------------------------------------------------------
- smoab::Range findAdjacentEntities(const smoab::Range& range,
- int dimension,
- const smoab::adjacency_type type = smoab::UNION) const
+ //----------------------------------------------------------------------------
+ smoab::Range findHighestDimensionEntities(const smoab::EntityHandle& entity,
+ bool recurse=false) const
{
- //the smoab and moab adjacent intersection enums are in the same order
- const int adjType = static_cast<int>(type);
- smoab::Range result;
- const bool create_if_missing = false;
- this->Moab->get_adjacencies(range,dimension,
- create_if_missing,
- result,
- adjType);
+ //the goal is to load all entities that are not entity sets of this
+ //node, while also subsetting by the highest dimension
- return result;
+ //lets find the entities of only the highest dimension
+ int num_ents=0;
+ int dim=3;
+ while(num_ents<=0&&dim>0)
+ {
+ this->Moab->get_number_entities_by_dimension(entity,dim,num_ents,recurse);
+ --dim;
+ }
+ ++dim; //reincrement to correct last decrement
+ if(num_ents > 0)
+ {
+ //we have found entities of a given dimension
+ return this->findEntitiesWithDimension(entity,dim,recurse);
+ }
+ return smoab::Range();
}
//----------------------------------------------------------------------------
//Find all elements in the database that have children and zero parents.
//this doesn't find
- smoab::Range findEntityRootParents(smoab::EntityHandle const& root) const
+ smoab::Range findEntityRootParents(const smoab::EntityHandle& root) const
{
smoab::Range parents;
@@ -258,7 +318,7 @@ public:
//----------------------------------------------------------------------------
//finds entities that have zero children and zero parents
- smoab::Range findDetachedEntities(moab::EntityHandle const& root) const
+ smoab::Range findDetachedEntities(const moab::EntityHandle& root) const
{
smoab::Range detached;
@@ -284,7 +344,7 @@ public:
//----------------------------------------------------------------------------
//find all children of the entity passed in that has multiple parents
- smoab::Range findEntitiesWithMultipleParents(smoab::EntityHandle const& root)
+ smoab::Range findEntitiesWithMultipleParents(const smoab::EntityHandle& root) const
{
smoab::Range multipleParents;
typedef moab::Range::const_iterator iterator;
@@ -305,8 +365,114 @@ public:
}
//----------------------------------------------------------------------------
+ //find all entities that are adjacent to a single entity
+ smoab::Range findAdjacencies(const smoab::EntityHandle& entity,
+ int dimension) const
+ {
+ const int adjType = static_cast<int>(smoab::INTERSECT);
+ smoab::Range result;
+ const bool create_if_missing = false;
+ this->Moab->get_adjacencies(&entity,
+ 1,
+ dimension,
+ create_if_missing,
+ result,
+ adjType);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ smoab::Range findAdjacencies(const smoab::Range& range,
+ int dimension,
+ const smoab::adjacency_type type = smoab::UNION) const
+ {
+ //the smoab and moab adjacent intersection enums are in the same order
+ const int adjType = static_cast<int>(type);
+ smoab::Range result;
+ const bool create_if_missing = false;
+ this->Moab->get_adjacencies(range,dimension,
+ create_if_missing,
+ result,
+ adjType);
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ //create adjacencies, only works when the dimension requested is lower than
+ //dimension of the range of entities
+ smoab::Range createAdjacencies(const smoab::Range& range,
+ int dimension,
+ const smoab::adjacency_type type = smoab::UNION) const
+ {
+ //the smoab and moab adjacent intersection enums are in the same order
+ const int adjType = static_cast<int>(type);
+ smoab::Range result;
+ const bool create_if_missing = true;
+ this->Moab->get_adjacencies(range,dimension,
+ create_if_missing,
+ result,
+ adjType);
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ int numChildMeshSets(const smoab::EntityHandle& root) const
+ {
+ int numChildren;
+ this->Moab->num_child_meshsets(root,&numChildren);
+ return numChildren;
+ }
+
+ //----------------------------------------------------------------------------
+ smoab::Range getChildSets(const smoab::EntityHandle& root) const
+ {
+ smoab::Range children;
+ this->Moab->get_child_meshsets(root,children,0);
+ return children;
+ }
+
+ //----------------------------------------------------------------------------
+ //remove a collection of entities from the database
+ void remove(smoab::Range const& toDelete) const
+ {
+ this->Moab->delete_entities(toDelete);
+ }
+
+ //----------------------------------------------------------------------------
+ //a entityHandle with value zero means no side element was found
+ smoab::EntityHandle sideElement(smoab::EntityHandle const& cell,
+ int dim, int side) const
+ {
+ smoab::EntityHandle result(0);
+ this->Moab->side_element(cell,dim,side,result);
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
+ //returns all the existing side elements of a cell, elements that
+ //are zero mean that side element doesn't exist
+ std::vector<smoab::EntityHandle> sideElements(
+ smoab::EntityHandle const& cell,
+ int dim) const
+ {
+ const EntityType volumeCellType = this->Moab->type_from_handle(cell);
+ const int numSides = static_cast<int>(moab::CN::NumSubEntities(
+ volumeCellType, dim));
+
+ std::vector<smoab::EntityHandle> result(numSides);
+ for (int side = 0; side < numSides; ++side)
+ {
+ smoab::EntityHandle *sideElem = &result[side]; //get memory of vector
+ this->Moab->side_element(cell,dim,side,*sideElem);
+ }
+ return result;
+ }
+
+ //----------------------------------------------------------------------------
//prints all elements in a range objects
- void printRange(smoab::Range const& range)
+ void printRange(const smoab::Range& range) const
{
typedef Range::const_iterator iterator;
for(iterator i=range.begin(); i!=range.end(); ++i)
@@ -315,12 +481,25 @@ public:
this->Moab->list_entity(*i);
}
}
-
friend class smoab::DataSetConverter;
+ friend class smoab::detail::LoadGeometry;
+ friend class smoab::detail::LoadPoly;
private:
moab::Interface* Moab;
};
+//----------------------------------------------------------------------------
+void RangeToVector(const smoab::Range &range,
+ std::vector<smoab::EntityHandle>& vector )
+{
+ vector.reserve(range.size());
+ std::copy(range.begin(),
+ range.end(),
+ std::back_inserter(vector));
+}
+
+
+
}
#endif
diff --git a/tools/vtkMOABReaderNew/detail/CellTypeToType.h b/tools/vtkMOABReaderNew/detail/CellTypeToType.h
new file mode 100644
index 0000000..b2955e4
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/CellTypeToType.h
@@ -0,0 +1,147 @@
+#ifndef __smoab_detail_CellTypeToType_h
+#define __smoab_detail_CellTypeToType_h
+
+#include "vtkCellType.h"
+#include <algorithm>
+
+namespace smoab{ namespace detail{
+
+template<int N> struct QuadratricOrdering{};
+
+template<> struct QuadratricOrdering<VTK_QUADRATIC_WEDGE>
+{
+ static const int NUM_VERTS = 15;
+ void reorder(vtkIdType* connectivity) const
+ {
+ std::swap_ranges(connectivity+9,connectivity+12,connectivity+12);
+ }
+};
+
+template<> struct QuadratricOrdering<VTK_TRIQUADRATIC_HEXAHEDRON>
+{
+ static const int NUM_VERTS = 27;
+ void reorder(vtkIdType* connectivity) const
+ {
+ std::swap_ranges(connectivity+12,connectivity+16,connectivity+16);
+
+ //move 20 to 22
+ //move 22 to 23
+ //move 23 to 20
+
+ //swap 20 with 22
+ std::swap(connectivity[20],connectivity[23]);
+
+ //swap 22 with 23
+ std::swap(connectivity[22],connectivity[23]);
+ }
+};
+
+template<typename QuadraticOrdering>
+void FixQuadraticIdOrdering(vtkIdType* connectivity, vtkIdType numCells,
+ QuadraticOrdering& ordering)
+{
+ //skip the first index that holds the length of the cells
+ //if we skip it once here, and than properly increment it makes the code
+ //far easier
+ connectivity+=1;
+ for(vtkIdType i=0; i < numCells; ++i)
+ {
+ ordering.reorder(connectivity);
+ connectivity += ordering.NUM_VERTS + 1;
+ }
+}
+
+
+int vtkCellType(moab::EntityType t, int &num_connect)
+ {
+ int ctype = -1;
+ switch (t)
+ {
+ case moab::MBEDGE:
+ if (num_connect == 2) ctype = VTK_LINE;
+ else if (num_connect == 3) ctype = VTK_QUADRATIC_EDGE;
+ break;
+ case moab::MBTRI:
+ if (num_connect == 3) ctype = VTK_TRIANGLE;
+ else if (num_connect == 6) ctype = VTK_QUADRATIC_TRIANGLE;
+ else if (num_connect == 7) ctype = VTK_BIQUADRATIC_TRIANGLE;
+ break;
+ case moab::MBQUAD:
+ if (num_connect == 4) ctype = VTK_QUAD;
+ else if (num_connect == 8) ctype = VTK_QUADRATIC_QUAD;
+ else if (num_connect == 9) ctype = VTK_BIQUADRATIC_QUAD;
+ break;
+ case moab::MBPOLYGON:
+ if (num_connect == 4) ctype = VTK_POLYGON;
+ break;
+ case moab::MBTET:
+ if (num_connect == 4) ctype = VTK_TETRA;
+ else if (num_connect == 10) ctype = VTK_QUADRATIC_TETRA;
+ break;
+ case moab::MBPYRAMID:
+ if (num_connect == 5) ctype = VTK_PYRAMID;
+ else if (num_connect == 13) ctype = VTK_QUADRATIC_PYRAMID;
+ break;
+ case moab::MBPRISM:
+ if (num_connect == 6) ctype = VTK_WEDGE;
+ else if (num_connect == 15) ctype = VTK_QUADRATIC_WEDGE;
+ break;
+ case moab::MBHEX:
+ if (num_connect == 8) ctype = VTK_HEXAHEDRON;
+ else if (num_connect == 20) ctype = VTK_QUADRATIC_HEXAHEDRON;
+ else if (num_connect == 21) ctype = VTK_QUADRATIC_HEXAHEDRON, num_connect = 20;
+ else if (num_connect == 27) ctype = VTK_TRIQUADRATIC_HEXAHEDRON;
+ break;
+ default:
+ ctype = -1;
+ break;
+ }
+ return ctype;
+ }
+
+int vtkLinearCellType(moab::EntityType t, int &num_connect)
+ {
+ int ctype = -1;
+ switch (t)
+ {
+ case moab::MBEDGE:
+ ctype = VTK_LINE;
+ num_connect = 2;
+ break;
+ case moab::MBTRI:
+ ctype = VTK_TRIANGLE;
+ num_connect = 3;
+ break;
+ case moab::MBQUAD:
+ ctype = VTK_QUAD;
+ num_connect = 4;
+ break;
+ case moab::MBPOLYGON:
+ ctype = VTK_POLYGON;
+ num_connect = 4;
+ break;
+ case moab::MBTET:
+ ctype = VTK_TETRA;
+ num_connect = 4;
+ break;
+ case moab::MBPYRAMID:
+ ctype = VTK_PYRAMID;
+ num_connect = 5;
+ break;
+ case moab::MBPRISM:
+ ctype = VTK_WEDGE;
+ num_connect = 6;
+ break;
+ case moab::MBHEX:
+ ctype = VTK_HEXAHEDRON;
+ num_connect = 8;
+ break;
+ default:
+ break;
+ }
+ return ctype;
+ }
+
+} } //namespace smaob::detail
+
+#endif // CELLTYPETOTYPE_H
diff --git a/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h b/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h
new file mode 100644
index 0000000..28319df
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/ContinousCellInfo.h
@@ -0,0 +1,18 @@
+#ifndef __smoab_detail_ContinousCellInfo_h
+#define __smoab_detail_ContinousCellInfo_h
+
+
+namespace smoab { namespace detail {
+
+struct ContinousCellInfo
+{
+ int type;
+ int numVerts;
+ int numUnusedVerts;
+ int numCells;
+
+};
+
+} } //namespace smoab::detail
+
+#endif
diff --git a/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h b/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h
new file mode 100644
index 0000000..1b94548
--- /dev/null
+++ b/tools/vtkMOABReaderNew/detail/LinearCellConnectivity.h
@@ -0,0 +1,219 @@
+#ifndef __smoab_LinearCellConnectivity_h
+#define __smoab_LinearCellConnectivity_h
+
+#include "CellTypeToType.h"
+#include "ContinousCellInfo.h"
+
+#include <algorithm>
+#include <vector>
+
+namespace smoab { namespace detail {
+
+namespace internal
+{
+ //we want a subset of the real connetivity array,
+ //this does that for use with a super easy wrapper
+ struct SubsetArray
+ {
+ SubsetArray(EntityHandle* realConn,
+ int numCells,
+ int currentVertsPerCell,
+ int newVertsPerCell):
+ Array()
+ {
+ const int size = numCells*newVertsPerCell;
+ this->Array.reserve(size);
+ if(currentVertsPerCell == newVertsPerCell)
+ {
+ std::copy(realConn,realConn+size, std::back_inserter(this->Array));
+ }
+ else
+ {
+ //skip copy only the first N points which we want
+ //since moab stores linear points first per cell
+ EntityHandle *pos = realConn;
+ for(int i=0; i < numCells;++i)
+ {
+ std::copy(pos,pos+newVertsPerCell,std::back_inserter(this->Array));
+ pos += currentVertsPerCell;
+ }
+ }
+ }
+ typedef std::vector<EntityHandle>::const_iterator const_iterator;
+ typedef std::vector<EntityHandle>::iterator iterator;
+
+ const_iterator begin() const { return this->Array.begin(); }
+ iterator begin() { return this->Array.begin(); }
+
+ const_iterator end() const { return this->Array.end(); }
+ iterator end(){ return this->Array.end(); }
+
+ private:
+ std::vector<EntityHandle> Array;
+ };
+}
+
+class LinearCellConnectivity
+{
+public:
+
+ LinearCellConnectivity(smoab::Range const& cells, moab::Interface* moab):
+ Connectivity(),
+ UniquePoints(),
+ Info()
+ {
+ int count = 0;
+ const std::size_t cellSize=cells.size();
+ while(count != cellSize)
+ {
+ EntityHandle* connectivity;
+ int numVerts=0, iterationCount=0;
+ //use the highly efficent calls, since we know that are of the same dimension
+ moab->connect_iterate(cells.begin()+count,
+ cells.end(),
+ connectivity,
+ numVerts,
+ iterationCount);
+ //if we didn't read anything, break!
+ if(iterationCount == 0)
+ {
+ break;
+ }
+
+ //identify the cell type that we currently have,
+ //store that along with the connectivity in a temp storage vector
+ const moab::EntityType type = moab->type_from_handle(*cells.begin()+count);
+
+ int vtkNumVerts;
+ int vtkCellType = smoab::detail::vtkLinearCellType(type,vtkNumVerts);
+
+ ContinousCellInfo info = { vtkCellType, vtkNumVerts, 0, iterationCount };
+ this->Info.push_back(info);
+
+
+ //we need to copy only a subset of the connectivity array
+ internal::SubsetArray conn(connectivity,iterationCount,numVerts,vtkNumVerts);
+ this->Connectivity.push_back(conn);
+
+ count += iterationCount;
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void compactIds(vtkIdType& numCells, vtkIdType& connectivityLength)
+ {
+ //converts all the ids to be ordered starting at zero, and also
+ //keeping the orginal logical ordering. Stores the result of this
+ //operation in the unstrucutred grid that is passed in
+
+ //lets determine the total length of the connectivity
+ connectivityLength = 0;
+ numCells = 0;
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i)
+ {
+ connectivityLength += (*i).numCells * (*i).numVerts;
+ numCells += (*i).numCells;
+ }
+
+ this->UniquePoints.reserve(connectivityLength);
+
+ this->copyConnectivity(this->UniquePoints);
+ std::sort(this->UniquePoints.begin(),this->UniquePoints.end());
+
+ typedef std::vector<EntityHandle>::iterator EntityIterator;
+ EntityIterator newEnd = std::unique(this->UniquePoints.begin(),
+ this->UniquePoints.end());
+
+ const std::size_t newSize = std::distance(this->UniquePoints.begin(),newEnd);
+ this->UniquePoints.resize(newSize);
+ }
+
+ //----------------------------------------------------------------------------
+ void moabPoints(smoab::Range& range) const
+ {
+ //from the documentation a reverse iterator is the fastest way
+ //to insert into a range.
+ std::copy(this->UniquePoints.rbegin(),
+ this->UniquePoints.rend(),
+ moab::range_inserter(range));
+ }
+
+ //----------------------------------------------------------------------------
+ //copy the connectivity from the moab held arrays to the user input vector
+ void copyConnectivity(std::vector<EntityHandle>& output) const
+ {
+ //walk the info to find the length of each sub connectivity array,
+ //and insert them into the vector, ordering is implied by the order
+ //the connecitivy sub array are added to this class
+ ConnConstIterator c = this->Connectivity.begin();
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i,++c)
+ {
+ //remember our Connectivity is a vector of pointers whose
+ //length is held in the info vector.
+ const int numUnusedPoints = (*i).numUnusedVerts;
+ const int connLength = (*i).numCells * (*i).numVerts;
+ std::copy(c->begin(),c->end(),std::back_inserter(output));
+ }
+ }
+
+ //copy the information from this contianer to a vtk cell array, and
+ //related lookup information
+ void copyToVtkCellInfo(vtkIdType* cellArray) const
+ {
+ ConnConstIterator c = this->Connectivity.begin();
+ for(InfoConstIterator i = this->Info.begin();
+ i != this->Info.end();
+ ++i, ++c)
+ {
+ //for this group of the same cell type we need to fill the cellTypes
+ const int numCells = (*i).numCells;
+ const int numVerts = (*i).numVerts;
+
+ //for each cell in this collection that have the same type
+ //grab the raw array now, so we can properly increment for each vert in each cell
+ internal::SubsetArray::const_iterator moabConnectivity = c->begin();
+ for(int j=0;j < numCells; ++j)
+ {
+ //cell arrays start and end are different, since we
+ //have to account for element that states the length of each cell
+ cellArray[0]=numVerts;
+
+
+ for(int k=0; k < numVerts; ++k, ++moabConnectivity )
+ {
+ //this is going to be a root of some failures when we start
+ //reading really large datasets under 32bit.
+
+
+ //fyi, don't use a range ds for unique points, distance
+ //function is horribly slow they need to override it
+ EntityConstIterator result = std::lower_bound(
+ this->UniquePoints.begin(),
+ this->UniquePoints.end(),
+ *moabConnectivity);
+ std::size_t newId = std::distance(this->UniquePoints.begin(),
+ result);
+ cellArray[k+1] = static_cast<vtkIdType>(newId);
+ }
+ cellArray += numVerts+1;
+ }
+ }
+ }
+
+private:
+ std::vector<internal::SubsetArray> Connectivity;
+ std::vector<EntityHandle> UniquePoints;
+
+ std::vector<detail::ContinousCellInfo> Info;
+
+ typedef std::vector<EntityHandle>::const_iterator EntityConstIterator;
+ typedef std::vector<internal::SubsetArray>::const_iterator ConnConstIterator;
+ typedef std::vector<detail::ContinousCellInfo>::const_iterator InfoConstIterator;
+};
+} } //namespace smoab::detail
+
+#endif // __smoab_LinearCellConnectivity_h
This diff is so big that we needed to truncate the remainder.
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.
1
0