Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smf2hdf.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: smf2hdf.C,v 1.3 2008/12/06 08:43:24 mtcampbe Exp $
24 // Converting a .smf file to .hdf.
25 
26 #include "SMF_Reader.h"
27 #include "roccom.h"
28 #include <iostream>
29 #include <sstream>
30 
31 using namespace std;
32 
34 
35 int main(int argc, char *argv[]) {
36  COM_init( &argc, &argv);
37 
38  if ( argc < 2) {
39  cout << "Usage: " << argv[0] << " <smf_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  SMF_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 }
92 
93 
94 
95 
96 
97 
This file contains the prototypes for Roccom API.
int read_mesh(const char *fname, const std::string &wname)
Definition: SMF_Reader.h:46
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
int main(int argc, char *argv[])
Definition: blastest.C:94
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
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116