Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
SetsNTags.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
#include "MBTagConventions.hpp"
#include <iostream>
+ Include dependency graph for SetsNTags.cpp:

Go to the source code of this file.

Macros

#define MESH_DIR   "."
 

Functions

int main (int argc, char **argv)
 

Variables

string test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" )
 
const char * tag_nms [] = { MATERIAL_SET_TAG_NAME, DIRICHLET_SET_TAG_NAME, NEUMANN_SET_TAG_NAME }
 

Macro Definition Documentation

◆ MESH_DIR

#define MESH_DIR   "."
Examples
SetsNTags.cpp.

Definition at line 20 of file SetsNTags.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
SetsNTags.cpp.

Definition at line 28 of file SetsNTags.cpp.

29 {
30  // Get the material set tag handle
31  Tag mtag;
32  ErrorCode rval;
33  Range sets, set_ents;
34 
35  // Get MOAB instance
36  Interface* mb = new( std::nothrow ) Core;
37  if( NULL == mb ) return 1;
38 
39  // Need option handling here for input filename
40  if( argc > 1 )
41  {
42  // User has input a mesh file
43  test_file_name = argv[1];
44  }
45 
46  // Load a file
47  rval = mb->load_file( test_file_name.c_str() );MB_CHK_ERR( rval );
48 
49  // Loop over set types
50  for( int i = 0; i < 3; i++ )
51  {
52  // Get the tag handle for this tag name; tag should already exist (it was created during
53  // file read)
54  rval = mb->tag_get_handle( tag_nms[i], 1, MB_TYPE_INTEGER, mtag );MB_CHK_ERR( rval );
55 
56  // Get all the sets having that tag (with any value for that tag)
57  sets.clear();
58  rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mtag, NULL, 1, sets );MB_CHK_ERR( rval );
59 
60  // Iterate over each set, getting the entities and printing them
61  Range::iterator set_it;
62  for( set_it = sets.begin(); set_it != sets.end(); ++set_it )
63  {
64  // Get the id for this set
65  int set_id;
66  rval = mb->tag_get_data( mtag, &( *set_it ), 1, &set_id );MB_CHK_ERR( rval );
67 
68  // Get the entities in the set, recursively
69  rval = mb->get_entities_by_handle( *set_it, set_ents, true );MB_CHK_ERR( rval );
70 
71  cout << tag_nms[i] << " " << set_id << " has " << set_ents.size() << " entities:" << endl;
72  set_ents.print( " " );
73  set_ents.clear();
74  }
75  }
76 
77  delete mb;
78 
79  return 0;
80 }

References moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, moab::Core::get_entities_by_handle(), moab::Core::get_entities_by_type_and_tag(), moab::Core::load_file(), mb, MB_CHK_ERR, MB_TYPE_INTEGER, MBENTITYSET, moab::Range::print(), moab::Range::size(), moab::Core::tag_get_data(), moab::Core::tag_get_handle(), tag_nms, and test_file_name.

Variable Documentation

◆ tag_nms

Examples
SetsNTags.cpp, and TestExodusII.cpp.

Definition at line 26 of file SetsNTags.cpp.

Referenced by main().

◆ test_file_name

string test_file_name = string( MESH_DIR ) + string( "/hex01.vtk" )
Examples
SetsNTags.cpp.

Definition at line 23 of file SetsNTags.cpp.

Referenced by main().