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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 31 of file pcommtest.C.

References COM_assertion, COM_call_function(), COM_finalize(), COM_FLOAT, COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), COM_init(), COM_load_module(), COM_new_attribute(), COM_resize_array(), COM_window_init_done(), j, and k.

31  {
32  COM_init( &argc, &argv);
33 
34  if ( argc < 2) {
35  std::cout << "Usage: " << argv[0]
36  << " <out_hdf_file> " << endl;
37  exit(-1);
38  }
39 
40  std::cout << "Reading mesh file \"" << argv[1] << '"' << endl;
41 
42  std::string wname("surf");
43 // std::string fname(argv[1]), wname;
44 // string::size_type n0 = fname.find_last_of( "/");
45 
46 // if ( n0 != std::string::npos)
47 // fname = fname.substr( n0+1, fname.size());
48 
49 // string::size_type ni;
50 // ni = fname.find_first_of( ".:-*[]?\\\"\'0123456789");
51 // COM_assertion_msg(ni, "File name must start with a letter");
52 
53 // if ( ni == std::string::npos) {
54 // wname = fname;
55 // }
56 // else {
57 // while (fname[ni-1]=='_') --ni; // Remove the '_' at the end.
58 // wname = fname.substr( 0, ni);
59 // }
60 
61  std::cout << "Creating window \"" << wname << '"' << endl;
62 
63  // Read in HDF format
64  COM_load_module( "Rocin", "IN");
65  std::cout << "Reading window " << endl;
66  int IN_read = COM_get_function_handle( "IN.read_window");
67  //COM_call_function( IN_read, argv[1], wname.c_str());
68  COM_call_function( IN_read,
69  "test/surf000[01].hdf",
70  wname.c_str());
71 
72  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
73  int mesh_hdl = COM_get_attribute_handle((wname+".mesh").c_str());
74  std::cout << "Obtaining the mesh " << endl;
75  COM_call_function( IN_obtain, &mesh_hdl, &mesh_hdl);
76 
77  // Change the memory layout to contiguous.
78  std::cout << "Resizing the attribute arrays " << endl;
79  COM_resize_array( (wname+".all").c_str(), 0, NULL, 0);
80 
81  // Delete all attributes and leave alone the mesh.
82  //std::cout << "deleting the attribute" << endl;
83  //COM_delete_attribute( (wname+".atts").c_str());
84 
85  int npanes;
86  int* pane_ids;
87  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
88  COM_assertion( npanes>=0);
89 
90  std::cout<< "Labeling nodes with pane ids" << endl;
91  COM_new_attribute("surf.pane_ids",'n', COM_FLOAT, 1, "empty");
92  COM_resize_array("surf.pane_ids");
93 
94  int nitems;
95  float *ptr;
96  for(int j = 0; j <npanes; ++j){
97  COM_get_size("surf.pane_ids", pane_ids[j], &nitems);
98  std::cout << " pane[" << j << "] has " << nitems << " items " << endl;
99  COM_get_array("surf.pane_ids", pane_ids[j], &ptr);
100  for(int k =0; k<nitems; ++k){
101  ptr[k] = pane_ids[j];
102  }
103  }
104  int pid_hdl = COM_get_attribute_handle("surf.pane_ids");
105 
106  COM_load_module( "Rocmap", "MAP");
107 
108  std::cout << "Performing an average-reduction on shared nodes." << endl;
109  int MAP_average_shared = COM_get_function_handle( "MAP.reduce_average_on_shared_nodes");
110  COM_call_function( MAP_average_shared, &pid_hdl);
111 
112  std::cout << "Updating ghost nodes." << endl;
113  int MAP_update_ghost = COM_get_function_handle( "MAP.update_ghosts");
114  COM_call_function( MAP_update_ghost, &pid_hdl);
115 
116  std::cout << "Finalizing the window" << endl;
117  COM_window_init_done( wname.c_str());
118 
119  std::cout << "loading Rocout" << endl;
120  COM_load_module("Rocout", "OUT");
121 
122  std::cout << "Output window into file..." << endl;
123 
124  // Output new mesh
125  int OUT_set = COM_get_function_handle( "OUT.set_option");
126  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
127 
128  COM_call_function( OUT_set, "mode", "w");
129  int all_hdl = COM_get_attribute_handle( (wname+".all").c_str());
130  COM_call_function( OUT_write, argv[1], &all_hdl,
131  (char*)wname.c_str(), "0000");
132 
133  COM_finalize();
134 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
j indices k indices k
Definition: Indexing.h:6
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
void COM_load_module(const char *libname, const char *winname)
Definition: roccom_c++.h:75
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
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: