Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
detectfeas.C File Reference
#include "roccom.h"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <sstream>
#include "roccom_assertion.h"
#include "../Rocsurf/test/IM_Reader.h"
Include dependency graph for detectfeas.C:

Go to the source code of this file.

Classes

struct  Control_parameter
 

Functions

 COM_EXTERN_MODULE (Rocprop)
 
 COM_EXTERN_MODULE (Rocout)
 
void load_modules ()
 
void print_usage (int argc, char *argv[])
 
void read_control_file (const char *fname, Control_parameter &cp)
 
void init_parameters (const Control_parameter &cntr_param)
 
std::string read_in_mesh (const char *fname)
 
void init_attributes (const string &wname, const Control_parameter &cntr_param)
 
void output_solution (const string &wname, const char *timelevel, const string &format)
 
int main (int argc, char *argv[])
 

Variables

static int rank = 0
 

Function Documentation

COM_EXTERN_MODULE ( Rocprop  )
COM_EXTERN_MODULE ( Rocout  )
void init_attributes ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 137 of file detectfeas.C.

References COM_DOUBLE, COM_INT, COM_new_attribute(), COM_resize_array(), COM_set_size(), and COM_window_init_done().

138  {
139  COM_new_attribute((wname+".disps").c_str(), 'n', COM_DOUBLE, 3, "m");
140 
141  // Ridges of each pane.
142  COM_new_attribute((wname+".ridges").c_str(), 'p', COM_INT, 2, "");
143  COM_set_size((wname+".ridges").c_str(), 0, 0);
144 
145  COM_new_attribute((wname+".tangranks").c_str(), 'n', COM_INT, 1, "");
146  // COM_new_attribute((wname+".weaks").c_str(), 'n', COM_INT, 1, "");
147 
148  COM_resize_array( (wname+".atts").c_str());
149  COM_window_init_done( wname.c_str());
150 }
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
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_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

Here is the call graph for this function:

void init_parameters ( const Control_parameter cntr_param)

Definition at line 98 of file detectfeas.C.

References COM_call_function(), COM_get_function_handle(), Control_parameter::fangle, rank, and Control_parameter::sangle.

98  {
99  int PROP_set_option = COM_get_function_handle( "PROP.set_option");
100 
101  if ( !cntr_param.fangle.empty()) {
102  COM_call_function( PROP_set_option, "fangle", cntr_param.fangle.c_str());
103  if ( rank==0) std::cout << "Set weak-feature angle to " << cntr_param.fangle << std::endl;
104  }
105  else
106  COM_call_function( PROP_set_option, "fangle", "15");
107 
108  if ( !cntr_param.sangle.empty()) {
109  COM_call_function( PROP_set_option, "sangle", cntr_param.sangle.c_str());
110  if ( rank==0) std::cout << "Set strong-feature angle to " << cntr_param.sangle << std::endl;
111  }
112  else
113  COM_call_function( PROP_set_option, "sangle", "60");
114 
115  COM_call_function( PROP_set_option, "rediter", "0");
116  COM_call_function( PROP_set_option, "weight", "3"); // Angle-based
117 }
static int rank
Definition: detectfeas.C:51
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void load_modules ( )

Definition at line 46 of file detectfeas.C.

References COM_LOAD_MODULE_STATIC_DYNAMIC.

46  {
49 }
Definition: Rocout.h:81
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int main ( int  argc,
char *  argv[] 
)

Definition at line 185 of file detectfeas.C.

References COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COMMPI_Comm_rank(), COMMPI_Initialized(), Control_parameter::format, init_attributes(), init_parameters(), load_modules(), MPI_COMM_WORLD, output_solution(), print_usage(), rank, read_control_file(), and read_in_mesh().

185  {
186  COM_init( &argc, &argv);
187  load_modules();
188  print_usage( argc, argv);
189 
191 
192  // Read in mesh file.
193  string wname = read_in_mesh( argv[1]);
194 
195  // Read in control parameters
196  Control_parameter cntr_param;
197  if ( argc>2) read_control_file( argv[2], cntr_param);
198 
199  // Initialize the attributes.
200  init_attributes( wname, cntr_param);
201 
202  // Attributes
203  int pmesh = COM_get_attribute_handle( (wname+".pmesh").c_str());
204  int disps = COM_get_attribute_handle( (wname+".disps").c_str());
205 
206  // Funcitions
207  int PROP_init = COM_get_function_handle( "PROP.initialize");
208  int PROP_propagate = COM_get_function_handle( "PROP.propagate");
209  init_parameters( cntr_param);
210 
211  if ( rank==0) cout << "Initializing data structures..." << endl;
212  // Initialize control parameters
213  COM_call_function( PROP_init, &pmesh);
214 
215  if ( rank==0) cout << "Detecting features..." << endl;
216  double zero=0.;
217  // Perform one step of smoothing to detect features.
218  COM_call_function( PROP_propagate, &pmesh, &disps, &zero, &disps, &zero);
219 
220  if ( rank==0) cout << "Writing out solutions..." << endl;
221  output_solution( wname, "00000", cntr_param.format);
222 
223  COM_finalize();
224 }
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
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
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void init_parameters(const Control_parameter &cntr_param)
Definition: advectest.C:217
std::string read_in_mesh(const char *fname)
Definition: advectest.C:283
static int rank
Definition: detectfeas.C:51
void COM_finalize()
Definition: roccom_c++.h:59
void print_usage(int argc, char *argv[])
Definition: advectest.C:68
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void load_modules()
Definition: advectest.C:58
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
int COMMPI_Initialized()
Definition: commpi.h:168
double output_solution(const string &wname, const char *timelevel, double ref=0.)
Definition: advectest.C:357
void init_attributes(const string &wname, const Control_parameter &cntr_param)
Definition: advectest.C:323
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
void read_control_file(const char *fname, Control_parameter &cp)
Definition: advectest.C:115

Here is the call graph for this function:

void output_solution ( const string &  wname,
const char *  timelevel,
const string &  format 
)

Definition at line 152 of file detectfeas.C.

References COM_call_function(), COM_get_attribute_handle(), COM_get_function_handle(), and COMMPI_Initialized().

153  {
154  static int OUT_write = 0, hdl;
155 
156  if ( OUT_write==0) {
157  OUT_write = COM_get_function_handle( "OUT.write_attribute");
158  hdl = COM_get_attribute_handle( (wname+".all").c_str());
159 
160  int OUT_set = COM_get_function_handle( "OUT.set_option");
161 #if USE_CGNS
162  if ( format != "HDF" && format != "hdf")
163  COM_call_function( OUT_set, "format", "CGNS");
164  else
165 #endif
166  COM_call_function( OUT_set, "format", "HDF");
167  }
168 
169  std::string fname = wname+"_"+timelevel;
170 
171  if ( !COMMPI_Initialized()) {
172 #if USE_CGNS
173  if ( format != "HDF" && format != "hdf")
174  fname.append(".cgns");
175  else
176 #endif
177  fname.append(".hdf");
178  }
179  else fname.append("_");
180 
181  COM_call_function( OUT_write, (char*)fname.c_str(),
182  &hdl, (char*)wname.c_str(), timelevel);
183 }
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COMMPI_Initialized()
Definition: commpi.h:168
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void print_usage ( int  argc,
char *  argv[] 
)

Definition at line 53 of file detectfeas.C.

53  {
54  if ( argc < 2) {
55  cout << "Usage: " << argv[0] << " <surffile> [<controlfile>]" << std::endl;
56 
57  exit(-1);
58  }
59 }
void read_control_file ( const char *  fname,
Control_parameter cp 
)

Definition at line 69 of file detectfeas.C.

References COM_assertion_msg, Control_parameter::fangle, Control_parameter::format, and Control_parameter::sangle.

69  {
70  /* Sample control file:
71  * fangle: 15 # weak feature edge angle: between 0 and 180
72  * sangle: 60 # strong feature edge angle: between 0 and 180
73  * format: CGNS # file format: CGNS or HDF
74  */
75  ifstream is(fname); COM_assertion_msg( is, "File does not exist");
76 
77  while ( !is.eof()) {
78  char buf[255];
79  is.get( buf, 255, ':');
80  if ( buf[0] == '\0') { is.getline( buf, 255); continue; }
81 
82  istringstream istr(buf);
83  string keyword; istr >> keyword;
84  is.getline( buf, 255, ':');
85 
86  if ( keyword == "fangle")
87  is >> cp.fangle;
88  else if ( keyword == "sangle")
89  is >> cp.sangle;
90  else if ( keyword == "format")
91  is >> cp.format;
92  else
93  std::cerr << "Unknow keyword " << keyword << std::endl;
94  is.getline( buf, 255);
95  }
96 }
#define COM_assertion_msg(EX, msg)
std::string read_in_mesh ( const char *  fname)

Definition at line 120 of file detectfeas.C.

References COM_assertion_msg, rank, and IM_Reader::read_winmesh().

120  {
121  if ( rank==0) cout << "Reading surface mesh file \"" << fname << '"' << endl;
122 
123  std::string fname_str(fname);
124 
125  std::string::size_type pos = fname_str.find_first_of( ".");
126  const string wname = fname_str.substr( 0, pos);
127 
128  if ( rank==0) cout << "Creating window \"" << wname << '"' << endl;
129 
130  IM_Reader im_reader;
131  int npanes = im_reader.read_winmesh( fname, wname, false);
132  COM_assertion_msg( npanes>=0, "Failed to read in mesh file. File empty?");
133 
134  return wname;
135 }
#define COM_assertion_msg(EX, msg)
static int rank
Definition: detectfeas.C:51
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
Definition: IM_Reader.h:58

Here is the call graph for this function:

Variable Documentation

int rank = 0
static

Definition at line 51 of file detectfeas.C.

Referenced by init_parameters(), main(), and read_in_mesh().