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

Go to the source code of this file.

Functions

 COM_EXTERN_MODULE (Rocface)
 
 COM_EXTERN_MODULE (Rocout)
 
 COM_EXTERN_MODULE (Rocin)
 
 COM_EXTERN_MODULE (Rocblas)
 
 COM_EXTERN_MODULE (Rocsurf)
 
void read_file (const char *fname, const string &wname, double alpha)
 
int main (int argc, char *argv[])
 

Function Documentation

COM_EXTERN_MODULE ( Rocface  )
COM_EXTERN_MODULE ( Rocout  )
COM_EXTERN_MODULE ( Rocin  )
COM_EXTERN_MODULE ( Rocblas  )
COM_EXTERN_MODULE ( Rocsurf  )
int main ( int  argc,
char *  argv[] 
)

Definition at line 162 of file surfextractor.C.

References COM_assertion_msg, COM_finalize(), COM_init(), COM_set_profiling(), ni, and read_file().

162  {
163  MPI_Init(&argc,&argv);
164  COM_init( &argc, &argv);
165 
166  if ( argc < 2) {
167  std::cerr << "Usage: " << argv[0]
168  << " <HDF|RocinControlFile1> " << std::endl
169  << "\t<HDF|RocinControl File1> specifies the file(s) from which to extract the time 0 mesh.\n"
170  << std::endl;
171  exit(-1);
172  }
173 
174  COM_set_profiling( 1);
175 
176  string fname(argv[1]);
177  string wname;
178  // Discard the directory name and suffix to obtain a window name.
179  string::size_type n0 = fname.find_last_of( "/");
180  std::string fname0;
181  if (n0 != std::string::npos)
182  fname = fname.substr( n0+1, fname.size());
183 
184  string::size_type ni;
185  ni = fname.find_first_of( ".:_-*[]?\\\"\'0123456789");
186  COM_assertion_msg(ni, "File name must start with a letter");
187 
188  if ( ni == std::string::npos) {
189  wname = fname;
190  fname.append(".hdf"); // Append the .hdf suffix to the file name.
191  }
192  else {
193  if ( fname[ni] == '_' && (fname[ni+1] == 's' || fname[ni+1] == 'f'))
194  ni += 2;
195  wname = fname.substr( 0, ni);
196  }
197  read_file( fname.c_str(), wname, 1.);
198 
199  COM_finalize();
200  MPI_Finalize();
201  return 0;
202 }
void read_file(const char *fname, const string &wname, double alpha)
Definition: autosurfer.C:39
#define COM_assertion_msg(EX, msg)
void COM_finalize()
Definition: roccom_c++.h:59
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
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

Here is the call graph for this function:

void read_file ( const char *  fname,
const string &  wname,
double  alpha 
)

Definition at line 43 of file surfextractor.C.

References COM_call_function(), COM_clone_attribute(), COM_delete_window(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_new_window(), COM_UNLOAD_MODULE_STATIC_DYNAMIC, COM_window_init_done(), i, MPI_COMM_WORLD, and rank.

43  {
44  char *lastdot=strrchr( const_cast<char *>(fname), '.');
45  int rank = 0;
46  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
47  COM_new_window( wname.c_str());
48  // Read in HDF files or a Rocin control file
49  if(!rank)
50  std::cout << "Reading file " << fname << "..." << std::endl;
51 
52  // Read in HDF format
54 
55  int IN_read;
56  // Read in HDF format using Rocin::read_window or ::read_by_control_file
57  if ( strcmp( lastdot, ".hdf")==0)
58  IN_read = COM_get_function_handle( "IN.read_window");
59  else
60  IN_read = COM_get_function_handle( "IN.read_by_control_file");
61 
62  MPI_Comm comm_null = MPI_COMM_WORLD;
63  std::string bufwin("bufwin");
64  COM_call_function( IN_read, fname, bufwin.c_str(), &comm_null);
65  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
66 
67  int all = COM_get_attribute_handle((bufwin+".all").c_str());
68  COM_call_function(IN_obtain,&all,&all);
69  // int buf_mesh = COM_get_attribute_handle((bufwin+".mesh").c_str());
70  // COM_call_function( IN_obtain, &buf_mesh, &buf_mesh);
71  // int bcflag = COM_get_attribute_handle((bufwin+".bcflag").c_str());
72  // if(bcflag > 0)
73  // COM_call_function(IN_obtain,&bcflag,&bcflag);
74 
75  // if (bcflag > 0) {
76  // Read in bcflags.
77  // COM_call_function( IN_obtain, &bcflag, &bcflag);
78 
79  // Obtain the IDs of the panes of the window
80  // int npanes, *pane_ids;
81  // COM_get_panes( bufwin.c_str(), &npanes, &pane_ids);
82 
83  // Loop through the panes to remove those with bcflag >1.
84  // for ( int i=0; i<npanes; ++i) {
85  // int *flag;
86  // COM_get_array( (bufwin+".bcflag").c_str(), pane_ids[i], &flag);
87  // if ( flag==NULL || *flag>1)
88  // COM_delete_pane( bufwin.c_str(), pane_ids[i]);
89  // }
90 
91  // remove buffers.
92  // COM_free_buffer( &pane_ids);
93  // }
94  if(!rank)
95  std::cout << "Recovering t = 0 positions." << std::endl;
96  COM_clone_attribute( (wname+".mesh").c_str(), (bufwin+".mesh").c_str(), 1);
97  COM_clone_attribute( (wname+".nc_t0").c_str(), (bufwin+".nc_t0").c_str(), 1);
98  COM_clone_attribute( (wname+".bcflag").c_str(), (bufwin+".bcflag").c_str(), 1);
99  COM_window_init_done(wname);
100  COM_delete_window( bufwin.c_str());
101  int *srcpane_ids;
102  int npanes;
103  std::vector<int> pane_id;
104  COM_get_panes( wname.c_str(), &npanes, &srcpane_ids);
105  pane_id.resize(npanes);
106  for(int i = 0;i < npanes;i++)
107  pane_id[i] = srcpane_ids[i];
108  // These are no longer necessary as we've duped the info into
109  // a locally allocated array
110  COM_free_buffer( &srcpane_ids);
111  for(int p = 0;p < npanes;p++){
112  // int *flag;
113  // COM_get_array((wname+".bcflag").c_str(),pane_id[p],&flag);
114  // if(flag && *flag < 2){
115  void *src_ptr = NULL;
116  int src_std = 0;
117  int src_cap = 0;
118  void *trg_ptr = NULL;
119  int trg_std = 0;
120  int trg_cap = 0;
121  COM_get_array((wname+".nc_t0").c_str(),pane_id[p],&src_ptr,&src_std,&src_cap);
122  COM_get_array((wname+".nc").c_str(),pane_id[p],&trg_ptr,&trg_std,&trg_cap);
123  if(src_ptr && trg_ptr && (trg_std*trg_cap == src_std*src_cap) && src_std > 1 && src_cap > 1)
124  memcpy(trg_ptr,src_ptr,sizeof(double)*src_std*src_cap);
125  else
126  if(!rank)
127  std::cout << "Warning: Not copying nc_t0 for Pane(" << pane_id[p]
128  << ") src_ptr(" << src_ptr << ") src_std(" << src_std
129  << ") src_cap(" << src_cap << ") trg_ptr(" << trg_ptr
130  << ") trg_std(" << trg_std << ") trg_cap(" << trg_cap
131  << ")" << endl;
132  }
133  //}
134  COM_window_init_done(wname);
136  int OUT_set_option = COM_get_function_handle( "Rocout.set_option");
137  std::string rankstr("0");
138  COM_call_function( OUT_set_option, "rankwidth", rankstr.c_str());
139  std::ostringstream Ostr;
140  Ostr << "surf0_" << setw(5) << setfill('0') << rank+1;
141  int whand = COM_get_function_handle("Rocout.write_attribute");
142  all = COM_get_attribute_handle((wname+".all"));
143  COM_call_function(whand,Ostr.str().c_str(),&all,wname.c_str(),"");
144  std::ofstream Ouf;
145  string controlfilename(Ostr.str() + "_in.txt");
146  Ouf.open(controlfilename.c_str());
147  Ouf << "@Proc: " << rank << endl
148  << "@Files: " << "surf0_" << setw(5)
149  << setfill('0') << rank+1 << ".hdf" << endl;
150  Ouf.clear();
151  Ouf << "@Panes: ";
152  std::vector<int>::iterator pii = pane_id.begin();
153  while(pii != pane_id.end())
154  Ouf << *pii++ << " ";
155  Ouf << endl;
156  Ouf.close();
157 
159 
160 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
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
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
Definition: Rocin.h:64
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_clone_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Clone the subset of panes of another window of which the given pane attribute has value val...
Definition: roccom_c++.h:234
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
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
static int rank
Definition: advectest.C:66
#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: