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

Go to the source code of this file.

Functions

 COM_EXTERN_MODULE (Rocface)
 
 COM_EXTERN_MODULE (Rocout)
 
 COM_EXTERN_MODULE (Rocblas)
 
 COM_EXTERN_MODULE (Rocsurf)
 
 COM_EXTERN_MODULE (Rocin)
 
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 ( Rocblas  )
COM_EXTERN_MODULE ( Rocsurf  )
COM_EXTERN_MODULE ( Rocin  )
int main ( int  argc,
char *  argv[] 
)

Definition at line 134 of file surfdiver.C.

References COM_assertion_msg, COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_print_profile(), COM_set_profiling(), COM_window_init_done(), k, ni, and read_file().

134  {
135  COM_init( &argc, &argv);
136 
137  if ( argc < 3) {
138  std::cerr << "Usage: " << argv[0]
139  << " <HDF|RocinControlFile1> <HDF|RocinControlFile2> [<out_prefix>] [<RocfaceControlFile>]\n\n"
140  << "\t<HDF|RocinControl File1> specifies the files for the first window\n"
141  << "\t<HDF|RocinControl File2> specifies the files for the second window\n"
142  << "\t<out_prefix> specifies a prefix for output files. \n\t\tDefault is the current directory\n"
143  << "\t<RocfaceControlFile> specifies a file name for Rocface control parameters. \n"
144  << "\nExample:\t"
145  << argv[0] << " \"ifluid*.hdf\" \"isolid*.hdf\" " << "\n\t\t"
146  << argv[0] << " Rocflo/Rocin/\"ifluid*.txt\" Rocfrac/Rocin/\"isolid*.txt\" Rocman/RocfloRocfrac/" << "\n\t\t"
147  << std::endl;
148  exit(-1);
149  }
150 
151  COM_set_profiling( 1);
152 
153  string fnames[2] = {string(argv[1]), string(argv[2])};
154  string pre = (argc>3)?argv[3]:"";
155  // Append '/' to pre if not there
156  if ( !pre.empty() && pre[pre.size()-1] != '/') pre.append("/");
157 
158  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
159 
160  int RFC_readcntr = COM_get_function_handle( "RFC.read_control_file");
161  int RFC_overlay = COM_get_function_handle( "RFC.overlay");
162  int RFC_write = COM_get_function_handle( "RFC.write_overlay");
163 
164  if ( argc>4) {
165  std::cout << "Reading Rocface control file..." << std::endl;
166  COM_call_function( RFC_readcntr, argv[4]);
167  std::cout << "Finished reading Rocface control file." << std::endl;
168  }
169 
170  string wnames[2];
171  for ( int k=0; k<2; ++k) {
172  // Discard the directory name and suffix to obtain a window name.
173  string::size_type n0 = fnames[k].find_last_of( "/");
174 
175  std::string fname;
176  if ( n0 == std::string::npos) fname=fnames[k];
177  else fname = fnames[k].substr( n0+1, fnames[k].size());
178 
179  string::size_type ni;
180  ni = fname.find_first_of( ".:_-*[]?\\\"\'0123456789");
181  COM_assertion_msg(ni, "File name must start with a letter");
182 
183  if ( ni == std::string::npos) {
184  wnames[k] = fname;
185  fnames[k].append(".hdf"); // Append the .hdf suffix to the file name.
186  }
187  else {
188  if ( fname[ni] == '_' && (fname[ni+1] == 's' || fname[ni+1] == 'f'))
189  ni += 2;
190  wnames[k] = pre+fname.substr( 0, ni);
191  }
192  COM_assertion_msg( k==0 || wnames[0]!=wnames[1],
193  "Two input files must have different alphabetic prefix");
194 
195  read_file( fnames[k].c_str(), wnames[k], 1.);
196 
197  COM_window_init_done( wnames[k].c_str());
198  }
199 
200  int tri1_mesh = COM_get_attribute_handle( (wnames[0]+".mesh").c_str());
201  int tri2_mesh = COM_get_attribute_handle( (wnames[1]+".mesh").c_str());
202 
203  //const char *format = "HDF";
204  const char *format = "CGNS";
205 
206  std::cout << "Starting mesh overlay..." << std::endl;
207  COM_call_function( RFC_overlay, &tri1_mesh, &tri2_mesh);
208  COM_call_function( RFC_write, &tri1_mesh, &tri2_mesh,
209  wnames[0].c_str(), wnames[1].c_str(), format);
210 
211  COM_print_profile( "", "");
212 
213  COM_finalize();
214 }
j indices k indices k
Definition: Indexing.h:6
void read_file(const char *fname, const string &wname, double alpha)
Definition: autosurfer.C:39
#define COM_assertion_msg(EX, msg)
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
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
#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:

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

Definition at line 39 of file surfdiver.C.

References COM_call_function(), COM_clone_attribute(), COM_delete_attribute(), COM_delete_pane(), 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, and i.

39  {
40  char *lastdot=strrchr( const_cast<char *>(fname), '.');
41  COM_new_window( wname.c_str());
42  // Read in HDF files or a Rocin control file
43  std::cout << "Reading file " << fname << "..." << std::endl;
44 
45  // Read in HDF format
47  int IN_read;
48 
49  // Read in HDF format using Rocin::read_window or ::read_by_control_file
50  bool processed = false;
51  if(!(lastdot == NULL)){
52  if ( strcmp( lastdot, ".hdf")==0){
53  IN_read = COM_get_function_handle( "IN.read_window");
54  processed = true;
55  }
56  }
57  if(!processed){
58  IN_read = COM_get_function_handle( "IN.read_by_control_file");
59  }
60 
61  // Pass MPI_COMM_NULL to Rocin so that the rank becomes a wildcard.
62  MPI_Comm comm_null = MPI_COMM_NULL;
63  std::string bufwin("bufwin");
64  COM_call_function( IN_read, fname, bufwin.c_str(), &comm_null);
65 
66  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
67 
68  // MS
69  /*
70  int npn, *pnids;
71  COM_get_panes( bufwin.c_str(), &npn, &pnids);
72  std::cout << "There exisits "<< npn
73  << " panes in this window." << std::endl;
74  for ( int i=0; i<npn; ++i) {
75  std::cout << "Pane ID = " << pnids[i] << std::endl;
76  }
77  */
78  // MS End
79 
80  // Check whether bcflag exists. If so, retain only the panes with flag<=1.
81  int bcflag = COM_get_attribute_handle((bufwin+".bcflag").c_str());
82  if (bcflag > 0) {
83  // Read in bcflags.
84  COM_call_function( IN_obtain, &bcflag, &bcflag);
85 
86  // Obtain the IDs of the panes of the window
87  int npanes, *pane_ids;
88  COM_get_panes( bufwin.c_str(), &npanes, &pane_ids);
89 
90  // Loop through the panes to remove those with bcflag >1.
91  for ( int i=0; i<npanes; ++i) {
92  int *flag;
93  COM_get_array( (bufwin+".bcflag").c_str(), pane_ids[i], &flag);
94  //std::cout << "Existing pane ID = " << pane_ids[i] << std::endl;
95  if ( flag==NULL || *flag>1) {
96  COM_delete_pane( bufwin.c_str(), pane_ids[i]);
97  //std::cout << "Removing..." << std::endl;
98  }
99  }
100 
101  // remove buffers.
102  COM_free_buffer( &pane_ids);
103  }
104 
105  // This is NOT correct for problems with regression.
106  int disp_hndl = COM_get_attribute_handle((bufwin+".uhat").c_str());
107  if(disp_hndl > 0){
108  std::cout << "Applying total displacements..." << std::endl;
110  int add = COM_get_function_handle( "BLAS.add");
111  COM_call_function(IN_obtain,&disp_hndl,&disp_hndl);
112  int nc_hndl = COM_get_attribute_handle( bufwin + ".nc");
113  COM_call_function( add, &disp_hndl, &nc_hndl, &nc_hndl);
115  }
116 
117  // Read in the mesh.
118  int buf_mesh = COM_get_attribute_handle((bufwin+".mesh").c_str());
119  COM_call_function( IN_obtain, &buf_mesh, &buf_mesh);
121 
122  // Remove all attributes except for the mesh
123  COM_delete_attribute( (bufwin+".atts").c_str());
124 
125 
126  std::cout << "Obtained window " << wname
127  << " from file " << fname << std::endl;
128 
129  // Change the memory layout to contiguous.
130  COM_clone_attribute( (wname+".mesh").c_str(), (bufwin+".mesh").c_str(), 0);
131  COM_delete_window( bufwin.c_str());
132 }
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
void COM_delete_attribute(const char *wa_str)
Delete an existing attribute.
Definition: roccom_c++.h:128
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
Definition: Rocin.h:64
blockLoc i
Definition: read.cpp:79
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_delete_pane(const char *str, int pid)
Definition: roccom_c++.h:110
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: