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

Go to the source code of this file.

Functions

 COM_EXTERN_MODULE (Rocin)
 
void project_window (const std::string &wName, const std::string &timeStr, const std::string &file_in)
 
int main (int argc, char *argv[])
 

Function Documentation

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

Definition at line 97 of file project_test.C.

References COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_set_profiling(), COM_set_verbose(), and project_window().

98 {
99  COM_init(&argc, &argv);
100 
101  if (argc != 2)
102  {
103  std::cerr << "Usage:project_test <hdf file>" << std::endl;
104  return 1;
105  }
106 
108 
109  int IN_obtain = COM_get_function_handle("IN.obtain_attribute");
110 
111  COM_set_verbose(0);
113 
114  std::string file_in(argv[1]);
115  std::string win_in(file_in);
116  std::string::size_type st = win_in.find_last_of('/');
117  if (st != std::string::npos)
118  win_in.erase(0, st+1);
119  st = win_in.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
120  if (st != std::string::npos)
121  win_in.erase(st);
122 
123  int len = 15;
124  char timeStr[16] = "";
125 
126 
127  std::cout << "Reading HDF file(s) " << file_in
128  << " into window " << win_in << std::endl;
129 
130  int IN_read = COM_get_function_handle("IN.read_window");
131  COM_call_function(IN_read, file_in.c_str(), win_in.c_str(), NULL, NULL,
132  timeStr, &len);
133 
134  cerr << "Finished reading HDF file into window\n";
135  int IN_all = COM_get_attribute_handle((win_in + ".all").c_str());
136  COM_call_function(IN_obtain, &IN_all, &IN_all);
137 
138  std::cout << "Projecting surface mesh to itself" << std::endl;
139  project_window(win_in, timeStr, file_in);
140  std::cout << "Done" << std::endl;
141 
142  COM_finalize();
143  return 0;
144 }
void COM_set_verbose(int i)
Definition: roccom_c++.h:543
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
Definition: Rocin.h:64
void project_window(const std::string &wName, const std::string &timeStr, const std::string &file_in)
Definition: project_test.C:37
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
#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 project_window ( const std::string &  wName,
const std::string &  timeStr,
const std::string &  file_in 
)

Definition at line 37 of file project_test.C.

References COM_free_buffer(), COM_get_panes(), COM_get_roccom(), dist(), i, j, n, paneIds, and q.

Referenced by main().

39 {
40  Vec3D p,q;
41  double dist;
42  double total_dist =0;
43  double total_nodes =0;
44 
45  // Obtain the list of panes
46  Window * w = COM_get_roccom()->get_window_object(wName.c_str());
47  vector<Pane*> ps;
48  unsigned int pass =0;
49  Pane * pn = NULL;
50  double * nc;
51  int nPanes;
52  int* paneIds;
53 
54  COM_get_panes(wName.c_str(), &nPanes, &paneIds);
55  w->panes(ps);
56  cerr <<"Window " << wName << " has " << nPanes << " panes." << endl;
57 
58 
59  for (unsigned int i=0; i<ps.size(); ++i)
60  {
61  pn = ps[i];
62  nc = pn->coordinates();
63  unsigned int n = pn->size_of_real_nodes();
64  total_nodes+=n;
65  SurfaceProjector_Pane sp(pn);
66 
67  cout << "PANE " << i
68  <<" projecting " << pn->size_of_real_nodes() << " nodes."
69  << endl;
70 
71  //loop through pane nodes
72  for(unsigned int j=0;j < pn->size_of_real_nodes();j++)
73  {
74  p[0] = nc[j];
75  p[1] = nc[j+ n];
76  p[2] = nc[j+2*n];
77 
78 
79  //project to surface
80 
81  dist = sp.project_point(p,q);
82  if( dist != 0)
83  {
84  total_dist+=dist;
85  }
86  else
87  pass++;
88 
89  }
90  }
91  cerr << "RESULTS: " << pass << " of " << pn->size_of_real_nodes()
92  <<" points projected to themselves, average error = " << total_dist/total_nodes << endl;
93 
94  COM_free_buffer(&paneIds);
95 }
NVec< 3, double > Vec3D
blockLoc i
Definition: read.cpp:79
const NT & n
j indices j
Definition: Indexing.h:6
NT q
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
long double dist(long double *coord1, long double *coord2, int size)
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
std::vector< int > paneIds
Array of paneIds.
Definition: hdf2pltV2.C:60

Here is the call graph for this function:

Here is the caller graph for this function: