[MOAB-dev] r4583 - MOAB/trunk/src/io

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri Mar 11 14:09:06 CST 2011


Author: kraftche
Date: 2011-03-11 14:09:06 -0600 (Fri, 11 Mar 2011)
New Revision: 4583

Modified:
   MOAB/trunk/src/io/WriteHDF5.cpp
   MOAB/trunk/src/io/WriteHDF5.hpp
Log:
Make HDF5 writer choose dense format for tag data more often.

If at least 2/3 of the entities in an export set have tag values, the tag
is a moab dense tag, and the tag has a default value, then write 
dense-formatted tag data for all entities in the export set.  The reader 
will create a single SequenceData for each export set anyway so no extra 
memory will be allocated to store the tag data when the file is read back 
in.  So this is just a question of using a little more disk space in exchange 
for better IO performance.



Modified: MOAB/trunk/src/io/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/src/io/WriteHDF5.cpp	2011-03-11 09:07:47 UTC (rev 4582)
+++ MOAB/trunk/src/io/WriteHDF5.cpp	2011-03-11 20:09:06 UTC (rev 4583)
@@ -2529,20 +2529,35 @@
       // data for. We never write dense data for variable-length
       // tag data.
     if (!var_len && writeTagDense) {
-      if (!nodeSet.range.empty() && range.contains(nodeSet.range)) {
+      // Check if we want to write this tag in dense format even if not
+      // all of the entities have a tag value.  The criterion of this
+      // is that the tag be dense, have a default value, and have at
+      // least 2/3 of the entities tagged.
+      bool prefer_dense = false;
+      TagType type;
+      rval = iFace->tag_get_type( tag_iter->tag_id, type );
+      CHK_MB_ERR_0(rval);
+      if (MB_TAG_DENSE == type) {
+        const void* defval = 0;
+        rval = iFace->tag_get_default_value( tag_iter->tag_id, defval, s );
+        if (MB_SUCCESS == rval)
+          prefer_dense = true;
+      } 
+    
+      if (check_dense_format_tag( nodeSet, range, prefer_dense )) {
         range -= nodeSet.range;
         tag_iter->denseList.push_back( nodeSet );
       }
 
       std::list<ExportSet>::const_iterator ex = exportList.begin();
       for ( ; ex != exportList.end(); ++ex) {
-        if (!ex->range.empty() && range.contains( ex->range )) {
+        if (check_dense_format_tag( *ex, range, prefer_dense )) {
           range -= ex->range;
           tag_iter->denseList.push_back( *ex );
         }
       }
 
-      if (!setSet.range.empty() && range.contains(setSet.range)) {
+      if (check_dense_format_tag( setSet, range, prefer_dense )) {
         range -= setSet.range;
         tag_iter->denseList.push_back( setSet );
       }
@@ -2564,6 +2579,31 @@
 }
 
 
+bool WriteHDF5::check_dense_format_tag( const ExportSet& ents, 
+                                        const Range& all_tagged, 
+                                        bool prefer_dense )
+{


More information about the moab-dev mailing list