Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ghostbuster.C File Reference
#include "Roccom_base.h"
#include "roccom.h"
#include "roccom_devel.h"
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cassert>
#include <map>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <cgnslib.h>
#include "Rocout.h"
Include dependency graph for ghostbuster.C:

Go to the source code of this file.

Classes

class  AutoCloser< T1, T2 >
 Automatically close open files, datasets, etc. More...
 

Macros

#define CG_CHECK(routine, args)
 

Functions

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

Macro Definition Documentation

#define CG_CHECK (   routine,
  args 
)
Value:
{ \
int ier = routine args; \
if (ier != 0) { \
cerr << "ghostbuster: " #routine " (line " << __LINE__ << " in " \
<< __FILE__ << ") failed: " << cg_get_error() << std::endl; \
return -1; \
} \
}
if(dy > dx)

Definition at line 44 of file ghostbuster.C.

Referenced by main().

Function Documentation

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

Definition at line 67 of file ghostbuster.C.

References CG_CHECK, COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_UNLOAD_MODULE_STATIC_DYNAMIC, and Mesquite::length().

67  {
68  if ( argc < 2) {
69  cout << "Usage: " << argv[0] << " <inputfile>" << endl;
70  return -1;
71  }
72 
73  // Determine true material names. There's no clean ROCCOM way to do this.
74  vector<string> wins;
75  string materials;
76  string file_in(argv[1]);
77  string::size_type c = file_in.length();
78  if (file_in.substr(c - 5) == ".cgns") {
79  int fn;
80  CG_CHECK(cg_open, (file_in.c_str(), MODE_READ, &fn));
81  AutoCloser auto1(fn);
82 
83  int nBases;
84  CG_CHECK(cg_nbases, (fn, &nBases));
85 
86  int B, cellDim, physDim;
87  char baseName[33];
88  for (B=1; B<=nBases; ++B) {
89  CG_CHECK(cg_base_read, (fn, B, baseName, &cellDim, &physDim));
90  std::string name(baseName);
91  c = name.length();
92  if (c <= 7 || name.substr(c - 7) != "_ridges") {
93  wins.push_back(name);
94  materials += name + ' ';
95  }
96  }
97  if (!materials.empty())
98  materials.erase(materials.size() - 1);
99  } else {
100  cout << "Error: " << argv[0] << " only handles CGNS files at this time."
101  << endl;
102  return -1;
103  }
104 
105  std::cout << "Found materials: " << materials << std::endl;
106 
107  string file_out(file_in);
108  c = file_out.rfind('/');
109  if (c != string::npos)
110  file_out.replace(0, c + 1, "gb_");
111  else
112  file_out.insert(0, "gb_");
113 
114  COM_init( &argc, &argv);
115 
118 
119  int IN_read = COM_get_function_handle( "IN.read_windows");
120  int OUT_set = COM_get_function_handle( "OUT.set_option");
121  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
122 
123  COM_call_function( OUT_set, "format", "CGNS");
124  COM_call_function( OUT_set, "ghosthandle", "ignore");
125 
126  char time_level[33] = "";
127  int length = 32;
128  vector<string>::iterator w;
129  for (w=wins.begin(); w!=wins.end(); ++w) {
130  COM_call_function( IN_read, file_in.c_str(), wins[0].c_str(), NULL, NULL,
131  NULL, time_level, &length);
132 
133  int IN_all = COM_get_attribute_handle((*w+".all").c_str());
134 
135  COM_call_function( OUT_write, file_out.c_str(), &IN_all, (*w).c_str(),
136  time_level);
137 
138  COM_call_function( OUT_set, "mode", "a");
139  }
140 
143 
144  COM_finalize();
145 
146  return 0;
147 }
Automatically close open files, datasets, etc.
Definition: Rocin.C:179
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
double length(Vector3D *const v, int n)
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
#define CG_CHECK(routine, args)
Definition: ghostbuster.C:44
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocin.h:64
Definition: Rocout.h:81
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
#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: