Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compare_normals.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 compare_normals.C:

Go to the source code of this file.

Classes

struct  Control_parameter
 

Typedefs

typedef MAP::Vector_3< double > Vector_3
 

Functions

 COM_EXTERN_MODULE (Rocblas)
 
 COM_EXTERN_MODULE (Rocmap)
 
 COM_EXTERN_MODULE (Rocsurf)
 
 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)
 
void func1 (Vector_3 &pnt, Vector_3 &nrm)
 
void func2 (Vector_3 &pnt, Vector_3 &nrm)
 
void func3 (Vector_3 &pnt, Vector_3 &nrm)
 
void init_normals (const string &wname, int func)
 
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)
 
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)
 
void compute_weighted_normals (const string &wname)
 
void compute_quadric_normals (const string &wname)
 
void output_solution (const string &wname, const char *timelevel)
 
int main (int argc, char *argv[])
 

Variables

static int rank = 0
 
const double pi = 3.14159265358979
 

Typedef Documentation

typedef MAP::Vector_3<double> Vector_3

Definition at line 43 of file compare_normals.C.

Function Documentation

COM_EXTERN_MODULE ( Rocblas  )
COM_EXTERN_MODULE ( Rocmap  )
COM_EXTERN_MODULE ( Rocsurf  )
COM_EXTERN_MODULE ( Rocprop  )
COM_EXTERN_MODULE ( Rocout  )
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 
)

Definition at line 320 of file compare_normals.C.

References COM_call_function(), COM_get_function_handle(), MPI_COMM_WORLD, scheme, and sqrt().

322  {
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;
326 
327  if ( SURF_normals==0) { // Load the functions
328  SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
329  SURF_integrate = COM_get_function_handle( "SURF.integrate");
330  SURF_comparea = COM_get_function_handle( "SURF.compute_element_areas");
331 
332  BLAS_dot = COM_get_function_handle( "BLAS.dot");
333  BLAS_mul_scalar = COM_get_function_handle( "BLAS.mul_scalar");
334  BLAS_sub_scalar = COM_get_function_handle( "BLAS.sub_scalar");
335  BLAS_sum_scalar_MPI = COM_get_function_handle( "BLAS.sum_scalar_MPI");
336  BLAS_max_scalar_MPI = COM_get_function_handle( "BLAS.max_scalar_MPI");
337  }
338 
339  // If two arguments are the same, then initialize ref_nrms
340  if ( ref_nrms_hdl == cur_nrms_hdl) {
341  COM_call_function( SURF_normals, &ref_nrms_hdl);
342  return std::pair<double,double>(0.,0.);
343  }
344  else {
345  MPI_Comm comm = MPI_COMM_WORLD;
346 
347  // Compute root-mean-square as \sqrt(\int_{2-ref_nrms*cur_nrm))
348  double err_rms, err_max, area, minus_two=-2;
349  // Compute area
350  COM_call_function( SURF_comparea, &buf_hdl);
351  COM_call_function( BLAS_sum_scalar_MPI, &buf_hdl, &area, &comm);
352 
353  COM_call_function( BLAS_dot, &cur_nrms_hdl, &ref_nrms_hdl, &buf_hdl);
354  COM_call_function( BLAS_mul_scalar, &buf_hdl, &minus_two, &buf_hdl);
355  COM_call_function( BLAS_sub_scalar, &buf_hdl, &minus_two, &buf_hdl);
356 
357  COM_call_function( BLAS_max_scalar_MPI, &buf_hdl, &err_max, &comm);
358  COM_call_function( SURF_integrate, &buf_hdl, &err_rms);
359 
360  std::pair<double,double> errs(err_rms/area, err_max);
361  if ( scheme) {
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;
366  }
367  return errs;
368  }
369 }
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
double sqrt(double d)
Definition: double.h:73
static const int scheme
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 compute_quadric_normals ( const string &  wname)

Definition at line 460 of file compare_normals.C.

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

Referenced by main().

460  {
461  int PROP_set = COM_get_function_handle( "PROP.set_option");
462  int PROP_propagate = COM_get_function_handle( "PROP.propagate");
463  int BLAS_add = COM_get_function_handle( "BLAS.add");
464  int nc = COM_get_attribute_handle( (wname+".nc").c_str());
465  int pmesh = COM_get_attribute_handle( (wname+".pmesh").c_str());
466  int spds = COM_get_attribute_handle( (wname+".spds").c_str());
467  int disps = COM_get_attribute_handle( (wname+".disps").c_str());
468 
469  double timestep = 1.e-4;
470 
471  int nrm_ana = COM_get_attribute_handle( (wname+".vnormals_ana").c_str());
472  int vbuf_hdl = COM_get_attribute_handle( (wname+".verrs").c_str());
473  int fbuf_hdl = COM_get_attribute_handle( (wname+".ferrs").c_str());
474  int nrm_eig = COM_get_attribute_handle( (wname+".vnormals_eig").c_str());
475 
476  COM_call_function( PROP_set, "rediter", "0");
477 
478 #if 0
479  COM_call_function( PROP_set, "reorthog", "0");
480 
481  COM_call_function( PROP_set, "weight", "1");
482  COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
483  compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "eigen-noweight");
484 
485  COM_call_function( PROP_set, "weight", "2");
486  COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
487  compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "eigen-area");
488 
489  COM_call_function( PROP_set, "weight", "3");
490  COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
491  compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "eigen-angle");
492 
493  COM_call_function( PROP_set, "weight", "4");
494  COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
495  compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "eigen-sphere");
496 #endif
497 
498 #if 1
499  COM_call_function( PROP_set, "reorthog", "1");
500  COM_call_function( PROP_set, "weight", "3");
501  COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
502  COM_call_function( BLAS_add, &nc, &disps, &nc);
503 
504  compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "mq-angle");
505  int nrm_mq = COM_get_attribute_handle( (wname+".vnormals_mq").c_str());
506  int BLAS_copy = COM_get_function_handle( "BLAS.copy");
507  COM_call_function( BLAS_copy, &nrm_eig, &nrm_mq);
508 #endif
509 
510 // COM_call_function( PROP_set, "reorthog", "0");
511 // COM_call_function( PROP_set, "weight", "2");
512 // COM_call_function( PROP_propagate, &pmesh, &spds, &timestep, &disps);
513 // compute_vnormal_error( nrm_ana, nrm_eig, vbuf_hdl, fbuf_hdl, "eigen-area");
514 }
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)
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 COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)

Definition at line 373 of file compare_normals.C.

References COM_call_function(), COM_get_function_handle(), MPI_COMM_WORLD, scheme, and sqrt().

Referenced by compute_quadric_normals(), and compute_weighted_normals().

376  {
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;
380 
381  if ( SURF_normals==0) { // Load the functions
382  SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
383  SURF_v2f = COM_get_function_handle( "SURF.interpolate_to_centers");
384  SURF_integrate = COM_get_function_handle( "SURF.integrate");
385  SURF_comparea = COM_get_function_handle( "SURF.compute_element_areas");
386 
387  BLAS_dot = COM_get_function_handle( "BLAS.dot");
388  BLAS_mul_scalar = COM_get_function_handle( "BLAS.mul_scalar");
389  BLAS_sub_scalar = COM_get_function_handle( "BLAS.sub_scalar");
390  BLAS_sum_scalar_MPI = COM_get_function_handle( "BLAS.sum_scalar_MPI");
391  BLAS_max_scalar_MPI = COM_get_function_handle( "BLAS.max_scalar_MPI");
392  }
393 
394  // If two arguments are the same, then initialize ref_nrms
395  if ( ref_nrms_hdl == cur_nrms_hdl) {
396  COM_call_function( SURF_normals, &ref_nrms_hdl);
397  return std::pair<double,double>(0.,0.);
398  }
399  else {
400  MPI_Comm comm = MPI_COMM_WORLD;
401 
402  // Compute root-mean-square as \sqrt(\int_{2-ref_nrms*cur_nrm))
403  double err_rms, err_max, area, minus_two=-2;
404  // Compute area
405  COM_call_function( SURF_comparea, &fbuf_hdl);
406  COM_call_function( BLAS_sum_scalar_MPI, &fbuf_hdl, &area, &comm);
407 
408  COM_call_function( BLAS_dot, &cur_nrms_hdl, &ref_nrms_hdl, &vbuf_hdl);
409  COM_call_function( BLAS_mul_scalar, &vbuf_hdl, &minus_two, &vbuf_hdl);
410  COM_call_function( BLAS_sub_scalar, &vbuf_hdl, &minus_two, &vbuf_hdl);
411 
412  COM_call_function( BLAS_max_scalar_MPI, &vbuf_hdl, &err_max, &comm);
413 
414  COM_call_function( SURF_v2f, &vbuf_hdl, &fbuf_hdl);
415  COM_call_function( SURF_integrate, &fbuf_hdl, &err_rms);
416 
417  std::pair<double,double> errs(err_rms/area, err_max);
418  if ( scheme) {
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;
423  }
424  return errs;
425  }
426 }
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
double sqrt(double d)
Definition: double.h:73
static const int scheme
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:

Here is the caller graph for this function:

void compute_weighted_normals ( const string &  wname)

Definition at line 429 of file compare_normals.C.

References COM_call_function(), COM_get_attribute_handle(), COM_get_function_handle(), compute_vnormal_error(), E2N_ANGLE, E2N_AREA, E2N_ONE, E2N_SPHERE, and scheme.

429  {
430  int SURF_compnrm = COM_get_function_handle( "SURF.compute_normals");
431  int mesh_handle = COM_get_attribute_handle( (wname+".mesh").c_str());
432 
433  int nrm_ana = COM_get_attribute_handle( (wname+".vnormals_ana").c_str());
434  int vbuf_hdl = COM_get_attribute_handle( (wname+".verrs").c_str());
435  int fbuf_hdl = COM_get_attribute_handle( (wname+".ferrs").c_str());
436 
437  int scheme = SURF::E2N_ONE;
438  int nrm_nw = COM_get_attribute_handle( (wname+".vnormals_nw").c_str());
439  COM_call_function( SURF_compnrm, &mesh_handle, &nrm_nw, &scheme);
440 
441  compute_vnormal_error( nrm_ana, nrm_nw, vbuf_hdl, fbuf_hdl, "no-weight");
442 
443  scheme = SURF::E2N_AREA;
444  int nrm_area = COM_get_attribute_handle( (wname+".vnormals_area").c_str());
445  COM_call_function( SURF_compnrm, &mesh_handle, &nrm_area, &scheme);
446  compute_vnormal_error( nrm_ana, nrm_area, vbuf_hdl, fbuf_hdl, "area-weighted");
447 
448  scheme = SURF::E2N_ANGLE;
449  int nrm_angle = COM_get_attribute_handle( (wname+".vnormals_angle").c_str());
450  COM_call_function( SURF_compnrm, &mesh_handle, &nrm_angle, &scheme);
451  compute_vnormal_error( nrm_ana, nrm_angle, vbuf_hdl, fbuf_hdl, "angle-weighted");
452 
453  scheme = SURF::E2N_SPHERE;
454  int nrm_sphere = COM_get_attribute_handle( (wname+".vnormals_sphere").c_str());
455  COM_call_function( SURF_compnrm, &mesh_handle, &nrm_sphere, &scheme);
456  compute_vnormal_error( nrm_ana, nrm_sphere, vbuf_hdl, fbuf_hdl, "sphere-weighted");
457 }
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)
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
static const int scheme
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 func1 ( Vector_3 pnt,
Vector_3 nrm 
)

Definition at line 242 of file compare_normals.C.

References Vector_3< Type >::cross_product(), and sqrt().

Referenced by init_normals().

242  {
243  // z=sqrt(2-x^2-y^2)
244  pnt[2] = std::sqrt(2-pnt[0]*pnt[0] - pnt[1]*pnt[1]);
245  if ( pnt[2]==0)
246  nrm = Vector_3( -pnt[0], -pnt[1], 0);
247  else
248  nrm = Vector_3::cross_product( Vector_3(0, 1, -pnt[1]/pnt[2]),
249  Vector_3(1, 0, -pnt[0]/pnt[2]));
250  nrm.normalize();
251 }
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
double sqrt(double d)
Definition: double.h:73
Point object that represents a single point.
Definition: datatypedef.h:68
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
Definition: mapbasic.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void func2 ( Vector_3 pnt,
Vector_3 nrm 
)

Definition at line 255 of file compare_normals.C.

References cos, Vector_3< Type >::cross_product(), pi, and sin.

Referenced by init_normals().

255  {
256  // z = x^2 + 0.25*sin( 2pi*y)
257  pnt[2] = pnt[0]*pnt[0] + 0.25*std::sin(2*pi*pnt[1]);
258  nrm = Vector_3::cross_product( Vector_3(0, 1, 0.5*pi*std::cos(2*pi*pnt[1])),
259  Vector_3(1, 0, 2*pnt[0]));
260  nrm.normalize();
261 }
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
Point object that represents a single point.
Definition: datatypedef.h:68
NT & sin
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
Definition: mapbasic.h:104
const double pi
NT & cos

Here is the call graph for this function:

Here is the caller graph for this function:

void func3 ( Vector_3 pnt,
Vector_3 nrm 
)

Definition at line 263 of file compare_normals.C.

References cos, Vector_3< Type >::cross_product(), pi, and sin.

Referenced by init_normals().

263  {
264  // z = 0.25*sin( pi*x) + 0.25*cos( pi*y)
265  pnt[2] = 0.25*(std::sin(pi*pnt[0]) + std::cos(pi*pnt[1]));
266  nrm = Vector_3::cross_product( Vector_3(0, 1, -0.25*pi*std::sin(pi*pnt[1])),
267  Vector_3(1, 0, 0.25*pi*std::cos(pi*pnt[0])));
268  nrm.normalize();
269 }
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
Point object that represents a single point.
Definition: datatypedef.h:68
NT & sin
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
Definition: mapbasic.h:104
const double pi
NT & cos

Here is the call graph for this function:

Here is the caller graph for this function:

void init_attributes ( const string &  wname)

Definition at line 212 of file compare_normals.C.

References COM_CHAR, COM_DOUBLE, COM_new_attribute(), COM_resize_array(), and COM_window_init_done().

212  {
213  COM_new_attribute((wname+".facenormals").c_str(), 'e', COM_DOUBLE, 3, "");
214  COM_new_attribute((wname+".facecenters").c_str(), 'e', COM_DOUBLE, 3, "");
215  COM_new_attribute((wname+".fnormals_ana").c_str(), 'e', COM_DOUBLE, 3, "");
216  COM_new_attribute((wname+".fnormals_cr").c_str(), 'e', COM_DOUBLE, 3, "");
217  COM_new_attribute((wname+".ferrs").c_str(), 'e', COM_DOUBLE, 1, "");
218  COM_new_attribute((wname+".verrs").c_str(), 'n', COM_DOUBLE, 1, "");
219 
220  COM_new_attribute((wname+".vnormals_ana").c_str(), 'n', COM_DOUBLE, 3, "");
221  COM_new_attribute((wname+".vnormals_nw").c_str(), 'n', COM_DOUBLE, 3, "");
222  COM_new_attribute((wname+".vnormals_area").c_str(), 'n', COM_DOUBLE, 3, "");
223  COM_new_attribute((wname+".vnormals_angle").c_str(), 'n', COM_DOUBLE, 3, "");
224  COM_new_attribute((wname+".vnormals_sphere").c_str(), 'n', COM_DOUBLE, 3, "");
225 
226  COM_new_attribute((wname+".vnormals_eig").c_str(), 'n', COM_DOUBLE, 3, "");
227  COM_new_attribute((wname+".vnormals_mq").c_str(), 'n', COM_DOUBLE, 3, "");
228 
229  // Attribute for storing the number of eigenvalues for each node.
230  COM_new_attribute((wname+".lambdas").c_str(), 'n', COM_DOUBLE, 3, "");
231  COM_new_attribute((wname+".eigvecs").c_str(), 'n', COM_DOUBLE, 9, "");
232  COM_new_attribute((wname+".tangranks").c_str(), 'n', COM_CHAR, 1, "");
233  COM_new_attribute((wname+".scales").c_str(), 'n', COM_DOUBLE, 1, "");
234 
235  COM_new_attribute((wname+".spds").c_str(), 'e', COM_DOUBLE, 1, "m/s");
236  COM_new_attribute((wname+".disps").c_str(), 'n', COM_DOUBLE, 3, "m");
237 
238  COM_resize_array( (wname+".atts").c_str());
239  COM_window_init_done( wname.c_str());
240 }
C/C++ Data types.
Definition: roccom_basic.h:129
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_normals ( const string &  wname,
int  func 
)

Definition at line 271 of file compare_normals.C.

References COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), func1(), func2(), func3(), i, and j.

Referenced by main().

271  {
272  int *pane_ids, npanes;
273  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
274 
275  // Compute vertex normals
276  for ( int i=0; i<npanes; ++i) {
277  int stride, nn;
278  Vector_3 *coors, *nrms;
279  COM_get_array( (wname+".nc").c_str(), pane_ids[i],
280  &(void*&)coors, &stride, &nn);
281  COM_get_array( (wname+".vnormals_ana").c_str(), pane_ids[i], &(void*&)nrms);
282 
283  for ( int j=0; j<nn; ++j) {
284  switch (func) {
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; }
288  }
289  }
290  }
291 
292  // Interpolate coordinates to face centers
293  int SURF_n2f = COM_get_function_handle( "SURF.interpolate_to_centers");
294  int nc = COM_get_attribute_handle( (wname+".nc").c_str());
295  int cnts = COM_get_attribute_handle( (wname+".facecenters").c_str());
296  COM_call_function( SURF_n2f, &nc, &cnts);
297 
298  // Compute face normals
299  for ( int i=0; i<npanes; ++i) {
300  int stride, ne;
301  Vector_3 *coors, *nrms;
302  COM_get_array( (wname+".facecenters").c_str(), pane_ids[i],
303  &(void*&)coors, &stride, &ne);
304  COM_get_array( (wname+".fnormals_ana").c_str(), pane_ids[i], &(void*&)nrms);
305 
306  for ( int j=0; j<ne; ++j) {
307  switch (func) {
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; }
311  }
312  }
313  }
314 
315  COM_free_buffer( &pane_ids);
316 }
void func2(Vector_3 &pnt, Vector_3 &nrm)
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
Definition: rfc_basic.h:42
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
void func3(Vector_3 &pnt, Vector_3 &nrm)
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
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
void func1(Vector_3 &pnt, Vector_3 &nrm)

Here is the call graph for this function:

Here is the caller graph for this function:

void init_parameters ( const Control_parameter cntr_param)

Definition at line 152 of file compare_normals.C.

References COM_call_function(), COM_get_function_handle(), Control_parameter::courant, Control_parameter::eigthres, Control_parameter::fangle, Control_parameter::method, Control_parameter::normaldif, rank, Control_parameter::verbose, and Control_parameter::wavefrontal.

152  {
153  int PROP_set_option = COM_get_function_handle( "PROP.set_option");
154 
155  if ( !cntr_param.method.empty()) {
156  COM_call_function( PROP_set_option, "method", cntr_param.method.c_str());
157 
158  if ( rank==0) std::cout << "Set propagation method to " << cntr_param.method << std::endl;
159  }
160 
161  if ( !cntr_param.wavefrontal.empty()) {
162  COM_call_function( PROP_set_option, "wavefrontal", cntr_param.wavefrontal.c_str());
163  if ( rank==0) std::cout << "Set wavefrontal to " << cntr_param.wavefrontal << std::endl;
164  }
165 
166  if ( !cntr_param.normaldif.empty()) {
167  COM_call_function( PROP_set_option, "normaldif", cntr_param.normaldif.c_str());
168  if ( rank==0) std::cout << "Set normaldif to " << cntr_param.normaldif << std::endl;
169  }
170 
171  if ( !cntr_param.eigthres.empty()) {
172  COM_call_function( PROP_set_option, "eigthres", cntr_param.eigthres.c_str());
173  if ( rank==0) std::cout << "Set eigthres to " << cntr_param.eigthres << std::endl;
174  }
175 
176  if ( !cntr_param.courant.empty()) {
177  COM_call_function( PROP_set_option, "courant", cntr_param.courant.c_str());
178  if ( rank==0) std::cout << "Set courant constant to " << cntr_param.courant << std::endl;
179  }
180 
181  if ( !cntr_param.fangle.empty()) {
182  COM_call_function( PROP_set_option, "fangle", cntr_param.fangle.c_str());
183  if ( rank==0) std::cout << "Set feature angle to " << cntr_param.fangle << std::endl;
184  }
185 
186  if ( !cntr_param.verbose.empty()) {
187  COM_call_function( PROP_set_option, "verbose", cntr_param.verbose.c_str());
188 
189  if ( rank==0) std::cout << "Set verbose level to " << cntr_param.verbose << std::endl;
190  }
191 
192 }
static int rank
string normaldif
Definition: advectest.C:84
string wavefrontal
Definition: advectest.C:83
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 51 of file compare_normals.C.

References COM_LOAD_MODULE_STATIC_DYNAMIC.

51  {
53  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocmap, "MAP");
57 }
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 533 of file compare_normals.C.

References COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_print_profile(), COMMPI_Comm_rank(), COMMPI_Initialized(), compute_quadric_normals(), Control_parameter::func, i, init_attributes(), init_normals(), init_parameters(), load_modules(), MPI_COMM_WORLD, output_solution(), Control_parameter::perturb, print_usage(), rank, read_control_file(), read_in_mesh(), and Control_parameter::steps.

533  {
534  COM_init( &argc, &argv);
535  load_modules();
536  print_usage( argc, argv);
537 
539 
540  // Read in mesh file.
541  string wname = read_in_mesh( argv[1]);
542 
543  // Read in control parameters
544  Control_parameter cntr_param;
545  read_control_file( argc>2?argv[2]:"control.txt", cntr_param);
546 
547  // Initialize the attributes
548  init_attributes( wname);
549  init_normals( wname, cntr_param.func);
550 
551  if ( cntr_param.perturb > 0) {
552  int PROP_perturb = COM_get_function_handle( "PROP.perturb_mesh");
553  int pmesh = COM_get_attribute_handle( (wname+".pmesh").c_str());
554  COM_call_function( PROP_perturb, &pmesh, &cntr_param.perturb);
555  }
556  output_solution( wname, "00000");
557 
558 // compute_weighted_normals( wname);
559 
560  // Initialize control parameters
561  init_parameters( cntr_param);
562  for ( int i=0; i<cntr_param.steps; ++i) {
563  char str[6];
565  std::sprintf( str, "%05d", i+1);
566  output_solution( wname, str);
567  }
568 
569  COM_print_profile( "", "Compute-normals");
570 
571  COM_finalize();
572 }
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
static int rank
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
void compute_quadric_normals(const string &wname)
void COM_finalize()
Definition: roccom_c++.h:59
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
void init_normals(const string &wname, int func)
blockLoc i
Definition: read.cpp:79
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 
)

Definition at line 516 of file compare_normals.C.

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

516  {
517  static int OUT_write = 0, hdl;
518 
519  if ( OUT_write==0) {
520  OUT_write = COM_get_function_handle( "OUT.write_attribute");
521  hdl = COM_get_attribute_handle( (wname+".all").c_str());
522  }
523 
524  std::string fname = wname+"_"+timelevel;
525 
526  if ( !COMMPI_Initialized()) fname.append(".hdf");
527  else fname.append("_");
528 
529  COM_call_function( OUT_write, (char*)fname.c_str(),
530  &hdl, (char*)wname.c_str(), timelevel);
531 }
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 61 of file compare_normals.C.

61  {
62  if ( argc <= 2) {
63  cout << "Usage: " << argv[0] << " <surffile> <controlfile>" << std::endl;
64 
65  exit(-1);
66  }
67 }
void read_control_file ( const char *  fname,
Control_parameter cp 
)

Definition at line 89 of file compare_normals.C.

References COM_assertion_msg, Control_parameter::courant, Control_parameter::eigthres, Control_parameter::fangle, Control_parameter::func, Control_parameter::interval, Control_parameter::method, Control_parameter::normaldif, Control_parameter::perturb, rank, Control_parameter::speed, Control_parameter::sploc, Control_parameter::steps, Control_parameter::timestep, Control_parameter::verbose, and Control_parameter::wavefrontal.

89  {
90  /* Sample control file:
91  * method: fo # method: fo and mp
92  * wavefrontal: 1 # wavefrontal condition
93  * normaldif: 1 # normal diffusion
94  * eigthres: 1.e-4 # threshold for null space: 0..1 (1.e-4 default)
95  * courant: 0.5 # courant constant
96  * fangle: 35 # feature edge angle: between 0 and 180
97  * speed: 0.1 # Speed
98  * sploc: e # location of speed: n or e
99  * timestep: 0.001 # time step
100  * steps: 100 # number of time steps
101  * interval: 10 # output intervals
102  * function: 1 # function
103  * verbose: 1 # verbose level
104  */
105  ifstream is(fname); COM_assertion_msg( is, "File does not exist");
106 
107  while ( !is.eof()) {
108  char buf[255];
109  is.get( buf, 255, ':');
110  if ( buf[0] == '\0') { is.getline( buf, 255); continue; }
111 
112  istringstream istr(buf);
113  string keyword; istr >> keyword;
114  is.getline( buf, 255, ':');
115 
116  if ( keyword == "method")
117  is >> cp.method;
118  else if ( keyword == "wavefrontal")
119  is >> cp.wavefrontal;
120  else if ( keyword == "normaldif")
121  is >> cp.normaldif;
122  else if ( keyword == "eigthres")
123  is >> cp.eigthres;
124  else if ( keyword == "courant")
125  is >> cp.courant;
126  else if ( keyword == "fangle")
127  is >> cp.fangle;
128  else if ( keyword == "perturb")
129  is >> cp.perturb;
130  else if ( keyword == "speed")
131  is >> cp.speed;
132  else if ( keyword == "sploc")
133  is >> cp.sploc;
134  else if ( keyword == "timestep")
135  is >> cp.timestep;
136  else if ( keyword == "steps")
137  is >> cp.steps;
138  else if ( keyword == "interval")
139  is >> cp.interval;
140  else if ( keyword == "function")
141  is >> cp.func;
142  else if ( keyword == "verbose")
143  is >> cp.verbose;
144  else
145  std::cerr << "Unknow keyword " << keyword << std::endl;
146  is.getline( buf, 255);
147  }
148 
149  if ( rank==0) std::cout << " speed is " << cp.speed << std::endl;
150 }
#define COM_assertion_msg(EX, msg)
static int rank
string normaldif
Definition: advectest.C:84
string wavefrontal
Definition: advectest.C:83
std::string read_in_mesh ( const char *  fname)

Definition at line 195 of file compare_normals.C.

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

195  {
196  if ( rank==0) cout << "Reading surface mesh file \"" << fname << '"' << endl;
197 
198  std::string fname_str(fname);
199 
200  std::string::size_type pos = fname_str.find_first_of( ".");
201  const string wname = fname_str.substr( 0, pos);
202 
203  if ( rank==0) cout << "Creating window \"" << wname << '"' << endl;
204 
205  IM_Reader im_reader;
206  int npanes = im_reader.read_winmesh( fname, wname);
207  COM_assertion_msg( npanes>=0, "Failed to read in mesh file. File empty?");
208 
209  return wname;
210 }
#define COM_assertion_msg(EX, msg)
static int rank
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 59 of file compare_normals.C.

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