Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::ReadDamsel Class Reference

#include <ReadDamsel.hpp>

+ Inheritance diagram for moab::ReadDamsel:
+ Collaboration diagram for moab::ReadDamsel:

Classes

class  subrange
 

Public Member Functions

ErrorCode load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0)
 Load an NC file. More...
 
 ReadDamsel (Interface *impl=NULL)
 Constructor. More...
 
virtual ~ReadDamsel ()
 Destructor. More...
 
virtual ErrorCode read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0)
 Read tag values from a file. More...
 
- Public Member Functions inherited from moab::ReaderIface
virtual ~ReaderIface ()
 

Static Public Member Functions

static ReaderIfacefactory (Interface *)
 

Private Member Functions

ErrorCode get_contents (damsel_model m, damsel_container c, Range &ents)
 Get contents of the container (containing file-side handles) and translate to moab-side handles. More...
 
ErrorCode get_contents (damsel_model m, damsel_container c, EntityHandle *ents)
 Get contents of the container (containing file-side handles) and translate to moab-side handles ents argument should point to already-allocated space. More...
 
ErrorCode init ()
 
ErrorCode parse_options (const FileOptions &opts, bool &parallel)
 
ErrorCode process_tags (std::vector< damsel_tag_buf_type > &tag_infos)
 
ErrorCode process_ent_info (const damsel_entity_buf_type &einfo)
 
ErrorCode process_entity_tags (int count, damsel_container tag_container, damsel_container app_cont, Range &these_ents)
 
ErrorCode process_coll_infos (std::vector< damsel_collection_buf_type > &coll_infos)
 
ErrorCode container_to_handle_pairs (damsel_container &cont, std::vector< damsel_handle > &handle_pairs)
 Convert handles in a container into handle pairs, one pair per contiguous sequence of handles in the container. More...
 
ErrorCode insert_into_map (std::vector< damsel_handle > &handle_pairs, EntityHandle start_handle)
 Store MOAB handles starting from start_handle, corresponding to store handles in handle_pairs, into the entity map. More...
 

Private Attributes

InterfacembImpl
 Interface instance. More...
 
ReadUtilIfacereadMeshIface
 UtilIface. More...
 
std::string fileName
 File name. More...
 
bool nativeParallel
 Whether this reader natively supports parallel semantics. More...
 
ParallelCommmyPcomm
 Parallel info. More...
 
Tag mGlobalIdTag
 Used to track file handles. More...
 
RangeMap< damsel_handle, EntityHandle, 0 > dmHandleRMap
 map from damsel to moab handles More...
 
DamselUtil dU
 Keep various damsel data. More...
 

Detailed Description

Definition at line 36 of file ReadDamsel.hpp.

Constructor & Destructor Documentation

◆ ReadDamsel()

moab::ReadDamsel::ReadDamsel ( Interface impl = NULL)

Constructor.

Definition at line 30 of file ReadDamsel.cpp.

31  : mbImpl( impl ), readMeshIface( NULL ), nativeParallel( false ), myPcomm( NULL ), mGlobalIdTag( 0 ), dU()
32 {
33  init();
34 }

References init().

Referenced by factory().

◆ ~ReadDamsel()

moab::ReadDamsel::~ReadDamsel ( )
virtual

Destructor.

Definition at line 36 of file ReadDamsel.cpp.

37 {
39 
40  DMSLlib_finalize( dU.dmslLib );
41 }

References moab::DamselUtil::dmslLib, dU, mbImpl, readMeshIface, and moab::Interface::release_interface().

Member Function Documentation

◆ container_to_handle_pairs()

ErrorCode moab::ReadDamsel::container_to_handle_pairs ( damsel_container &  cont,
std::vector< damsel_handle > &  handle_pairs 
)
private

Convert handles in a container into handle pairs, one pair per contiguous sequence of handles in the container.

◆ factory()

ReaderIface * moab::ReadDamsel::factory ( Interface iface)
static

Definition at line 25 of file ReadDamsel.cpp.

26 {
27  return new ReadDamsel( iface );
28 }

References iface, and ReadDamsel().

Referenced by moab::ReaderWriterSet::ReaderWriterSet().

◆ get_contents() [1/2]

ErrorCode moab::ReadDamsel::get_contents ( damsel_model  m,
damsel_container  c,
EntityHandle ents 
)
private

Get contents of the container (containing file-side handles) and translate to moab-side handles ents argument should point to already-allocated space.

Definition at line 489 of file ReadDamsel.cpp.

490 {
491  EntityHandle eh;
492  int ind = 0;
493 
494  if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
495  {
496  damsel_handle start;
497  size_t count, stride;
498  damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
499  CHK_DMSL_ERR( err, "Problem calling DMSLcontainer_sequence_get_contents" );
500  if( stride == 1 )
501  {
502  while( count )
503  {
504  // Get start in rangemap
506  if( beg == dmHandleRMap.end() ) return MB_SUCCESS;
507  unsigned int diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
508  unsigned int num = std::min( count - diff, (size_t)( *beg ).count );
509  for( EntityHandle hdl = ( *beg ).begin + diff; hdl <= (int)( *beg ).begin + diff + num - 1; hdl++ )
510  ents[ind++] = hdl;
511  count -= ( diff + num );
512  ++beg;
513  }
514  }
515  else
516  {
517  for( int i = count - 1; i >= 0; i-- )
518  {
519  if( dmHandleRMap.find( start + i, eh ) ) ents[i] = eh;
520  }
521  }
522  }
523  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
524  {
525  damsel_handle_ptr handle_ptr;
526  size_t count;
527  damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
528  CHK_DMSL_ERR( err, "Failed to get vector contents" );
529  for( int i = count - 1; i >= 0; i-- )
530  {
531  if( dmHandleRMap.find( handle_ptr[i], eh ) ) ents[i] = eh;
532  }
533  }
534  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
535  {
536  damsel_handle_ptr node_ptr = NULL;
537  damsel_container cont = NULL;
538  while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
539  {
540  ErrorCode rval = get_contents( m, cont, ents );
541  if( MB_SUCCESS != rval ) return rval;
542  unsigned int num = DMSLcontainer_count( cont );
543  ents += num;
544  }
545  }
546 
547  return MB_SUCCESS;
548 }

References CHK_DMSL_ERR, dmHandleRMap, moab::RangeMap< KeyType, ValType, NullVal >::end(), ErrorCode, moab::RangeMap< KeyType, ValType, NullVal >::find(), get_contents(), moab::RangeMap< KeyType, ValType, NullVal >::lower_bound(), and MB_SUCCESS.

◆ get_contents() [2/2]

ErrorCode moab::ReadDamsel::get_contents ( damsel_model  m,
damsel_container  c,
Range ents 
)
private

Get contents of the container (containing file-side handles) and translate to moab-side handles.

Definition at line 433 of file ReadDamsel.cpp.

434 {
435  EntityHandle eh;
436  if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
437  {
438  damsel_handle start;
439  size_t count, stride;
440  damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
441  CHK_DMSL_ERR( err, "DMSLcontainer_sequence_get_contents" );
442  if( stride == 1 )
443  {
444  while( count )
445  {
446  // Get start in rangemap
448  if( beg == dmHandleRMap.end() ) return MB_SUCCESS;
449  unsigned long diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
450  unsigned long num = std::min( count - diff, (size_t)( *beg ).count );
451  ents.insert( ( *beg ).begin + diff, ( *beg ).begin + diff + num - 1 );
452  count -= ( diff + num );
453  ++beg;
454  }
455  }
456  else
457  {
458  for( int i = count - 1; i >= 0; i-- )
459  {
460  if( dmHandleRMap.find( start + i, eh ) ) ents.insert( eh );
461  }
462  }
463  }
464  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
465  {
466  damsel_handle* handle_ptr;
467  size_t count;
468  damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
469  CHK_DMSL_ERR( err, "Trouble getting vector contents" );
470  for( int i = count - 1; i >= 0; i-- )
471  {
472  if( dmHandleRMap.find( handle_ptr[i], eh ) ) ents.insert( eh );
473  }
474  }
475  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
476  {
477  damsel_handle_ptr node_ptr = NULL;
478  damsel_container cont = NULL;
479  while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
480  {
481  ErrorCode rval = get_contents( m, c, ents );
482  if( MB_SUCCESS != rval ) return rval;
483  }
484  }
485 
486  return MB_SUCCESS;
487 }

References CHK_DMSL_ERR, dmHandleRMap, moab::RangeMap< KeyType, ValType, NullVal >::end(), ErrorCode, moab::RangeMap< KeyType, ValType, NullVal >::find(), moab::Range::insert(), moab::RangeMap< KeyType, ValType, NullVal >::lower_bound(), and MB_SUCCESS.

Referenced by get_contents(), and process_ent_info().

◆ init()

ErrorCode moab::ReadDamsel::init ( )
private

Definition at line 43 of file ReadDamsel.cpp.

44 {
46  assert( readMeshIface );
47 
48  return MB_SUCCESS;
49 }

References MB_SUCCESS, mbImpl, moab::Interface::query_interface(), and readMeshIface.

Referenced by ReadDamsel().

◆ insert_into_map()

ErrorCode moab::ReadDamsel::insert_into_map ( std::vector< damsel_handle > &  handle_pairs,
EntityHandle  start_handle 
)
private

Store MOAB handles starting from start_handle, corresponding to store handles in handle_pairs, into the entity map.

◆ load_file()

ErrorCode moab::ReadDamsel::load_file ( const char *  file_name,
const EntityHandle file_set,
const FileOptions opts,
const SubsetList subset_list = 0,
const Tag file_id_tag = 0 
)
virtual

Load an NC file.

Implements moab::ReaderIface.

Definition at line 70 of file ReadDamsel.cpp.

75 {
76  ErrorCode rval;
77 
78  rval = parse_options( opts, nativeParallel );
79  if( MB_SUCCESS != rval ) return rval;
80 
81  // Initialize damsel
82  dU.dmslLib = DMSLlib_init();
83 
84  // Create a damsel model
85  dU.dmslModel =
86  DMSLmodel_create( sizeof( EntityHandle ) == 8 ? DAMSEL_HANDLE_TYPE_HANDLE64 : DAMSEL_HANDLE_TYPE_HANDLE32 );
87 
88  // Model attach - need model id from make model, filename
89 #ifdef MOAB_HAVE_MPI
90  MPI_Comm comm = MPI_COMM_WORLD;
91  if( nativeParallel )
92  {
93  comm = myPcomm->proc_config().proc_comm();
94  }
95 #endif
96 
97  damsel_err_t err;
98  err = DMSLmodel_attach( dU.dmslModel, filename, comm, NULL );
99  CHK_DMSL_ERR( err, "DMSLmodel_attach failed" );
100  err = DMSLmodel_populate( dU.dmslModel );
101  CHK_DMSL_ERR( err, "DMSLmodel_populate failed" );
102 
103  // STEP 0: GET COLLECTION, TAG, ENTITY INFOS FOR GLOBAL MODEL
104  int num_containers = 0, num_tag_infos = 0, num_ent_infos = 0;
105  DMSLmodel_get_tuple_count( dU.dmslModel, &num_containers, &num_tag_infos );
106  num_ent_infos = DMSLmodel_get_entity_count( dU.dmslModel );
107  int num_coll_infos = DMSLmodel_get_collection_count( dU.dmslModel );
108  CHK_DMSL_ERR( err, "DMSLmodel_get_collection_count failed" );
109  if( -1 == num_containers || -1 == num_tag_infos || -1 == num_ent_infos )
110  MB_SET_ERR( MB_FAILURE, "Bad count for containers/tags/ents" );
111 
112  std::vector< damsel_entity_buf_type > ent_infos( num_ent_infos );
113  std::vector< damsel_collection_buf_type > coll_infos( num_coll_infos );
114  std::vector< damsel_tag_buf_type > tag_infos( num_tag_infos );
115  std::vector< damsel_container_buf_type > cont_infos( num_containers );
116  err = DMSLmodel_get_entity_infos( dU.dmslModel, &ent_infos[0] );
117  CHK_DMSL_ERR( err, "Failure getting entity infos" );
118  err = DMSLmodel_get_collection_infos( dU.dmslModel, &coll_infos[0] );
119  CHK_DMSL_ERR( err, "Failure getting collection infos" );
120  err = DMSLmodel_get_tag_infos( dU.dmslModel, &tag_infos[0] );
121  CHK_DMSL_ERR( err, "Failure getting tag infos" );
122  err = DMSLmodel_get_container_infos( dU.dmslModel, &cont_infos[0] );
123  CHK_DMSL_ERR( err, "Failure getting container infos" );
124 
125  // Create MOAB-side tags for all damsel tags except pre-defined ones
126  rval = process_tags( tag_infos );MB_CHK_SET_ERR( rval, "Error processing tags" );
127 
128  /*
129  if (nativeParallel) {
130  // STEP 1: GET COLLECTION(S) REPRESENTING PARTITION:
131  // Input: tag name, optionally value;
132  // Output: container with file-side handles of collections satisfying those criteria
133  // - Get all handles/values for tag
134  // - Select handles matching criteria for tag value (will be collection handles)
135  std::string partn_tag_name("PARALLEL_PARTITION");
136  damsel_handle partn_tag = DMSLselect_tag_by_name(dU.dmslModel, partn_tag_name.c_str());
137  // Get all the parts with that tag regardless of value
138  damsel_container part_handles = DMSLselect_handles_with_values(dU.dmslModel, partn_tag);
139 
140  // STEP 2: GET HANDLES FOR TAGS WE NEED FOR THIS READER:
141  // - "SET_CHARACTERISTIC"
142  damsel_handle setchar_tag = DMSLselect_tag_by_name(dU.dmslModel, "SET_CHARACTERISTIC");
143  // - "PARENT_LIST"
144  //damsel_handle plist_tag = DMSLselect_tag_by_name(dU.dmslModel, "PARENT_LIST");
145  // - "CHILD_LIST"
146  //damsel_handle clist_tag = DMSLselect_tag_by_name(dU.dmslModel, "CHILD_LIST");
147 
148  // STEP 3: GET VALUES FOR "SET_CHARACTERISTIC" TAG ON PARTITION COLLECTIONS,
149  // GET VECTOR- OR SET-TYPE FLAGS FOR PARTITION COLLECTIONS
150  // (gives tracking flag for moab)
151  int num_handles = DMSLcontainer_count(part_handles);
152  std::vector<unsigned> char_tagvals(num_handles);
153  // Map the set chars
154  err = DMSLmodel_map_tag(&char_tagvals[0], part_handles, &setchar_tag);CHK_DMSL_ERR(err,
155  "Problem calling DMSLmodel_map_tag");
156 
157  // Execute the transfer
158  err = DMSLmodel_transfer_sync(dU.dmslModel, DAMSEL_TRANSFER_TYPE_READ);CHK_DMSL_ERR(err,
159  "Problem calling DMSLmodel_transfer_sync");
160 
161  // STEP 4: READ/PROCESS PARTITION COLLECTION(S)
162  // Decide the handles I am responsible using round-robin for now
163  // - GET TYPE, CONTENTS OF COLLECTION CONTENTS CONTAINER
164  // - Allocate moab-side container (using count from container)
165  // - MAP storage TO CONTAINER
166  // - EXECUTE
167  // ==> have list of all handles (entities + collections) represented on this proc
168 
169  int tmp_num = num_handles / proc_size, extra = num_handles % proc_size;
170  if (extra) tmp_num++;
171  int my_num_handles = tmp_num;
172  if (proc_rank >= extra) my_num_handles--;
173  int first_ind = std::min(proc_rank, extra) * tmp_num +
174  std::max(proc_rank - extra, 0) * (tmp_num - 1);
175 
176  // - Create moab entity sets for partition collection(s)
177  EntityHandle start_handle;
178  rval = readMeshIface->create_entity_sets(my_num_handles, &char_tagvals[first_ind], 0,
179  start_handle);MB_CHK_SET_ERR(rval, "Problem creating entity sets");
180  }
181  else {
182  */
183  // Initialize just by entity; each call to process_ent_info will:
184  // a. Create moab-side representation to read into
185  // b. Map those handles to damsel handles
186  // c. Map coords / connectivity storage to damsel equivalent
187  // d. For each tag, map moab storage to damsel storage
188  std::vector< damsel_entity_buf_type >::iterator eiit;
189 
190  // Process verts info first
191  for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
192  {
193  if( ( *eiit ).entity_type == DAMSEL_ENTITY_TYPE_VERTEX )
194  {
195  rval = process_ent_info( *eiit );MB_CHK_ERR( rval );
196  }
197  }
198 
199  for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
200  {
201  if( ( *eiit ).entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
202  {
203  rval = process_ent_info( *eiit );MB_CHK_ERR( rval );
204  }
205  }
206 
207  /*
208  }
209 
210  // Process collections
211  rval = process_coll_infos(coll_infos);MB_CHK_ERR(rval);
212 
213  // STEP 5: Process into list of local info structs, each represents file-side struct and
214  // portion of that struct
215  // ASSUMPTION: Each local info struct represents single entity type & # vertices or collection
216 
217  // STEP 6: For each local info struct:
218 
219  // STEP 6b: READ CONTAINER INTO LOCAL BUFFER
220  // STEP 6c: Create app representation of entities/vertices/collection, and damsel container
221  for them,
222  // and MAP APP HANDLE CONTAINER TO DAMSEL CONTAINER
223  // STEP 6d: Process vertices/entities/collection
224  // 6d1: If vertices, continue
225  // 6d2: If entities:
226  // - MAP LOCAL CONNECTIVITY REP'N TO DAMSEL (might be tag, don't know yet)
227  // 6d3: If collection:
228  // - (everything in STEP 4 for this collection except for EXECUTE)
229  // - might need to filter out things not represented on this rank
230  // 6d4: If sparse tag:
231  // - Create app-side representation of sparse tag
232  // - READ CONTAINER OF MODEL HANDLES INTO LOCAL BUFFER
233  // - Allocate app-side storage for tag values
234  // - MAP APP STORAGE TO MODEL TAG + (implicit?) CONTAINER
235 
236  // STEP 6e: Process dense tags for the local info struct; for each dense tag:
237  // - Get app tag handle for model tag handle
238  // - Get app storage for app tag handle + container
239  // - MAP APP STORAGE TO MODEL TAG + CONTAINER
240 
241  // STEP 7: EXECUTE
242  // - Assign all mapped data
243  // - Translate all damsel handles to app handles
244  // uninit damsel
245 
246  */
247 
248  return MB_SUCCESS;
249 }

References CHK_DMSL_ERR, moab::DamselUtil::dmslLib, moab::DamselUtil::dmslModel, dU, ErrorCode, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, myPcomm, nativeParallel, parse_options(), moab::ProcConfig::proc_comm(), moab::ParallelComm::proc_config(), process_ent_info(), and process_tags().

◆ parse_options()

ErrorCode moab::ReadDamsel::parse_options ( const FileOptions opts,
bool &  parallel 
)
private

Definition at line 51 of file ReadDamsel.cpp.

52 {
53  // Handle parallel options
54  bool use_mpio = ( MB_SUCCESS == opts.get_null_option( "USE_MPIO" ) );
55  ErrorCode rval = opts.match_option( "PARALLEL", "READ_PART" );
56  parallel = ( rval != MB_ENTITY_NOT_FOUND );
57  nativeParallel = ( rval == MB_SUCCESS );
58  if( use_mpio && !parallel )
59  {
60  MB_SET_ERR( MB_NOT_IMPLEMENTED, "'USE_MPIO' option specified w/out 'PARALLEL' option" );
61  }
62 
63  return MB_SUCCESS;
64 }

References ErrorCode, moab::FileOptions::get_null_option(), moab::FileOptions::match_option(), MB_ENTITY_NOT_FOUND, MB_NOT_IMPLEMENTED, MB_SET_ERR, MB_SUCCESS, and nativeParallel.

Referenced by load_file().

◆ process_coll_infos()

ErrorCode moab::ReadDamsel::process_coll_infos ( std::vector< damsel_collection_buf_type > &  coll_infos)
private

◆ process_ent_info()

ErrorCode moab::ReadDamsel::process_ent_info ( const damsel_entity_buf_type &  einfo)
private

Definition at line 317 of file ReadDamsel.cpp.

318 {
319  // Create this chunk of entities
320  EntityHandle *connect, start_handle;
321  ErrorCode rval;
322  damsel_err_t err;
323  damsel_container app_cont;
324  Range these_ents;
325 
326  // Check that there's only one contiguous run of file-side handles, fail if there isn't
327 #ifndef NDEBUG
328  Range fside_handles;
329  rval = DamselUtil::container_to_range( dU.dmslModel, const_cast< damsel_container& >( einfo.entity_container ),
330  fside_handles );
331  if( MB_SUCCESS != rval || fside_handles.size() != einfo.count || fside_handles.psize() != 1 ) return MB_FAILURE;
332 #endif
333 
334  if( einfo.entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
335  {
336  // Create the moab entities
337  rval = readMeshIface->get_element_connect( einfo.count, einfo.vertices_per_entity,
338  DamselUtil::dtom_entity_type[einfo.entity_type], 0, start_handle,
339  connect );MB_CHK_ERR( rval );
340  these_ents.insert( start_handle, start_handle + einfo.count - 1 );
341 
342  // Create an app-side sequence and map to file-side container
343  app_cont = DMSLcontainer_create_sequence( dU.dmslModel, einfo.count, start_handle, 1 );
344  err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
345  CHK_DMSL_ERR( err, "Error returned mapping entity handles" );
346 
347  // Map connectivity
348  assert( DMSLcontainer_count( einfo.vertex_container ) == (int)( einfo.vertices_per_entity * einfo.count ) );
349  rval = get_contents( dU.dmslModel, einfo.vertex_container, connect );MB_CHK_SET_ERR( rval, "Error returned mapping connectivity" );
350  }
351  else
352  {
353  // Get the number of coordinate arrays
354  int num_ctags = 0;
355  damsel_handle xcoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_XCOORDS" );
356  if( xcoord_dtag ) num_ctags++;
357  damsel_handle ycoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_YCOORDS" );
358  if( ycoord_dtag ) num_ctags++;
359  damsel_handle zcoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_ZCOORDS" );
360  if( zcoord_dtag ) num_ctags++;
361 
362  // Should have one vertex per entity
363  assert( einfo.vertices_per_entity == 1 );
364  std::vector< double* > coord_arrays;
365  rval = readMeshIface->get_node_coords( num_ctags, einfo.count, 0, start_handle, coord_arrays );MB_CHK_ERR( rval );
366 
367  these_ents.insert( start_handle, start_handle + einfo.count - 1 );
368 
369  // Create an app-side sequence and map to file-side container
370  app_cont = DMSLcontainer_create_sequence( dU.dmslModel, start_handle, einfo.count, 1 );
371  err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
372  CHK_DMSL_ERR( err, "Trouble mapping entity handles" );
373 
374  // Map the coords storage
375  if( xcoord_dtag != 0 )
376  {
377  err = DMSLmodel_map_tag( coord_arrays[0], app_cont, (damsel_handle_ptr)&dU.xcoordsTag.mTagh );
378  CHK_DMSL_ERR( err, "Trouble mapping x coordinate tag" );
379  }
380  if( ycoord_dtag != 0 )
381  {
382  err = DMSLmodel_map_tag( coord_arrays[1], app_cont, (damsel_handle_ptr)&dU.ycoordsTag.mTagh );
383  CHK_DMSL_ERR( err, "Trouble mapping y coordinate tag" );
384  }
385  if( zcoord_dtag != 0 )
386  {
387  err = DMSLmodel_map_tag( coord_arrays[2], app_cont, (damsel_handle_ptr)&dU.zcoordsTag.mTagh );
388  CHK_DMSL_ERR( err, "Trouble mapping z coordinate tag" );
389  }
390  }
391 
392  // Save mapping from moab entity to einfo
393  dmHandleRMap.insert( DMSLcontainer_handle_at_position( einfo.entity_container, 0 ), start_handle, einfo.count );
394 
395  rval = process_entity_tags( einfo.tag_count, einfo.tag_handle_container, app_cont, these_ents );
396 
397  return rval;
398 }

References CHK_DMSL_ERR, moab::DamselUtil::container_to_range(), dmHandleRMap, moab::DamselUtil::dmslModel, moab::DamselUtil::dtom_entity_type, dU, ErrorCode, get_contents(), moab::ReadUtilIface::get_element_connect(), moab::ReadUtilIface::get_node_coords(), moab::Range::insert(), moab::RangeMap< KeyType, ValType, NullVal >::insert(), MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, moab::DamselUtil::tinfo::mTagh, process_entity_tags(), moab::Range::psize(), readMeshIface, moab::Range::size(), moab::DamselUtil::xcoordsTag, moab::DamselUtil::ycoordsTag, and moab::DamselUtil::zcoordsTag.

Referenced by load_file().

◆ process_entity_tags()

ErrorCode moab::ReadDamsel::process_entity_tags ( int  count,
damsel_container  tag_container,
damsel_container  app_cont,
Range these_ents 
)
private

Definition at line 400 of file ReadDamsel.cpp.

404 {
405  // Process tags on these entities
406  ErrorCode rval = MB_SUCCESS;
407  for( int i = 0; i < count; i++ )
408  {
409  damsel_handle dtagh = DMSLcontainer_handle_at_position( tag_container, i );
410 
411  // Don't do conventional tags here
412  std::vector< DamselUtil::tinfo >::iterator vit =
413  std::find_if( dU.tagMap.begin(), dU.tagMap.end(), DamselUtil::DtagP< DamselUtil::tinfo >( dtagh ) );
414 
415  if( ( *vit ).tagType == MB_TAG_ANY )
416  continue;
417  else if( vit == dU.tagMap.end() )
418  MB_SET_ERR( MB_FAILURE, "Failed to find tag" );
419 
420  Tag tagh = ( *vit ).mTagh;
421  assert( tagh );
422  void* tag_data;
423  int ecount = these_ents.size();
424  rval = mbImpl->tag_iterate( tagh, these_ents.begin(), these_ents.end(), ecount, tag_data );MB_CHK_SET_ERR( rval, "Problem getting tag iterator" );
425  assert( ecount == (int)these_ents.size() );
426  damsel_err_t err = DMSLmodel_map_tag( tag_data, app_cont, (damsel_handle_ptr)&tagh );
427  CHK_DMSL_ERR( err, "Problem calling DMSLmodel_map_tag" );
428  }
429 
430  return rval;
431 }

References moab::Range::begin(), CHK_DMSL_ERR, dU, moab::Range::end(), ErrorCode, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MB_TAG_ANY, mbImpl, moab::Range::size(), moab::Interface::tag_iterate(), and moab::DamselUtil::tagMap.

Referenced by process_ent_info().

◆ process_tags()

ErrorCode moab::ReadDamsel::process_tags ( std::vector< damsel_tag_buf_type > &  tag_infos)
private

Definition at line 260 of file ReadDamsel.cpp.

261 {
262  Tag tagh;
263  ErrorCode rval = MB_SUCCESS, tmp_rval;
264  for( std::vector< damsel_tag_buf_type >::iterator tit = tag_infos.begin(); tit != tag_infos.end(); ++tit )
265  {
266  if( DamselUtil::dtom_data_type[( *tit ).tag_datatype] == MB_TYPE_OPAQUE )
267  {
268  std::cout << "Damsel reader encountered opaque tag." << std::endl;
269  continue;
270  }
271 
272  tmp_rval = mbImpl->tag_get_handle( ( *tit ).name, 1, DamselUtil::dtom_data_type[( *tit ).tag_datatype], tagh,
274  if( MB_SUCCESS != tmp_rval )
275  rval = tmp_rval;
276  else
277  {
278  dU.tagMap.push_back( DamselUtil::tinfo( tagh, 0, MB_TAG_DENSE ) );
279  // Also store predefined tags specially...
280  if( !strncmp( ( *tit ).name, "mbdmsl_", 7 ) )
281  {
282  // Predefined tag name, store the handle
283  if( !strcmp( ( *tit ).name, "mbdmsl_XCOORDS" ) )
284  dU.xcoordsTag = dU.tagMap.back();
285  else if( !strcmp( ( *tit ).name, "mbdmsl_YCOORDS" ) )
286  {
287  dU.ycoordsTag = dU.tagMap.back();
288  }
289  else if( !strcmp( ( *tit ).name, "mbdmsl_ZCOORDS" ) )
290  {
291  dU.zcoordsTag = dU.tagMap.back();
292  }
293  else if( !strcmp( ( *tit ).name, "mbdmsl_COLL_FLAGS" ) )
294  {
295  dU.collFlagsTag = dU.tagMap.back();
296  }
297  else if( !strcmp( ( *tit ).name, "mbdmsl_PARENTS" ) )
298  {
299  dU.parentsTag = dU.tagMap.back();
300  }
301  else if( !strcmp( ( *tit ).name, "mbdmsl_CHILDREN" ) )
302  {
303  dU.childrenTag = dU.tagMap.back();
304  }
305  else
306  {
307  rval = MB_FAILURE;
308  continue;
309  }
310  }
311  }
312  }
313 
314  return rval;
315 }

References moab::DamselUtil::childrenTag, moab::DamselUtil::collFlagsTag, moab::DamselUtil::dtom_data_type, dU, ErrorCode, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_OPAQUE, mbImpl, moab::DamselUtil::parentsTag, moab::Interface::tag_get_handle(), moab::DamselUtil::tagMap, moab::DamselUtil::xcoordsTag, moab::DamselUtil::ycoordsTag, and moab::DamselUtil::zcoordsTag.

Referenced by load_file().

◆ read_tag_values()

ErrorCode moab::ReadDamsel::read_tag_values ( const char *  file_name,
const char *  tag_name,
const FileOptions opts,
std::vector< int > &  tag_values_out,
const SubsetList subset_list = 0 
)
virtual

Read tag values from a file.

Read the list if all integer tag values from the file for a tag that is a single integer value per entity.

Parameters
file_nameThe file to read.
tag_nameThe tag for which to read values
tag_values_outOutput: The list of tag values.
subset_listAn 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 tags (intersection) should be read.
subset_list_lengthThe length of the 'subset_list' array.

Implements moab::ReaderIface.

Definition at line 251 of file ReadDamsel.cpp.

256 {
257  return MB_FAILURE;
258 }

Member Data Documentation

◆ dmHandleRMap

RangeMap< damsel_handle, EntityHandle, 0 > moab::ReadDamsel::dmHandleRMap
private

map from damsel to moab handles

Definition at line 122 of file ReadDamsel.hpp.

Referenced by get_contents(), and process_ent_info().

◆ dU

DamselUtil moab::ReadDamsel::dU
private

Keep various damsel data.

Definition at line 125 of file ReadDamsel.hpp.

Referenced by load_file(), process_ent_info(), process_entity_tags(), process_tags(), and ~ReadDamsel().

◆ fileName

std::string moab::ReadDamsel::fileName
private

File name.

Definition at line 110 of file ReadDamsel.hpp.

◆ mbImpl

Interface* moab::ReadDamsel::mbImpl
private

Interface instance.

Definition at line 104 of file ReadDamsel.hpp.

Referenced by init(), process_entity_tags(), process_tags(), and ~ReadDamsel().

◆ mGlobalIdTag

Tag moab::ReadDamsel::mGlobalIdTag
private

Used to track file handles.

Definition at line 119 of file ReadDamsel.hpp.

◆ myPcomm

ParallelComm* moab::ReadDamsel::myPcomm
private

Parallel info.

Definition at line 116 of file ReadDamsel.hpp.

Referenced by load_file().

◆ nativeParallel

bool moab::ReadDamsel::nativeParallel
private

Whether this reader natively supports parallel semantics.

Definition at line 113 of file ReadDamsel.hpp.

Referenced by load_file(), and parse_options().

◆ readMeshIface

ReadUtilIface* moab::ReadDamsel::readMeshIface
private

UtilIface.

Definition at line 107 of file ReadDamsel.hpp.

Referenced by init(), process_ent_info(), and ~ReadDamsel().


The documentation for this class was generated from the following files: