[MOAB-dev] r3343 - in MOAB/trunk: . parallel test/h5file test/perf tools tools/dagmc tools/iMesh tools/mbcoupler tools/mcnpmit
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Fri Nov 13 15:00:42 CST 2009
Author: kraftche
Date: 2009-11-13 15:00:42 -0600 (Fri, 13 Nov 2009)
New Revision: 3343
Modified:
MOAB/trunk/MBCore.cpp
MOAB/trunk/MBCore.hpp
MOAB/trunk/MBInterface.hpp
MOAB/trunk/MBReaderIface.hpp
MOAB/trunk/MBTest.cpp
MOAB/trunk/ReadABAQUS.cpp
MOAB/trunk/ReadABAQUS.hpp
MOAB/trunk/ReadCGM.cpp
MOAB/trunk/ReadCGM.hpp
MOAB/trunk/ReadGmsh.cpp
MOAB/trunk/ReadGmsh.hpp
MOAB/trunk/ReadHDF5.cpp
MOAB/trunk/ReadHDF5.hpp
MOAB/trunk/ReadIDEAS.cpp
MOAB/trunk/ReadIDEAS.hpp
MOAB/trunk/ReadMCNP5.cpp
MOAB/trunk/ReadMCNP5.hpp
MOAB/trunk/ReadNASTRAN.cpp
MOAB/trunk/ReadNASTRAN.hpp
MOAB/trunk/ReadNCDF.cpp
MOAB/trunk/ReadNCDF.hpp
MOAB/trunk/ReadSTL.cpp
MOAB/trunk/ReadSTL.hpp
MOAB/trunk/ReadSms.cpp
MOAB/trunk/ReadSms.hpp
MOAB/trunk/ReadTetGen.cpp
MOAB/trunk/ReadTetGen.hpp
MOAB/trunk/ReadVtk.cpp
MOAB/trunk/ReadVtk.hpp
MOAB/trunk/Tqdcfr.cpp
MOAB/trunk/Tqdcfr.hpp
MOAB/trunk/cub_file_test.cc
MOAB/trunk/exodus_test.cc
MOAB/trunk/gmsh_test.cc
MOAB/trunk/kd_tree_test.cpp
MOAB/trunk/nastran_test.cc
MOAB/trunk/parallel/ReadParallel.cpp
MOAB/trunk/parallel/ReadParallel.hpp
MOAB/trunk/parallel/mbparallelcomm_test.cpp
MOAB/trunk/parallel/parallel_hdf5_test.cc
MOAB/trunk/parallel/parallel_unit_tests.cpp
MOAB/trunk/parallel/pcomm_serial.cpp
MOAB/trunk/parallel/uber_parallel_test.cpp
MOAB/trunk/stl_test.cc
MOAB/trunk/test/h5file/h5partial.cpp
MOAB/trunk/test/h5file/h5sets_test.cpp
MOAB/trunk/test/perf/adj_time.cpp
MOAB/trunk/test/perf/point_in_elem.cpp
MOAB/trunk/tools/convert.cpp
MOAB/trunk/tools/dagmc/DagMC.cpp
MOAB/trunk/tools/dagmc/cub2h5m.cc
MOAB/trunk/tools/dagmc/main.cc
MOAB/trunk/tools/dagmc/quads_to_tris_driver.cpp
MOAB/trunk/tools/dagmc/test_geom.cc
MOAB/trunk/tools/depth.cpp
MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
MOAB/trunk/tools/mcnpmit/main.cpp
Log:
MBInterface API and behavior change. Previously, MOAB would create a new
entity set for each call to MBInterface::load_file, containing all entities
read from the file. It no longer does this (ever.) Rather than passing
back the handle for the (no longer created) file set from
MBInterface::load_file, MBInterface::load_file is now passed a
'const MBEntityHandle*', which may be NULL. If it is not NULL, then
it is assumed that the *caller* *allocated* a set, and the entities
read from the file will be added to the passed set.
Readers are no longer responsible for adding entities to the file set,
if there is one. This was the case prior to this commit. Clean up
the remaining places where readers add entities to the passed set anyway.
Update all readers such that file set is optional (even though readers
don't put entities in the set, some still attach meta-data to the set.)
Change ReadNASTRAN to use RangeMap rather than offsets with optional
lookup by tag value.
Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/MBCore.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -363,13 +363,12 @@
const int* block_id_list,
const int num_blocks )
{
- MBEntityHandle file_set;
const char* name = block_id_list ? MATERIAL_SET_TAG_NAME : 0;
- return load_file( file_name, file_set, 0, name, block_id_list, num_blocks );
+ return load_file( file_name, 0, 0, name, block_id_list, num_blocks );
}
MBErrorCode MBCore::load_file( const char* file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const char* options,
const char* set_tag_name,
const int* set_tag_vals,
@@ -424,7 +423,7 @@
}
MBErrorCode MBCore::serial_load_file( const char* file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subsets,
int num_sets,
@@ -441,10 +440,6 @@
rval = get_entities_by_handle( 0, initial_ents );
if (MB_SUCCESS != rval)
return rval;
-
- rval = create_meshset( MESHSET_SET, file_set );
- if (MB_SUCCESS != rval)
- return rval;
// otherwise try using the file extension to select a reader
MBReaderIface* reader = set->get_file_extension_reader( file_name );
@@ -475,11 +470,9 @@
new_ents = subtract( new_ents, initial_ents );
if (MB_SUCCESS != rval) {
delete_entities( new_ents );
- file_set = 0;
}
- else {
- new_ents.erase( file_set );
- rval = add_entities( file_set, new_ents );
+ else if (file_set) {
+ rval = add_entities( *file_set, new_ents );
}
return rval;
Modified: MOAB/trunk/MBCore.hpp
===================================================================
--- MOAB/trunk/MBCore.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/MBCore.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -96,7 +96,7 @@
/**Load or import a file. */
virtual MBErrorCode load_file( const char* file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set = 0,
const char* options = 0,
const char* set_tag_name = 0,
const int* set_tag_values = 0,
@@ -104,7 +104,7 @@
/**Load or import a file. */
MBErrorCode serial_load_file( const char* file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/MBInterface.hpp
===================================================================
--- MOAB/trunk/MBInterface.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/MBInterface.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -214,7 +214,7 @@
*\param num_set_tag_values The length of set_tag_values.
*/
virtual MBErrorCode load_file( const char* file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set = 0,
const char* options = 0,
const char* set_tag_name = 0,
const int* set_tag_values = 0,
Modified: MOAB/trunk/MBReaderIface.hpp
===================================================================
--- MOAB/trunk/MBReaderIface.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/MBReaderIface.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -49,11 +49,10 @@
* Method all readers must provide to import a mesh.
*
*\param file_name The file to read.
- *\param file_set The entity set to which to add all entities read
- * from the file. If the reader returns anything
- * other than MB_SUCCESS, it is the responsibility
- * of the caller to delete this set and any contained
- * entities that were read.
+ *\param file_set Optional pointer to entity set representing
+ * file. If this is not NULL, reader may optionally
+ * tag the pointed-to set with format-specific
+ * meta-data.
*\param subset_list An array of tag name and value sets specifying
* the subset of the file to read. If multiple
* tags are specified, the sets that match all
@@ -64,7 +63,7 @@
*\author Jason Kraftcheck
*/
virtual MBErrorCode load_file( const char* file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/MBTest.cpp
===================================================================
--- MOAB/trunk/MBTest.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/MBTest.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -6794,18 +6794,17 @@
const char* argv0 = 0;
MBErrorCode mb_read_fail_test(MBInterface* mb)
{
- MBEntityHandle set;
MBErrorCode rval;
// try reading a non-existant file
- rval = mb->load_file( tmpnam(0), set );
+ rval = mb->load_file( tmpnam(0) );
if (MB_FILE_DOES_NOT_EXIST != rval)
return MB_FAILURE;
// try reading an invalid file
if (!argv0) // not set by main, oops!
return MB_FAILURE;
- rval = mb->load_file( argv0, set );
+ rval = mb->load_file( argv0 );
if (MB_SUCCESS == rval)
return MB_FAILURE;
Modified: MOAB/trunk/ReadABAQUS.cpp
===================================================================
--- MOAB/trunk/ReadABAQUS.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadABAQUS.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -132,7 +132,7 @@
MBErrorCode ReadABAQUS::load_file(const char *abaqus_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set_ptr,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -148,6 +148,11 @@
bool in_unsupported = false;
+ MBEntityHandle file_set;
+ status = mdbImpl->create_meshset( MESHSET_SET, file_set );
+ if (MB_SUCCESS != status)
+ return status;
+
next_line_type = get_next_line_type();
while (next_line_type != abq_eof)
{
@@ -254,8 +259,11 @@
}
-
- return MB_SUCCESS;
+ if (file_set_ptr) {
+ status = mdbImpl->unite_meshset( *file_set_ptr, file_set );
+ MB_RETURN_IF_FAIL;
+ }
+ return mdbImpl->delete_entities( &file_set, 1 );
}
Modified: MOAB/trunk/ReadABAQUS.hpp
===================================================================
--- MOAB/trunk/ReadABAQUS.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadABAQUS.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -162,7 +162,7 @@
//! load an ABAQUS file
MBErrorCode load_file( const char *exodus_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadCGM.cpp
===================================================================
--- MOAB/trunk/ReadCGM.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadCGM.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -112,7 +112,7 @@
// copy geometry into mesh database
MBErrorCode ReadCGM::load_file(const char *cgm_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -146,8 +146,10 @@
act_att = false;
// tag the file_set with the faceting_tol
- rval = mdbImpl->tag_set_data( faceting_tol_tag, &file_set, 1, &faceting_tol );
- if(MB_SUCCESS != rval) return rval;
+ if (file_set) {
+ rval = mdbImpl->tag_set_data( faceting_tol_tag, file_set, 1, &faceting_tol );
+ if(MB_SUCCESS != rval) return rval;
+ }
// CGM data
std::map<RefEntity*,MBEntityHandle> entmap[5]; // one for each dim, and one for groups
@@ -201,9 +203,6 @@
rval = mdbImpl->create_meshset( dim == 1 ? MESHSET_ORDERED : MESHSET_SET, handle );
if (MB_SUCCESS != rval)
return rval;
-
- rval = mdbImpl->add_entities( file_set, &handle, 1 );
- if(MB_SUCCESS != rval) return rval;
entmap[dim][ent] = handle;
@@ -298,9 +297,6 @@
rval = mdbImpl->create_meshset( MESHSET_SET, h );
if (MB_SUCCESS != rval)
return rval;
-
- rval = mdbImpl->add_entities( file_set, &h, 1 );
- if(MB_SUCCESS != rval) return rval;
char namebuf[NAME_TAG_SIZE];
memset( namebuf, '\0', NAME_TAG_SIZE );
Modified: MOAB/trunk/ReadCGM.hpp
===================================================================
--- MOAB/trunk/ReadCGM.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadCGM.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -56,7 +56,7 @@
// * MAX_FACET_EDGE_LENGTH=<real> (default: 0.0)
// * CGM_ATTRIBS=<yes|no> (default: no)
MBErrorCode load_file( const char *cgm_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadGmsh.cpp
===================================================================
--- MOAB/trunk/ReadGmsh.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadGmsh.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -70,7 +70,7 @@
MBErrorCode ReadGmsh::load_file( const char* filename,
- MBEntityHandle,
+ const MBEntityHandle*,
const FileOptions& ,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
Modified: MOAB/trunk/ReadGmsh.hpp
===================================================================
--- MOAB/trunk/ReadGmsh.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadGmsh.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -40,7 +40,7 @@
static MBReaderIface* factory( MBInterface* );
MBErrorCode load_file( const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/ReadHDF5.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadHDF5.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -317,7 +317,7 @@
}
MBErrorCode ReadHDF5::load_file( const char* filename,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -337,8 +337,8 @@
if (MB_SUCCESS == rval && file_id_tag)
rval = store_file_ids( *file_id_tag );
- if (MB_SUCCESS == rval)
- rval = read_qa( file_set );
+ if (MB_SUCCESS == rval && 0 != file_set)
+ rval = read_qa( *file_set );
MBErrorCode rval2 = clean_up_read( opts );
if (rval == MB_SUCCESS && rval2 != MB_SUCCESS)
Modified: MOAB/trunk/ReadHDF5.hpp
===================================================================
--- MOAB/trunk/ReadHDF5.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadHDF5.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -51,7 +51,7 @@
* \param export_set_count Length of <code>export_sets</code> array.
*/
MBErrorCode load_file( const char* filename,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadIDEAS.cpp
===================================================================
--- MOAB/trunk/ReadIDEAS.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadIDEAS.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -35,7 +35,7 @@
MBErrorCode ReadIDEAS::load_file(const char* fname,
- MBEntityHandle meshset,
+ const MBEntityHandle* ,
const FileOptions& options,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
Modified: MOAB/trunk/ReadIDEAS.hpp
===================================================================
--- MOAB/trunk/ReadIDEAS.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadIDEAS.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -21,7 +21,7 @@
static MBReaderIface* factory( MBInterface* );
MBErrorCode load_file( const char* fname,
- MBEntityHandle meshset,
+ const MBEntityHandle* meshset,
const FileOptions&,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadMCNP5.cpp
===================================================================
--- MOAB/trunk/ReadMCNP5.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadMCNP5.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -68,12 +68,12 @@
// load the file as called by the MBInterface function
-MBErrorCode ReadMCNP5::load_file(const char *filename,
- MBEntityHandle input_meshset,
- const FileOptions &options,
- const MBReaderIface::IDTag* subset_list,
- int subset_list_length,
- const MBTag* file_id_tag) {
+MBErrorCode ReadMCNP5::load_file(const char *filename,
+ const MBEntityHandle *input_meshset,
+ const FileOptions &options,
+ const MBReaderIface::IDTag *subset_list,
+ int subset_list_length,
+ const MBTag *file_id_tag) {
// at this time there is no support for reading a subset of the file
if (subset_list && subset_list_length) {
readMeshIface->report_error( "Reading subset of files not supported for meshtal." );
@@ -132,10 +132,10 @@
// This actually reads the file. It creates the mesh elements unless
// the file is being averaged with a pre-existing mesh.
-MBErrorCode ReadMCNP5::load_one_file(const char *fname,
- MBEntityHandle input_meshset,
- const FileOptions &options,
- const bool average ) {
+MBErrorCode ReadMCNP5::load_one_file(const char *fname,
+ const MBEntityHandle *input_meshset,
+ const FileOptions &options,
+ const bool average ) {
bool debug = false;
if (debug) std::cout << "begin ReadMCNP5::load_one_file" << std::endl;
@@ -192,8 +192,8 @@
// Everything stored in the file being read will be in the input_meshset.
// if this is being saved in MOAB, set header tags
- if (!average) {
- result = set_header_tags( input_meshset,
+ if (!average && 0 != input_meshset) {
+ result = set_header_tags( *input_meshset,
date_and_time,
title,
nps,
Modified: MOAB/trunk/ReadMCNP5.hpp
===================================================================
--- MOAB/trunk/ReadMCNP5.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadMCNP5.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -54,7 +54,7 @@
static MBReaderIface* factory( MBInterface* );
MBErrorCode load_file( const char* fname,
- MBEntityHandle input_meshset,
+ const MBEntityHandle *input_meshset,
const FileOptions &options,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
@@ -99,10 +99,10 @@
int nodeId, elemId;
// reads the meshtal file
- MBErrorCode load_one_file( const char *fname,
- MBEntityHandle input_meshset,
- const FileOptions &options,
- const bool average );
+ MBErrorCode load_one_file( const char *fname,
+ const MBEntityHandle *input_meshset,
+ const FileOptions &options,
+ const bool average );
MBErrorCode create_tags( MBTag &date_and_time_tag,
MBTag &title_tag,
Modified: MOAB/trunk/ReadNASTRAN.cpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadNASTRAN.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -38,7 +38,7 @@
// constructor
ReadNASTRAN::ReadNASTRAN(MBInterface* impl)
- : MBI(impl), fileIDTag(0) {
+ : MBI(impl) {
assert(NULL != impl);
void *ptr = 0;
MBI->query_interface("MBReadUtilIface", &ptr);
@@ -66,7 +66,7 @@
// load the file as called by the MBInterface function
MBErrorCode ReadNASTRAN::load_file(const char *filename,
- MBEntityHandle file_set,
+ const MBEntityHandle *,
const FileOptions &options,
const MBReaderIface::IDTag *subset_list,
int subset_list_length,
@@ -76,23 +76,14 @@
readMeshIface->report_error( "Reading subset of files not supported for NASTRAN." );
return MB_UNSUPPORTED_OPERATION;
}
-
- nodeId = elemId = 0;
- fileIDTag = file_id_tag;
+ nodeIdMap.clear();
+ elemIdMap.clear();
+
bool debug = false;
if (debug) std::cout << "begin ReadNASTRAN::load_file" << std::endl;
MBErrorCode result;
- // create tags
- MBTag id_tag, material_tag;
- result = MBI->tag_create(GLOBAL_ID_TAG_NAME, sizeof(int), MB_TAG_DENSE,
- MB_TYPE_INTEGER, id_tag, 0);
- if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
- result = MBI->tag_create(MATERIAL_SET_TAG_NAME, sizeof(int), MB_TAG_DENSE,
- MB_TYPE_INTEGER, material_tag, 0);
- if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
-
// Count the entities of each type in the file. This is used to allocate the node array.
int entity_count[MBMAXTYPE];
for(int i=0; i<MBMAXTYPE; i++) entity_count[i] = 0;
@@ -131,13 +122,10 @@
std::cout << "entity_count[" << i << "]=" << entity_count[i] << std::endl;
}
}
+
+ // Keep list of material sets
+ std::vector<MBRange> materials;
- /* If we assume that the node ids are continuous, then the node ids can be
- easily mapped to vertex handles. If they are not continuous then the node
- ids themselves will need to be used to create connectivity. It is very
- slow to find each node by its id because this is a tag call. */
- bool node_ids_are_continuous = true;
-
// Now that the number of vertices is known, create the vertices.
MBEntityHandle start_vert = NULL;
std::vector<double*> coord_arrays(3);
@@ -145,7 +133,7 @@
start_vert, coord_arrays );
if(MB_SUCCESS != result) return result;
if(0 == start_vert) return MB_FAILURE; // check for NULL
- int vert_index = 0;
+ int id, vert_index = 0;
if(debug) std::cout << "allocated coord arrays" << std::endl;
// Read the file again to create the entities.
@@ -169,17 +157,29 @@
// Create the entity.
if(MBVERTEX == type) {
- result = read_node(tokens, id_tag, file_set, debug, coord_arrays,
- vert_index, start_vert, node_ids_are_continuous );
+ double* coords[3] = { coord_arrays[0] + vert_index,
+ coord_arrays[1] + vert_index,
+ coord_arrays[2] + vert_index };
+ result = read_node(tokens, debug, coords, id );
if(MB_SUCCESS != result) return result;
+ if (!nodeIdMap.insert( id, start_vert + vert_index, 1 ).second)
+ return MB_FAILURE; // duplicate IDs!
+ ++vert_index;
} else {
- result = read_element(tokens, id_tag, material_tag, type, file_set,
- debug, start_vert, node_ids_are_continuous );
+ result = read_element( tokens, materials, type, debug );
if(MB_SUCCESS != result) return result;
}
}
+
+ result = create_materials( materials );
+ if(MB_SUCCESS != result) return result;
+
+ result = assign_ids( file_id_tag );
+ if(MB_SUCCESS != result) return result;
file.close();
+ nodeIdMap.clear();
+ elemIdMap.clear();
return MB_SUCCESS;
}
@@ -313,16 +313,12 @@
/* It has been determined that this line is a vertex. Read the rest of
the line and create the vertex. */
MBErrorCode ReadNASTRAN::read_node( const std::vector<std::string> tokens,
- MBTag id_tag,
- const MBEntityHandle file_set,
- const bool debug,
- std::vector<double*> coord_arrays,
- int &vert_index,
- const MBEntityHandle start_vert,
- bool &node_ids_are_continuous ) {
+ const bool debug,
+ double* coords[3],
+ int& id ) {
// read the node's id (unique)
MBErrorCode result;
- int id = atoi(tokens[1].c_str());
+ id = atoi(tokens[1].c_str());
// read the node's coordinate system number
// "0" or blank refers to the basic coordinate system.
@@ -334,32 +330,12 @@
}
// read the coordinates
- double coords[3];
for(unsigned int i=0; i<3; i++) {
- result = get_real( tokens[i+3], coords[i] );
+ result = get_real( tokens[i+3], *coords[i] );
if(MB_SUCCESS != result) return result;
if(debug) std::cout << "read_node: coords[" << i << "]=" << coords[i] << std::endl;
}
- // create the node
- MBEntityHandle vert = start_vert+vert_index;
- for(int i=0; i<3; i++) coord_arrays[i][vert_index] = coords[i];
- vert_index++;
-
- // check to see if the node ids are still continuous
- if(id != vert_index) {
- node_ids_are_continuous = false;
- std::cout << "node ids are not continuous" << std::endl;
- }
-
- // tag with the global id from the NASTRAN file
- result = MBI->tag_set_data( id_tag, &vert, 1, &id );
- if(MB_SUCCESS != result) return result;
-
- // add to the file set
- result = MBI->add_entities( file_set, &vert, 1 );
- if(MB_SUCCESS != result) return result;
-
return MB_SUCCESS;
}
@@ -367,75 +343,114 @@
line and create the element. Assume that all of the nodes have already
been created. */
MBErrorCode ReadNASTRAN::read_element( const std::vector<std::string> tokens,
- MBTag id_tag,
- MBTag material_tag,
+ std::vector<MBRange> &materials,
const MBEntityType element_type,
- const MBEntityHandle file_set,
- const bool debug,
- const MBEntityHandle start_vert,
- const bool node_ids_are_continuous ) {
+ const bool debug ) {
// read the element's id (unique) and material set
MBErrorCode result;
int id = atoi(tokens[1].c_str());
int material = atoi(tokens[2].c_str());
+
+ // Resize materials list if necessary. This code is somewhat complicated
+ // so as to avoid copying of MBRanges
+ if (material >= (int)materials.size()) {
+ if ((int)materials.capacity() < material)
+ materials.resize( material+1 );
+ else {
+ std::vector<MBRange> new_mat( material+1 );
+ for (size_t i = 0; i < materials.size(); ++i)
+ new_mat[i].swap( materials[i] );
+ materials.swap( new_mat );
+ }
+ }
// the size of the connectivity array depends on the element type
int n_conn = MBCN::VerticesPerEntity(element_type);
+ MBEntityHandle conn_verts[27];
+ assert(n_conn <= (int)(sizeof(conn_verts)/sizeof(MBEntityHandle)));
// read the connected node ids from the file
- int conn[n_conn];
for(int i=0; i<n_conn; i++) {
- conn[i] = atoi(tokens[3+i].c_str());
+ int n = atoi(tokens[3+i].c_str());
+ conn_verts[i] = nodeIdMap.find( n );
+ if (!conn_verts[i]) // invalid vertex id
+ return MB_FAILURE;
}
- /* Get the vertex handles with those node ids. If the nodes do not have
- continuous ids we need to do a very slow tag search for global ids.
- The cannonical numbering between NASTRAN and MOAB is the same for
- tets and prisms. */
- MBEntityHandle conn_verts[n_conn];
- for(int i=0; i<n_conn; i++) {
- if(node_ids_are_continuous) {
- conn_verts[i] = start_vert + conn[i] -1;
- } else {
- void *vert_id_val[] = {&conn[i]};
- MBRange vert;
- result = MBI->get_entities_by_type_and_tag( file_set, MBVERTEX, &id_tag,
- vert_id_val, 1, vert );
- if(MB_SUCCESS != result) return result;
- if(1 != vert.size()) return MB_FAILURE; // only one vertex should have this global id
- conn_verts[i] = vert.front();
- }
- if(debug) std::cout << "conn[" << i << "]=" << conn[i] << std::endl;
- }
-
// Create the element and set the global id from the NASTRAN file
MBEntityHandle element;
result = MBI->create_element( element_type, conn_verts, n_conn, element );
if(MB_SUCCESS != result) return result;
- result = MBI->tag_set_data( id_tag, &element, 1, &id );
- if(MB_SUCCESS != result) return result;
+ elemIdMap.insert( id, element, 1 );
+
+ materials[material].insert( element );
+ return MB_SUCCESS;
+}
- // Create the material set for the element if it does not already exist.
- void *mat_val[] = {&material};
- MBRange material_set;
- result = MBI->get_entities_by_type_and_tag( file_set, MBENTITYSET, &material_tag,
- mat_val, 1, material_set );
- if(MB_SUCCESS != result) return result;
- if(0 == material_set.size()) {
- MBEntityHandle new_material_set;
- result = MBI->create_meshset( 0, new_material_set );
- if(MB_SUCCESS != result) return result;
- result = MBI->add_entities( file_set, &new_material_set, 1 );
- if(MB_SUCCESS != result) return result;
- result = MBI->tag_set_data( material_tag, &new_material_set, 1, &material );
- if(MB_SUCCESS != result) return result;
- material_set.insert( new_material_set );
- } else if(1 < material_set.size()) {
- return MB_MULTIPLE_ENTITIES_FOUND;
+
+MBErrorCode ReadNASTRAN::create_materials( const std::vector<MBRange>& materials )
+{
+ MBErrorCode result;
+ MBTag material_tag;
+ result = MBI->tag_create(MATERIAL_SET_TAG_NAME, sizeof(int), MB_TAG_DENSE,
+ MB_TYPE_INTEGER, material_tag, 0);
+ if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
+
+ for (size_t i = 0; i < materials.size(); ++i) {
+ if (materials[i].empty())
+ continue;
+
+ // Merge with existing or create new? Original code effectively
+ // created new by only merging with existing in current file set,
+ // so do the same here. - j.kraftcheck
+
+ MBEntityHandle handle;
+ result = MBI->create_meshset( MESHSET_SET, handle );
+ if (MB_SUCCESS != result)
+ return result;
+
+ result = MBI->add_entities( handle, materials[i] );
+ if (MB_SUCCESS != result)
+ return result;
+
+ int id = i;
+ result = MBI->tag_set_data( material_tag, &handle, 1, &id );
+ if (MB_SUCCESS != result)
+ return result;
}
- result = MBI->add_entities( material_set.front(), &element, 1 );
- if(MB_SUCCESS != result) return result;
+
+ return MB_SUCCESS;
+}
+MBErrorCode ReadNASTRAN::assign_ids( const MBTag* file_id_tag )
+{
+
+ // create tag
+ MBErrorCode result;
+ MBTag id_tag;
+ result = MBI->tag_create(GLOBAL_ID_TAG_NAME, sizeof(int), MB_TAG_DENSE,
+ MB_TYPE_INTEGER, id_tag, 0);
+ if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
+
+ RangeMap<int,MBEntityHandle>::iterator i;
+ std::vector<int> ids;
+ for (int t = 0; t < 2; ++t) {
+ RangeMap<int,MBEntityHandle>& fileIdMap = t ? elemIdMap : nodeIdMap;
+ for (i = fileIdMap.begin(); i != fileIdMap.end(); ++i) {
+ MBRange range( i->value, i->value + i->count - 1 );
+
+ result = readMeshIface->assign_ids( id_tag, range, i->begin );
+ if (MB_SUCCESS != result)
+ return result;
+
+ if (file_id_tag && *file_id_tag != id_tag) {
+ result = readMeshIface->assign_ids( *file_id_tag, range, i->begin );
+ if (MB_SUCCESS != result)
+ return result;
+ }
+ }
+ }
+
return MB_SUCCESS;
}
Modified: MOAB/trunk/ReadNASTRAN.hpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadNASTRAN.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -39,6 +39,7 @@
#include "MBInterface.hpp"
#include "MBReaderIface.hpp"
#include "FileTokenizer.hpp"
+#include "RangeMap.hpp"
class MBReadUtilIface;
@@ -50,7 +51,7 @@
static MBReaderIface* factory( MBInterface* );
MBErrorCode load_file( const char *filename,
- MBEntityHandle file_set,
+ const MBEntityHandle *file_set,
const FileOptions &options,
const MBReaderIface::IDTag *subset_list = 0,
int subset_list_length = 0,
@@ -65,7 +66,7 @@
const char *tag_name,
const FileOptions &opts,
std::vector<int> &tag_values_out,
- const IDTag *subset_list,
+ const IDTag *subset_list,
int subset_list_length );
protected:
@@ -76,10 +77,9 @@
// MOAB Interface
MBInterface* MBI;
+
+ RangeMap<int, MBEntityHandle> nodeIdMap, elemIdMap;
- const MBTag* fileIDTag;
- int nodeId, elemId;
-
enum line_format { SMALL_FIELD,
LARGE_FIELD,
FREE_FIELD };
@@ -96,21 +96,17 @@
MBErrorCode get_real( const std::string, double &real );
MBErrorCode read_node(const std::vector<std::string> tokens,
- MBTag id_tag,
- const MBEntityHandle file_set,
const bool debug,
- std::vector<double*> coord_arrays,
- int &vert_index,
- const MBEntityHandle start_vert,
- bool &node_ids_are_continuous );
+ double* coord_arrays[3],
+ int &node_id);
MBErrorCode read_element(const std::vector<std::string> tokens,
- MBTag id_tag,
- MBTag material_tag,
- const MBEntityType element_type,
- const MBEntityHandle file_set,
- const bool debug,
- const MBEntityHandle start_vert,
- const bool node_ids_are_continuous );
+ std::vector<MBRange> &materials,
+ const MBEntityType element_type,
+ const bool debug );
+
+ MBErrorCode create_materials( const std::vector<MBRange> &materials );
+
+ MBErrorCode assign_ids( const MBTag* file_id_tag );
};
#endif
Modified: MOAB/trunk/ReadNCDF.cpp
===================================================================
--- MOAB/trunk/ReadNCDF.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadNCDF.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -250,7 +250,7 @@
MBErrorCode ReadNCDF::load_file(const char *exodus_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -329,8 +329,10 @@
if (MB_FAILURE == status) return status;
// 8. Read qa records
- status = read_qa_records(file_set);
- if (MB_FAILURE == status) return status;
+ if (file_set) {
+ status = read_qa_records(*file_set);
+ if (MB_FAILURE == status) return status;
+ }
// what about properties???
Modified: MOAB/trunk/ReadNCDF.hpp
===================================================================
--- MOAB/trunk/ReadNCDF.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadNCDF.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -70,7 +70,7 @@
//! load an ExoII file
MBErrorCode load_file( const char *exodus_file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadSTL.cpp
===================================================================
--- MOAB/trunk/ReadSTL.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadSTL.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -76,7 +76,7 @@
// pure-virtual function implemented in subclasses to read
// the data from the file.
MBErrorCode ReadSTL::load_file( const char* filename,
- MBEntityHandle file_set,
+ const MBEntityHandle* ,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -145,18 +145,6 @@
handle, coord_arrays );
if (MB_SUCCESS != result)
return result;
-
- // Add vertices to entity set
- MBRange range(handle, handle+vertex_map.size()-1);
- result = mdbImpl->add_entities(file_set, range);
- if (MB_SUCCESS != result)
- return result;
-
- if (file_id_tag) {
- result = readMeshIface->assign_ids( *file_id_tag, range );
- if (MB_SUCCESS != result)
- return result;
- }
// Copy vertex coordinates into entity sequence coordinate arrays
// and copy handle into vertex_map.
@@ -181,19 +169,7 @@
connectivity );
if (MB_SUCCESS != result)
return result;
-
- // Add triangles to entity set
- MBRange range2(handle, handle+triangles.size()-1);
- result = mdbImpl->add_entities(file_set, range2);
- if (MB_SUCCESS != result)
- return result;
- if (file_id_tag) {
- result = readMeshIface->assign_ids( *file_id_tag, range2 );
- if (MB_SUCCESS != result)
- return result;
- }
-
// Use vertex_map to reconver triangle connectivity from
// vertex coordinates.
MBEntityHandle *conn_sav = connectivity;
Modified: MOAB/trunk/ReadSTL.hpp
===================================================================
--- MOAB/trunk/ReadSTL.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadSTL.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -72,7 +72,7 @@
//! Generic file loading code for both binary and ASCII readers.
//! Calls reader-specific read_triangles function to do actual I/O.
MBErrorCode load_file( const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadSms.cpp
===================================================================
--- MOAB/trunk/ReadSms.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadSms.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -73,7 +73,7 @@
MBErrorCode ReadSms::load_file( const char* filename,
- MBEntityHandle ,
+ const MBEntityHandle* ,
const FileOptions& ,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
Modified: MOAB/trunk/ReadSms.hpp
===================================================================
--- MOAB/trunk/ReadSms.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadSms.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -18,7 +18,7 @@
static MBReaderIface* factory( MBInterface* );
MBErrorCode load_file( const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadTetGen.cpp
===================================================================
--- MOAB/trunk/ReadTetGen.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadTetGen.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -74,7 +74,7 @@
MBErrorCode ReadTetGen::load_file( const char* file_name_c,
- MBEntityHandle file_set,
+ const MBEntityHandle* ,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -138,23 +138,12 @@
MBRange tets, tris, edges;
std::vector<MBEntityHandle> nodes;
rval = read_node_file( node_file, &attr_tags[0][0], &attr_idx[0][0], attr_tags[0].size(), nodes );
- if (MB_SUCCESS == rval)
- rval = mbIface->add_entities( file_set, &nodes[0], nodes.size() );
- if (MB_SUCCESS == rval && ele_file.is_open()) {
+ if (MB_SUCCESS == rval && ele_file.is_open())
rval = read_elem_file( MBTET, ele_file, nodes, tets );
- if (MB_SUCCESS == rval)
- rval = mbIface->add_entities( file_set, tets );
- }
- if (MB_SUCCESS == rval && face_file.is_open()) {
+ if (MB_SUCCESS == rval && face_file.is_open())
rval = read_elem_file( MBTRI, face_file, nodes, tris );
- if (MB_SUCCESS == rval)
- rval = mbIface->add_entities( file_set, tris );
- }
- if (MB_SUCCESS == rval && edge_file.is_open()) {
+ if (MB_SUCCESS == rval && edge_file.is_open())
rval = read_elem_file( MBEDGE, edge_file, nodes, edges );
- if (MB_SUCCESS == rval)
- rval = mbIface->add_entities( file_set, edges );
- }
if (file_id_tag && MB_SUCCESS == rval)
rval = readTool->assign_ids( *file_id_tag, &nodes[0], nodes.size() );
Modified: MOAB/trunk/ReadTetGen.hpp
===================================================================
--- MOAB/trunk/ReadTetGen.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadTetGen.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -37,7 +37,7 @@
//! load a file
MBErrorCode load_file( const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions&,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/ReadVtk.cpp
===================================================================
--- MOAB/trunk/ReadVtk.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadVtk.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -179,7 +179,7 @@
MBErrorCode ReadVtk::load_file( const char *filename,
- MBEntityHandle ,
+ const MBEntityHandle* ,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
Modified: MOAB/trunk/ReadVtk.hpp
===================================================================
--- MOAB/trunk/ReadVtk.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/ReadVtk.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -33,7 +33,7 @@
//! load a file
MBErrorCode load_file( const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* file_set,
const FileOptions&,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/Tqdcfr.cpp
===================================================================
--- MOAB/trunk/Tqdcfr.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/Tqdcfr.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -202,7 +202,7 @@
}
MBErrorCode Tqdcfr::load_file(const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle* ,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -2590,10 +2590,9 @@
MBCore *my_impl = new MBCore();
Tqdcfr *my_tqd = new Tqdcfr(my_impl);
- MBEntityHandle file_set;
FileOptions opts(NULL);
- MBErrorCode result = my_tqd->load_file(file, file_set, opts, 0, 0, 0);
+ MBErrorCode result = my_tqd->load_file(file, 0, opts, 0, 0, 0);
if (MB_SUCCESS == result)
std::cout << "Success." << std::endl;
@@ -2612,7 +2611,7 @@
my_impl = new MBCore;
my_tqd = new Tqdcfr(my_impl);
- result = my_tqd->load_file(file, file_set, opts, 0, 0, 0);
+ result = my_tqd->load_file(file, 0, opts, 0, 0, 0);
if (MB_SUCCESS == result)
std::cout << "Success." << std::endl;
@@ -2640,7 +2639,7 @@
std::string options = "PARALLEL=READ_DELETE;PARTITION=MATERIAL_SET;PARTITION_DISTRIBUTE";
std::cout << "Testing parallel..." << std::endl;
- result = my_impl->load_file(file, file_set,
+ result = my_impl->load_file(file, 0,
options.c_str());
if (MB_SUCCESS == result)
Modified: MOAB/trunk/Tqdcfr.hpp
===================================================================
--- MOAB/trunk/Tqdcfr.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/Tqdcfr.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -293,7 +293,7 @@
// read cub file
MBErrorCode load_file(const char *file_name,
- MBEntityHandle file_set,
+ const MBEntityHandle *file_set,
const FileOptions& opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
Modified: MOAB/trunk/cub_file_test.cc
===================================================================
--- MOAB/trunk/cub_file_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/cub_file_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -171,13 +171,10 @@
void read_file( MBInterface& moab, const char* input_file )
{
MBErrorCode rval;
- MBEntityHandle set;
Tqdcfr reader( &moab );
FileOptions opts("");
- rval = moab.create_meshset( MESHSET_SET, set );
+ rval = reader.load_file( input_file, 0, opts, 0, 0, 0 );
CHECK_ERR(rval);
- rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
- CHECK_ERR(rval);
}
void test_vertices()
Modified: MOAB/trunk/exodus_test.cc
===================================================================
--- MOAB/trunk/exodus_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/exodus_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -181,13 +181,10 @@
const char* input_file )
{
MBErrorCode rval;
- MBEntityHandle set;
ReadNCDF reader( &moab );
FileOptions opts("");
- rval = moab.create_meshset( MESHSET_SET, set );
+ rval = reader.load_file( input_file, 0, opts, 0, 0, 0 );
CHECK_ERR(rval);
- rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
- CHECK_ERR(rval);
}
void write_and_read( MBInterface& write_mb,
@@ -196,7 +193,6 @@
{
const char* tmp_file = "exodus_test_tmp.g";
MBErrorCode rval;
- MBEntityHandle set;
ReadNCDF reader( &read_mb );
WriteNCDF writer( &write_mb );
FileOptions opts("");
@@ -211,11 +207,7 @@
remove(tmp_file);
CHECK_ERR(rval);
- rval = read_mb.create_meshset( MESHSET_SET, set );
- if (MB_SUCCESS != rval)
- remove(tmp_file);
- CHECK_ERR(rval);
- rval = reader.load_file( tmp_file, set, opts, 0, 0, 0 );
+ rval = reader.load_file( tmp_file, 0, opts, 0, 0, 0 );
remove( tmp_file );
CHECK_ERR(rval);
}
Modified: MOAB/trunk/gmsh_test.cc
===================================================================
--- MOAB/trunk/gmsh_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/gmsh_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -40,11 +40,9 @@
void read_file( MBInterface& moab, const char* input_file )
{
MBErrorCode rval;
- MBEntityHandle set;
- moab.create_meshset( MESHSET_SET, set );
ReadGmsh reader( &moab );
FileOptions opts("");
- rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
+ rval = reader.load_file( input_file, 0, opts, 0, 0, 0 );
CHECK_ERR(rval);
}
Modified: MOAB/trunk/kd_tree_test.cpp
===================================================================
--- MOAB/trunk/kd_tree_test.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/kd_tree_test.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -116,23 +116,14 @@
}
// write to file
-#if MB_VERSION_MAJOR <= 3
- err = moab.write_mesh( "tree.h5m" );
-#else
err = moab.write_file( "tree.h5m" );
-#endif
assert(!err);
// clear everything
moab.delete_mesh();
// read tree from file
-#if MB_VERSION_MAJOR <= 3
- err = moab.load_mesh( "tree.h5m" );
-#else
- MBEntityHandle file;
- err = moab.load_file( "tree.h5m", file );
-#endif
+ err = moab.load_file( "tree.h5m" );
assert(!err);
// get tag handle by name, because the handle may have changed
@@ -183,23 +174,14 @@
// write to file
-#if MB_VERSION_MAJOR <= 3
- err = moab.write_mesh( "tree.h5m" );
-#else
err = moab.write_file( "tree.h5m" );
-#endif
assert(!err);
// clear everything
moab.delete_mesh();
// read tree from file
-#if MB_VERSION_MAJOR <= 3
- err = moab.load_mesh( "tree.h5m" );
-#else
- MBEntityHandle file;
- err = moab.load_file( "tree.h5m", file );
-#endif
+ err = moab.load_file( "tree.h5m" );
assert(!err);
// check that tag doesn't exist
Modified: MOAB/trunk/nastran_test.cc
===================================================================
--- MOAB/trunk/nastran_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/nastran_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -40,11 +40,9 @@
void read_file( MBInterface& moab, const char* input_file )
{
MBErrorCode rval;
- MBEntityHandle set;
- moab.create_meshset( MESHSET_SET, set );
ReadNASTRAN reader( &moab );
FileOptions opts("");
- rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
+ rval = reader.load_file( input_file, 0, opts, 0, 0, 0 );
CHECK_ERR(rval);
}
Modified: MOAB/trunk/parallel/ReadParallel.cpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/ReadParallel.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -54,7 +54,7 @@
MBErrorCode ReadParallel::load_file(const char **file_names,
const int num_files,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions &opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
@@ -222,7 +222,7 @@
MBErrorCode ReadParallel::load_file(const char **file_names,
const int num_files,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set_ptr,
int parallel_mode,
std::string &partition_tag_name,
std::vector<int> &partition_tag_vals,
@@ -262,8 +262,10 @@
act_times[0] = MPI_Wtime();
// make a new set for the parallel read
+ MBEntityHandle file_set;
result = mbImpl->create_meshset(MESHSET_SET, file_set);
if (MB_SUCCESS != result) return result;
+
bool i_read = false;
MBTag id_tag = 0;
bool use_id_tag = false;
@@ -281,9 +283,11 @@
if (debug)
std::cout << "Reading file " << file_names[j] << std::endl;
- MBEntityHandle new_file_set = 0;
+ MBEntityHandle new_file_set;
+ result = mbImpl->create_meshset(MESHSET_SET, new_file_set);
+ if (MB_SUCCESS != result) return result;
tmp_result = impl->serial_load_file( file_names[j],
- new_file_set,
+ &new_file_set,
opts,
subset_list,
subset_list_length,
@@ -356,7 +360,7 @@
std::vector<MBReaderIface::IDTag> subset( subset_list,
subset_list + subset_list_length );
subset.push_back( parts );
- tmp_result = impl->serial_load_file( *file_names, file_set, opts,
+ tmp_result = impl->serial_load_file( *file_names, &file_set, opts,
&subset[0], subset.size(), file_id_tag );
if (MB_SUCCESS == tmp_result)
@@ -490,6 +494,13 @@
std::cout << ")" << std::endl;
}
+ if (MB_SUCCESS == result && file_set_ptr) {
+ MBRange all_ents;
+ result = mbImpl->get_entities_by_handle(file_set, all_ents);
+ if (MB_SUCCESS == result)
+ result = mbImpl->add_entities(*file_set_ptr, all_ents);
+ }
+
return result;
}
Modified: MOAB/trunk/parallel/ReadParallel.hpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.hpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/ReadParallel.hpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -18,7 +18,7 @@
//! load a file
MBErrorCode load_file(const char *file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions &opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
@@ -27,7 +27,7 @@
//! load multiple files
MBErrorCode load_file(const char **file_names,
const int num_files,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions &opts,
const MBReaderIface::IDTag* subset_list = 0,
int subset_list_length = 0,
@@ -35,7 +35,7 @@
MBErrorCode load_file(const char **file_names,
const int num_files,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
int parallel_mode,
std::string &partition_tag_name,
std::vector<int> &partition_tag_vals,
@@ -101,7 +101,7 @@
};
inline MBErrorCode ReadParallel::load_file(const char *file_name,
- MBEntityHandle& file_set,
+ const MBEntityHandle* file_set,
const FileOptions &opts,
const MBReaderIface::IDTag* subset_list,
int subset_list_length,
Modified: MOAB/trunk/parallel/mbparallelcomm_test.cpp
===================================================================
--- MOAB/trunk/parallel/mbparallelcomm_test.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/mbparallelcomm_test.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -337,7 +337,6 @@
if (print_parallel)
options << ";PRINT_PARALLEL";
- std::vector<MBEntityHandle> filesets(filenames.size());
std::vector<MBParallelComm*> pcs(filenames.size());
std::vector<ReadParallel*> rps(filenames.size());
MBErrorCode result;
@@ -347,7 +346,7 @@
pcs[i] = new MBParallelComm(mbImpl);
rps[i] = new ReadParallel(mbImpl, pcs[i]);
- result = rps[i]->load_file(filenames[i].c_str(), filesets[i],
+ result = rps[i]->load_file(filenames[i].c_str(), 0,
FileOptions(options.str().c_str()), 0, 0, 0);
if (MB_SUCCESS != result)
PRINT_LAST_ERROR;
@@ -368,7 +367,7 @@
}
}
else {
- result = mbImpl->load_file(filenames[0].c_str(), filesets[0],
+ result = mbImpl->load_file(filenames[0].c_str(), 0,
options.str().c_str());
pcs[0] = MBParallelComm::get_pcomm(mbImpl, 0);
assert(pcs[0]);
@@ -383,7 +382,10 @@
{
// read the mesh
MBEntityHandle file_set;
- MBErrorCode result = mbImpl->load_file(filename, file_set, NULL);
+ MBErrorCode result = mbImpl->create_meshset( MESHSET_SET, file_set );
+ RRA("create_meshset failed.");
+
+ result = mbImpl->load_file(filename, &file_set, NULL);
if (MB_SUCCESS != result) {
std::cerr << "Reading file failed; message:" << std::endl;
PRINT_LAST_ERROR;
Modified: MOAB/trunk/parallel/parallel_hdf5_test.cc
===================================================================
--- MOAB/trunk/parallel/parallel_hdf5_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/parallel_hdf5_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -262,9 +262,8 @@
void load_and_partition( MBInterface& moab, const char* filename, bool print )
{
MBErrorCode rval;
- MBEntityHandle set;
- rval = moab.load_file( filename, set,
+ rval = moab.load_file( filename, 0,
"PARALLEL=READ_DELETE;"
"PARTITION=GEOM_DIMENSION;PARTITION_VAL=3;"
"PARTITION_DISTRIBUTE;"
@@ -279,7 +278,6 @@
void save_and_load_on_root( MBInterface& moab, const char* tmp_filename )
{
MBErrorCode rval;
- MBEntityHandle set;
int procnum;
MPI_Comm_rank( MPI_COMM_WORLD, &procnum );
@@ -296,7 +294,7 @@
moab.delete_mesh();
if (procnum == 0) {
- rval = moab.load_file( tmp_filename, set );
+ rval = moab.load_file( tmp_filename );
if (!KeepTmpFiles)
remove( tmp_filename );
CHECK_ERR(rval);
@@ -438,8 +436,7 @@
if (rank == 0) {
MBCore moab2;
- MBEntityHandle set;
- rval = moab2.load_file( InputFile, set );
+ rval = moab2.load_file( InputFile );
CHECK_ERR(rval);
check_identical_mesh( moab, moab2 );
}
@@ -484,8 +481,7 @@
MBCore moab2_instance;
MBInterface& moab2 = moab2_instance;
- MBEntityHandle set;
- rval = moab2.load_file( InputFile, set );
+ rval = moab2.load_file( InputFile );
CHECK_ERR(rval);
MBTag mattag1, mattag2;
@@ -746,7 +742,6 @@
MBCore moab;
MBInterface &mb = moab;
MBErrorCode rval;
- MBEntityHandle file_set;
// if root processor, create hdf5 file for use in testing
if (0 == rank)
@@ -757,7 +752,7 @@
const char opt1[] = "PARALLEL=READ_PART;PARTITION=PARTITION";
const char opt2[] = "PARALLEL=READ_PART;PARTITION=PARTITION;PARTITION_BY_RANK";
const char* opt = numproc == 1 ? 0 : by_rank ? opt2 : opt1;
- rval = mb.load_file( file_name, file_set, opt );
+ rval = mb.load_file( file_name, 0, opt );
MPI_Barrier(MPI_COMM_WORLD); // make sure all procs complete before removing file
if (0 == rank && !KeepTmpFiles) remove( file_name );
CHECK_ERR(rval);
@@ -809,7 +804,6 @@
MPI_Comm_size( MPI_COMM_WORLD, &numproc );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
MBErrorCode rval;
- MBEntityHandle file_set;
// if root processor, create hdf5 file for use in testing
if (0 == rank)
@@ -827,7 +821,7 @@
times[0] = MPI_Wtime();
tmp_t = clock();
const char opt[] = "PARALLEL=READ_PART;PARTITION=PARTITION;PARTITION_BY_RANK";
- rval = mb.load_file( file_name, file_set, opt );
+ rval = mb.load_file( file_name, 0, opt );
CHECK_ERR(rval);
times[0] = MPI_Wtime() - times[0];
times[1] = double(clock() - tmp_t) / CLOCKS_PER_SEC;
@@ -839,7 +833,7 @@
times[2] = MPI_Wtime();
tmp_t = clock();
const char opt2[] = "PARALLEL=READ_DELETE;PARTITION=PARTITION;PARTITION_BY_RANK";
- rval = mb2.load_file( file_name, file_set, opt2 );
+ rval = mb2.load_file( file_name, 0, opt2 );
CHECK_ERR(rval);
times[2] = MPI_Wtime() - times[2];
times[3] = double(clock() - tmp_t) / CLOCKS_PER_SEC;
@@ -851,7 +845,7 @@
times[4] = MPI_Wtime();
tmp_t = clock();
const char opt3[] = "PARALLEL=BCAST_DELETE;PARTITION=PARTITION;PARTITION_BY_RANK";
- rval = mb3.load_file( file_name, file_set, opt3 );
+ rval = mb3.load_file( file_name, 0, opt3 );
CHECK_ERR(rval);
times[4] = MPI_Wtime() - times[4];
times[5] = double(clock() - tmp_t) / CLOCKS_PER_SEC;
@@ -883,7 +877,6 @@
MBCore moab;
MBInterface &mb = moab;
MBErrorCode rval;
- MBEntityHandle file_set;
// if root processor, create hdf5 file for use in testing
if (0 == rank)
@@ -893,7 +886,7 @@
// do parallel read unless only one processor
const char opt1[] = "PARALLEL=READ_PART;PARTITION=PARTITION";
const char* opt = numproc == 1 ? 0 : opt1;
- rval = mb.load_file( file_name, file_set, opt );
+ rval = mb.load_file( file_name, 0, opt );
MPI_Barrier(MPI_COMM_WORLD); // make sure all procs complete before removing file
if (0 == rank && !KeepTmpFiles) remove( file_name );
CHECK_ERR(rval);
@@ -955,7 +948,6 @@
MBCore moab;
MBInterface &mb = moab;
MBErrorCode rval;
- MBEntityHandle file_set;
const int def_val = 0xdeadcad;
const int global_val = -11;
@@ -967,7 +959,7 @@
// do parallel read unless only one processor
const char opt1[] = "PARALLEL=READ_PART;PARTITION=PARTITION";
const char* opt = numproc == 1 ? 0 : opt1;
- rval = mb.load_file( file_name, file_set, opt );
+ rval = mb.load_file( file_name, 0, opt );
MPI_Barrier(MPI_COMM_WORLD); // make sure all procs complete before removing file
if (0 == rank && !KeepTmpFiles) remove( file_name );
CHECK_ERR(rval);
@@ -1010,7 +1002,6 @@
MBCore moab;
MBInterface &mb = moab;
MBErrorCode rval;
- MBEntityHandle file_set;
// if root processor, create hdf5 file for use in testing
if (0 == rank)
@@ -1020,7 +1011,7 @@
// do parallel read unless only one processor
const char opt1[] = "PARALLEL=READ_PART;PARTITION=PARTITION";
const char* opt = numproc == 1 ? 0 : opt1;
- rval = mb.load_file( file_name, file_set, opt );
+ rval = mb.load_file( file_name, 0, opt );
MPI_Barrier(MPI_COMM_WORLD); // make sure all procs complete before removing file
if (0 == rank && !KeepTmpFiles) remove( file_name );
CHECK_ERR(rval);
Modified: MOAB/trunk/parallel/parallel_unit_tests.cpp
===================================================================
--- MOAB/trunk/parallel/parallel_unit_tests.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/parallel_unit_tests.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -399,10 +399,9 @@
MBCore mb_instance;
MBInterface& moab = mb_instance;
MBErrorCode rval;
- MBEntityHandle set;
const char* geom_names[] = { "vertex", "curve", "surface", "volume", "unknown" };
- rval = moab.load_file( filename, set,
+ rval = moab.load_file( filename, 0,
"PARALLEL=READ_DELETE;"
"PARTITION=GEOM_DIMENSION;PARTITION_VAL=3;"
"PARTITION_DISTRIBUTE;"
@@ -650,7 +649,6 @@
MBCore mb_instance;
MBInterface& moab = mb_instance;
MBErrorCode rval;
- MBEntityHandle set;
std::ostringstream file_opts;
file_opts << "PARALLEL=READ_DELETE;"
@@ -662,7 +660,7 @@
<< bridge_dimension << '.'
<< num_layers;
- rval = moab.load_file( filename, set, file_opts.str().c_str() );
+ rval = moab.load_file( filename, 0, file_opts.str().c_str() );
CHKERR(rval);
MBTag geom_tag, id_tag;
rval = moab.tag_get_handle( GEOM_DIMENSION_TAG_NAME, geom_tag ); CHKERR(rval);
@@ -773,8 +771,7 @@
// read file in serial
MBCore moab2;
- MBEntityHandle set2;
- rval = moab2.load_file( filename, set2 );
+ rval = moab2.load_file( filename );
PCHECK(MB_SUCCESS == rval);
// get the global IDs of teh entities we expect to be ghosted
@@ -842,9 +839,8 @@
MBCore mb_instance;
MBInterface& moab = mb_instance;
MBErrorCode rval;
- MBEntityHandle set;
- rval = moab.load_file( filename, set,
+ rval = moab.load_file( filename, 0,
"PARALLEL=READ_DELETE;"
"PARTITION=GEOM_DIMENSION;PARTITION_VAL=3;"
"PARTITION_DISTRIBUTE;"
@@ -935,9 +931,8 @@
MBCore mb_instance;
MBInterface& moab = mb_instance;
MBErrorCode rval;
- MBEntityHandle set;
- rval = moab.load_file( filename, set,
+ rval = moab.load_file( filename, 0,
"PARALLEL=READ_DELETE;"
"PARTITION=GEOM_DIMENSION;PARTITION_VAL=3;"
"PARTITION_DISTRIBUTE;"
Modified: MOAB/trunk/parallel/pcomm_serial.cpp
===================================================================
--- MOAB/trunk/parallel/pcomm_serial.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/pcomm_serial.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -59,8 +59,7 @@
for (int i = 0; i < nprocs; i++) {
ReadParallel rp(moab+i, pc[i]);
- MBEntityHandle tmp_set = 0;
- rval = rp.load_file(fnames, 1, tmp_set, ReadParallel::POPT_READ_DELETE,
+ rval = rp.load_file(fnames, 1, 0, ReadParallel::POPT_READ_DELETE,
ptag_name,
partition_tag_vals, partition_distrib, false, pa_vec,
fopts, NULL, 0, NULL, i, false, -1, -1, -1, -1, 0);
Modified: MOAB/trunk/parallel/uber_parallel_test.cpp
===================================================================
--- MOAB/trunk/parallel/uber_parallel_test.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/parallel/uber_parallel_test.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -125,9 +125,8 @@
MBCore mb_instance;
MBInterface& moab = mb_instance;
MBErrorCode rval;
- MBEntityHandle set;
- rval = moab.load_file( filename, set, option);
+ rval = moab.load_file( filename, 0, option);
CHKERR(rval);
MBParallelComm* pcomm = MBParallelComm::get_pcomm(&moab, 0);
Modified: MOAB/trunk/stl_test.cc
===================================================================
--- MOAB/trunk/stl_test.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/stl_test.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -59,11 +59,9 @@
MBErrorCode read_file_( MBInterface& moab, const char* input_file, const char* options = "" )
{
MBErrorCode rval;
- MBEntityHandle set;
- moab.create_meshset( MESHSET_SET, set );
ReadSTL reader( &moab );
FileOptions opts(options);
- rval = reader.load_file( input_file, set, opts, 0, 0, 0 );
+ rval = reader.load_file( input_file, 0, opts, 0, 0, 0 );
return rval;
}
@@ -76,13 +74,11 @@
void convert_file( const char* input_file, const char* output_file, const char* options )
{
MBErrorCode rval;
- MBEntityHandle set;
MBCore moab;
- moab.create_meshset( MESHSET_SET, set );
ReadSTL reader( &moab );
FileOptions opts_reader("");
- rval = reader.load_file( input_file, set, opts_reader, 0, 0, 0 );
+ rval = reader.load_file( input_file, 0, opts_reader, 0, 0, 0 );
CHECK_ERR(rval);
WriteSTL writer( &moab );
Modified: MOAB/trunk/test/h5file/h5partial.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5partial.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/test/h5file/h5partial.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -227,7 +227,9 @@
// now read back in only the empty set
MBEntityHandle file_set;
int id = non_existant ? 8 : 7;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, &id, 1 );
+ rval = mb.create_meshset( MESHSET_SET, file_set );
+ CHECK_ERR(rval);
+ rval = mb.load_file( TEST_FILE, &file_set, READ_OPTS, ID_TAG_NAME, &id, 1 );
if (non_existant) {
CHECK_EQUAL( MB_ENTITY_NOT_FOUND, rval );
return;
@@ -306,8 +308,10 @@
values.resize( num_read_sets );
for (int i = 0; i < num_read_sets; ++i) values[i] = 2*(i+1);
MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, &values[0], num_read_sets );
+ rval = mb.create_meshset( MESHSET_SET, file_set );
CHECK_ERR(rval);
+ rval = mb.load_file( TEST_FILE, &file_set, READ_OPTS, ID_TAG_NAME, &values[0], num_read_sets );
+ CHECK_ERR(rval);
int count, expected = 0;
rval = mb.get_number_entities_by_dimension( 0, 0, count );
@@ -556,8 +560,7 @@
for (int id = 1; id <= NUM_SETS; ++id) {
rval = mb.delete_mesh();
CHECK_ERR(rval);
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, &id, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, &id, 1 );
CHECK_ERR(rval);
MBRange verts;
rval = mb.get_entities_by_type( 0, MBVERTEX, verts );
@@ -576,8 +579,10 @@
create_mesh( true, false, false, false );
int ids[2] = { 2, 8 };
MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, ids, 2 );
+ rval = mb.create_meshset( MESHSET_SET, file_set );
CHECK_ERR(rval);
+ rval = mb.load_file( TEST_FILE, &file_set, READ_OPTS, ID_TAG_NAME, ids, 2 );
+ CHECK_ERR(rval);
MBRange sets;
rval = mb.get_entities_by_type( 0, MBENTITYSET, sets );
@@ -641,8 +646,7 @@
create_mesh( true, false, false, false );
int ids[2] = { 1, 4 };
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, ids, 2 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 2 );
CHECK_ERR(rval);
MBTag tag = check_tag( mb, CENTROID_NAME, MB_TAG_DENSE, MB_TYPE_DOUBLE, 3*sizeof(double) );
@@ -671,8 +675,7 @@
create_mesh( true, false, false, false );
int ids[2] = { 1, 4 };
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, ids, 2 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 2 );
CHECK_ERR(rval);
MBTag tag = check_tag( mb, LOGICAL_NAME, MB_TAG_DENSE, MB_TYPE_OPAQUE, 2*sizeof(int) );
@@ -701,8 +704,7 @@
const char tag_name[] = "VTX_ADJ";
create_mesh( true, false, false, false, tag_name, var_len );
int ids[2] = { 7, 10 };
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, ids, 2 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 2 );
CHECK_ERR(rval);
MBTag tag = check_tag( mb, tag_name, MB_TAG_DENSE, MB_TYPE_HANDLE,
@@ -754,8 +756,7 @@
create_mesh( false, false, true, false );
int id = 5;
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, &id, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, &id, 1 );
CHECK_ERR(rval);
MBRange verts;
@@ -778,8 +779,7 @@
create_mesh( false, false, false, true );
int id = 1; // NOTE: this test will only succeed for ID == 1
- MBEntityHandle file_set;
- rval = mb.load_file( TEST_FILE, file_set, READ_OPTS, ID_TAG_NAME, &id, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, &id, 1 );
CHECK_ERR(rval);
MBRange verts;
@@ -897,8 +897,7 @@
rval = mb.delete_mesh();
CHECK_ERR(rval);
- MBEntityHandle file;
- rval = mb.load_file( TEST_FILE, file, READ_OPTS, ID_TAG_NAME, ids, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 1 );
CHECK_ERR(rval);
MBRange rpoly;
@@ -966,8 +965,10 @@
CHECK_ERR(rval);
MBEntityHandle file;
+ rval = mb.create_meshset( MESHSET_SET, file );
+ CHECK_ERR(rval);
int id = i+1;
- rval = mb.load_file( TEST_FILE, file, READ_OPTS ";SETS=NONE", ID_TAG_NAME, &id, 1 );
+ rval = mb.load_file( TEST_FILE, &file, READ_OPTS ";SETS=NONE", ID_TAG_NAME, &id, 1 );
CHECK_ERR(rval);
// check that the total number of sets read is as expected
@@ -1146,8 +1147,11 @@
rval = mb.delete_mesh();
CHECK_ERR(rval);
- rval = mb.load_file( TEST_FILE, file, opt.c_str(), ID_TAG_NAME, test_ids+i, 1 );
+ rval = mb.create_meshset( MESHSET_SET, file );
CHECK_ERR(rval);
+
+ rval = mb.load_file( TEST_FILE, 0, opt.c_str(), ID_TAG_NAME, test_ids+i, 1 );
+ CHECK_ERR(rval);
rval = mb.tag_get_handle( ID_TAG_NAME, id_tag );
CHECK_ERR(rval);
@@ -1216,7 +1220,8 @@
MBEntityHandle file;
const int read_id = 3;
rval = mb.delete_mesh(); CHECK_ERR(rval);
- rval = mb.load_file( TEST_FILE, file, opt.c_str(), ID_TAG_NAME, &read_id, 1 );
+ rval = mb.create_meshset( MESHSET_SET, file ); CHECK_ERR(rval);
+ rval = mb.load_file( TEST_FILE, &file, opt.c_str(), ID_TAG_NAME, &read_id, 1 );
CHECK_ERR(rval);
// get any sets that were read it
@@ -1292,10 +1297,9 @@
MBInterface& mb = instance;
// read some sets
- MBEntityHandle file;
const int ids[] = { 1, 5, 9 };
const int num_sets = sizeof(ids)/sizeof(int);
- rval = mb.load_file( TEST_FILE, file, READ_OPTS, ID_TAG_NAME, ids, num_sets );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, num_sets );
CHECK_ERR(rval);
MBTag id_tag;
@@ -1380,8 +1384,7 @@
// read mesh
rval = mb.delete_mesh(); CHECK_ERR(rval);
- MBEntityHandle file;
- rval = mb.load_file( TEST_FILE, file, READ_OPTS, ID_TAG_NAME, ids, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 1 );
CHECK_ERR(rval);
// expect two hexes and two edges
@@ -1466,8 +1469,7 @@
// read first set back in
rval = mb.delete_mesh(); CHECK_ERR(rval);
- MBEntityHandle file;
- rval = mb.load_file( TEST_FILE, file, READ_OPTS, ID_TAG_NAME, ids, 1 );
+ rval = mb.load_file( TEST_FILE, 0, READ_OPTS, ID_TAG_NAME, ids, 1 );
CHECK_ERR(rval);
// check expected counts
Modified: MOAB/trunk/test/h5file/h5sets_test.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5sets_test.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/test/h5file/h5sets_test.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -18,12 +18,14 @@
MBErrorCode rval;
rval = output.write_file( filename );
CHECK_ERR(rval);
- rval = input.load_file( filename, file );
+ if (input_set) {
+ rval = input.create_meshset( MESHSET_SET, *input_set );
+ CHECK_ERR(rval);
+ }
+ rval = input.load_file( filename, input_set );
if (!keep_file)
remove(filename);
CHECK_ERR(rval);
- if (input_set)
- *input_set = file;
}
void test_ranged_set_with_holes()
@@ -265,7 +267,7 @@
// write file and read back in
rval = mb.write_file( str.str().c_str(), 0, "BUFFER_SIZE=1024" ); CHECK_ERR(rval);
mb.delete_mesh();
- rval = mb.load_file( str.str().c_str(), root );
+ rval = mb.load_file( str.str().c_str() );
if (!keep_file)
remove( str.str().c_str() );
CHECK_ERR(rval);
Modified: MOAB/trunk/test/perf/adj_time.cpp
===================================================================
--- MOAB/trunk/test/perf/adj_time.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/test/perf/adj_time.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -19,8 +19,7 @@
MBInterface& mb = moab;
// load test file
- MBEntityHandle set;
- rval = mb.load_file( default_input_file, set );
+ rval = mb.load_file( default_input_file );
if (MB_SUCCESS != rval) {
std::cerr << default_input_file <<": failed to load file." << std::endl;
return 1;
Modified: MOAB/trunk/test/perf/point_in_elem.cpp
===================================================================
--- MOAB/trunk/test/perf/point_in_elem.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/test/perf/point_in_elem.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -116,10 +116,9 @@
MBCore moab;
MBInterface& mb = moab;
MBErrorCode rval;
- MBEntityHandle file_set;
std::string init_msg, msg;
mb.get_last_error( init_msg );
- rval = mb.load_file( input_file, file_set );
+ rval = mb.load_file( input_file );
if (MB_SUCCESS != rval) {
std::cerr << input_file << " : failed to read file." << std::endl;
mb.get_last_error( msg );
Modified: MOAB/trunk/tools/convert.cpp
===================================================================
--- MOAB/trunk/tools/convert.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/convert.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -271,8 +271,7 @@
// Read the input file.
reset_times();
- MBEntityHandle read_meshset;
- result = gMB->load_file( in, read_meshset, read_options.c_str() );
+ result = gMB->load_file( in, 0, read_options.c_str() );
if (MB_SUCCESS != result)
{
std::cerr << "Failed to load \"" << in << "\"." << std::endl;
Modified: MOAB/trunk/tools/dagmc/DagMC.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/dagmc/DagMC.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -887,7 +887,6 @@
const double facet_tolerance)
{
MBErrorCode rval;
- MBEntityHandle file_set;
// override default value of facetingTolerance with passed value
if (facet_tolerance > 0 )
@@ -901,7 +900,7 @@
char options[120] = "CGM_ATTRIBS=yes;FACET_DISTANCE_TOLERANCE=";
strcat(options,facetTolStr);
- rval = MBI->load_file(cfile, file_set, options, NULL, 0, 0);
+ rval = MBI->load_file(cfile, 0, options, NULL, 0, 0);
if (MB_SUCCESS != rval) {
std::cerr << "Couldn't read file " << cfile << std::endl;
return rval;
Modified: MOAB/trunk/tools/dagmc/cub2h5m.cc
===================================================================
--- MOAB/trunk/tools/dagmc/cub2h5m.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/dagmc/cub2h5m.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -113,16 +113,15 @@
MBCore *my_impl = new MBCore();
Tqdcfr *my_tqd = new Tqdcfr(my_impl);
ReadNCDF my_ex_reader(my_impl);
- MBEntityHandle file_set;
char options[120] = "tdata=coord,";
strcat(options, time_step);
strcat(options,",set");
FileOptions opts(options) ;
- MBErrorCode result = my_tqd->load_file(input_name, file_set, opts, NULL, 0, 0);
+ MBErrorCode result = my_tqd->load_file(input_name, 0, opts, NULL, 0, 0);
//opts = "tdata=coord, 100, sum, temp.exo";
- result = my_ex_reader.load_file(update_name, file_set, opts, NULL, 0 , 0);
+ result = my_ex_reader.load_file(update_name, 0, opts, NULL, 0 , 0);
// convert the quads to tris
quads_to_tris( my_impl, file_set );
Modified: MOAB/trunk/tools/dagmc/main.cc
===================================================================
--- MOAB/trunk/tools/dagmc/main.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/dagmc/main.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -129,7 +129,6 @@
// Intitalize MOAB
MBCore moab;
MBInterface* iface = &moab;
- MBEntityHandle file_set;
MBErrorCode rval;
// If CUB file, extract ACIS geometry
@@ -163,12 +162,12 @@
exit(2);
}
- rval = iface->load_file(temp_name,file_set,options,NULL,0,0);
+ rval = iface->load_file(temp_name,0,options,NULL,0,0);
remove( temp_name );
free( temp_name );
}
else {
- rval = iface->load_file(input_name,file_set,options,NULL,0,0);
+ rval = iface->load_file(input_name,0,options,NULL,0,0);
}
if (MB_SUCCESS != rval) {
std::cerr << "Failed to read '" << input_name << "' of type '" << file_type << "'" << std::endl;
Modified: MOAB/trunk/tools/dagmc/quads_to_tris_driver.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/quads_to_tris_driver.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/dagmc/quads_to_tris_driver.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -22,11 +22,10 @@
// load file from input argument
MBErrorCode result;
std::string filename = argv[1];
- MBEntityHandle input_meshset;
- result = MBI->load_file( filename.c_str(), input_meshset );
+ result = MBI->load_file( filename.c_str() );
assert( MB_SUCCESS == result );
- result = quads_to_tris( MBI, input_meshset );
+ result = quads_to_tris( MBI, 0 );
assert( MB_SUCCESS == result );
Modified: MOAB/trunk/tools/dagmc/test_geom.cc
===================================================================
--- MOAB/trunk/tools/dagmc/test_geom.cc 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/dagmc/test_geom.cc 2009-11-13 21:00:42 UTC (rev 3343)
@@ -174,8 +174,7 @@
}
DagMC& dagmc = *DagMC::instance();
- MBEntityHandle file_set;
- rval = dagmc.moab_instance()->load_file( filename, file_set );
+ rval = dagmc.moab_instance()->load_file( filename );
//rval = dagmc.load_file( filename, 0 );
remove( filename );
if (MB_SUCCESS != rval) {
Modified: MOAB/trunk/tools/depth.cpp
===================================================================
--- MOAB/trunk/tools/depth.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/depth.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -77,7 +77,8 @@
MBEntityHandle file;
MBErrorCode rval;
- rval = mb.load_file( input, file );
+ rval = mb.create_meshset( MESHSET_SET, file ); check(rval);
+ rval = mb.load_file( input, &file );
if (MB_SUCCESS != rval) {
std::cerr << "Failed to load file: " << input << std::endl;
return FILE_IO_ERROR;
Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -51,7 +51,7 @@
MBErrorCode create_int_ents(MBInterface *instance,
MBRange &from_ents,
- MBEntityHandle in_set = 0);
+ const MBEntityHandle* in_set = 0);
#define CHECK_SIZE(array, allocated, size, type, retval) \
if (0 != allocated && NULL != array && allocated < (size)) {\
@@ -313,9 +313,16 @@
eatwhitespace(tmp_options);
std::string opts = ";"; opts += tmp_options;
- MBEntityHandle file_set;
+ MBRange orig_ents;
+ MBErrorCode result = MBI->get_entities_by_handle( 0, orig_ents );
+ if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
- MBErrorCode result = MBI->load_file(tmp_filename.c_str(), file_set, opts.c_str());
+ const MBEntityHandle* file_set = 0;
+ if (handle != 0 /*root_set*/) {
+ file_set = reinterpret_cast<const MBEntityHandle*>(&handle);
+ }
+
+ result = MBI->load_file(tmp_filename.c_str(), file_set, opts.c_str());
if (MB_SUCCESS != result) {
std::string msg("iMesh_load:ERROR loading a mesh, with error type: ");
@@ -324,19 +331,12 @@
RETURN(iBase_ERROR_MAP[result]);
}
- if (handle) {
- MBRange set_ents;
- result = MBI->get_entities_by_handle(file_set, set_ents);
- if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
- result = MBI->add_entities(ENTITY_HANDLE(handle), set_ents);
- if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
- }
-
// create interior edges/faces if requested
if (MBimesh->AdjTable[5] || MBimesh->AdjTable[10]) {
MBRange set_ents;
- result = MBI->get_entities_by_handle(file_set, set_ents, true);
+ result = MBI->get_entities_by_handle(0, set_ents);
if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
+ set_ents = subtract( set_ents, orig_ents );
result = create_int_ents(MBI, set_ents, file_set);
if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
}
@@ -2956,7 +2956,7 @@
MBErrorCode create_int_ents(MBInterface *instance,
MBRange &from_ents,
- MBEntityHandle in_set)
+ const MBEntityHandle* in_set)
{
MBiMesh* mbimesh = dynamic_cast<MBiMesh*>(instance);
assert(mbimesh->AdjTable[10] || mbimesh->AdjTable[5]);
@@ -2970,7 +2970,7 @@
unsigned int old_size = from_ents.size();
from_ents.merge(int_ents);
if (old_size != from_ents.size() && in_set) {
- result = instance->add_entities(in_set, int_ents);
+ result = instance->add_entities(*in_set, int_ents);
if (MB_SUCCESS != result) return result;
}
}
@@ -2983,7 +2983,7 @@
unsigned int old_size = from_ents.size();
from_ents.merge(int_ents);
if (old_size != from_ents.size() && in_set) {
- result = instance->add_entities(in_set, int_ents);
+ result = instance->add_entities(*in_set, int_ents);
if (MB_SUCCESS != result) return result;
}
}
Modified: MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -88,14 +88,12 @@
// read in mesh(es)
std::vector<MBParallelComm *> pcs(filenames.size());
std::vector<ReadParallel *> rps(filenames.size());
- std::vector<MBEntityHandle> filesets(filenames.size());
for (unsigned int i = 0; i < filenames.size(); i++) {
pcs[i] = new MBParallelComm(mbImpl);
rps[i] = new ReadParallel(mbImpl, pcs[i]);
- result = rps[i]->load_file(filenames[i], filesets[i],
- FileOptions(opts.c_str()), 0, 0, 0);
+ result = rps[i]->load_file(filenames[i], 0, FileOptions(opts.c_str()));
PRINT_LAST_ERROR;
}
Modified: MOAB/trunk/tools/mcnpmit/main.cpp
===================================================================
--- MOAB/trunk/tools/mcnpmit/main.cpp 2009-11-12 22:25:37 UTC (rev 3342)
+++ MOAB/trunk/tools/mcnpmit/main.cpp 2009-11-13 21:00:42 UTC (rev 3343)
@@ -148,6 +148,8 @@
}
else {
+ MBresult = MBI->create_meshset( MESHSET_SET, meshset );
+ assert( MB_SUCCESS == MBresult );
MBresult = MBI->load_file( CAD_filename.c_str(), meshset );
assert( MB_SUCCESS == MBresult );
More information about the moab-dev
mailing list