Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
msh2hdf.C File Reference
#include "MSH_Reader.h"
#include "roccom.h"
#include <iostream>
#include <sstream>
Include dependency graph for msh2hdf.C:

Go to the source code of this file.

Functions

 COM_EXTERN_MODULE (Rocout)
 
int main (int argc, char *argv[])
 

Function Documentation

COM_EXTERN_MODULE ( Rocout  )
int main ( int  argc,
char *  argv[] 
)

Definition at line 35 of file msh2hdf.C.

References COM_call_function(), COM_finalize(), COM_free_buffer(), COM_get_attribute_handle_const(), COM_get_function_handle(), COM_get_panes(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_new_window(), COM_window_init_done(), i, and MSH_Reader::read_mesh().

35  {
36  COM_init( &argc, &argv);
37 
38  if ( argc < 2) {
39  cout << "Usage: " << argv[0] << " <msh_file> [hdf_name] " << endl;
40  return -1;
41  }
42 
43  char *firstdot=strchr( argv[1], '.');
44  const string wname(argv[1], firstdot? firstdot-argv[1]: strlen( argv[1]));
45 
46  std::cout << "Reading surface mesh file \"" << argv[1] << '"' << endl;
47 
48  COM_new_window( wname.c_str());
49  MSH_Reader().read_mesh( argv[1], wname);
50  COM_window_init_done( wname.c_str());
51 
52  // Output mesh
54 
55  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
56  int mesh = COM_get_attribute_handle_const( (wname+".mesh").c_str());
57 
58 
59  std::string fname( argc>=3 ? argv[2] : (wname+".hdf").c_str());
60 
61  int separate_files = fname.find( ".hdf") == string::npos;
62 
63  if ( !separate_files) {
64  std::cout << "Writing HDF file(s) " << fname << endl;
65 
66  COM_call_function( OUT_write, fname.c_str(), &mesh, (char*)wname.c_str(), "000");
67  }
68  else {
69  int npanes, *paneIDs;
70  COM_get_panes( wname.c_str(), &npanes, &paneIDs);
71 
72  for ( int i=0; i<npanes; ++i) {
73  std::ostringstream ostr;
74 
75  ostr << fname;
76  ostr.fill('0'); ostr.width(5);
77  ostr << paneIDs[i] << ".hdf";
78 
79  std::cout << "Writing HDF file(s) " << ostr.str() << endl;
80 
81  COM_call_function( OUT_write, ostr.str().c_str(), &mesh,
82  (char*)wname.c_str(),
83  "000", NULL, NULL, &paneIDs[i]);
84  }
85 
86  COM_free_buffer( &paneIDs);
87  }
88 
89  COM_finalize();
90  return 0;
91 }
int read_mesh(const char *fname, const std::string &wname)
Definition: MSH_Reader.h:47
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocout.h:81
blockLoc i
Definition: read.cpp:79
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_attribute_handle_const(const char *waname)
Definition: roccom_c++.h:420
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function: