39 #include "../Rocsurf/test/IM_Reader.h"
63 cout <<
"Usage: " << argv[0] <<
" <surffile> <controlfile>" << std::endl;
71 steps(0), interval(0), func(1) {}
109 is.get( buf, 255,
':');
110 if ( buf[0] ==
'\0') { is.getline( buf, 255);
continue; }
112 istringstream istr(buf);
113 string keyword; istr >> keyword;
114 is.getline( buf, 255,
':');
116 if ( keyword ==
"method")
118 else if ( keyword ==
"wavefrontal")
120 else if ( keyword ==
"normaldif")
122 else if ( keyword ==
"eigthres")
124 else if ( keyword ==
"courant")
126 else if ( keyword ==
"fangle")
128 else if ( keyword ==
"perturb")
130 else if ( keyword ==
"speed")
132 else if ( keyword ==
"sploc")
134 else if ( keyword ==
"timestep")
136 else if ( keyword ==
"steps")
138 else if ( keyword ==
"interval")
140 else if ( keyword ==
"function")
142 else if ( keyword ==
"verbose")
145 std::cerr <<
"Unknow keyword " << keyword << std::endl;
146 is.getline( buf, 255);
149 if (
rank==0) std::cout <<
" speed is " << cp.
speed << std::endl;
155 if ( !cntr_param.
method.empty()) {
158 if (
rank==0) std::cout <<
"Set propagation method to " << cntr_param.
method << std::endl;
163 if (
rank==0) std::cout <<
"Set wavefrontal to " << cntr_param.
wavefrontal << std::endl;
168 if (
rank==0) std::cout <<
"Set normaldif to " << cntr_param.
normaldif << std::endl;
171 if ( !cntr_param.
eigthres.empty()) {
173 if (
rank==0) std::cout <<
"Set eigthres to " << cntr_param.
eigthres << std::endl;
176 if ( !cntr_param.
courant.empty()) {
178 if (
rank==0) std::cout <<
"Set courant constant to " << cntr_param.
courant << std::endl;
181 if ( !cntr_param.
fangle.empty()) {
183 if (
rank==0) std::cout <<
"Set feature angle to " << cntr_param.
fangle << std::endl;
186 if ( !cntr_param.
verbose.empty()) {
189 if (
rank==0) std::cout <<
"Set verbose level to " << cntr_param.
verbose << std::endl;
196 if (
rank==0) cout <<
"Reading surface mesh file \"" << fname <<
'"' << endl;
198 std::string fname_str(fname);
200 std::string::size_type pos = fname_str.find_first_of(
".");
201 const string wname = fname_str.substr( 0, pos);
203 if (
rank==0) cout <<
"Creating window \"" << wname <<
'"' << endl;
244 pnt[2] =
std::sqrt(2-pnt[0]*pnt[0] - pnt[1]*pnt[1]);
246 nrm =
Vector_3( -pnt[0], -pnt[1], 0);
253 const double pi = 3.14159265358979;
257 pnt[2] = pnt[0]*pnt[0] + 0.25*
std::sin(2*
pi*pnt[1]);
272 int *pane_ids, npanes;
276 for (
int i=0;
i<npanes; ++
i) {
280 &(
void*&)coors, &stride, &nn);
281 COM_get_array( (wname+
".vnormals_ana").c_str(), pane_ids[i], &(
void*&)nrms);
283 for (
int j=0;
j<nn; ++
j) {
285 case 1: {
func1( coors[
j], nrms[j]);
break; }
286 case 2: {
func2( coors[
j], nrms[j]);
break; }
287 case 3: {
func3( coors[
j], nrms[j]);
break; }
299 for (
int i=0;
i<npanes; ++
i) {
303 &(
void*&)coors, &stride, &ne);
304 COM_get_array( (wname+
".fnormals_ana").c_str(), pane_ids[i], &(
void*&)nrms);
306 for (
int j=0;
j<ne; ++
j) {
308 case 1: {
func1( coors[
j], nrms[j]);
break; }
309 case 2: {
func2( coors[
j], nrms[j]);
break; }
310 case 3: {
func3( coors[
j], nrms[j]);
break; }
319 std::pair<double,double>
321 const int cur_nrms_hdl,
322 const int buf_hdl,
const char *
scheme=NULL) {
323 static int SURF_normals=0, SURF_integrate=0, SURF_comparea=0;
324 static int BLAS_dot=0, BLAS_mul_scalar=0, BLAS_sub_scalar=0;
325 static int BLAS_sum_scalar_MPI=0, BLAS_max_scalar_MPI=0;
327 if ( SURF_normals==0) {
340 if ( ref_nrms_hdl == cur_nrms_hdl) {
342 return std::pair<double,double>(0.,0.);
348 double err_rms, err_max, area, minus_two=-2;
360 std::pair<double,double> errs(err_rms/area, err_max);
362 std::cout <<
"Root-mean-square error in " <<
scheme
363 <<
" is " <<
std::sqrt(errs.first) << std::endl;
364 std::cout <<
"Max square-root of error in " <<
scheme
365 <<
" is " <<
std::sqrt(errs.second) << std::endl;
372 std::pair<double,double>
374 const int cur_nrms_hdl,
376 const int fbuf_hdl,
const char *
scheme=NULL) {
377 static int SURF_normals=0, SURF_integrate=0, SURF_v2f=0, SURF_comparea=0;
378 static int BLAS_dot=0, BLAS_mul_scalar=0, BLAS_sub_scalar=0;
379 static int BLAS_sum_scalar_MPI=0, BLAS_max_scalar_MPI=0;
381 if ( SURF_normals==0) {
395 if ( ref_nrms_hdl == cur_nrms_hdl) {
397 return std::pair<double,double>(0.,0.);
403 double err_rms, err_max, area, minus_two=-2;
417 std::pair<double,double> errs(err_rms/area, err_max);
419 std::cout <<
"Root-mean-square error in " <<
scheme
420 <<
" is " <<
std::sqrt(errs.first) << std::endl;
421 std::cout <<
"Max square-root of error in " <<
scheme
422 <<
" is " <<
std::sqrt(errs.second) << std::endl;
469 double timestep = 1.e-4;
517 static int OUT_write = 0, hdl;
524 std::string fname = wname+
"_"+timelevel;
527 else fname.append(
"_");
530 &hdl, (
char*)wname.c_str(), timelevel);
533 int main(
int argc,
char *argv[]) {
562 for (
int i=0;
i<cntr_param.
steps; ++
i) {
565 std::sprintf( str,
"%05d",
i+1);
int COMMPI_Comm_rank(MPI_Comm c)
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 func2(Vector_3 &pnt, Vector_3 &nrm)
#define COM_assertion_msg(EX, msg)
std::pair< double, double > compute_vnormal_error(const int ref_nrms_hdl, const int cur_nrms_hdl, const int vbuf_hdl, const int fbuf_hdl, const char *scheme=NULL)
This file contains the prototypes for Roccom API.
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.
SURF::Vector_3< Real > Vector_3
int COM_get_attribute_handle(const char *waname)
void init_parameters(const Control_parameter &cntr_param)
std::string read_in_mesh(const char *fname)
void compute_quadric_normals(const string &wname)
Point object that represents a single point.
void COM_print_profile(const char *fname, const char *header)
void init_normals(const string &wname, int func)
void compute_weighted_normals(const string &wname)
void COM_window_init_done(const char *w_str, int pane_changed=true)
This file contains a set of routines for error assertion.
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
void print_usage(int argc, char *argv[])
void COM_call_function(const int wf, int argc,...)
int main(int argc, char *argv[])
std::pair< double, double > compute_fnormal_error(const int ref_nrms_hdl, const int cur_nrms_hdl, const int buf_hdl, const char *scheme=NULL)
void COM_init(int *argc, char ***argv)
void func3(Vector_3 &pnt, Vector_3 &nrm)
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
void COM_free_buffer(int **buf)
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
double output_solution(const string &wname, const char *timelevel, double ref=0.)
void init_attributes(const string &wname, const Control_parameter &cntr_param)
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
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.
int COM_get_function_handle(const char *wfname)
void read_control_file(const char *fname, Control_parameter &cp)
void func1(Vector_3 &pnt, Vector_3 &nrm)
#define COM_EXTERN_MODULE(moduleName)