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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 35 of file pconntest.C.

References COM_assertion, COM_assertion_msg, COM_call_function(), COM_delete_attribute(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_resize_array(), COM_window_init_done(), and ni.

35  {
36  COM_init( &argc, &argv);
37 
38  if ( argc < 3) {
39  std::cout << "Usage: " << argv[0]
40  << " <in_hdf_file> <out_hdf_file> " << endl;
41  exit(-1);
42  }
43 
44  std::cout << "Reading mesh file \"" << argv[1] << '"' << endl;
45 
46  std::string fname(argv[1]), wname;
47  string::size_type n0 = fname.find_last_of( "/");
48 
49  if ( n0 != std::string::npos)
50  fname = fname.substr( n0+1, fname.size());
51 
52  string::size_type ni;
53  ni = fname.find_first_of( ".:-*[]?\\\"\'0123456789");
54  COM_assertion_msg(ni, "File name must start with a letter");
55 
56  if ( ni == std::string::npos) {
57  wname = fname;
58  }
59  else {
60  while (fname[ni-1]=='_') --ni; // Remove the '_' at the end.
61  wname = fname.substr( 0, ni);
62  }
63 
64  std::cout << "Creating window \"" << wname << '"' << endl;
65 
66  // Read in HDF format
68  std::cout << "Reading window " << endl;
69  int IN_read = COM_get_function_handle( "IN.read_window");
70  COM_call_function( IN_read, argv[1], wname.c_str());
71  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
72  int mesh_hdl = COM_get_attribute_handle((wname+".mesh").c_str());
73  std::cout << "Obtaining the mesh " << endl;
74  COM_call_function( IN_obtain, &mesh_hdl, &mesh_hdl);
75 
76  // Change the memory layout to contiguous.
77  std::cout << "Resizing the array " << endl;
78  COM_resize_array( (wname+".mesh").c_str(), 0, NULL, 0);
79  // Delete all attributes and leave alone the mesh.
80  std::cout << "deleting the attribute" << endl;
81  COM_delete_attribute( (wname+".atts").c_str());
82 
83  int npanes; COM_get_panes( wname.c_str(), &npanes, NULL);
84 
85  COM_assertion( npanes>=0);
86 
87  std::cout << "finishing up window initialization" << endl;
88  COM_window_init_done( wname.c_str());
89 
90  std::cout << "loading Rocout" << endl;
92 
93  std::cout << "Computing connectivity map... " << endl;
94 
95  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocmap, "MAP");
96 
97  // Invoke compute_pconn to obtain pane connectivity.
98  int MAP_compute_pconn = COM_get_function_handle( "MAP.compute_pconn");
99  const string pconn = wname+".pconn";
100  int pconn_hdl = COM_get_attribute_handle( pconn.c_str());
101  COM_call_function( MAP_compute_pconn, &mesh_hdl, &pconn_hdl);
102 
103  std::cout << "Output window into file..." << endl;
104 
105  // Output pconn
106  int OUT_set = COM_get_function_handle( "OUT.set_option");
107  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
108 
109  COM_call_function( OUT_set, "mode", "w");
110  int all_hdl = COM_get_attribute_handle( (wname+".all").c_str());
111  COM_call_function( OUT_write, argv[2], &all_hdl,
112  (char*)wname.c_str(), "000");
113 
114  COM_finalize();
115 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
#define COM_assertion_msg(EX, msg)
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_delete_attribute(const char *wa_str)
Delete an existing attribute.
Definition: roccom_c++.h:128
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocin.h:64
Definition: Rocout.h:81
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function: