moab
SetsNTags.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/Range.hpp"
#include "MBTagConventions.hpp"
#include <iostream>

Go to the source code of this file.

Defines

#define MESH_DIR   "."

Functions

int main (int argc, char **argv)

Variables

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

Define Documentation

#define MESH_DIR   "."

Definition at line 20 of file SetsNTags.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file SetsNTags.cpp.

                                {
    // get the material set tag handle
  Tag mtag;
  ErrorCode rval;
  Range sets, set_ents;

    // instantiate & load a file
  Interface *mb = new Core();

    // need option handling here for input filename
  if (argc > 1){
    //user has input a mesh file
    test_file_name = argv[1];
  }  

  rval = mb->load_file(test_file_name.c_str());
  if (MB_SUCCESS != rval) return 1;

    // loop over set types
  for (int i = 0; i < 3; i++) {
      // get the tag handle for this tag name; tag should already exist (it was created during file read)
    rval = mb->tag_get_handle(tag_nms[i], 1, MB_TYPE_INTEGER, mtag);
    if (MB_SUCCESS != rval) return 1;

      // get all the sets having that tag (with any value for that tag)
    sets.clear();
    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &mtag, NULL, 1, sets);
    if (MB_SUCCESS != rval) return 1;

      // iterate over each set, getting the entities and printing them
    Range::iterator set_it;
    for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
        // get the id for this set
      int set_id;
      rval = mb->tag_get_data(mtag, &(*set_it), 1, &set_id);
      if (MB_SUCCESS != rval) return 1;

        // get the entities in the set, recursively
      rval = mb->get_entities_by_handle(*set_it, set_ents, true);
      if (MB_SUCCESS != rval) return 1;

      cout << tag_nms[i] << " " << set_id << " has " 
                << set_ents.size() << " entities:" << endl;
      set_ents.print("   ");
      set_ents.clear();
    }
  }

  delete mb;
}

Variable Documentation

string test_file_name = string(MESH_DIR) + string("/1hex.g")

Definition at line 23 of file SetsNTags.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines