Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
im2hdf.C File Reference
#include "IM_Reader.h"
#include "roccom.h"
#include <iostream>
#include <sstream>
Include dependency graph for im2hdf.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 im2hdf.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 IM_Reader::read_mesh().

35  {
36  COM_init( &argc, &argv);
37 
38  if ( argc < 2) {
39  cout << "Usage: " << argv[0] << " <im_file> [hdf_prefix] " << endl
40  << "\tWrite each pane into a separate HDF file." << std::endl;
41  cout << "Usage: " << argv[0] << " <im_file> [hdf_name] " << endl
42  << "\tWrite all panes into one HDF file." << std::endl;
43  exit(-1);
44  }
45 
46  char *firstdot=strchr( argv[1], '.');
47  const string wname(argv[1], firstdot? firstdot-argv[1]: strlen( argv[1]));
48 
49  std::cout << "Reading surface mesh file \"" << argv[1] << '"' << endl;
50 
51  COM_new_window( wname.c_str());
52  IM_Reader().read_mesh( argv[1], wname, NULL);
53  COM_window_init_done( wname.c_str());
54 
55  // Output mesh
57 
58  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
59  int mesh = COM_get_attribute_handle_const( (wname+".mesh").c_str());
60 
61 
62  std::string fname;
63  if ( argc>2) fname = argv[2]; else fname = wname+".hdf";
64 
65  int separate_files = fname.find( ".hdf") == string::npos;
66 
67  if ( !separate_files) {
68  std::cout << "Writing HDF file(s) " << fname << endl;
69 
70  COM_call_function( OUT_write, fname.c_str(), &mesh, (char*)wname.c_str(), "000");
71  }
72  else {
73  int npanes, *paneIDs;
74  COM_get_panes( wname.c_str(), &npanes, &paneIDs);
75 
76  for ( int i=0; i<npanes; ++i) {
77  std::ostringstream ostr;
78 
79  ostr << fname;
80  ostr.fill('0'); ostr.width(5);
81  ostr << paneIDs[i] << ".hdf";
82 
83  std::cout << "Writing HDF file(s) " << ostr.str() << endl;
84 
85  COM_call_function( OUT_write, ostr.str().c_str(), &mesh,
86  (char*)wname.c_str(),
87  "000", NULL, NULL, &paneIDs[i]);
88  }
89 
90  COM_free_buffer( &paneIDs);
91  }
92 
93  COM_finalize();
94 }
void COM_finalize()
Definition: roccom_c++.h:59
int read_mesh(const char *fname, const std::string &wname, Func_ptr is_local)
Definition: IM_Reader.h:102
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: