![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #include
00002 #include
00003 #include "moab/ProgOptions.hpp"
00004
00005 using namespace moab;
00006 using namespace std;
00007 const char BRIEF_DESC[] = "Add higher order nodes to existing mesh, eg. hex8 to hex27 (default). "
00008 "Use available options as desired.";
00009 std::ostringstream LONG_DESC;
00010
00011 int main( int argc, char* argv[] )
00012 {
00013 moab::Core* mb = new moab::Core();
00014 moab::ErrorCode rval;
00015 bool edge = false;
00016 bool face = false;
00017 bool volume = false;
00018
00019 LONG_DESC << "mbhonodes tool reads a mesh file and adds higher order nodes." << std::endl
00020 << "Options to add higher order nodes on all volume or face or edge elements of the mesh "
00021 "are supported"
00022 << std::endl
00023 << "Example1: Use the following command to create hex mid volume nodes, in.h5m is a hex8 "
00024 "mesh"
00025 << std::endl
00026 << " -> mbhonodes -i in.h5m -o o.h5m -f -e" << std::endl
00027 << "Example2: Use the following command to create hex27 mesh o2.h5m, in.h5m is a hex8 mesh" << std::endl
00028 << " -> mbhonodes -i in.h5m -o o2.h5m" << std::endl;
00029
00030 ProgOptions opts( LONG_DESC.str(), BRIEF_DESC );
00031 string inFileName = "";
00032 opts.addRequiredArg< string >( "inFile,i", "Specify the output file name string", &inFileName );
00033 #ifdef MOAB_HAVE_HDF5
00034 string outFileName = "outfile.h5m";
00035 #else
00036 string outFileName = "outfile.vtk";
00037 #endif
00038 opts.addOpt< string >( "outFile,o", "Specify the output file name string (default outfile.h5m)", &outFileName );
00039 opts.addOpt< void >( "edge,e", "DO NOT create mid nodes along edge (default=true)", &edge );
00040 opts.addOpt< void >( "face,f", "DO NOT create face mid nodes (default=true)", &face );
00041 opts.addOpt< void >( "volume,v", "DO NOT create volume mid nodes (default=true)", &volume );
00042
00043 opts.parseCommandLine( argc, argv );
00044
00045 // load the input file
00046 rval = mb->load_mesh( inFileName.c_str() );MB_CHK_SET_ERR( rval, "Failed to write the mesh file" );
00047 std::cout << "Read input mesh file: " << inFileName << std::endl;
00048 moab::Range entities;
00049 moab::EntityHandle meshset;
00050
00051 rval = mb->get_entities_by_type( 0, MBHEX, entities );MB_CHK_SET_ERR( rval, "Failed to get hex entities" );
00052 rval = mb->create_meshset( MESHSET_SET, meshset );MB_CHK_SET_ERR( rval, "Failed to create meshset" );
00053 rval = mb->add_entities( meshset, entities );MB_CHK_SET_ERR( rval, "Failed to add entitites to meshset" );
00054
00055 rval = mb->convert_entities( meshset, !edge, !face, !volume );MB_CHK_SET_ERR( rval, "Failed to convert to higher dimension entities" );
00056
00057 rval = mb->write_mesh( outFileName.c_str() );MB_CHK_SET_ERR( rval, "Failed to write the mesh file" );
00058 std::cout << "Wrote mesh file: " << outFileName << std::endl;
00059 delete mb;
00060 }